akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

class UF {

  vector<int> par; // 親
  vector<int> rank; // 深さ

public:

  void init(int n) { // n個で初期化
    for(int i=0;i<n;i++) {
      par.push_back(i);
      rank.push_back(0);
    }
  }

  UF(int n) {
    for(int i=0;i<n;i++) {
      par.push_back(i);
      rank.push_back(0);
    }
  }

  int find(int x) { // 木の中のxの深さを返す
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
  }

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

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

  bool same(int x, int y) { // xとyが等しいかどうか判定する
    return find(x) == find(y);
  }
};

struct Edge {
  int from, to, cost;
};

bool operator<(const Edge& e1, const Edge& e2) {
  return e1.cost > e2.cost;
}

struct Point {
  int pos, x, y;
};

bool operator<(const Point& p1, const Point& p2) {
  return p1.x < p2.x;
}

bool operator>(const Point& p1, const Point& p2) {
  return p1.y < p2.y;
}

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  vector<Point> p(n);
  REP(i, n) {
    p[i].pos = i;
    cin >> p[i].x >> p[i].y;
  }

  vector<vector<Edge>> g(n);
  
  sort(ALL(p));
  REP(i, n-1) {
    Edge e;
    int cost = min(abs(p[i].x - p[i+1].x), abs(p[i].y - p[i+1].y));
    e.from = p[i].pos;
    e.to = p[i+1].pos;
    e.cost = cost;
    g[e.from].pb(e);
    swap(e.from, e.to);
    g[e.from].pb(e);
  }

  sort(ALL(p), greater<Point>());
  REP(i, n-1) {
    Edge e;
    int cost = min(abs(p[i].x - p[i+1].x), abs(p[i].y - p[i+1].y));
    e.from = p[i].pos;
    e.to = p[i+1].pos;
    e.cost = cost;
    g[e.from].pb(e);
    swap(e.from, e.to);
    g[e.from].pb(e);
  }

  UF uf(n);

  ll ans = 0;
  int cnt = 0;
  priority_queue<Edge> edges;
  REP(i, SZ(g[0])) {
    edges.push(g[0][i]);
  }
  
  while(cnt < n-1) {
    Edge next = edges.top(); edges.pop();
    if(!uf.same(next.from, next.to)) {
      uf.unite(next.from, next.to);
      ans += next.cost;
      cnt++;
      REP(i, SZ(g[next.to])) {
        edges.push(g[next.to][i]);
      }
    }
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 16152
import java.util.Arrays;
import java.util.Scanner;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int K = sc.nextInt();
		int N = sc.nextInt();
		int[] A = new int[N];
		Arrays.setAll(A, $ -> sc.nextInt());
		int max = (K - A[A.length - 1]) + A[0];
		for (int i = 1; i < A.length; i++) {
			max = Math.max(A[i] - A[i - 1], max);
		}
		System.out.println(K - max);
	}
}

class Main {
	public static void main(String... args) {
		Scanner in = new Scanner(System.in);

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 65856
// package app;

import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);

        final String S = sc.next();
        int cnt = 0;
        for (int i = 0; i < S.length(); i++) {
            if(S.charAt(i) == 'o') cnt++;
        }


        System.out.println(700 + cnt * 100);

    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int seat[17] = {0};
	int X = 0;
	int stop[100] = {0};
	int time = 0;
	queue<int> Q;
	while(X < 100){
		int x;
		if(time%5 == 0 && time < 500){
			Q.push(time/5);
		}
		while(1){
			if(Q.size())x = Q.front();
			else x = -1;
			bool f = false;
			
			if(~x){
				int people = (x%5==1?5:2);
				int use = 19 + 3 * (x%3) + 17 * (x%2);
				rep(i,17-people+1){
					bool flag = true;
					rep(j,people){
						flag &= seat[i+j] == 0;
					}
					if(flag){
						rep(j,people){
							seat[i+j] = use;
						}
						f = true;
						break;
					}
				}
			}
			if(f){	
				stop[x] = time - x * 5;
				Q.pop();
				X++;
			}
			if(!f)break;
		}
		rep(i,17){
			seat[i] = max(0,seat[i]-1);
		}
		time++;
	}
	int n,c=0;
	
	while(cin >> n){
		if(n < 50)c++;
		cout << stop[n] << endl;
	}
	int a = 0;
	while(c>=5){cout << a/a << endl;};
	
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    double ans = w * h / 2.0;
    printf("%.10f ", ans);
    bool f = ((x * 2 == w) && (y * 2 == h));
    printf("%d\n", f ? 1 : 0);
    return 0;
}


Measured memory_bytes: 256
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE MultiParamTypeClasses #-}
import Data.Char (isSpace)
import Data.Int
import Data.List (unfoldr)
import Control.Monad
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS
import Data.Array.ST
import Control.Monad.ST
---
import qualified Data.Array.Base
import qualified Unsafe.Coerce
import Data.Coerce

main = do
  [n,m] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  ss <- U.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  ts <- U.unfoldrN m (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let result :: N
      result = runST $ do
        arr <- asSTUArray $ newArray ((-1,-1),(n-1,m-1)) 0
        forM_ [-1..n-1] $ \i -> writeArray arr (i,-1) 1
        forM_ [-1..m-1] $ \j -> writeArray arr (-1,j) 1
        flip U.imapM_ ss $ \i s -> do
          flip U.imapM_ ts $ \j t -> do
            a <- readArray arr (i-1,j-1)
            b <- readArray arr (i-1,j)
            c <- readArray arr (i,j-1)
            writeArray arr (i,j) $! if s == t
                                    then b + c
                                    else b + c - a
        readArray arr (n-1,m-1)
  print result

---

modulo :: Int64
modulo = 10^9+7
addMod, subMod, mulMod :: Int64 -> Int64 -> Int64
addMod !x !y = (x + y) `rem` modulo
subMod !x !y = (x - y) `mod` modulo
mulMod !x !y = (x * y) `rem` modulo

newtype N = N { unwrapN :: Int64 } deriving (Eq)
instance Show N where
  show (N x) = show x
instance Num N where
  N x + N y = N ((x + y) `rem` modulo)
  N x - N y = N ((x - y) `mod` modulo)
  N x * N y = N ((x * y) `rem` modulo)
  fromInteger n = N (fromInteger (n `mod` fromIntegral modulo))
  abs = undefined; signum = undefined

---

--- STUArray s i N

unsafeCoerce_STUArray_N_Int :: STUArray s i N -> STUArray s i Int64
unsafeCoerce_STUArray_N_Int = Unsafe.Coerce.unsafeCoerce
unsafeCoerce_STUArray_Int_N :: STUArray s i Int64 -> STUArray s i N
unsafeCoerce_STUArray_Int_N = Unsafe.Coerce.unsafeCoerce

instance Data.Array.Base.MArray (STUArray s) N (ST s) where
  getBounds arr = Data.Array.Base.getBounds (unsafeCoerce_STUArray_N_Int arr)
  getNumElements arr = Data.Array.Base.getNumElements (unsafeCoerce_STUArray_N_Int arr)
  newArray lu e = unsafeCoerce_STUArray_Int_N <$> Data.Array.Base.newArray lu (coerce e)
  newArray_ lu = unsafeCoerce_STUArray_Int_N <$> Data.Array.Base.newArray_ lu
  unsafeNewArray_ lu = unsafeCoerce_STUArray_Int_N <$> Data.Array.Base.unsafeNewArray_ lu
  unsafeRead arr i = coerce <$> Data.Array.Base.unsafeRead (unsafeCoerce_STUArray_N_Int arr) i
  unsafeWrite arr i e = Data.Array.Base.unsafeWrite (unsafeCoerce_STUArray_N_Int arr) i (coerce e)

asSTUArray :: ST s (STUArray s i a) -> ST s (STUArray s i a)
asSTUArray arr = arr


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

using ll = long long;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}

const char EOL = '\n';
const int MOD = 1000000007;
const int INF = 1000000001;

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

void solve() {
    int n;
    string s;
    cin >> n >> s;
    vector<ll> v(26, 0);
    REP(i, n) v[s[i] - 'a']++;
    ll ans = 1LL;
    REP(i, 26) {
        ans *= v[i] + 1;
        ans %= MOD;
    }
    cout << ans - 1 << EOL;
}

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

typedef long long ll;

void solve()
{
    ll n, x, t;
    cin >> n >> x >> t;
    int y = 0;
    if (n % x)
    {
        y += t;
    }
    cout << (n / x) * t + y << endl;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++)
    {
        // cout << "Case #" << i << ": ";
        solve();
    }
}

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

using namespace std;

int main(void) {
	int x,y,s;
	while (cin >> x >> y >> s, x) {
		int res = 0;
		for (int p1 = 1; p1 <= s/2; ++p1) {
			for (int p2 = 1; p2 < s; ++p2) {
				int p3 = ((p1*(100+x))/100) + ((p2*(100+x))/100);
				if (p3 == s) {
					int r = ((p1*(100+y))/100) + ((p2*(100+y))/100);
					res = max(res,r);
				}
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
	int n,k,s=1;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
	{
		s=min(s*2,s+k);
	}
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

class Main {

    private final  ArrayList<Integer> primes = new ArrayList<Integer>();
    private final  ArrayList<Integer> targets = new ArrayList<Integer>();
    private final int n;

    public Main(int n) {
        this.n = n;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        if (scanner.hasNextLine()) {
            int N = Integer.parseInt(scanner.nextLine());

            new Main(N).start();
        }
    }

    private void start() {
        targets.add(3);
        for (int i = 1; true; ++i) {
            if (addAndCheck(i * 6 - 1)) {
                break;
            }
            if (addAndCheck(i * 6 + 1)) {
                break;
            }
        }

        StringBuilder builder = new StringBuilder();
        for (int i : targets) {
            if (builder.length() > 0) {
                builder.append(' ');
            }
            builder.append(i);
        }

        System.out.println(builder);
    }

    private boolean addAndCheck(int num) {
        if (isPrime(num)) {
            primes.add(num);
            if (num % 10 == 3) {
                targets.add(num);
                if (targets.size() >= n) {
                    return true;
                }
            }
        }

        return false;
    }

    private boolean isPrime(int num) {
        for (int i : primes) {
            if (num % i == 0) {
                return false;
            }
            if (num <= i * i) {
                return true;
            }
        }
        return true;
    }
}

Measured memory_bytes: 22100
N = int(input())
dic, rst = {}, []
for i in range(N):
    key = input()
    if key in dic:
        dic[key] += 1
    else:
        dic[key] = 1
max_val = max(dic.values())
rst = [ key for key, value in dic.items() if value == max_val ]
[ print(i) for i in sorted(rst) ]

Measured memory_bytes: 36400
fn read<T: std::str::FromStr>() -> (T, T) {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let mut iter = buf.split_whitespace().map(|x| x.parse().ok().unwrap());
    (iter.next().unwrap(), iter.next().unwrap())
}

fn main() {
    let (n, m) = read::<usize>();
    let mut v1 = vec![false; n + 1];
    let mut v2 = vec![false; n + 1];
    for _ in 0..m {
        let (a, b) = read::<usize>();
        v1[b] |= a == 1;
        v2[a] |= b == n;
    }
    if (1..n + 1).any(|i| v1[i] & v2[i]) {
        println!("POSSIBLE");
    } else {
        println!("IMPOSSIBLE"); 
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const ll INF=(ll)1e18+1;
ll a,b,c,d;

ll solve(ll n){
    map<ll,ll> mp;
    priority_queue<pair<ll,ll>> q;
    q.push({n,0});
    while(q.size()){
        auto p = q.top();
        q.pop();
        if(mp[p.first] < 0) {
            cout << p.first << " " << p.second << " " << mp[p.first] << endl;
            break;
        }

        for(int x: {2,3,5}){
            ll cost=0;
            if(x==2) cost = a;
            else if(x==3) cost = b;
            else cost = c;

            ll m = p.first;
            ll y = mp[m];
            pair<ll,ll> np1,np2;
            if(m == 1){
                if(mp[0] == 0){
                    q.push({0,y+d});
                    mp[0] = y+d;
                }
                mp[0] = min(mp[0],y+d);
                continue;
            }
            
            np1.first = m/x;
            np1.second = y+(m%x) * d + cost;
            if((np1.second-y)/d > abs(m-np1.first))
                np1.second = min(np1.second,y+abs(m-np1.first)*d);
            // cout << "np1:" << np1.first << " " << np1.second << endl;
            if(mp[np1.first] == 0) {
                q.push(np1);
                mp[np1.first] = np1.second;
            }
            mp[np1.first] = min(mp[np1.first], np1.second);

            if(m%x!=0){
                np2.first = m/x+1;
                np2.second = y+(x-m%x)*d + cost;
                if((np2.second-y)/d > abs(m-np2.first))
                    np2.second = min(np2.second,y+abs(np2.first-m)*d);
                // cout << "np2:" << np2.first << " " << np2.second << endl;
                if(mp[np2.first] == 0) {
                    q.push(np2);
                    mp[np2.first] = np2.second;
                }
                mp[np2.first] = min(mp[np2.first], np2.second);
            }
        }
    }

    // for(auto p:mp){
    //     cout << p.first << " " << p.second << endl;    
    // }
    return mp[0];
}

int main(){
    int t;
    cin >> t;
    ll n;
    vector<vector<ll>> vp;
    rep(i,t){
        vector<ll> v(5);
        cin >> v.at(0) >> v.at(1) >> v.at(2) >> v.at(3) >> v.at(4);
        vp.push_back(v);
    }

    rep(i,t){
        n=vp.at(i).at(0);
        a=vp.at(i).at(1);
        b=vp.at(i).at(2);
        c=vp.at(i).at(3);
        d=vp.at(i).at(4);
        ll res = solve(n);
        cout << res << endl;
    }

    return 0;
}

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

int main(void){
    int i, n;
    cin >> n ;
    int *a;
    a = new int[n];
    for(i=0; i<n; i++) cin >> a[i];
    
    int first;
    int f_max, s_max;
    first = 0;
    f_max = 0;
    s_max = 0;
    for(i=0; i<n; i++){
        if(f_max<a[i]){
            s_max = f_max;
            first = i;
            f_max = a[i];
        }else if(s_max<a[i]){
            s_max = a[i];
        }
    }
    // output
    for(i=0; i<n; i++){
        if(i!=first){
            cout << f_max << endl;
        }else{
            cout << s_max << endl;
        }
    }
    
    
    return 0;
}
    

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

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REP1(i,n) for(int i = 1; i <= (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define ALL(a) begin(a), end(a)
#define MP(a,b) make_pair((a), (b))
#define ROUNDUP(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second
#define DEBUG(a) cout << #a << ": " << a << "\n"
// #define DEBUG(a) {}

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

constexpr int MOD = 1e9 + 7;
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 4 * 1e18 + 1;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

int dx[] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1, 0};

template<typename T>
T debug(T x) {
	DEBUG(x);
	return x;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vi a(n);
	REP(i, n) cin >> a[i];
	vi aa = a;
	sort(ALL(aa));
	REP(i, n){
		if(a[i] <= aa[n / 2 - 1]) cout << aa[n / 2] << "\n";
		else cout << aa[n / 2 - 1] << "\n";
	}
	return 0;
}


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

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int  MOD=1000000007;
const int  INF= int(1e9);
const int  MAX=100007;
int dp[MAX],a[MAX],n;

int main()
{
	ios_base::sync_with_stdio(false);
    cin>>n;
    for(int i=0;i<n;i++) {
        cin>>a[i];
    }
    vi lis;
    lis.push_back(a[0]);
    for(int i=1;i<n;i++) {
        if(a[i] > *(lis.rbegin())) {
            lis.push_back(a[i]);
        } else {
            auto it= lower_bound(lis.begin(),lis.end(),a[i]) ;
            *it=a[i];
        }
    }
    cout<<lis.size()<<"\n";
	return 0;

}

Measured memory_bytes: 3872
s = input()
 
answer = "Yes"
 
for i in range(len(s)):
    if i % 2 == 0 and s[i] == "L":
        answer = "No"
        break
    if i % 2 == 1 and s[i] == "R":
        answer = "No"
        break
 
print(answer)

Measured memory_bytes: 2940
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
q = deque()
q.append(['0',1])
qq = []
while q:
    a,b = q.popleft()
    if b >= n: 
        qq.append(a)
        continue
    ln = len(a)
    mx = 0
    for i in a:
        mx = max(mx, int(i))
    for i in range(mx+2):
        tmp = a + str(i)
        q.append([tmp,b+1])
qq.sort()
lr = len(qq)
for i in range(lr):
    a = qq[i]
    res = []
    for j in a:
        res.append(chr(ord('a') + int(j)))
    print(''.join(res))


Measured memory_bytes: 25600
#include <iostream>
using namespace std;
int main(void){
  int a;
  cin >> a;
  if (a % 2 == 0){
    cout << 0.5 << endl;
  } else {
    cout << (double)(a + 1) / (double)(a * 2) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n,k=map(int, input().split())
k -= 1
s = [i for i in input()]

if s[k] == 'A':
    s[k] = 'a'
if s[k] == 'B':
    s[k] = 'b'
if s[k] == 'C':
    s[k] = 'c'

for i in range(n):
    print(s[i], end='')

print()

Measured memory_bytes: 3060
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

VI A(123456);
bool used[123456]={false};

void dfs(int i,int &num){
    if(A[i]==2){num++; return;}

    cerr<<i<<" "<<A[i]<<endl;
    if(used[i]==false){
        used[i]=true;
        num++;

        dfs(A[i],num);
    }
    else{
        num=-1;
    }
}


int main(){
    
    int n;
    cin>>n;
    REP(i,n){
        cin>>A[i+1];
    }
    int num;
    dfs(1,num);
    cout<<num<<endl;
}


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

using namespace std;

typedef long long ll;

struct Node {
    ll sum, val;
};

struct IT {
private:
    vector<Node> t;
    int n;

    void propagate(int id, int l, int r) {
        ll &x = t[id].val;
        if (x != -1) {
            int m = (l+r)/2;
            t[2*id].val = t[2*id+1].val = x;
            t[2*id].sum = (m-l+1)*x;
            t[2*id+1].sum = (r-m)*x;
            x = -1;
        }
    }

    void update(int id, int l, int r, int i, int j, ll x) {
        if (l > j || r < i) return;
        if (i <= l && r <= j) {
            t[id].val = x;
            t[id].sum = (r-l+1)*x;
            return;
        }
        propagate(id, l, r);
        int m = (l+r)/2;
        update(2*id, l, m, i, j, x); update(2*id+1, m+1, r, i, j, x);
        t[id].sum = t[2*id].sum + t[2*id+1].sum;
    }

    long long query(int id, int l, int r, int i, int j) {
        if (l > j || r < i) return 0;
        if (i <= l && r <= j) return t[id].sum;
        propagate(id, l, r);
        int m = (l+r)/2;
        return query(2*id, l, m, i, j) + query(2*id+1, m+1, r, i, j);
    }

public:
    IT(int n): n(n) {t.assign(4*n+1, {0, -1});}

    void update(int i, int j, ll x) {update(1, 1, n, i, j, x);}

    long long query(int i, int j) {return query(1, 1, n, i, j);}
};

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

    IT t(n);

    for(int i = 0; i < q; ++i) {
        int r; ll p;
        scanf("%d%lld", &r, &p);

        int lo = 1, hi = r-1, l = r;
        while (lo <= hi) {
            int mid = (lo + hi)/2;
            ll aMid = t.query(mid, mid);
            ll x = (r-mid+1)*aMid - t.query(mid, r);

            if (x <= p) {
                l = mid;
                hi = mid-1;
            } else
                lo = mid+1;
        }

        ll aL = t.query(l, l);
        p -= (r-l+1) * aL - t.query(l, r);

        ll aNew = aL + p/(r-l+1);
        int m = l + p%(r-l+1) - 1;
        t.update(l, m, aNew + 1);
        t.update(m + 1, r, aNew);
    }

    for(int i = 1; i <= n; ++i)
        printf("%lld\n", t.query(i, i));

    return 0;
}


Measured memory_bytes: 7808
from itertools import product
N, A, B, C = [int(i) for i in input().split()]
l_ls = list()
for i in range(N):
    l_ls.append(int(input()))
best = 1e9
for combi in product(range(4),repeat=N):
    a = [l for l, label in zip(l_ls, combi) if label == 1]
    b = [l for l, label in zip(l_ls, combi) if label == 2]
    c = [l for l, label in zip(l_ls, combi) if label == 3]
    dis = abs(A - sum(a)) + abs(B - sum(b)) + abs(C - sum(c)) \
          + (len(a) + len(b) + len(c) - 3) * 10
    if len(a) * len(b) * len(c) == 0:
        continue
    if best > dis:
        best = dis
print(best)

Measured memory_bytes: 3192
n, k = map(int,input().split(" "))
num_count = dict()
for i in range(n):
    a, b = map(int, input().split(" "))
    if a not in num_count:
        num_count[a] = 0

    num_count[a] += b

temp = 0
for key in sorted(num_count.keys()):
    temp += num_count[key]
    if temp >= k:
        print(key)
        break


Measured memory_bytes: 10596
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = null;
		PrintStream out = null;
		try {
			sc = new Scanner(System.in);
			out = System.out;
			exec(sc, out);
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			if(out != null) {
				out.close();
			}
			if(sc != null) {
				sc.close();
			}
		}
		System.exit(0);
	}
	private static void next(final long[] T, final long[] R, int n) {
		for(int i=0;i<13;i++) {
			int index =(i*10+n)%13;
			T[index] = T[index]+R[i];
		}
	}
	public static void exec(final Scanner sc, final PrintStream out) throws Exception{
		final String S = sc.nextLine();
		final int L = S.length();
		final long[] R = new long[13];
		final long[] T = new long[13];
		final long mod = 1000000000+7;
		for(int i=0;i<13;i++) {
			R[i] = 0L;
			T[i] = 0L;
		}

		char c = S.charAt(0);
		if(c=='?') {
			for(int r=0;r<10;r++) {
				R[r] = 1;
			}
		}else {
			R[(int)(c-'0')] = 1;
		}


		for(int i=1;i<L;i++) {
			for(int t=0;t<13;t++) {
				T[t] = 0;
			}
			c = S.charAt(i);
			if(c=='?') {
				for(int r=0;r<10;r++) {
					next(T, R, r);
				}
			}else {
				next(T, R, (int)(c-'0'));
			}
			for(int j=0;j<13;j++) {
				R[j]=T[j]%mod;
			}

		}
		out.println(R[5]);
	}
}


Measured memory_bytes: 27772
#include <iostream>
#include <stdio.h>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <deque>
#include <algorithm>
#include <math.h>
#include <random>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define int long long
#define double long double
#define Matrix vector<vector<int> >
#define kektor vector

using namespace std;

typedef long long ll;

int RanddInt(int min, int max) {
  if (max < min) {
    return 0;
  }
  random_device rd;
  mt19937 mt(rd());
  uniform_int_distribution<int> dist(min, max);
  return dist(mt);
}

const int maxn = 1e3, mod = 1e9 + 7;
bool debug = false;
int x, y; 

void solve()  { 
	cin >> x >> y;
	if (x % y == 0) {
		cout << -1;
		return; 
	}
	cout << x;
}


signed main() {
    /*!

    !*/
    cout.precision(10);
    cout << fixed;
    if (!debug) {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    }
//   	freopen("TASK.in", "r", stdin);
  // 	freopen("TASK.out", "w", stdout);
    solve();
    return 0;
}


Measured memory_bytes: 256
/******************************************
*    AUTHOR:         CHIRAG AGARWAL       *
*    INSTITUITION:   BITS PILANI, PILANI  *
******************************************/
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL; 
typedef long double LD;
const int MAX=5e5+5;
int pr[MAX];
int nxt[MAX];
int dp[MAX];


int main() 
{
	int n;
	scanf("%d",&n);
	string s;
	cin>>s;
	s=' '+s;
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='0')
		{
			pr[i]=i;
		}
		else
		{
			pr[i]=pr[i-1];
		}
	}
	nxt[n+1]=n+1;
	for(int i=n;i>=1;i--)
	{
		if(s[i]=='0')
		{
			nxt[i]=i;
		}
		else
		{
			nxt[i]=nxt[i+1];
		}
	}

	for(int i=1;i<=n;i++)
	{
		if(i>=3&&s[i]=='1'&&s[i-1]=='0'&&s[i-2]=='1')
		{
			int lstone=pr[i-2]+1;
			dp[i]=max(dp[lstone-1]+(i-lstone-1),dp[i]);
			if(lstone!=(i-2))
			dp[i]=max(dp[lstone]+(i-lstone-2),dp[i]);
			lstone=nxt[i]-1;
			dp[lstone]=max(dp[lstone],dp[i-3]+(lstone-i+1));
			if(lstone!=i)
			dp[lstone-1]=max(dp[lstone-1],dp[i-3]+(lstone-i));
		}
		dp[i+1]=max(dp[i+1],dp[i]);
	}
	printf("%d\n",dp[n+1]);
	
	return 0;
}


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

using namespace std;

int main()
{
    string a;
    cin>>a;
    int len=a.length();
    int sum=0;
    for(int i=0;i<len;i++)
        {
            sum+=a[i]-'0';
        }
        if(sum%9==0)cout<<"Yes";
        else cout<<"No";

    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v(1,1);
  for (ll i = 2; n >= i * i; ++i) {
		if(!(n % i)){
      v.pb(i);
	  }
  }
  if(v.size()==1)v.pb(n);
  return v;
}


int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n>>n>>n>>n;
  print(n == 1);
  return 0;
} 

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAX = 5010;
const int P = 1e9 + 7;
void add(int &a,int b){
  a += b;
  if(a >= P) a-= P;
}
int mul(int a,int b){
  return a * b % P;
}
int n,a,b;
int p2[MAX];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n >> a >> b;
  p2[0] = 1;
  R(i,MAX-1){
    p2[i+1] = p2[i];
    add(p2[i+1], p2[i]);
  }
  if(a < b)swap(a, b);
  if(a == 1 || b == 1){
    cout << p2[n] << "\n";
    return 0;
  }
  vector<vector<int>> dpa(n+1,vector<int>(n+1));
  vector<vector<int>> dpb(n+1,vector<int>(n+1));
  dpa[0][0] = 1;
  int res = 0;
  for(int i = 0; i < n; i++){
    int sum = 0;
    for(int j = 0; j < a; j++){
      add(sum, dpa[i][j]);
      if(i + b <= n){
        if(j + b >= a){
          add(res, mul(p2[n-i-b], dpa[i][j]));
        }else{
          add(dpb[i + b][j + b], dpa[i][j]);
        }
      }
      if(j != a-1){
        add(dpa[i+1][j+1], dpa[i][j]);
        add(dpa[i+1][j+1], dpb[i][j]);
        add(dpb[i+1][j+1], dpb[i][j]);
      }else{
        int mn = 0;
        add(mn, dpa[i][j]);
        add(mn, dpb[i][j]);
        add(mn, dpb[i][j]);
        add(res, mul(mn, p2[n-i-1]));
      }
    }
    for(int j = 1; j < b; j++){
      if(i + j + 1 < n){
        add(dpa[i + j + 1][1], sum);
      }
    }
  }
  cout << res << "\n";
}


Measured memory_bytes: 394444
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ARB ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pp __builtin_popcount
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
int main()
{
    ARB
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])
        cout<<"Yes";
    else
        cout<<"No";
}


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

int a,b,c;

int main(void)
{
	cin>>a>>b>>c;
	if(a-c>=0)cout<<0;
	else if(b<(c-a))cout<<"NA";
	else cout<<(c-a);
	cout<<endl;


	return 0;
}



Measured memory_bytes: 3136
import java.io.*;
import java.util.*;

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		String S;
		S = sc.next();
		String T;
		T = sc.next();
		long A;
		A = sc.nextLong();
		long B;
		B = sc.nextLong();

		Map<String, Long> h = new HashMap<>();
		h.put(S, A);
		h.put(T, B);
		String U = sc.next();
		if (h.containsKey(U)) {
			h.put(U, h.get(U) - 1);
		}

		System.out.println(h.get(S) + " " + h.get(T));
	}
}


Measured memory_bytes: 22996
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const long long LINF = 1000000000000000018ll;
const int INF = 1000000009;
const int mod = 1000000007;
const int mod2 = 998244353;

int dx[] = {-1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};

int main() {
  std::cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::setprecision(20) << std::fixed;

  int n;
  cin >> n;

  map<string, bool> mp;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    mp[s] = true;
  }

  cout << mp.size() << endl;

  return 0;
}


Measured memory_bytes: 19248
def main():
  import sys
  
  a, b, m = map(int, input().split())
  a = list(map(int, sys.stdin.readline().split()))
  b = list(map(int, sys.stdin.readline().split()))
  ans = min(a) + min(b)
  
  for _ in range(m):
    i, j, c = map(int, input().split())
    ans = min(ans, a[i-1]+b[j-1]-c)
  
  print(ans)
  
if __name__=='__main__':
  main()

Measured memory_bytes: 18616
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<cstring>
using namespace std;
 
int main(){

  int n, d[100], ans=1;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> d[i];
  }

  sort(d, d+n);
  for(int i=0; i<n-1; i++){
    if(d[i]<d[i+1]){
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int x[10000],y[10000],i,j,h,w;
  for(i=0;i<10000;i++){
    scanf("%d %d",&x[i],&y[i]);
    if(x[i]==0&&y[i]==0){
      break;
    }
  }
  for(j=0;j<i;j++){
    for(h=0;h<x[j];h++){
      for(w=0;w<y[j];w++){
        if(h%2==0){
          if(w%2==0){
            printf("#");
          }
          else{
            printf(".");
          }
        }
        else{
          if(w%2==0){
            printf(".");
          }
          else{
            printf("#");
          }
        }
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 2572
#include<stdio.h>
int main()
{
    int n,a,b;
    scanf("%d %d %d",&n,&a,&b);
    while(a<b && a,b>=0 && a,b<=n)
    {
        a++;
        if(a==b)
            {printf("Borys");
            break;
            }
        if(b-a ==1)
        {
            printf("Alice");
             break;
        }

        b--;

    }
    return 0;
}


Measured memory_bytes: 1728
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;

//Prim
struct edge{int to,cost;};

int main(){
  int V,E;
  vector<edge> G[10000];
  scanf("%d %d",&V,&E);
  for(int i=0;i<E;i++){
    int s,t,w;
    scanf("%d %d %d",&s,&t,&w);
    edge tmp;
    tmp.cost = w;
    tmp.to = t;
    G[s].push_back(tmp);
    tmp.to = s;
    G[t].push_back(tmp);
  }
  int ans = 0;
  bool used[V];
  fill(used,used+V,false);
  priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > q;
  q.push(make_pair(0,0));
  while(!q.empty()){
    pair<int,int> p = q.top();
    q.pop();
    int c = p.first;
    int v = p.second;
    if(used[v]) continue;
    used[v] = true;
    ans+=c;
    for(int i=0;i<G[v].size();i++){
      q.push(make_pair(G[v][i].cost,G[v][i].to));
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 7380
<?php
error_reporting(0);
$N = trim(fgets(STDIN));
//$A = explode(" ",trim(fgets(STDIN)));
//list($N,$A,$B) = explode(" ",trim(fgets(STDIN)));
$len = strlen($N);
$h = 0;
for($i=0;$i<$len;$i++) {
  $h += $N[$i];
}
if (($N % $h) == 0) {
  printf("Yes\n");
}
else {
  printf("No\n");
}


Measured memory_bytes: 3828
char a[2][204];n,m,i,j,c,p;main(s){for(;i=scanf(m="%d %[^\n] %[^\n]",&n,a,a+1)>2;printf(m<n?"%d\n":"NA\n",m)){for(;~i;m>c?m=c:0,--i)for(j=i,c=p=0;s=a[j][p+p]-50,c<n&&!s|n+~p;)p+=p<n&&s?~s|a[j][p+p+2]-49?j=!j,++c,2:1:-1;}}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

signed main() {
  int N;
  cin >> N;
  
  int a = 1;
  for (int i = 2; i * i <= N; ++i) {
    if (N % i == 0) a = max(a, i);
  }
  int b = N / a;
  int ans = a + b - 2;
  
  cout << ans << endl;
  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define pb push_back
typedef long long ll;
#define int long long
#define ld long double
#define f(i,n) for(ll i=0;i<n;i++)
#define fo(i,a,b) for(ll i=a;i<=b;i++)
#define forr(i,a,b) for(ll i=a;i>=b;i--)
#define ee endl
#define mem(a,b) memset(a,b,sizeof(a))
#define bp __builtin_popcount
#define all(x) (x).begin(),(x).end()
#define s(x) sort(all(x))
#define r(x) reverse(all(x))
#define sz size()
#define ln length()
#define mod 1000000007
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second 
#define mxe(v) *max_element(all(v))
#define vl vector<ll>
#define pll pair<ll,ll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 
#define KHILADI ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))

ll max(ll a , ll b){ if(a>b) return a; else return b;}
ll min(ll a , ll b){ if(a<b) return a; else return b;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}          
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

void solve(int ttt)
{
    ll n;
    cin >> n;
    cout << n+pow(n,2)+ pow(n,3);
}

signed main()
{
    KHILADI;
    ll test_case=1;
    //cin >> test_case;
    fo(ttt,1,test_case)
    {
        solve(ttt);
    }
    return 0;
}

Measured memory_bytes: 4208
mod = 1000000007
N, K = map(int, input().split())

S = [0]
for i in range(N):
	S.append(S[i]+i+1)

r = 1

for i in range(K, N+1):
	up = S[N]-S[N-i]
	low = S[i-1]
	r = (r+(up-low+1))%mod

print(r)

Measured memory_bytes: 19232
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = scan.nextInt();
        System.out.println(solve(n));
    }
    public static int solve(int n) {
        int[] nine = new int[6];
        nine[0] = 9;
        for(int i = 1; i < 6; i++) {
            nine[i] = nine[i-1] * 9;
        }
        int[] six = new int[7];
        six[0] = 6;
        for(int i = 1; i < 7; i++) {
            six[i] = six[i - 1] * 6;
        }
        int[] dp = new int[100001];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;
        dp[1] = 1;
        for(int i = 0; i < nine.length; i++) {
            if (nine[i] <= n) {
                dp[nine[i]] = 1;
            }
        }
        for(int i = 0; i < six.length; i++) {
            if (six[i] <= n) {
                dp[six[i]] = 1;
            }
        }
        for (int i = 1; i < n; i++) {
            if (dp[i] == Integer.MAX_VALUE) {
                continue;
            }
            dp[i+1] = Math.min(dp[i+1], dp[i]+1);
            for(int j = 0; j < nine.length; j++) {
                if (i + nine[j] <= n) {
                    dp[i + nine[j]] = Math.min(dp[i + nine[j]], dp[i] + 1);
                }
            }
            for(int j = 0; j < six.length; j++) {
                if (i + six[j] <= n) {
                    dp[i + six[j]] = Math.min(dp[i + six[j]], dp[i] + 1);
                }
            }
        }
        return dp[n];
    }
}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
int N, A[3][3], b[10];
bool appear[3][3];
int main() {
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) cin >> A[i][j];
    }
    cin >> N;
    for(int i = 0; i < N; i++) cin >> b[i];
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            appear[i][j] = false;
            for(int k = 0; k < N; k++) {
                if(A[i][j] == b[k]) appear[i][j] = true;
            }
        }   
    }
    string ANS = "No";
    for(int i = 0; i < 3; i++) {
        if(appear[i][0] and appear[i][1] and appear[i][2]) ANS = "Yes";
    }
    for(int i = 0; i < 3; i++) {
        if(appear[0][i] and appear[1][i] and appear[2][i]) ANS = "Yes";
    }
    if(appear[0][0] && appear[1][1] && appear[2][2]) ANS = "Yes";
    if(appear[0][2] && appear[1][1] && appear[2][0]) ANS = "Yes";
    cout << ANS << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

		//?????£?????????
		int numN;

		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			String line = br.readLine();

			numN = Integer.parseInt(line);

			//????????¨
			String outputNum = "";

			for (int i = 1; i <= numN; i++) {



				//3????????°????????§??????
				if(i % 3 == 0){
					outputNum +=" " + i;

				//3???????????°???????????§??????
				}else if (String.valueOf(i).indexOf("3") != -1) {
					outputNum +=" " + i;
				}
			}
			//???????????????
			System.out.println(outputNum);
		}catch (NumberFormatException e) {
			System.out.println(e);
		} catch (IOException e) {
			System.out.println(e);
		}

	}

}

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

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

    int a[20], x[20][20], y[20][20];

    rep(i, n){
        cin >> a[i + 1];
        rep(j, a[i + 1]){
            cin >> x[i + 1][j + 1];
            cin >> y[i + 1][j + 1];
            x[i + 1][j + 1]--;
        }
    }
    int ans = 0;
    for (int bits = 1; bits < (1<<n); bits++){
        bool flag = true;
        for(int i = 1; i <= n; i++){
            if (bits & (1<<(i - 1))){
                for(int j = 1; j <= a[i]; j++){
                    if ((1 & (bits>>x[i][j])) ^ y[i][j]) flag = false;
                }
            }
        }
        if (flag) ans = max(ans, __builtin_popcount(bits));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);



	class scH extends HashMap<String, Character> {

		public Character put(Character value, String key) {

			// TODO Auto-generated method stub

			return super.put(key, value);

		}

	}



	class scH2 extends HashMap<Character, String> {

		public String put(String value, Character key) {

			// TODO Auto-generated method stub

			return super.put(key, value);

		}

	}



	void run() {

		scH hash = new scH();

		// HashMap<Character, String> hash = new HashMap<Character, String>();

		hash.put(' ', "101");

		hash.put('\'', "000000");

		hash.put(',', "000011");

		hash.put('-', "10010001");

		hash.put('.', "010001");

		hash.put('?', "000001");

		hash.put('A', "100101");

		hash.put('B', "10011010");

		hash.put('C', "0101");

		hash.put('D', "0001");

		hash.put('E', "110");

		hash.put('F', "01001");

		hash.put('G', "10011011");

		hash.put('H', "010000");

		hash.put('I', "0111");

		hash.put('J', "10011000");

		hash.put('K', "0110");

		hash.put('L', "00100");

		hash.put('M', "10011001");

		hash.put('N', "10011110");

		hash.put('O', "00101");

		hash.put('P', "111");

		hash.put('Q', "10011111");

		hash.put('R', "1000");

		hash.put('S', "00110");

		hash.put('T', "00111");

		hash.put('U', "10011100");

		hash.put('V', "10011101");

		hash.put('W', "000010");

		hash.put('X', "10010010");

		hash.put('Y', "10010011");

		hash.put('Z', "10010000");



		scH2 hash2 = new scH2();

		// HashMap<String, Character> hash2 = new HashMap<String, Character>();

		hash2.put("00000", 'A');

		hash2.put("00001", 'B');

		hash2.put("00010", 'C');

		hash2.put("00011", 'D');

		hash2.put("00100", 'E');

		hash2.put("00101", 'F');

		hash2.put("00110", 'G');

		hash2.put("00111", 'H');

		hash2.put("01000", 'I');

		hash2.put("01001", 'J');

		hash2.put("01010", 'K');

		hash2.put("01011", 'L');

		hash2.put("01100", 'M');

		hash2.put("01101", 'N');

		hash2.put("01110", 'O');

		hash2.put("01111", 'P');

		hash2.put("10000", 'Q');

		hash2.put("10001", 'R');

		hash2.put("10010", 'S');

		hash2.put("10011", 'T');

		hash2.put("10100", 'U');

		hash2.put("10101", 'V');

		hash2.put("10110", 'W');

		hash2.put("10111", 'X');

		hash2.put("11000", 'Y');

		hash2.put("11001", 'Z');

		hash2.put("11010", ' ');

		hash2.put("11011", '.');

		hash2.put("11100", ',');

		hash2.put("11101", '-');

		hash2.put("11110", '\'');

		hash2.put("11111", '?');



		for (; sc.hasNextLine();) {

			String buffer = sc.nextLine();

			String b = "";

			for (char c : buffer.toCharArray()) {

				b += hash2.get(c);

			}

			String temp = "";

			String ans = "";

			for (int index = 0;index < b.length(); index++) {

				temp+=b.charAt(index);

				if(hash.containsKey(temp)){

					ans += hash.get(temp);

					temp = "";

				}

			}

			System.out.println(ans);

		}

	}



	public static void main(String[] args) {

		Main m = new Main();

		m.run();

	}

}

Measured memory_bytes: 12000