akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,M = inpl()

if M == N-1: # 一本道
    for _ in range(M):
        s,t = inpl()
    print(M)
else:
    lines = defaultdict(set)
    LL = [0]*N
    for _ in range(M):
        s,t = inpl()
        s -= 1; t -= 1
        lines[s].add(t)
        LL[s] += 1

    def dfs(s):
        global MEMO
        if MEMO[s] != -1:
            return MEMO[s]
        else:
            tmp = 0
            for t in lines[s]:
                if MEMO[t] != -1:
                    tmp += MEMO[t] + 1
                else:
                    tmp += dfs(t) + 1
            MEMO[s] = tmp / LL[s]
            return MEMO[s]

    MEMO = [-1]*N
    MEMO[-1] = 0
    dfs(0)
    koho = [-1]*N
    for s in range(N):
        x = -1
        for t in lines[s]:
            if x < MEMO[t]:
                x = MEMO[t]
                koho[s] = t

    ans = 10**10
    for s in range(N-1):
        t = koho[s]
        if LL[s] == 1 or t == -1:
            continue
        MEMO = [-1]*N
        MEMO[-1] = 0
        lines[s].remove(t)
        LL[s] -= 1
        ans = min(ans,dfs(0))
        lines[s].add(t)
        LL[s] += 1
    print(ans)


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

long long int X, Y, Z, S, K;

static inline void exap(string &src, string s, long long int t){
    for(int i = 0; i < t; ++i)src += s;
}

void twoletter(long long X, long long Y, string xc, string yc){
    while(X && Y){
        if(X > Y){
            X -= Y;
            yc = xc + yc;
        }else{
            K = Y / X;
            Y %= X;
            X -= Y;
            exap(xc, yc, K);
            yc = xc + yc;
        }
    }
    for(int i = 0; i < X; ++i)cout << xc;
    for(int i = 0; i < Y; ++i)cout << yc;
    cout << endl;
    return;
}

int main(){
    scanf("%lld%lld%lld", &X, &Y, &Z);
    S = X + Y + Z;
    if(S == X || S == Y || S == Z){
        for(int i = 0; i < X; ++i)cout << "a";
        for(int i = 0; i < Y; ++i)cout << "b";
        for(int i = 0; i < Z; ++i)cout << "c";
        cout << endl;
        return 0;
    }
    string A = "a", B = "b", C = "c";
    while(1){
        //cout << A << X << " " << B << Y << " " << C << Z << endl;
        if(X == 0){
            twoletter(Y, Z, B, C);
            return 0;
        }
        if(Y == 0){
            twoletter(X, Z, A, C);
            return 0;
        }
        if(Z == 0){
            twoletter(X, Y, A, B);
            return 0;
        }
        if(X > Z){
            X -= Z;
            C = A + C;
        }else{
            K = Z / X;
            Z %= X;
            X -= Z;
            exap(A, C, K);
            C = A + C;
        }
        swap(B, C);
        swap(Y, Z);
    }
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
#include<algorithm>
#include<set>
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)



int main(){
  int N;
  string s;
  set<string>st;
cin>>N;
rep(i,N){
  cin>>s;
  st.insert(s);
}
cout<<st.size()<<endl;
return 0;
}

Measured memory_bytes: 15484
heihousu = set(int(i**2) for i in range(1000))
N,D = list(map(int,input().split()))
X = [list(map(int,input().split()))   for i in range(N)]

cnt = 0
for i in range(N-1):
  for j in range(i+1,N):
    if sum([int((X[i][d]-X[j][d])**2) for d in range(D)]) in heihousu:
      cnt+=1
print(cnt)


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

dev = -2
ans = ''
Q = N

if Q == 0:
    ans += '0'
    
while Q != 0:

    if Q%dev != 0:
        Q -= 1
        ans = '1' + ans
    else:
        ans = '0' + ans

    Q = Q//dev


print(ans)

Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	var w, h, x, y float64
	fmt.Scan(&w)
	fmt.Scan(&h)

	fmt.Scan(&x)
	fmt.Scan(&y)

	var ok int
	if x == w/2 && y == h/2 {
		ok = 1
	}

	fmt.Printf("%v %v\n", w*h/2, ok)
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
  ll a, b;
  cin >> a >> b;
  ll ans = a * b / __gcd(a, b);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
INF = float("inf")


N,M = map(int,input().split())
ab =[list(map(int,input().split())) for i in range(M)]
dist = [INF]*(N)
for i in range(M):
    if ab[i][0] == 1:
        dist[ab[i][1]-1] = 1
for i in range(M):
    if ab[i][1] == N:
        if dist[ab[i][0]-1] <= 1:
            print("POSSIBLE")
            exit()
        else:
            continue
print("IMPOSSIBLE")

Measured memory_bytes: 53280
from sys import stdin


def convert(n, k):
    tmp = n
    ans = ''
    while tmp > 0:
        ans += str(tmp % k)
        tmp = tmp // k
    return ans


def main():
    n, k = map(int, stdin.readline().split())
    print(len(convert(n, k)))


if __name__ == "__main__":
    main()

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    int lim = (N-1)*(N-2)/2;
    if (lim < K) {
        cout << -1 << endl;
        return 0;
    }

    vector<pair<int, int>> edge, V;
    REP(i, 1, N) {
        edge.push_back(make_pair(1, i+1));
    }

    for (int i = 2; i < N; ++i) {
        for (int j = i + 1; j <= N; ++j) {
            if (lim > K) edge.push_back(make_pair(i, j));
            lim--;
        }
    }

    cout << edge.size() << endl;
    rep(i, edge.size()) {
        printf("%d %d\n", edge[i].first, edge[i].second);
    }

    return 0;
}

Measured memory_bytes: 384
// C - All Green
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define chmin(x,y) x=min(x,(y))

int main(){
	int D,G; cin>>D>>G;
	vvi PC(D, vi(2)); // <count, bonus>
	rp(i, 0,D ) cin>>PC[i][0]>>PC[i][1];

	int ans = INT_MAX;
	int n = 1<<D;
	rp(bit, 1, n){

		int cnt = 0, tot = 0;
		rp(j, 0, D)
			if(bit & (1<<j)){
				cnt += PC[j][0]; // count
				tot += PC[j][0] * (j+1) * 100 + PC[j][1]; // total
			}
		if(tot >= G) chmin(ans, cnt);

		rp(j, 0, D)
			if(bit & (1<<j)){
				int now_cnt = cnt - PC[j][0];
				int now_tot = tot - (PC[j][0] * (j+1) * 100 + PC[j][1]);
				rp(k, 1, PC[j][0]) // [1,p-1]
					if(now_tot+(j+1)*k*100 >= G) chmin(ans, now_cnt + k);
			}

	}
	cout<< ans <<endl;
}


Measured memory_bytes: 256
n,l = map(int, input().split())
ls = []
minNum = 0
num = float('inf')
for i in range(1,n+1):
    ls.append(i+l -1)
    if num > abs(ls[i-1]):
        num = abs(ls[i-1])
        minNum = ls[i-1]
ls.pop(ls.index(minNum))
print(sum(ls))

Measured memory_bytes: 3064
import sys

int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def cal(xp):
    res=[inf]*(n+1)
    xp.sort()
    m=len(xp)
    dp=[[inf]*(m+1) for _ in range(m+1)]
    dp[0][0]=0
    for l,(x,p) in enumerate(xp):
        dp[l+1][0]=dp[l][0]+abs(x)*p
    for l in range(m):
        dpl=dp[l]
        for r in range(l+1,m+1):
            dpr=dp[r]
            val=inf
            for lx,_ in xp[l:r]:
                cur=0
                for x,p in xp[l:r]:
                    cur+=min(abs(x-lx),abs(x))*p
                val=min(cur,val)
            for j in range(1,m+1):
                dpr[j]=min(dpr[j],dpl[j-1]+val)
    dpm=dp[m]
    for i in range(m+1):res[i]=dpm[i]
    return res

inf = 10 ** 16
n = II()
xyp = LLI(n)
ans=[inf]*(n+1)
for s in range(1<<n):
    xp=[]
    yp=[]
    for i,(x,y,p) in enumerate(xyp):
        if s>>i&1:xp.append((x,p))
        else:yp.append((y,p))
    xc=cal(xp)
    yc=cal(yp)
    for i in range(n+1):
        for j in range(n+1-i):
            ans[i+j]=min(ans[i+j],xc[i]+yc[j])

for a in ans:print(a)


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

using namespace std;

map <int, int> mp;

const int MOD = 1e9 + 7;

int main() {
    ios :: sync_with_stdio(0);
    cin.tie(nullptr);
    int n; cin >> n;
    for(int i = 1; i <= n; ++i) {
        int cl = i;
        for(int d = 2; d * d <= cl; ++d) {
            while (cl % d == 0) {
                ++mp[d];
                cl /= d;
            }
        }
        if (cl != 1) {
            ++mp[cl];
        }
    }
    long long int sol = 1;
    for(auto x : mp) {
        sol = sol * (x.second + 1);
        sol %= MOD;
    }

    cout << sol;

    return 0;
}


Measured memory_bytes: 256
def main():
    s = input()

    ans = 'Yes'

    for odd_s in s[::2]:
        if odd_s not in ['R', 'U', 'D']:
            ans = 'No'
            return(ans)

    for even_s in s[1:][::2]:
        if even_s not in ['L', 'U', 'D']:
            ans = 'No'
            return(ans)

    return(ans)

if __name__ == '__main__':
    ans = main()
    print(ans)


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

using namespace std;
typedef long long ll;
typedef long double ld;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define pcnt __builtin_popcount
#define pcntll(x) __builtin_popcountll(x)
#define DMAX DBL_MAX;
#define IMIN INT_MIN;
#define IMAX INT_MAX;

//const ll MOD = 1e9+7;
//const ll MOD = 998244353;
//const ll MAX = 3e5+1;
//const ll INF = 1e20;
//const ld PI = acos(-1);

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    int H, W, N;
    in(H); in(W); in(N);
    int sr, sc;
    in(sr); in(sc);
    sr--;
    sc--;
    string S, T;
    in(S); in(T);

    bool taka_win = true;
    int L, R;

    // up, down
    L = 0;
    R = H-1;
    if (S[N-1] == 'U') L++;
    if (S[N-1] == 'D') R--;
    for (int i=N-2; i>=0; i--) {
        if (T[i] == 'D') L = max(0, L-1);
        if (T[i] == 'U') R = min(R+1, H-1);
        if (S[i] == 'U') L++;
        if (S[i] == 'D') R--;
        if (R < L) taka_win = false;
    }
    if (sr < L || R < sr) taka_win = false;

    // left, right
    L = 0;
    R = W-1;
    if (S[N-1] == 'L') L++;
    if (S[N-1] == 'R') R--;
    for (int i=N-2; i>=0; i--) {
        if (T[i] == 'R') L = max(0, L-1);
        if (T[i] == 'L') R = min(R+1, W-1);
        if (S[i] == 'L') L++;
        if (S[i] == 'R') R--;
        if (R < L) taka_win = false;
    }
    if (sc < L || R < sc) taka_win = false;

    cout << (taka_win ? "YES" : "NO") << endl;


    return 0;
}


Measured memory_bytes: 920
c = [list(map(int, input().split())) for _ in range(3)]

for a1 in range(min(c[0])+1):
    for a2 in range(min(c[1])+1):
        for a3 in range(min(c[2])+1):
            b1 = c[0][0] - a1
            b2 = c[0][1] - a1
            b3 = c[0][2] - a1

            if c[1][0] == a2+b1 and c[1][1] == a2 + b2  and c[1][2] == a2 + b3 and c[2][0] == a3+b1 and c[2][1] == a3 + b2  and c[2][2] == a3 + b3:
                print('Yes')
                exit()
print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>

using namespace std;

typedef pair<long, long> P;

int main(){
    long N;
    P a[100001];
    long ans[100000];
    cin >> N;
    for(long i = 0; i < N; i++){
        ans[i] = 0;
        cin >> a[i].first;
        a[i].second = i;
    }
    a[N].first = 0;
    a[N].second = N;
    N++;
    sort(a, a+N, greater<P>());
    P tmp, prev;
    long sum = 0;
    long sum_ans = 0;
    long ini;
    for(long i = 1; i < N; i++){
        sum += a[i-1].first;
        if(a[i].first != a[i-1].first){
            tmp = a[i-1];
            //ans[tmp.second] = sum-(a[i-1].first*(i));
            //sum_ans += ans[tmp.second];
            prev = tmp;
            ini = i+1;
            break;
        }
    }
    
    for(long i = ini; i < N; i++){
        sum += a[i-1].first;
        if(a[i].first != a[i-1].first){
            if(prev.second > a[i-1].second){
                tmp = a[i-1];
                ans[prev.second] = sum-(a[i-1].first*(i))-sum_ans;
                sum_ans += ans[prev.second];
                //cout << sum << ' ' << (a[i].first*(i))+sum_ans << endl;
                prev = tmp;
            }
        }
    }

    //tmp = a[i-1];
    ans[prev.second] = sum-sum_ans;
    sum_ans += ans[prev.second];

    for(long i = 0; i < N-1; i++){
        cout << ans[i] << '\n'; 
    }
    
}

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define int ll
#define INF (ll)1e18
#define maxn 100001
#define MOD 1000000007

int dist(pi i,pi j){
	return abs(i.f-j.f)+abs(i.s-j.s);
}
int N;
int32_t main()
{
	cin>>N;
	
	int mxpl=-INF,mxm=-INF,mnpl=INF,mnm=INF;
	FOR(i,1,N){
		int x,y;
		cin>>x>>y;
		
		mxpl = max(mxpl,x+y); mnpl = min(mnpl,x+y);
		mxm = max(mxm,x-y); mnm = min(mnm,x-y);
	}
	cout<<max(mxpl-mnpl, mxm - mnm);
	
}


Measured memory_bytes: 3588
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

bool board[10][10];

signed main() {
    string s;
    while(cin >> s, s != "#") {
        memset(board, false, sizeof(board));
        int x = 0, y = 0;
        int H = 0, W = 0;
        rep(i,0,s.length()) {
            if(s[i] == 'b') {
                board[x][y] = true;
                y++;
            }
            else if(s[i] == '/') {
                H++; W = y;
                x++; y = 0;
            }
            else {
                int v = s[i] - '0';
                rep(j,0,v) y++;
            }
        }
        H++;

        int a, b, c, d; cin >> a >> b >> c >> d;
        a--; b--; c--; d--;
        swap(board[a][b], board[c][d]);

        rep(i,0,H) {
            int cnt = 0;
            rep(j,0,W) {
                if(board[i][j]) {
                    if(cnt) cout << cnt;
                    cout << "b";
                    cnt = 0;
                }
                else cnt++;
            }
            if(cnt) cout << cnt;
            if(i != H-1) cout << "/";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3176
using Base.Collections
function dijkstra(G,s)
	dist=ones(Int,length(G))*10^18
	dist[s]=0
	P=PriorityQueue(Int,Int)
	P[s]=0
	while !isempty(P)
		(u,cost)=peek(P)
		dequeue!(P)
		for (v,c)=G[u]
			nxt=cost+c
			if dist[v]>nxt
				dist[v]=nxt
				P[v]=nxt
			end
		end
	end
	dist
end
function main()
	N,M,S,T=map(x->parse(Int,x),split(readline()))
	Gs=[Pair{Int,Int}[] for _=1:N]
	Gt=[Pair{Int,Int}[] for _=1:N]
	for s=readlines()
		u,v,a,b=map(x->parse(Int,x),split(s))
		push!(Gs[u],v=>a)
		push!(Gs[v],u=>a)
		push!(Gt[u],v=>b)
		push!(Gt[v],u=>b)
	end
	ds=dijkstra(Gs,S)
	dt=dijkstra(Gt,T)
	ans=Array{Int}(N)
	ret=10^15
	for i=N:-1:1
		ret=min(ret,ds[i]+dt[i])
		ans[i]=10^15-ret
	end
	println.(ans)
end
main()


Measured memory_bytes: 211184
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

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

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

        vector<long long> v(N, 0);
        for(int i = 0; i < N; i++) cin >> v[i];

        vector<long long> left(N, 0);
        vector<long long> right(N, 0);

        long long tmp = v[0];
        left[0] = v[0];
        for(int i = 1; i < N; i++)
        {
                tmp = gcd(tmp, v[i]);
                left[i] = tmp;
        }
        tmp = v[N-1];
        right[N-1] = v[N-1];
        for(int i = N-2; i >= 0; i--)
        {
                tmp = gcd(tmp, v[i]);
                right[i] = tmp;
        }

        long long ans = 0;
        for(int i = 0; i < N; i++)
        {
                long long sub;
                if(i == 0) sub = right[i+1];
                else if(i == N-1) sub = left[i-1];
                else sub = gcd(left[i-1], right[i+1]);

                if(ans < sub) ans = sub;
        }

        cout << ans << endl;

        return 0;
}

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

int main() {
	int K, S;
	//int X, Y;
	int count = 0;
	cin >> K >> S;

	for (int i = 0; i <= K; i++) {
		for (int i2 = 0; i2 <= K; i2++) {
			int Z = S - i -  i2;
			if (0 <= Z && Z <= K) {
				count++;
			}
		}
	}
	cout << count << endl;
}

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

int main(){
  long K, N;
  cin >> K >> N;
  vector<long> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  vector<long> distance(N);
  distance[N-1] = K-A[N-1] + A[0];
  for(int i=0; i<N-1; i++){
    distance[i] = A[i] > A[i+1] ? A[i]-A[i+1]:A[i+1]-A[i];
  }
  long max = -1;
  for(int i=0; i<N; i++){
    if(distance[i]>max)max = distance[i];
  }
  long min_dis=0;
  bool flag = false;
  for(int i=0; i<N; i++){
    if(distance[i]!=max || flag){
      min_dis+=distance[i];
    }
    if(!flag && distance[i]==max){
      flag = true;
    }
  }
  cout << min_dis << endl;
  return 0;
}

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


int main() {
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	vector<int> waters;
	vector<int> sugars;
	for (int i = 0; i <= F; i++) {
		for (int j = 0; j <= F; j++) {
			int water = 100 * B * i + 100 * A * j;
			int sugar = D * i + C * j;
			if (water <= F && water>0) waters.push_back(water);
			if (sugar <= F) sugars.push_back(sugar);
			if (water > F&& sugar > F) break;
		}
	}
	sort(waters.begin(), waters.end());
	sort(sugars.begin(), sugars.end());
	waters.erase(unique(waters.begin(), waters.end()), waters.end());
	sugars.erase(unique(sugars.begin(), sugars.end()), sugars.end());

	int max_sugar = 0;
	int max_water = 0;
	double max_noudo = -1;
	for (int water : waters) {
		for (int sugar : sugars) {
			if (water + sugar > F) break;
			double noudo = sugar * 100.0 / (1.0 * sugar + 1.0 * water);
			if (noudo > E * 100.0 / (100.0 + 1.0 * E)) break;
			if (max_noudo < noudo) {
				max_noudo = noudo;
				max_water = water;
				max_sugar = sugar;
			}
		}
	}

	cout << max_water + max_sugar << " " << max_sugar;
}

Measured memory_bytes: 1400
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()
 
int main() {
  int A, B;
  cin >> A >> B;
  cout << max(A+B, max(A-B, A * B)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9

int main(){
    int n, d, x;
    cin >> n >> d >> x;
    int ans = 0;
    vector<int> a(n);
    rep (i, n) {
        cin >> a[i];
    }

    rep (i, n) {
        ans += (d - 1) / a[i] + 1;
    }

    cout << ans + x << endl;

    return 0;
}

Measured memory_bytes: 3612
// Rustで競技プログラミングの入力をスッキリ記述するマクロ
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

use std::cmp::min;

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

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

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

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

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

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

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

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

fn main() {
    input! {
      n: usize,
      k: usize,
      h: [i64; n]
    };
    let mut dp:Vec<i64> = vec![9223372036854775806; n];
    dp[0] = 0;
    for i in 1..n {
        for j in 1..(k + 1) {
            if i < j {
                break;
            }
            dp[i] = min(dp[i], dp[i - j] + (&h[i] - &h[i - j]).abs());
        }
    }
    println!("{:?}", dp[n - 1]);
}


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

nA = [ 0 for i in range(N)]
nB = [ 0 for i in range(N)]

Tmp = []
Tmp = input().rstrip().split(' ')

for i in range(N-1):
  nB[i] = int(Tmp[i])

Ans = nB[0]
Ans += nB[N-2]

for i in range(N-2):
  B1 = nB[i]
  B2 = nB[i+1]
  Tmp = min(B1, B2)
  Ans += Tmp

print(Ans)



Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<int, int>
const ll  MOD = 1000000007;

int main() {
	string s, t;
	cin >> s >> t;
	if (s.size() < t.size()) {
		cout << "UNRESTORABLE";
		return 0;
	}
	ll a = -1;
	rep(i, s.size() - t.size() + 1) {
		for (ll j = s.size() - t.size(); j >= 0; j--) {
			ll cnt = 0;
			rep(k, t.size()) {
				if (s.at(j + k) == t.at(k) || s.at(j + k) == '?') {
					cnt++;
				}
			}
			if (cnt == t.size()) {
				a = j;
				goto OUT;
			}
		}
	}
	if(a == -1) {
		cout << "UNRESTORABLE";
		return 0;
	}
OUT:
	rep(i, t.size()) s.at(a + i) = t.at(i);
	rep(i, s.size()) {
		if (s.at(i) == '?') s.at(i) = 'a';
	}
	cout << s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
     
#define pll pair <long long,long long>
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define vll vector <ll>
#define NFS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl '\n'
#define M 1000000007   
using namespace std;

void solve()
{
	int s,w;
	cin>>s>>w;
	if(w>=s)
		cout<<"unsafe";
	else
		cout<<"safe";
}
 
int main()
{
    NFS
 	int t=1;
 	//cin>>t;
 	while(t--)
 	{
 		solve();
 	}
    return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    int c = 0;

    for (int i = 0; i<2; ++i) {
        if (a >= b) {
            c += a;
            --a;
        } else {
            c += b;
            b--;
        }
    }
    cout << c << endl; 
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_D
{
    class _089
    {
        static void Main(string[] args)
        {
            int[] p = Console.ReadLine().Split(' ').Select(xx => int.Parse(xx)).ToArray();
            int H = p[0], W = p[1], D = p[2];

            int N = H * W;
            int[] h = new int[N + 1];
            int[] w = new int[N + 1];

            for (int i = 0; i < H; i++)
            {
                int[] aa = Console.ReadLine().Split(' ').Select(xx => int.Parse(xx)).ToArray();
                for (int j = 0; j < W; j++)
                {
                    int A = aa[j];
                    h[A] = i;
                    w[A] = j;
                }
            }

            long[] S = new long[N + 1];
            for (int k = 1; k <= D; k++)
            {
                long distance = 0;
                for (int j = k + D; j <= N; j += D)
                {
                    distance += Math.Abs(h[j] - h[j - D]) + Math.Abs(w[j] - w[j - D]);
                    S[j] = distance;
                }
            }


            int Q = int.Parse(Console.ReadLine());
            for (int i = 0; i < Q; i++)
            {
                int[] lr = Console.ReadLine().Split(' ').Select(xx => int.Parse(xx)).ToArray();
                int L = lr[0], R = lr[1];
                long sum = S[R] - S[L];
                Console.WriteLine(sum);
            }
        }
    }
}


Measured memory_bytes: 18996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll arr[3000];
ll dp[3000][3000];
ll func(ll low,ll high)
{
	if(low>high)
		return 0;
	if(low==high)
		return arr[low];
	if(dp[low][high]!=-1)
		return dp[low][high];
	ll pos1=arr[low] + min(func(low+2,high),func(low+1,high-1));
	ll pos2=arr[high] + min(func(low,high-2),func(low+1,high-1));
	return dp[low][high] = max(pos1,pos2);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,sum=0;
	cin>>n;
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
		sum+=arr[i];
	}
	memset(dp,-1,sizeof dp);
	cout<<2*func(0,n-1)-sum;
}

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

typedef pair<int, int> P;

const int MAX_S = 51;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
int H, W;
char G[MAX_S][MAX_S];
bool vis[MAX_S][MAX_S];

void show() {
  for(int i = 0; i < H; ++i) {
    for(int j = 0; j < W; ++j) {
      cout << G[i][j];
    }
    cout << endl;
  }
}

pair<P, P> rec(int x, int y, char c) {
  vis[y][x] = true;
  pair<P, P> p = make_pair(P(x, y), P(x, y));
  for(int i = 0; i < 4; ++i) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(nx < 0 || nx >= W) continue;
    if(ny < 0 || ny >= H) continue;
    if(vis[ny][nx]) continue;
    if(G[ny][nx] != c) continue;
    pair<P, P> q = rec(nx, ny, c);
    p.first.first = min(p.first.first, q.first.first);
    p.first.second = min(p.first.second, q.first.second);
    p.second.first = max(p.second.first, q.second.first);
    p.second.second = max(p.second.second, q.second.second);
  }
  return p;
}

void make(map<char, pair<P, P> > &m) {
  for(int i = 0; i < H; ++i) fill(vis[i], vis[i]+W, false);

  for(int i = 0; i < H; ++i) {
    for(int j = 0; j < W; ++j) {
      if(!vis[i][j] && G[i][j] != '.') {
	pair<P, P> q = rec(j, i, G[i][j]);
	//v.push_back(q);
	if(m.find(G[i][j]) == m.end()) {
	  m[G[i][j]] = q;
	} else {
	  pair<P, P> &p = m[G[i][j]];
	  p.first.first = min(p.first.first, q.first.first);
	  p.first.second = min(p.first.second, q.first.second);
	  p.second.first = max(p.second.first, q.second.first);
	  p.second.second = max(p.second.second, q.second.second);
	}
      }
    }
  }
}

bool isShikaku(int sx, int sy, int ex, int ey) {
  char c = 0;
  for(int i = sy; i <= ey; ++i) {
    for(int j = sx; j <= ex; ++j) {
      if(G[i][j] == '.') return false;
      if(c == 0) {
	if(G[i][j] != '#') c = G[i][j];
      } else if(G[i][j] != c && G[i][j] != '#') {
	return false;
      }
    }
  }
  return true;
}

void fills(int sx, int sy, int ex, int ey) {
  for(int i = sy; i <= ey; ++i) {
    for(int j = sx; j <= ex; ++j) {
      G[i][j] = '#';
    }
  }
}

bool ans() {
  vector<pair<P, P> > v;
  map<char, pair<P, P > > m;
  make(m);
  v.clear();
  for(map<char, pair<P, P> >::iterator it = m.begin(); it != m.end(); ++it) {
    v.push_back(it->second);
  }
  for(;;) {
    bool flag = true;
    for(vector<pair<P, P> >::iterator it = v.begin(); it != v.end();) {
      pair<P, P> p = *it;
      if(isShikaku(p.first.first, p.first.second,
		   p.second.first, p.second.second)) {

	fills(p.first.first, p.first.second,
	      p.second.first, p.second.second);

	it = v.erase(it);
	flag = false;
      } else {
	++it;
      }
    }
    if(flag) return v.size() == 0;
  }
}

int main() {
  int T;
  cin >> T;
  while(T--) {
    cin >> H >> W;
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
	cin >> G[i][j];
      }
    }
    if(ans()) cout << "SAFE" << endl;
    else cout << "SUSPICIOUS" << endl;
    //show();
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

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

    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        n -= a;
    }

    cout << (n >= 0 ? n : -1) << endl;

    return 0;
}


Measured memory_bytes: 3612
s=list(input())
count=0
for i in s:
    if i.isupper():
        count +=1
if count!=2:print("WA");exit()
else:
    if s[0]=="A":
        if s[2:-1].count("C")==1:
            print("AC")
        else:print("WA")
    else:print("WA")

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {
		public static void main(String[] args) {

			//スキャナーを宣言する
		    Scanner sc = new Scanner(System.in);

		    //入力を受け取る
		    int N = Integer.parseInt(sc.next());
		    int K = Integer.parseInt(sc.next());

		    int l[] = new int[N+1];

		    //入力を受け取る
		    for(int cnt = 0; cnt < N; cnt++) {
		    	l[cnt] = Integer.parseInt(sc.next());
		    }
		    //スキャナーを閉じる
		    sc.close();

		    int tmp;
		    int sum = 0;

		    //大きい順にソート
		    //まず0番目と1～N番目の中を比較し、大きかったら入れ替える
		    for(int cnt = 0;cnt < N; cnt++) {
		    	for(int cnt2 = cnt+1;cnt2 < N;cnt2++ ) {
		    		if(l[cnt] < l[cnt2]) {
		    			tmp = l[cnt];
		    			l[cnt] = l[cnt2];
		    			l[cnt2] = tmp;
		    		}
		    	}
		    }
		    //合計を出す
		    for(int cnt =0; cnt < K; cnt++) {
		    	sum = l[cnt] + sum;
		    }

		    System.out.println(sum);
		}
}

Measured memory_bytes: 23636
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
from functools import reduce
import sys
import math
import bisect
import random
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return list(map(float, sys.stdin.readline().split()))
def LS():return sys.stdin.readline().split()
def SR(n): return [list(sys.stdin.readline())[:-1] for i in range(n)]
def IR(n): return [int(sys.stdin.readline()) for i in range(n)]
def LIR(n): return [list(map(int, sys.stdin.readline().split())) for i in range(n)]
def LSR(n): return [list(map(list, sys.stdin.readline().split())) for i in range(n)]
_gcd = lambda x, y: _gcd(y, x%y) if (x%y) else y
_lcm = lambda x, y: x*y // _gcd(x, y)
def gcd(*numbers):
    return reduce(_gcd, numbers)
def lcm(*numbers):
    return reduce(_lcm, numbers)
sys.setrecursionlimit(1000000)
INF = float('inf')
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

N = I()

A = IR(N)

left = [0]*N
right = [0]*N

left[0] = A[0]
right[-1] = A[-1]

for i in range(1,N):
    left[i] = max(left[i-1], A[i])
for i in range(0, N-1)[::-1]:
    right[i] = max(right[i+1], A[i])

print(right[1])
for i in range(1,N-1):
    print(max(left[i-1], right[i+1]))
print(left[-2])

Measured memory_bytes: 16616
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;

int main() {
    int a,b,c;
    cin >> a>>b>>c;
    int dex = a;
    for(int i = a; i<=a*b; i+=dex){
        if(i%b == c) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3632
using System;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            var split = Console.ReadLine().Split(" ");
            long a = long.Parse(split[0]);
            long b = long.Parse(split[1]);
            long c = long.Parse(split[2]);
            long d = long.Parse(split[3]);

            long answer = Math.Max(Math.Max(b * c, b * d), Math.Max(a * c, a * d));
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 27512
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	int[] num = new int[101];
	int max = 0;
	while(kbd.hasNext()){
	    int a = kbd.nextInt();
	    num[a]++;
	    if(max<num[a]) max = num[a];
	}
	for(int i=0; i<num.length; i++){
	    if(num[i]==max)
		System.out.println(i);
	}
    }
}

Measured memory_bytes: 18252
K, A, B = map(int, input().split())
ans = 1
if B - A <= 1:
    print(K+1)
elif K < A + 1:
    print(K+1)
else:
    K -= A+1
    ans = B
    ans += (B - A) * (K // 2)
    ans += K % 2
    print(ans)

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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 (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

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

    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    for(int i=K;i<N;i++){
        if(A[i]>A[i-K]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 4756
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define mp make_pair
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
    IOS;
    int s,w;
    cin>>s>>w;
    if(w>=s) cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
}


Measured memory_bytes: 3612
using System;
using System.Linq;

namespace AGC026.Task02
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            for (var i = 0; i < n; i++)
            {
                if (Solve())
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
        }

        public static bool Solve()
        {
            var line = Console.ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();
            var a = line[0];
            var b = line[1];
            var c = line[2];
            var d = line[3];

            if (b > a)
            {
                return false;
            }

            if (b > d)
            {
                return false;
            }

            if (c >= b) {
                return true;
            }

            var g = Gcd(b, d);
            var max = b - g + (a % g);

            return max <= c;
        }

        static long Gcd(long x, long y)
        {
            if (x < y)
            {
                var t = x;
                x = y;
                y = t;
            }
            while (y != 0)
            {
                var t2 = x % y;
                x = y;
                y = t2;
            }
            return x;
        }
    }
}


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

#define fast ios::sync_with_stdio(false);cin.tie(NULL)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define eb emplace_back

int n;
int a[100];
int b[100];
int c[100];

int main() {
	fast;

	cin >> n;

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

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

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

	int ans = 0;
	for(int i=1; i<=n; i++) {
		ans += b[a[i]];
		if(i > 1 && a[i] == a[i-1]+1) {
			ans += c[a[i-1]];
		}
	}

	cout << ans;
}

Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int64_t N,L,T;
int64_t POS[100000];
int32_t D[100000];
int64_t POS0; int32_t d0;
std::set<int64_t>
R_DIST, L_DIST;//0がR/L方向に進むとき、0からの距離*2
int64_t R_DIST_bace, L_DIST_bace;
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> N>>L>>T;
	for (int32_t i = 0; i < N; ++i)
	{
		in >> POS[i] >> D[i];
	}
	
	//POS0 = POS[0]*2;
	//d0 = D[0];
	//for (int32_t i = 1; i < N; ++i)
	//{
	//	if (D[i] == 1) {
	//		L_DIST.insert((L - POS[i])*2);
	//	}
	//	else {
	//		R_DIST.insert(POS[i]*2);
	//	}
	//}
	//int64_t T2=0;
	//for (;;)
	//{
	//	if (d0==1) {
	//		R_DIST.upper_bound(POS0);
	//	}
	//}

	const int a = -5 / 2;


	int64_t beg = 0;
	for (int32_t i = 0; i < N; ++i)
	{
		if (D[i] == 1) {
			POS[i] += T;
			beg+=POS[i]/L;
			POS[i] %= L;
		}
		else {
			POS[i] -= T;
			beg += POS[i] / L;
			POS[i] %= L;
			if (POS[i] < 0) {
				--beg;
				POS[i] += L;
				POS[i] %= L;
			}
		}
	}
	std::sort(POS,POS+N);
	beg %= N;
	beg += N;
	beg %= N;
	for (int32_t i = beg; i < N; ++i)
	{
		out << POS[i] << endl;
	}
	for (int32_t i = 0; i < beg; ++i)
	{
		out << POS[i] << endl;
	}

	return 0;
}
#endif


Measured memory_bytes: 2432
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;
//#define _USE_MATH_DEFINES

int main(void) {
	string s, s2;
	int k;
	vector<string> s3;
	cin >> s;
	cin >> k;
	s2 = s;
	sort(s2.begin(), s2.end());

	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < k; j++) {
			if (s[i] == s2[j]) {
				for (int l = 1; l <= k; l++) {
					s3.push_back(s.substr(i, l));
				}
				//cout << s.substr(i, k) << endl;
			}
		}
	}
	sort(s3.begin(), s3.end());

	s3.erase(unique(s3.begin(), s3.end()), s3.end());
	sort(s3.begin(), s3.end());
	cout << s3[k - 1] << endl;


	return 0;
}

Measured memory_bytes: 7156
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n = int(input())
    nc = n
    ncsum = 0
    while nc:
        ncsum += nc % 10
        nc = nc // 10
    if n % ncsum == 0:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9064
#include <cstdio>
#include <string>
#include <math.h>

#include<iostream>
#include <tuple>
#include <vector>

using namespace std;

int main() {

	int N;
	cin >> N;

	struct Record
	{
		int t;
		int x;
		int y;
	};

	vector<Record> recordContainer;

	for (int i = 0; i < N; i++){
		int t, x, y;
		cin >> t;
		cin >> x;
		cin >> y;

		recordContainer.push_back({ t, x, y });
	}

	//#TODO 相対化
	Record zero = { 0, 0, 0 };
	for(auto& absRecord : recordContainer){
		Record relativeRecord = { absRecord.t - zero.t, absRecord.x - zero.x, absRecord.y - zero.y };
		zero = absRecord;
		absRecord = relativeRecord;
	}

	//判定
	auto isEnabled = [](auto record){
		if (abs(record.x) + abs(record.y) > record.t) {
			return false;
		}

		for (int i = 0; i <= record.t; i++) {
			int tX = i;
			int tY = record.t - i;

			//if (tX > abs(record.x) || tY > abs(record.y)) {
			//	continue;
			//}

			if (abs(tX - record.x) % 2 == 0
				&& abs(tY - record.y) % 2 == 0) {
				return true;
			}
		}

		return false;
	};

	for (auto record : recordContainer) {
		if (!isEnabled(record)) {
			cout << "No";
			return 0;
		}
	}

	cout << "Yes";

	return 0;
}

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

int main(){
    int n;
    int a[100];
    string ans = "APPROVED";
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
	if(a[i] % 2 == 0){
	    if(a[i] % 3 != 0 && a[i] % 5 != 0){
	        ans = "DENIED";
	    }
	}
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

long long n,m;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n >> m;
    cout << (1900ll*m+100*(n-m))*(1<<m);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	int N, K;
	cin >> N >> K;
	vector<int> V[100001];
	rep(i, N) {
		int t, d;
		cin >> t >> d;
		V[t].pb(d);
	}

	int shurui = 0;
	vector<int> saidai;
	vector<int> sonota;
	rep(i, 100001) {
		if (V[i].size()) {
			shurui++;
			sort(V[i].begin(), V[i].end());
			reverse(V[i].begin(), V[i].end());
			saidai.pb(V[i][0]);
			for (auto itr = ++V[i].begin(); itr != V[i].end(); itr++) {
				sonota.pb(*itr);
			}
		}
	}

	sort(sonota.begin(), sonota.end());
	reverse(sonota.begin(), sonota.end());
	vector<ll> ruiseki;
	ll kari = 0;
	for (int i : sonota) {
		kari += i;
		ruiseki.pb(kari);
	}

	sort(saidai.begin(), saidai.end());
	reverse(saidai.begin(), saidai.end());
	vector<ll> ruiseki2;
	kari = 0;
	for (int i : saidai) {
		kari += i;
		ruiseki2.pb(kari);
	}

	ll kotae = 0;
	for (int i = max(1, K - N + shurui); i <= min(K, shurui); i++) {
		ll kari2 = ruiseki2[i - 1];
		if(K - i - 1 >= 0) kari2 += ruiseki[K - i - 1];
		kari2 += 1ll * i * i;
		kotae = max(kotae, kari2);
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 7288
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //const ll p = 1e9 + 7;
    //const ll p = 998244353;
    
    clock_t start = clock();
    
    ll d;
    cin >> d;
    vector<ll> c(26);
    for (ll i = 0; i < 26; i++) cin >> c[i];
    vector<vector<ll>> s(d, vector<ll>(26));
    for (ll i = 0; i < d; i++) {
        for (ll j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    
    vector<ll> w(0);
    for (ll i = 0; i < 26; i++) {
        w.push_back(i);
        for (ll j = 0; j < c[i]; j++) {
            w.push_back(i);
        }
    }
    ll m = w.size();
    
    random_device rand;
    vector<ll> ans(d);
    for (ll i = 0; i < d; i++) ans[i] = w[rand() % m];
    
    auto calc_score = [&] () {
        vector<ll> v(26, -1);
        ll ret = 0;
        for (ll i = 0; i < d; i++) {
            v[ans[i]] = i;
            ret += s[i][ans[i]];
            for (ll j = 0; j < 26; j++) {
                ret -= c[j] * (i - v[j]);
            }
        }
        return ret;
    };
    
    ll score = calc_score();
    
    while (clock() - start <= 1.95 * CLOCKS_PER_SEC) {
        ll change_at1 = rand() % d, into1 = w[rand() % m];
        ll change_at2 = rand() % d, into2 = w[rand() % m];
        ll memo1 = ans[change_at1], memo2 = ans[change_at2];
        ll memo_score = score;
        ans[change_at1] = into1; ans[change_at2] = into2;
        score = calc_score();
        if (score < memo_score) {
            ans[change_at1] = memo1; ans[change_at2] = memo2;
            score = memo_score;
        }
    }
    
    for (ll i = 0; i < d; i++) cout << ans[i] + 1 << endl;
    xout << score << endl;
}


Measured memory_bytes: 3816