akhauriyash/Code-Regression huggingface dataset:
use text_io::*;
use std::process::exit;

fn main(){
    let a:usize = read!();
    let b:usize = read!();
    let mut v:Vec<usize> = Vec::new();
    for i in 0..b {
        let d:usize = read!();
        v.push(d);
    }
    for i in 0..200 {
        if v.contains(&(a-i)) {
        }
        else {
            println!("{}",a-i);
            exit(0);
        }
        if v.contains(&(a+i)) {
        }
        else {
            println!("{}",a+i);
            exit(0);
        }
    }
}

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

int main(){
    int a,p;
    cin >> a >> p;
    int ans = (3*a+p)/2;
    cout << ans << endl;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;


namespace AtCoder
{
    class Program
    {
        public static void Main()
        {
            new Program().Solve();
        }

        void Solve()
        {
            var tmp = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int n = tmp[0];
            int k = tmp[1];
            var a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            var dict = new Dictionary<int, int>();
            for (int i = 0; i < a.Length; i++)
            {
                if (dict.ContainsKey(a[i]))
                {
                    dict[a[i]]++;
                }
                else
                {
                    dict.Add(a[i], 1);
                }
            }

            int r = dict.Count - k;
            int count = 0;
            if (r > 0)
            {
                foreach (var item in dict.OrderBy(x => x.Value))
                {
                    count += item.Value;
                    r--;
                    if (r <= 0)
                        break;
                }

            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 41680
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i > 0; i--)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
template <typename Iter> std::string join(Iter begin, Iter end, std::string const& separator){ std::ostringstream result; if (begin != end){ result << *begin++; }; while (begin != end){ result << separator << *begin++; }; return result.str(); }
using namespace std;
typedef long long ll;
ll match_id(ll p1, ll p2, ll N) {
  ll p3 = min(p1, p2);
  ll p4 = max(p1, p2);
  return p3 * N + p4;
}
pair<ll, ll> match_pair(ll id, ll N) {
  ll p1 = id / N;
  ll p2 = id % N;
  ll p3 = min(p1, p2);
  ll p4 = max(p1, p2);
  return make_pair(p3, p4);
}
void solve() {
  ll N; cin >> N;
  vector<vector<ll>> A(N, vector<ll>(N-1));
  REP(i, N) {
    REP(j, N-1) {
      ll a;
      cin >> a;
      a--;
      A[i][j] = a;
    }
  }
  vector<vector<ll>> next_match(N * N + N, vector<ll>(2, -1));
  vector<ll> depend(N * N + N, 0);
  REP(i, N) {
    REP(j, N-2)  {
      ll p1 = i;
      ll p2 = A[i][j];
      ll p2next = A[i][j+1];
      ll current = match_id(p1, p2, N);
      ll next = match_id(p1, p2next, N);
      if(next_match[current][0] == -1) {
        next_match[current][0] = next;
      } else {
        next_match[current][1] = next;
      }
      depend[next]++;
    }
  }
  unordered_set<ll> avail;
  REP(i, N) {
    ll p1 = i;
    ll p2 = A[i][0];
    auto match = match_id(p1, p2, N);
    if(depend[match] == 0) {
      avail.insert(match);
    }
  }
  ll n_match = 0;
  REP(d, N * (N - 1) / 2) {
    if(avail.size() == 0) {
      cout << -1 << endl;
      return;
    }
    unordered_set<ll> next_avail;
    for(auto m: avail) {
      n_match++;
      for(auto next: next_match[m]) {
        if(next == -1) continue;
        depend[next]--;
        if(depend[next] == 0) next_avail.insert(next);
      }
    }
    avail = next_avail;
    if(n_match == N * (N - 1) / 2) {
      cout << d + 1 << endl;
      return;
    }
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 70656
import numpy as np
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()

n,wmax=IL()
dp=np.zeros(wmax+1,dtype=int)
for i in range(n):
    w,v=IL()
    dp[w:]=np.maximum(dp[w:],dp[:-w]+v)
print(dp[wmax])

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

int main() {
	int n;
	cin>>n;
	int x[n];
	int dp[n];
	for(int i=0;i<n;i++){
		cin>>x[i];
	}
	dp[0]=0;
	dp[1]=abs(x[0]-x[1]);
	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-2]+abs(x[i]-x[i-2]),dp[i-1]+abs(x[i]-x[i-1]));
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;

int main(void){
    // Your code here!
    ll N,K;
    cin >> N >> K;
    
    vector<pair<ll, ll>> ab(N);
    
    for(ll i = 0; i < N; i++){
        cin >> ab.at(i).first >> ab.at(i).second;
    }
    
    sort(ab.begin(), ab.end());
    
    
    
    
    ll now = 0;
    for(ll i = 0; i < N; i++){
        now += ab.at(i).second;
        if(now >= K){
            cout << ab.at(i).first << endl;
            break;
        }
    }
    
}



Measured memory_bytes: 1792
import itertools
S = list(itertools.accumulate([0] + [1 if s == 'A' else 0 for s in input()]))
T = list(itertools.accumulate([0] + [1 if t == 'A' else 0 for t in input()]))
Q = int(input())
ABCD = [[int(_) for _ in input().split()] for _ in range(Q)]
for a, b, c, d in ABCD:
    x = ((b - a + 1) + (S[b] - S[a - 1]))
    y = ((d - c + 1) + (T[d] - T[c - 1]))
    print('NO') if (x - y) % 3 else print('YES')


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

int main()
{
    int t,c=0;
    cin>>t;
    int ar[t];
    for(int i=0;i<t;i++){
        cin>>ar[i];
    }
    for(int i=1;i<t-1;i++){
        if((ar[i]>ar[i+1] && ar[i]<ar[i-1]) || (ar[i]<ar[i+1] && ar[i]>ar[i-1])){
            c++;
        }
    }
    cout<<c<<endl;

}


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
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; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	while (N != 0) {
		vector<vb> Map(21,vb(21,false));
		REP(i, N) {
			int x, y;
			cin >> x >> y;
			Map[x][y] = true;
		}
		int M;
		cin >> M;
		pair<int, int> cur(10,10);
		int cnt = 0;
		REP(i, M) {
			char dir;
			int step;
			cin >> dir >> step;
			REP(i, step) {
				if (dir == 'N')cur.second++;
				else if (dir == 'E')cur.first++;
				else if (dir == 'S')cur.second--;
				else if (dir == 'W')cur.first--;
				if (Map[cur.first][cur.second]) {
					cnt++;
					Map[cur.first][cur.second] = false;
				}
			}
		}
		if (cnt == N) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		cin >> N;
	}
	return 0;
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int main(){
    i64 n,ans=0;
    cin>>n;
    for(i64 i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0) ans+=i;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3636
import sys
while True:
    dic = {}
    n = int(input())
    if n == 0:
        sys.exit(0)
    for _ in range(n):
        key, val = input().strip().split()
        dic[key] = val
    m = int(input())
    indata = []
    for i in range(m):
        indata.append(input().strip())
    outdata = []
    for c in indata:
        if c in dic:
            outdata.append(dic[c])
        else:
            outdata.append(c)

    print(''.join(outdata))

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


int main()
{
	long long A, B, K;
	cin >> A >> B >> K;
	if(B-A>K&& ((double)B - (double)A) / 2.0 +1.0> (double)K){
		for (int i = 0; i < K; ++i) {
			cout << A + i << endl;
		}
		for (int i = 0; i < K; ++i) {
			cout << B - K + i + 1 << endl;
		}
	}
	else {
		for (int i = 0; i <= B - A; ++i) {
			cout << A + i << endl;
		}
	}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];
const int INF = 1e9;
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B)
{
    vector<ll> ans(M);
    ans[M - 1] = N * (N - 1) / 2;
    UnionFind un(N);
    for (int i = M - 1; i >= 1; i--)
    {
        if (un.find(A[i]) != un.find(B[i]))
        {
            ans[i - 1] = ans[i] - un.size(A[i]) * un.size(B[i]);
            un.Union(A[i], B[i]);
        }
        else
        {
            ans[i - 1] = ans[i];
        }
    }

    for (int i = 0; i < M; i++)
    {
        cout << ans[i] << endl;
    }
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for (int i = 0; i < M; i++)
    {
        scanf("%lld", &A[i]);
        scanf("%lld", &B[i]);
        A[i]--;
        B[i]--;
    }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}


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

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))    
#define OUT(P) cout << (P) << endl    
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl    
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;    
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)    
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)    
typedef long long ll;    

int sum_digits(int num);    
template <class T>    
vector<T> copy_vector(vector<T> vec);    
int gcd(int a, int b);    

int main() {    
    int n, k;
    cin >> n >> k;
    int ans = 0;
    if(k > 1) {
        ans = n - k;
    }
    cout << ans << endl;

    return 0;    
}    

/******************************/    
/***** DECRARED FUNCTIONS *****/    
/******************************/    

int sum_digits(int num) {    
    int rtn = 0;    
    while(num != 0) {    
        int tmp = num % 10;    
        rtn += tmp;    
        num /= 10;    
    }    
    return rtn;    
}    

// vectorのコピー    
template <class T>    
vector<T> copy_vector(vector<T> vec) {    
    vector<T> rtn;    
    rtn.reserve(vec.size());    
    copy(vec.begin(), vec.end(), back_inserter(rtn));    
    return rtn;    
}    

// ユークリウッドの互除法    
int gcd(int a, int b) {    
    if(b==0) return a;    
    else return gcd(b, a % b);    
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

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

  return 0;
}


Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    a = LI()

    b = [0] * N
    for i in range(N):
        # (N-1-i)*2以降を全部足したのをaから引く
        tmp = 0
        for j in range(N - 1 - i, N, N - i):
            tmp ^= b[j]
        b[N-1-i] = tmp ^ a[N-1-i]

    m = b.count(1)
    print(m)
    if m >= 1:
        ans = []
        for i, e in enumerate(b):
            if e == 1:
                ans.append(i + 1)
        print(*ans)

if __name__ == '__main__':
    resolve()


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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main(){
   ll n;
   cin >> n;
   string ans;
   while(n>0){
      n--;
      ll p3 = n/26 , q3 = n%26;
      ans += 'a' + q3;
      n = p3;
   }
   reverse(ans.begin(),ans.end());
   cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h> 
using namespace std;
int main() {
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++) {cin>>a[i];}
  int dp[n+1]={0};
  dp[0]=0;
  dp[1]=abs(a[0]-a[1]);
  for(int i=2;i<n;i++) {
  	dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
  }
  cout<<dp[n-1]<<endl;
return 0;
}

Measured memory_bytes: 4380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;



int main(){
    ll N; cin >> N; 
    vector<ll> A(N); for(int i = 0; i < N; i++) cin >> A[i];
    vector<ll> DP(N+2);
    for(int i = N-1; i >= 0; i--){
        ll x = A[i];
        DP[x] = DP[x+1]+1;
    }
    ll Max = 1;
    for(int i = 1; i < N+1; i++) Max = max(Max, DP[i]);
    cout << N-Max << endl;






}

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

int main(){
  int N, K, x, S;
  cin >> N >> K;
  S = 0;
  for (int i = 0; i < N; i++){
    cin >> x;
    if (x < K - x){
      S += 2 * x;
    }
    else{
      S += 2 * (K - x);
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
#include<unordered_map>
#include<list>
#include<fstream>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;




int main(){
    ll n;
    cin>>n;
    vector<ll> a;
    for(int i=0;i<n;i++){
        ll b;
        cin>>b;
        a.push_back(b);
    }
    reverse(a.begin(),a.end());
    bool j=true;
    ll mi=1,mx=1;
    if(a[0]!=2){j=false;}
    for(int i=1;i<n && j;i++){
        ll s=mi*a[i-1];
        ll b=(mx+1)*a[i-1]-1;
        mi=(s+a[i]-1)/a[i];
        mx=b/a[i];
        //cout<<s<<" "<<b<<" "<<mi<<" "<<mx<<endl;
        if(mi>mx){j=false;}
        if(mx==0 || mi==0){j=false;}
    }
    if(!j){cout<<-1<<endl;}
    else{
        //cout<<mi<<" "<<mx<<endl;
        reverse(a.begin(),a.end());
        cout<<a[0]*mi<<" "<<(mx+1)*a[0]-1<<endl;
    }
    
    return 0;
}


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

using namespace std;

#define ll long long
#define ull unsigned long long
#define pl pair<ll, ll>
#define vll vector<ll>
#define pll vector<pair<ll, ll>>
#define f(i,a, b) for (ll i = a; i < b; i++)
#define ft int t; cin>>t; while(t--)
#define mp make_pair
#define pb push_back
#define ld float
#define fd(i,a, b) for (ll i = a; i >= b; i--)

 /*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
     typedef tree<ll ,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;*/

int main() {
int t=1;
while(t--){
 ll n,k;
 cin>>n>>k;
 ll dc=n/k;
 ll rem=n%k;
 cout<<min(n-dc*k,min(rem,k-rem));
}

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
const int N=1e6+10;
typedef long long ll;
const ll mod=1e9+7;
#define per(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define inf 0x3f3f3f3f
#define qwq puts("QWQ");
#define qaq puts("QAQ");
#define mem(a,b) memset(a,b,sizeof(a))
#define mid ((l+r)>>1)
#define l(x) x<<1
#define r(x) x<<1|1
#define lson rt<<1,l,mid
#define rson rt<<1|1,mid+1,r
void read(int &x)
{
	int f=1;x=0;
	char s=getchar();
	while(s<'0'||s>'9')
    {
    	if(s=='-')f=-1;
    	s=getchar();
	}
	while(s>='0'&&s<='9')x=x*10+s-'0',s=getchar();
	x*=f;
}
int a,b;
int main()
{
	read(a),read(b);
	b*=2;
	if(b>=a)puts("0");
	else printf("%d\n",a-b);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 1000005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 998244353;

int main()
{
    int n, k;
    string s;
    cin >> s >> k;
    n = s.size();
    vector<string>v;
    f(n) {
        fr(j,1,min(n-i,k) + 1) {
            v.pb(s.substr(i,j));
        }
    }
    sort(all(v));
    v.erase(unique(all(v)),v.end());
    cout << v[k-1] << '\n';
}


Measured memory_bytes: 1660
#include<iostream>
#include<vector>
int N;
std::vector<int>ans;
int main() {
	std::cin >> N;
	if (N == 3) {
		std::cout << 2 << " " << 3 << " " << 25 << std::endl;
		return 0;
	}
	std::cout << 3 << " " << 9;
	N -= 2;
	int M = 0;
	for (; N >= 2 && M + 4 <= 30000; N -= 2, M += 6) {
		std::cout <<" "<< M + 2 << " " << M + 4;
	}
	M = 12;
	for (; N >= 2 && M + 9 <= 30000; N -= 2, M += 12) {
		std::cout << " " << M + 3 << " " << M + 9;
	}
	M = 1;
	for (; N >= 1 && M*6 <= 30000; N--, M++) {
		std::cout << " " << 6 * M;
	}
	std::cout << std::endl;
	return 0;
}

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

int main()
{
	int n;
	cin >> n;
	int *a = new int[n];

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

	for (int i = 0; i < n; i++) {
		int v = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];			
			a[j] = v;
			j--;
		}
		for (int y = 0; y < n; y++) {
			cout << a[y];
			if (y != n - 1) cout << " ";
		}
		cout << "\n";
	}
	delete[] a;
	return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

int N;

struct Point{
	int x,y;
};

struct Info{
	int num_point;
	Point point[10];
};

void func(){

	Info base;
	int DIFF_X,DIFF_Y;

	int M;
	scanf("%d",&M);

	base.num_point = M;

	for(int i = 0; i < M; i++){
		scanf("%d %d",&base.point[i].x,&base.point[i].y);
	}

	DIFF_X = -base.point[0].x;
	DIFF_Y = -base.point[0].y;

	for(int i = 0; i < base.num_point; i++){
		base.point[i].x += DIFF_X;
		base.point[i].y += DIFF_Y;
	}

	Info tmp;

	int new_x,new_y;

	for(int id = 1; id <= N; id++){
		scanf("%d",&M);

		tmp.num_point = M;

		for(int i = 0; i < M; i++){
			scanf("%d %d",&tmp.point[i].x,&tmp.point[i].y);
		}

		if(base.num_point != tmp.num_point){
			continue;
		}

		DIFF_X = -tmp.point[0].x;
		DIFF_Y = -tmp.point[0].y;

		for(int i = 0; i < tmp.num_point; i++){
			tmp.point[i].x += DIFF_X;
			tmp.point[i].y += DIFF_Y;
		}

		bool FLG;
		int base_x_diff,base_y_diff,tmp_x_diff,tmp_y_diff;

		for(int loop = 0; loop < 4; loop++){

			for(int k = 0; k < tmp.num_point; k++){
				new_x = tmp.point[k].y;
				new_y = -tmp.point[k].x;
				tmp.point[k].x = new_x;
				tmp.point[k].y = new_y;
			}

			FLG = true;

			for(int i = 1; i < tmp.num_point; i++){
				base_x_diff = base.point[i].x - base.point[i-1].x;
				base_y_diff = base.point[i].y - base.point[i-1].y;
				tmp_x_diff = tmp.point[i].x - tmp.point[i-1].x;
				tmp_y_diff = tmp.point[i].y - tmp.point[i-1].y;

				if(base_x_diff != tmp_x_diff || base_y_diff != tmp_y_diff){
					FLG = false;
					break;
				}
			}

			if(FLG){
				printf("%d\n",id);
				break;
			}

			FLG = true;

			for(int i = 1; i < tmp.num_point; i++){
				base_x_diff = base.point[i].x - base.point[i-1].x;
				base_y_diff = base.point[i].y - base.point[i-1].y;
				tmp_x_diff = tmp.point[(tmp.num_point-1)-i].x - tmp.point[(tmp.num_point-1)-(i-1)].x;
				tmp_y_diff = tmp.point[(tmp.num_point-1)-i].y - tmp.point[(tmp.num_point-1)-(i-1)].y;

				if(base_x_diff != tmp_x_diff || base_y_diff != tmp_y_diff){
					FLG = false;
					break;
				}
			}

			if(FLG){
				printf("%d\n",id);
				break;
			}
		}
	}

	printf("+++++\n");
}

int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 2580
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	if(n&1){
		cout<<"No"<<endl;
		return 0;
	}
	int f=0;
	for(int i=0;i<n/2;i++){
		if(s[i]!=s[i+n/2]){
			cout<<"No"<<endl;
			f=1;
			break;
		}
	}
	if(f==0){
		cout<<"Yes"<<endl;
	}
}

Measured memory_bytes: 256
import java.util.*;
import java.util.function.*;
import java.lang.*;
import java.io.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        
        System.err.printf("a = %d\n", a);
        System.out.println(a + a*a + a*a*a);
        
    }
}


Measured memory_bytes: 35796
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define N 200000



int main () {
	lli ans,n,mini;
	lli a[N];

	cin >> n;

	for(lli i=0;i<n;i++){
		lli k;
		cin >> k;
		a[i]=k;
	}

	ans = a[1]-a[0];
	mini = a[0];
	for(lli i=1;i<n;i++){
		ans = max(ans,a[i] - mini);
		mini = min(mini,a[i]);
	}


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

Measured memory_bytes: 4632
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>

using namespace std;

//#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")




// Union-Find Disjoint Sets Library written in OOP manner, using both path compression and union by rank heuristics
// initialize: UnionFind UF(N)

class UnionFind {                                              // OOP style
private:
	vector<int> p, rank, setSize;
	// p = path toward the root of disjoint set; p[i] = i means it is root
	// rank = upper bound of the actual height of the tree; not reliable as accurate measure
	// setSize = size of each disjoint set

	int numSets;
public:
	UnionFind(int N) {
		setSize.assign(N, 1);
		numSets = N;
		rank.assign(N, 0);
		p.assign(N, 0);
		for (int i = 0; i < N; i++) p[i] = i;	// each belongs to its own set
	}

	int findSet(int i) {
		return (p[i] == i) ? i : (p[i] = findSet(p[i]));		// path compression: cut short of the path if possible
	}

	bool isSameSet(int i, int j) {
		return findSet(i) == findSet(j);
	}

	void unionSet(int i, int j) {
		if (!isSameSet(i, j)) {
			numSets--;
			int x = findSet(i), y = findSet(j);
			// rank is used to keep the tree short
			if (rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
			else {
				p[x] = y; setSize[y] += setSize[x];
				if (rank[x] == rank[y]) rank[y]++;
			}
		}
	}

	int numDisjointSets() {		// # of disjoint sets
		return numSets;
	}

	int sizeOfSet(int i) {		// size of set
		return setSize[findSet(i)];
	}
};


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

	int n, m, i, j, k, a, b, ans;
	cin >> n >> m;
	UnionFind uf(n + 1);
	for (i = 0; i < m; i++) {
		cin >> a >> b;
		uf.unionSet(a, b);
	}
	ans = 0;
	for (i = 1; i <= n; i++) ans = max(ans, uf.sizeOfSet(i));
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 5540
#include<stdio.h>
  
 int main(void){
 	int a,b;
scanf("%d %d",&a,&b);
if(a<b){
	printf("a < b\n");
}else if(a>b){
	printf("a > b\n");
}else{
	printf("a == b\n");
}
 return 0;
	}


Measured memory_bytes: 2624
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextLine().toInt()
    val a = sc.nextLine().split(" ")

    val emp = a.groupingBy { it }.eachCount()

    val sb = StringBuilder()
    (1..n).forEach {
        sb.append(emp[it.toString()] ?: 0).append("\n")
    }
    print(sb.toString())
}

Measured memory_bytes: 84560
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char const *argv[]) {
  int i,j,n,ca=0,cb=0;
  scanf("%d",&n );
  for(i=1;i<=n;i+=2){
    for(j=1;j<=i;j++){
    if(i%j==0)
    ca++;
    }
    if(ca==8)
    cb++;
    ca=0;
  }
  printf("%d\n",cb );
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
#define No cout<<"No"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    unsigned long long x,y;
    cin>>x>>y;
    ll ans=0;
    while(x<=y){
        x=2*x;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

pair<int,int> a[300005];

int X, Y, A, B, C;

priority_queue<int>q1,q2,q3,q4;

int main(){
    scanf("%d%d%d%d%d", &X, &Y, &A, &B, &C);

    for(int i=1;i<=A+B+C;++i){
        int x;scanf("%d",&x);
        if(i<=A){
            q1.push(x);
        }else if(i<=A+B){
            q2.push(x);
        }else{
            q3.push(x);
        }
    }

    long long res=0;
    for(int i=1;i<=X;++i){
        res+=q1.top();
        q4.push(-q1.top());
        q1.pop();
    }

    for(int i=1;i<=Y;++i){
        res+=q2.top();
        q4.push(-q2.top());
        q2.pop();
    }

    while(!q3.empty()&&q3.top()>-q4.top()){
        res+=q4.top();
        q4.pop();
        res+=q3.top();
        q3.pop();
    }

    printf("%lld",res);

    return 0;
}


Measured memory_bytes: 5500
N = int(input())
lis = [(input() + " " + str(i+1)).split() for i in range(N)]

lis = [k for k in lis]

lis.sort(key=lambda k: int(k[1]), reverse=True)
lis.sort(key=lambda k: k[0])


for j in lis:
    print(j[2])


Measured memory_bytes: 9076
N, M = map(int, input().split())

graph = [[] for i in range(N)]

for i in range(M):
    ai, bi = map(int, input().split())
    ai -= 1
    bi -= 1
    graph[ai].append(bi)
    graph[bi].append(ai)

rank = [N] * N
low = [N] * N
visited = [False] * N


def dfs(k, pos, parent):
    rank[pos] = k
    low[pos] = k

    k += 1

    visited[pos] = True

    for i in graph[pos]:
        if not visited[i]:
            dfs(k, i, pos)
            low[pos] = min(low[pos], low[i])
        elif i != parent:
            low[pos] = min(low[pos], rank[i])


def main():
    dfs(0, 0, -1)

    ans = 0

    for i in range(N):
        for j in graph[i]:
            if rank[j] < low[i]:
                ans += 1

    print(ans)
    return


main()


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  int cnt=0;
  for(int i=0;500*i<=X && i<=A;i++){
    for(int k=0;100*k<=X-500*i && k<=B;k++){
      if((X-500*i-100*k)/50<=C)cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i32,
        k: i32
    }
    let m = n % k;
    if m == 0 {
        println!("0");
    } else {
        println!("1");
    }
}


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

using namespace std;
#define int long long
const int N = 666666 ,inf = 0x3f3f3f3f;
int n,arr[N];
signed main(){
	cin>>n;
	cin>>arr[1];
	int s=0;
	for(int i=2;i<=n;i++){
		cin>>arr[i];
		if(arr[i]<arr[i-1]){
			s+=abs(arr[i]-arr[i-1]);arr[i]=arr[i-1];
		}
	}
	cout<<s;
	return 0;
}

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

class abc126_B
{
    static void Main(string[] args)
    {
        var QS = Console.ReadLine();
        try{
            var first = int.Parse(QS.Substring(0, 2));
            var second = int.Parse(QS.Substring(2, 2));

            var firstCanMonth = 1 <= first && first <= 12;
            var secondCanMonth = 1 <= second && second <= 12;

            if(firstCanMonth && secondCanMonth) {
                Console.WriteLine("AMBIGUOUS");
            } else if(firstCanMonth) {
                Console.WriteLine("MMYY");
            } else if(secondCanMonth) {
                Console.WriteLine("YYMM");
            } else {
                Console.WriteLine("NA");
            }
        }catch(Exception) {
            Console.WriteLine("NA");
        }


    }

    
    static long[][] readLongsN(int N) { return Enumerable.Range(0, N).Select(x => readLongs()).ToArray(); }
    
    static long readLong() { return long.Parse(Console.ReadLine()); }

    static long[] readLongs() { return Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray(); }

}

Measured memory_bytes: 11092
#include <stdio.h>

int main(void)
{
    int N, i;
    int D1[101], D2[101];

    scanf("%d",&N);
    for(i=0; i<N; i++) scanf("%d %d",&D1[i],&D2[i]);

    for(i=0; i<N-2; i++){
        if((D1[i]==D2[i])&&(D1[i+1]==D2[i+1])&&(D1[i+2]==D2[i+2])){
            printf("Yes\n");
            return 0;
        }
    }

    printf("No\n");

    return 0;
}

Measured memory_bytes: 1664
N, K = gets.chomp.split.map(&:to_i)

array = Array.new(N) { |i| [i + 1, Rational(1, N)] }

while array[0][0] < K
  0.upto(N - 1) do |i|
    break if array[i][0] >= K
    array[i][0] *= 2
    array[i][1] /= 2
  end
end

puts array.inject(0) { |ans, a| ans + a[1] }.to_f


Measured memory_bytes: 14972
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define REPR(i, x, n) for(int i = n - 1 ; i >= x ; i--)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) REPR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    int i = 0;
    bool ans = true;
    while(i < s.size()){
        if(s.substr(i, 5) == "maerd"){
            i += 5;
        }else if(s.substr(i, 5) == "esare"){
            i += 5;
        }else if(s.substr(i, 6) == "resare"){
            i += 6;
        }else if(s.substr(i, 7) == "remaerd"){
            i += 7;
        }else{
            ans = false;
            break;
        }
    }
    if(ans){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    string w;
    cin>>w;
    char hoge;
    int count;
    for(hoge='a';hoge<='z';hoge++){
        count = 0;
        rep(i,0,w.size()-1){
            if(w[i]==hoge) count++;
        }
        if(count%2==1) break;
    }
    if(count%2==1) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
//shara's here
#include <bits/stdc++.h>
using namespace std;
typedef int q;
typedef double w;
typedef string s;
typedef long long ll;
q main(){
    q a; cin>>a;
    q s[3];
    s[0]=a%10;
    s[1]=(a/10)%10;
    s[2]=(a/100%10);
    q x=0;
    for( x ; x<=2; x++ ){
        if(s[x]==9){s[x]=1;}else{s[x]=9;}
    }
cout<<s[2]<<s[1]<<s[0];
return 0;}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int a,b,k;
void solve(){
	cin >> a >> b >> k;
	
	for(int i = 0; i < k/2; i++){
		a /= 2;
		b += a;
		b /= 2;
		a += b;
	}
	if(k&1) a /= 2;
	if(k&1) b += a;
	cout << a << " " << b << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
static ll f[(ll)1e7+5]={0};
int main(void){
    ll n;
    cin>>n;
    rep(1,i,n+1){
        for(ll j=i;j<=n;j+=i)++f[j];
    }
    //rep(0,i,n+1)cout<<f[i]<<endl;
    ll ans=0;
    rep(1,i,n+1)ans+=i*f[i];
    cout<<ans;
}


Measured memory_bytes: 81720
use std::io::{stdin, Read};
use std::str::FromStr;
use std::cmp;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let a: i64 = read().unwrap();
    let b: i64 = read().unwrap();
    if a == b {
        println!("{}", a + b);
    } else {
        let larger: i64 = cmp::max(a, b);
        println!("{}", larger + larger - 1);
    }
}


Measured memory_bytes: 2164
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define all(_obj) _obj.begin(),_obj.end()
#define F first
#define S second
#define INF 1e18
#define pll pair<ll, ll> 
#define vll vector<ll>
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=1e5+11,mod=1e9+7;
inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline vll read(int n) {vll v(n);for (int i = 0; i < v.size(); i++)cin>>v[i];return v;}
void sol()
{
cin>>n>>x>>temp;
cout<<((n+x-1)/x)*temp;
return ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    //cin>>test;
    for(int i=1;i<=test;i++)
    sol();
}


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

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
vector<string> field;
int H, W;

int BFS(int sh, int sw)
{
    vector<int> dist(450, -1);
    int max_dist = 0;
    queue<int> que;
    dist[sh * W + sw] = 0;
    que.push(sh * W + sw);
    while (!que.empty())
    {
        int v = que.front();
        que.pop();
        int h = v / W;
        int w = v % W;
        for (int dir = 0; dir < 4; dir++)
        {
            int nh = h + dx[dir];
            int nw = w + dy[dir];

            if (nh < 0 || nh >= H || nw < 0 || nw >= W)
                continue;
            if (field[nh][nw] == '#')
                continue;
            if (dist[nh * W + nw] != -1)
                continue;

            int ndist = dist[v] + 1;
            max_dist = max(ndist, max_dist);
            dist[nh * W + nw] = ndist;

            que.push(nh * W + nw);
        }
    }
    return max_dist;
}

int main()
{
    cin >> H >> W;
    field.resize(H);
    for (int i = 0; i < H; i++)
        cin >> field[i];

    int max_dist = 0;
    for (int h = 0; h < H; h++)
    {
        for (int w = 0; w < W; w++)
        {
            if (field[h][w] != '#')
                max_dist = max(max_dist, BFS(h, w));
        }
    }
    cout << max_dist << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

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

const ll oo = 1e18;
const ll mod = 1e9 + 7,maxn = 100000000;
const double PI = acos(-1);

ll mulmod(__int128_t a, __int128_t b){
    __int128_t ans = 0;
    while (b){
        if (a > oo || ans > oo) return -1;
        if (b&1) {
            ans += a;
        }
        a = a+a;
        b >>= 1;
    }
    return( ll) ans;
}

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n, ans = 1;
    cin >> n;

    vector<ll> v(n);

    for (auto& x: v) cin >> x;

    sort(all(v));

    for (auto x: v){
        ans = mulmod(ans, x);
        if (ans == -1){
            cout << ans << endl;
            return 0;
        }
        else if (ans == 0){
            cout << "0" << endl;
            return 0;
        }
    }

    if(ans > oo)  cout << "-1" << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3992
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>

using namespace std;

using P = pair<int, int>;
using i64 = int64_t;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;


int main(int argc, char **argv) {
    int n;
    cin >> n;
    int ans{0}, pre_b{0};
    for (int i=1; i<n; ++i) {
        int b;
        cin >> b;
        if (i==1) pre_b = b;
        if (b >= pre_b)
            ans += pre_b;
        else
            ans += b;
        if (i==n-1) ans += b;
        pre_b = b;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// +build ignore
package main

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

func solve(sc *scanner, wr *bufio.Writer) int {
	A := sc.i()
	B := sc.i()
	C := sc.i()
	D := sc.i()

	for {
		C -= B
		if C <= 0 {
			fmt.Println("Yes")
			return 0
		}

		A -= D
		if A <= 0 {
			fmt.Println("No")
			return 0
		}
	}
	return 0
}

func main() {
	sc := newScanner(os.Stdin)
	wr := bufio.NewWriter(os.Stdout)
	ret := solve(sc, wr)
	wr.Flush()
	os.Exit(ret)
}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}


Measured memory_bytes: 1756
#include <bits/stdc++.h>
#define ll long long
#define x first
#define y second
#define pb push_back
#define endl "\n"

using namespace std;
const int maxn=1e6+5;
vector <pair<int,int>> adj[maxn];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    int arr[n+1];
    for (int i=1 ; i<=n ; i++) cin>>arr[i];
    for (int i=0 ; i<m ; i++)
    {
        int a,b;
        cin>>a>>b;
        adj[a].pb({arr[b],b});
        adj[b].pb({arr[a],a});
    }
    ll ans=0;
    for (int i=1 ; i<=n ; i++)
    {   if(adj[i].size()==0) {ans++; continue;}
        sort(adj[i].begin(),adj[i].end());
        if(adj[i][adj[i].size()-1].x <arr[i] ) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 30944
#define _USE_MATH_DEFINES

#include<math.h>
#include<stdio.h>
#include<utility>
#include<algorithm>

int main() {
	int H, W, n, m;
	n = 1;
	m = 1;
	while (true) {
		scanf("%d %d", &H, &W);

		if (H + W == 0) {
			break;
		}
		else {
			while (n <= H) {
				while (m <= W) {
					printf("#");
					m++;
				}
				printf("\n");
				n++;
				m = 1;
			}
			printf("\n");
			n = 1;
		}
	}
	return 0;
}

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

using namespace std;

int N,K;
int s[128];
string T;
char win[128];
int ans;
vector<int> v[128];
bool vis[200005];

int main()
{
	win['s']='R';
	win['p']='S';
	win['r']='P';
	cin >> N >> K;
	cin >> s['R'] >> s['S'] >> s['P'];
	cin >> T;
	for (int i=0; i<N; i++) v[win[T[i]]].push_back(i);
	for (int i=0; i<128; i++)
	{
		for (size_t j=0; j<v[i].size(); j++)
		{
			if (v[i][j]<K||T[v[i][j]-K]!=T[v[i][j]]||!vis[v[i][j]])
			{
				ans+=s[i];
				vis[v[i][j]+K]=true;
			}
			else vis[v[i][j]+K]=false;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <map>
#define ll long long
#define out(a) printf("%lld",a)
#define ln printf("\n")
const int N=2e5+50;
const int MOD=1e9+7;
const int inf=0x7f7f7f7f;
using namespace std;
char s1[N],s2[N];
ll len;
ll ans=0;
bool flag=false;
ll cnt[30][N];
ll tot[30],now[30];
ll erfen(ll l_,ll r_,ll x,ll id)
{
	ll anss=0;
	while (l_<=r_){
	  ll mid=(l_+r_)>>1;
	  if (cnt[id][mid]<=x) l_=mid+1;
	  else r_=mid-1,anss=mid;
	}
	if (anss>0) return cnt[id][anss];
	else return 0;
}
int main()
{
	scanf("%s",s1); flag=false; len=strlen(s1);
	for (int i=0;i<strlen(s1);i++){
	  cnt[s1[i]-'a'][++tot[s1[i]-'a']]=i+1;
	  now[s1[i]-'a']++;
	}
	scanf("%s",s2);
	if (!now[s2[0]-'a']){
	  puts("-1");
	  return 0;
    }
	ans=cnt[s2[0]-'a'][1];
	for (int i=1;i<strlen(s2);i++){
	  ll num=s2[i]-'a'; ll l=0;
	  if (now[num]==0){
	    flag=true;
	    break;
	  }
	  //now[num]++;
	  if (ans%len==0) l=len;
	  else l=ans%len;
	  ll p=0;
	  p=erfen(1,tot[num],l,num);
	  //out(ans); ln;
	  if (p) ans=(ll)ans+p-l;
	  else {
	    if (ans%len!=0) ans=(ll)(ans/len+1)*len;
		ans=(ll)ans+cnt[num][1];
	  }
	}
	if (flag) puts("-1");
	else out(ans);
	return 0;
}

Measured memory_bytes: 41472
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >

using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=1e5+10,mod=1e9+7;
vector<int> G[N];
ll dp[N][2],n;
ll dfs(int u,int p,bool col){
    ll &ret = dp[u][col];
    if(ret+1) return ret;
    ret = 1;
    for(auto v:G[u]){
        if(v!=p){
            int cur = dfs(v,u,1);
            if(col){
                cur += dfs(v,u,0);
                cur %= mod;
            }
            ret *= cur;
            ret %= mod;
        }
    }
    return ret;
}
int main()
{
    FASTIO
    memset(dp,-1,sizeof dp);
    cin >> n;
    for(int i=1;i<n;i++){
        int u,v;
        cin >> u >> v;
        G[u].pb(v);
        G[v].pb(u);
    }
    ll ans=dfs(2,-1,0)+dfs(2,-1,1);
    ans %= mod;
    cout << ans << endl;
    return 0;
}
/**

*/


Measured memory_bytes: 12800
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll; ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);
ll fac(ll x){if(x==0) return 1;  return x*fac(x-1);}

int main(){
 char a; cin>>a;
  printf("%c",a+1);
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int INF = 1e9+5;
int main(){
  int x,a,b;
  cin >> x >> a >> b;
  x-=a;
  int res = x%b;
  cout << res << endl;
}

Measured memory_bytes: 256