akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <stack>
    #include <string>
    #include <cstring>
    #include <cmath>
    #include <vector>
    #include <set>
    #define INF  0x3f3f3f3f;
    #define maxn 1000605
    typedef long long LL;
    using namespace std;
    int h[100005];
    int d[100005];
    int get_min(int a,int b){
        if(a<b)
            return a;
        else
            return b;
    }

    int main(){
        int n;
        while(cin>>n){
            for(int i=1;i<=n;i++)
                cin>>h[i];
            d[1]=0;
            d[2]=abs(h[2]-h[1]);
            for(int i=3;i<=n;i++){
                d[i]=get_min(d[i-1]+abs(h[i]-h[i-1]),d[i-2]+abs(h[i]-h[i-2]));
            }
            cout<<d[n]<<endl;
        }
        return 0;
    }


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main(){
    long long n, k;
    cin >> n >> k;
    vector<int> A(n);
    for(int i = 0; i < n; i++) cin >> A[i];
    set<int> s;
    vector<int> v;
    s.insert(1);
    v.push_back(1);
    v.push_back(A[0]);
    long long i = 0;
    bool f = false;
    for(i = 0; i < k; i++){
        auto r = s.insert(v[i + 1]);
        if (r.second == false){
            f = true;
            break;
        }
        v.push_back(A[v[i + 1]-1]);
    }
    if(f == false){
        cout << v[k];
        return 0;
    }
    long long end = i + 1;
    long long start = 0;
    for(long long j = 0; j < n; j++){
        if(v[end] == v[j]){
            start = j;
            break;
        }
    }
    cout << v[(k - start) % (end - start) + start];

    return 0;
}

Measured memory_bytes: 12108
import math
import sys

m=10**9 + 7 
sys.setrecursionlimit(1000010)
S = input()
Q = int(input())

inv = 0
head=[]
tail=[]
for _ in range(Q):
    q = input()
    if q == '1':
        inv = 1 - inv
    else:
        (T,F,C) = list(q.split())
        #print(T,F,C)
        if inv == 0:
            if F == '1':
                head.append(C)
            else:
                tail.append(C)
        else:
            if F == '1':
                tail.append(C)
            else:
                head.append(C)
    # print(head,S,tail)

if inv == 0:
    print(''.join(list(reversed(head))) + S + ''.join(tail))
else:
    print(''.join(list(reversed(tail))) + ''.join(list(reversed(S))) + ''.join(head))



Measured memory_bytes: 6344
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a,b;
	cin>>a>>b;
	vector<pair<int,int>>arr;
	for(int i=0;i<n;i++)
	{
		int p;
		cin>>p;
		//cin>>arr[i];
		arr.push_back(make_pair(p,i));
	}
	sort(arr.begin(),arr.end());
	map<pair<int,int>,bool>M;
	int ct=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			for(int k=j+1;k<n;k++)
			{
				if(M.find(arr[i])==M.end() && M.find(arr[j])==M.end() && M.find(arr[k])==M.end())
				{
					if(arr[i].first<=a && arr[j].first>=(a+1) && arr[j].first<=b && arr[k].first>b)
					{
						ct++;
						M[arr[i]]=true;
						M[arr[j]]=true;
						M[arr[k]]=true;
					}
				}
			}
		}
	}
	cout<<ct<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  double count = 0;//yen
  
  for (int i = 0;i < N;i++) {
    double x;
    string u;
    cin >> x >> u;
    if (u == "BTC") {
      x = x * 380000.0;
    }
    count += x;
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const LL INF=1e10;
LL a[100003];
bool st[100003];
priority_queue<LL, vector<LL>, greater<LL> > costs[100003];
struct UnionFind
{
    vector<int> par;
    vector<int> sizes;
    vector<int> rnk;
    
    UnionFind(){}
    UnionFind(int n){
        par.resize(n);rnk.resize(n,0);
        sizes.resize(n, 1);
        REP(i,n){
            par[i] = i;
            costs[i].push(a[i]);
        }
    }

    int find(int x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x==y)return;
        if(rnk[x]<rnk[y]){
            par[x]=y;
            sizes[y]+=sizes[x];
            while(!costs[x].empty()){
                costs[y].push(costs[x].top());
                costs[x].pop();
            }
        }else{
            par[y]=x;
            sizes[x]+=sizes[y];
            while(!costs[y].empty()){
                costs[x].push(costs[y].top());
                costs[y].pop();
            }
            if(rnk[x]==rnk[y])rnk[x]++;
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        return sizes[find(x)];
    }
};
int main(){
  int N,M;
  cin>>N>>M;
  REP(i,N)cin>>a[i];
  UnionFind uf(N);
  REP(i,M){
    LL x,y;
    cin>>x>>y;
    uf.unite(x,y);
  }
  CLR(st);
  priority_queue<PLL> que;
  REP(i,N){
    int p=uf.find(i);
    if(!st[p]){
        st[p]=1;
        que.push(MP(uf.size(p),p));
    }
  }
  LL res=0;
  while(SZ(que)>1){
    PLL pi1=que.top();que.pop();
    PLL pi2=que.top();que.pop();
    if(costs[uf.find(pi1.second)].empty()||costs[uf.find(pi2.second)].empty()){
        cout<<"Impossible"<<endl;return 0;
    }
    res+=(costs[uf.find(pi1.second)].top()+costs[uf.find(pi2.second)].top());
    costs[uf.find(pi1.second)].pop();costs[uf.find(pi2.second)].pop();
    uf.unite(pi1.second,pi2.second);
    que.push(MP(uf.size(pi1.second),uf.find(pi1.second)));
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 11512
#include <stdio.h>
#include <algorithm>
using namespace std;
int n, r[500]; long double x[501];
int main() {
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d", &r[i]);
    for(int i = 0; i < n; i++) {
        x[i] = r[i];
        for(int j = 0; j < i; j++) {
            long double dist = sqrtl((r[j] + r[i]) * (r[j] + r[i]) - (r[j] - r[i]) * (r[j] - r[i]));
            x[i] = max(x[i], x[j] + dist);
        }
    }
    long double ret = 0.0;
    for(int i = 0; i < n; i++) {
        ret = max(ret, x[i] + r[i]);
    }
    printf("%.9Lf\n", ret);
    return 0;
}

Measured memory_bytes: 2720
#include<bits/stdc++.h>
using namespace std;
long KnapSack(int W, vector<int>&wt, vector<int>&val, int n) {
  int i, w;
  long K[n+1][W+1];
  for (i = 0; i <= n; i++) {
	   for (w = 0; w <= W; w++){
		     if (i==0 || w==0)
			      K[i][w] = 0;
		     else if (wt[i-1] <= w)
				    K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]], K[i-1][w]);
		     else
				    K[i][w] = K[i-1][w];
	    }
  }

  return K[n][W];
}

int main() {
  int n, W;
  cin >> n >> W;
  int w_val, p_val;
  vector<int>w;
  vector<int>p;
  for(int i=0; i<n; i++){
	  cin >> w_val;
	  w.push_back(w_val);
	  cin >> p_val;
	  p.push_back(p_val);
  }
  cout << KnapSack(W, w, p, n);
 
}





Measured memory_bytes: 79104
while(1)
h,w=gets.chomp.split(" ").map(&:to_i)
if(w==0&&h==0)
 break
end
j=0
while(j<h)
 i=0
 while(i<w)
  print"#"
  i=i+1
 end
 print"\n"
 j=j+1
end
 print"\n"
end



Measured memory_bytes: 6872
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    var(int, H, W);
    vector<int> chrCnt(26);
    auto mat = makeV(-1, H, W);

    rep(i, 0, H) {
        var(string, s);
        rep(j, 0, W) chrCnt[s[j] - 'a'] += 1;
    }

    vector<int> hoge(5);
    {
        int id = 0;
        rep(i, 0, H) rep(j, 0, W) {
            if (~mat[i][j]) continue;
            mat[i][j] = mat[H-i-1][j] = mat[i][W-j-1] = mat[H-i-1][W-j-1] = id++;
        }

        vector<int> chrCnt(id);
        rep(i, 0, H) rep(j, 0, W) ++chrCnt[mat[i][j]];
        for (int e : chrCnt) ++hoge[e];
    }

    dump(chrCnt);
    dump(hoge);

    int g1 = hoge[1];
    int g2 = hoge[2];
    int g4 = hoge[4];

    rep(c, 0, 26) {
        while (chrCnt[c] >= 4 && g4) --g4, chrCnt[c] -=4;
    }
    rep(c, 0, 26) {
        while (chrCnt[c] >= 2 && g2) --g2, chrCnt[c] -= 2;
    }
    rep(c, 0, 26) {
        while (chrCnt[c] >= 1 && g1) --g1, chrCnt[c] -= 1;
    }

    if (g1 || g2 || g4 || any_of(all(chrCnt), [](int e) { return e > 0; })) {
        print("No");
    } else {
        print("Yes");
    }

    return 0;
}


Measured memory_bytes: 384
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

const int64_t MOD = 1000000007;

void solve()
{
    int64_t N;
    std::cin >> N;
    std::vector<int64_t> A(N);
    for (auto& v : A) std::cin >> v;

    std::vector<int64_t> cum(N + 1);
    cum[0] = 0;
    for (int64_t i = 1; i < N + 1; i++)
    {
        cum[i] = cum[i - 1] + A[i - 1];
    }

    int64_t ans = 0;
    for (int64_t i = 0; i < N; i++)
    {
        int64_t sum = (cum[N] - cum[i + 1]) % MOD;
        ans += sum * A[i];
        ans %= MOD;
    }

    std::cout << ans << std::endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}


Measured memory_bytes: 6308
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=55,M=22;
const ll inf=1e18;

int n,len[N];
ll f[N][M][2],c[N],ans=inf;
char s[N][M];

ll dp(int x,int y,int d) {//x????,y???,d???(??)
    if(y>=len[x]) return 0;
    if(~f[x][y][d]) return f[x][y][d];
    ll &v=f[x][y][d];
     v=inf;
	bool flag=1;
	if(!d) {for(int j=y,k=len[x];j<k;j++,k--) if(s[x][j]!=s[x][k]) {flag=0; break;}}
	else {for(int j=y,k=1;j>k;j--,k++) if(s[x][j]!=s[x][k]) {flag=0; break;}}
	if(flag) return v=0;
    for(int i=1,j,k;i<=n;i++) {//???????????
        flag=1;
        if(!d) {
            for(j=y,k=len[i];j<=len[x]&&k>=1;j++,k--)
                if(s[x][j]!=s[i][k]) {flag=0; break;}
            if(flag) {
                if(k<1) v=min(v,c[i]+dp(x,j,0));
                else v=min(v,c[i]+dp(i,k,1));
            }
        }
        else {
            for(j=y,k=1;j>=1&&k<=len[i];j--,k++)
                if(s[x][j]!=s[i][k]) {flag=0; break;}
            if(flag) {
                if(j<1) v=min(v,c[i]+dp(i,k,0));
                else v=min(v,c[i]+dp(x,j,1));
            }
        }
    }
    return v;
}

int main() {
    scanf("%d",&n); memset(f,-1,sizeof(f));
    for(int i=1;i<=n;i++) scanf("%s",s[i]+1),scanf("%lld",&c[i]),len[i]=strlen(s[i]+1);
    for(int i=1;i<=n;i++) 
		ans=min(ans,c[i]+dp(i,1,0));
    printf("%lld\n",ans==inf?-1:ans);return 0;
}



Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,P;cin >> N >> P;
  string S;cin >> S;
  if(P==2 || P==5){
    ll sum = 0;
    rep(i,N){
      if((S[i]-'0')%P==0)sum += i+1;
    }
    cout << sum << endl;
    return 0;
  }

  int m10 = 1;
  int U = 0;
  vector<ll> v(P,0);
  ll ans = 0;
  v[0] = 1;
  per(i,N){
    int x = S[i] - '0';
    U += x*m10;
    U %= P;
    ans += v[U];
    ++v[U];
    m10 *= 10;
    m10 %= P;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 720
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top, S[1000];

void push(int v)
{
	S[++top] = v;
}

int pop()
{
        top--;
	return S[top + 1];
}

int main() 
{
	char a[100];
        top = 0;
	int op1, op2;
	
	while (scanf("%s", a) != EOF) {
		if (a[0] == '+') {
			op1 = pop();
			op2 = pop();
			push(op1 + op2);
		} else if (a[0] == '*') {
			op1 = pop();
			op2 = pop();
			push(op1 * op2);	
		} else if (a[0] == '-') {
			op2 = pop();
			op1 = pop();
			push(op1 - op2);	
		} else {
			push(atoi(a));
		}
	}
	
	printf("%d\n", pop());
	
	return 0;
}


Measured memory_bytes: 2044
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <math.h>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,f,n) for(int i=f;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;

signed main(void){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int x, y, z, k;
    cin >> x >> y >> z >> k;

    vector<int> a(x), b(y), c(z);

    for(auto&& e : a){
        cin >> e;
    }
    for(auto&& e : b){
        cin >> e;
    }
    for(auto&& e : c){
        cin >> e;
    }

    sort(all(c), greater<>());

    vector<int> ab;

    rep(i,x){
        rep(j,y){
            ab.emplace_back(a[i] + b[j]);
        }
    }    

    sort(all(ab), greater<>()); 

    vector<int> res;

    rep(i,z){
        rep(j,min(x*y, k)){
            res.emplace_back(c[i] + ab[j]);
        }
    }

    sort(all(res), greater<>());

    rep(i,k){
        cout << res[i] << '\n';
    }

    return 0;
}

Measured memory_bytes: 43368
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
char s[220];
int main(){
    cin>>s;
    int n=strlen(s);
    for(int i=n-2;i;i-=2){
        if(strncmp(s,s+i/2,i/2)==0){
            cout<<i<<endl;
            return 0;
        }
    }
}

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

using namespace std;

 map<string,int> a;
int ans;

int main()
{
    string s;
    int n;
    cin >> n;
    for(int i = 0; i < n; i ++)
    {
        cin >> s;
        a[s] ++;
    }
    for(auto& t:a) ans = max(ans, t.second);
    for(auto& t:a)
    {
        if(t.second == ans) cout << t.first << endl;
    }
    return 0;
}

Measured memory_bytes: 25216
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
i = int(input())-1
print(l[i])

Measured memory_bytes: 3060
#include <cstdio>

int main() {
    int S, h, m, s;
    scanf("%d", &S);
    h = S / 3600;
    m = ( S - h * 3600 ) / 60;
    s = S - h * 3600 - m * 60;
    printf("%d:%d:%d\n", h, m, s);
}


Measured memory_bytes: 2744
def solve():
    N, A, B = map(int, input().split())
    h = []
    for _ in range(N):
        h.append(int(input()))
    ans_min = 0
    ans_max = 10 ** 9
    while ans_min + 1 < ans_max:
        ans = (ans_min + ans_max) // 2
        count = 0
        for i in h:
            count += (max(0, i - B * ans) + A - B - 1) // (A - B)
        if count > ans:
            ans_min = ans
        else:
            ans_max = ans
    print(ans_max)
    return
solve()

Measured memory_bytes: 50648
#include<bits/stdc++.h>
using namespace std;priority_queue<pair<int,int> >p;int n,q,a,b,d[1<<20];int main(){cin>>n>>q;a=n;while(a--)p.push(make_pair(0,a)),d[a]=0;while(q--){cin>>a>>b;a=n-a,d[a]+=b;p.push(make_pair(d[a],a));while(1){a=p.top().first,b=p.top().second;if(d[b]==a){cout<<n-b<<" "<<a<<endl;break;}p.pop();}}return 0;}

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

int main() {
  long N, count=0, sum=0, mini=LONG_MAX;
  cin >> N;
  vector<long> A(N);
  for (int i=0; i<N; i++) cin >> A.at(i);
  for (int i=0; i<N; i++) {
    if (A.at(i) < 0) count++;
  }
  for (int i=0; i<N; i++) {
    mini = min(mini, abs(A.at(i)));
    sum += abs(A.at(i));
  }
  if (count % 2 == 1) cout << sum - mini*2 << endl;
  else cout << sum << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pi;
typedef tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); 
  ll n;
  cin >> n;
  vector<int> a(n), ao;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  ao = a;
  sort(ao.begin(), ao.end());
  if (ao[0] == ao[n-1]) 
    cout << ao[0] << endl;
  else {
    int bmin = 0, bmax = n;
    while (bmax-bmin>1) {
      int b = (bmax+bmin)/2;
      vector<int> c(n+1, 0);
      for (int i = 0; i < n; i++) {
        if (a[i] >= ao[b]) c[i+1] = c[i]+1;
        else c[i+1] = c[i];
      }
      ordered_set conj;
      conj.insert({0,0});
      ll tot = 0;
      for (int r = 1; r <= n; r++) {
        tot += conj.order_of_key({1+2*c[r]-r, -1});
        conj.insert({2*c[r]-r, r});
      }
      if (tot >= (1+n*(n+1)/2)/2) bmin = b;
      else bmax = b;
    }
    cout << ao[bmin] << endl;
  }
  return 0;
}



Measured memory_bytes: 7736
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  	int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  out((c-a)*60+d-b-e);
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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;
}

int main()
{   
    ll n;cin >> n;
    cout << ((n/500)*1000+((n%500)/5)*5) << endl;
}
    

Measured memory_bytes: 256
#include <stdio.h>

int main(){

	int x, y, z;
	int divisao;
	
	scanf("%d%d%d", &x, &y, &z);
	
	divisao = x/(y+z);
	
	if ((divisao * (y+z)) + z <= x){
		printf("%d\n", divisao);
	} else {
		printf("%d\n", divisao - 1);
	}
		
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m;
    cin >> n >> m;
    priority_queue<int> a;
    for(int i = 0; i < n; i++) {
        int v;
        cin >> v;
        a.push(v);
    }

    int idx = 0, maxidx = 0;
    REP(i, m)
    {
        a.push(a.top() / 2);
        a.pop();
    }
    
    ll ans = 0;
    REP(i, n)
    {
        ans += a.top();
        a.pop();
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 892
N, K = map(int, input().split())
lst = []
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for char in A:
        if char not in lst:
            lst.append(char)
count = 0
for i in range(1, N+1):
    if i not in lst:
        count += 1
print(count)

Measured memory_bytes: 9124
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.valueOf(br.readLine());
		long[] arr=new long[n];
		long[] counter=new long[100001];
		long sum=0;
		String[] cmd=br.readLine().split(" ");
		for(int i=0;i<n;i++)
		{
			arr[i]=Long.valueOf(cmd[i]);
			sum+=arr[i];
			counter[(int)arr[i]]++;
		}
		int q=Integer.valueOf(br.readLine());
		for(int i=0;i<q;i++)
		{
			cmd=br.readLine().split(" ");
			long x=Long.valueOf(cmd[0]);
			long y=Long.valueOf(cmd[1]);
			long diff=y-x;
			sum=sum+diff*counter[(int)x];
			counter[(int)y]=counter[(int)x]+counter[(int)y];
			counter[(int)x]=0;
			System.out.println(sum);
		}
	}

}


Measured memory_bytes: 66864
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int s = 0, t = 1 << 30, u = 0;
    for (int i = 0; i < n; i++) {
        int a = l + i;
        s += a;
        int b = abs(a);
        if (b < t) {
            t = b;
            u = a;
        }
    }

    cout << s - u << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;

#define LL long long

const int MAXN = 500000 + 5;



int main()
{
    LL a[1111], N, i, share;
    cin >> N;
    for (i = 0; i < N; i ++)
    {
        cin >> a[i];
    }
    i = share = 0;
    LL m = 1000;
    while (1){
        while (i + 1 < N && a[i] >= a[i + 1]){
            i ++;
        }
        if (i + 1 == N){
            break;
        }
        share = m / a[i];
        m = m % a[i];
        while (i + 1 < N && a[i] <= a[i + 1]){
            i ++;
        }
        if (i + 1 == N){
            m += share * a[N - 1];
            break;
        }
        m += share * a[i];
        share = 0;
    }
    cout << m;
    system("pause");
    return 0;
}

Measured memory_bytes: 3700
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String a = in.next();
		int count=0;
		for(int i=0;i<a.length();i++) {
			char charAt = a.charAt(i);
			if(charAt=='1') {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define put(n) cout<<(n)<<endl
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()


int main(){
    int N;
    cin>>N;
    cout<<N*32<<endl;
}


Measured memory_bytes: 3060
#include<stdio.h>

int main(){
    int n, q;
    int s[11000], t[1000];
    int i, j;
    int ans=0;

    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &s[i]);
    }

    scanf("%d", &q);
    for(i=0; i<q; i++){
        scanf("%d", &t[i]);
    }

    for(i=0; i<q; i++){
        for(j=0; j<n; j++){
            if(s[j]==t[i]){
                ans++;
                break;
            }
        }
    }

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 2108
require 'matrix'
n, m, l = gets.split.map(&:to_i)
a = (0..n-1).map{|i| gets.split.map(&:to_i)}
b = (0..m-1).map{|i| gets.split.map(&:to_i)}
puts Array(Matrix[*a] * Matrix[*b]).map{|i| i * " "}

Measured memory_bytes: 9812
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
// #define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


int n;
const int N = 222222;
vi a(N);
vii G(N);
vi ans(N);

void dfs(int now, int par, vi &dp) {
    int value = a[now];
    auto itr = lower_bound(all(dp), value);
    int idx = itr - dp.begin();

    itr = lower_bound(all(dp), inf);
    itr--;
    int idx2 = itr - dp.begin();

    int ori = dp[idx];
    ans[now] = max(idx, idx2);
    dp[idx] = value;
    for (int ch: G[now]) {
        if (ch == par) continue;
        dfs(ch, now, dp);
    }
    dp[idx] = ori;
}

signed main() {
    fio();

    cin >> n;
    rep (i, n) cin >> a[i];
    rep (i, n - 1) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    vi dp(n + 1, inf);
    dp[0] = -1;
    dfs(0, -1, dp);

    rep (i, n) {
        cout << ans[i] << endl;
    }
}

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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int N, Q;
	cin >> N >> Q;
	string S;
	cin >> S;
	vector<int> num(N, 0);
	for (int i = 0; i < N-1; i++)
	{
		if(S[i]=='A'&&S[i+1]=='C')num[i+1]++;
		num[i+1]+=num[i];
	}
	for (int i = 0; i < Q; i++)
	{
		int l, r;
		cin >> l >> r;
		cout << num[r-1]-num[l-1] << endl;
	}
	
	 
}

Measured memory_bytes: 1488
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<iomanip>
#include<unordered_map>
using namespace std;
#define l long
#define ll long long
#define ull unsigned long long
int main()
{
int n;
cin>>n;
int a[n][3];
for(int i=0;i<n;i++)
for(int j=0;j<3;j++)
cin>>a[i][j];

int dp[n][3];
dp[0][0]=a[0][0];dp[0][1]=a[0][1];dp[0][2]=a[0][2];

for(int i=1;i<n;i++)
for(int j=0;j<3;j++)
{int t=-1;
    for(int k=0;k<3;k++)
    {if(k==j)continue;
    if((dp[i-1][k]+a[i][j])>=t)t=(dp[i-1][k]+a[i][j]);
    //cout<<t<<endl;
    }
    dp[i][j]=t;
}
int t=-1;
for(int j=0;j<3;j++)
{if(dp[n-1][j]>=t)t=dp[n-1][j];}
cout<<t<<endl;

}

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

int main(){
  unsigned long long N, K;
  cin >> N;
  cin >> K;
  
  vector<bool> arr;
  for (int i = 0; i < N; ++i) {
    char hin;
    cin >> hin;

    bool l;
    if (hin == 'L') {
      l = true;
    } else {
      l = false;
    }
    
    arr.push_back(l);
  }

  int score = 0;
  for (int i = 0; i < N - 1; ++i) {
    if (arr[i] == arr[i+1]) {
      ++score;
    }
  }

  // cerr << "init score =" << score << endl;
  
  int max_score = arr.size() - 1;

  int cur_iter = 0;


  
  while (K > cur_iter) {
    if (max_score - score >= 2) {
      score += 2;
    } else if (max_score - score > 0) {
      score += 1;
    } else {
      // Do nothing.
      break;
    }
    cur_iter++;
  }
  cout << score;
}


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

int a[22][22];
vector<pair<int,int> >d;

int id[22][22];

int main(){
	int n,m,i,s,j,k,p,t,r;
	cin>>n>>m;
	char x;
	memset(a,0,sizeof(a));
	for(i=1;i<=n;++i){
		for(j=1;j<=m;++j){
			cin>>x;
			if(x=='.')a[i][j]=1;
			//cout<<a[i][j]<<" ";
		}
		//cout<<endl;
	}
	
	for(i=1;i<=n;++i){
		for(j=1;j<=m;++j){
			if(!a[i][j])continue;
			if(((!a[i-1][j])or(!a[i+1][j]))and((!a[i][j-1])or(!a[i][j+1]))or((!a[i-1][j-1])and(!a[i+1][j-1]))or((!a[i+1][j-1])and(!a[i+1][j+1]))){
				id[i][j]=d.size();
				d.push_back(make_pair(i,j));
				
				a[i][j]=3;//顶点 
				k=i+1;
				while(a[k][j]){
					a[k][j]=max(a[k][j],2);
					k++;
				}
				k=i-1;
				while(a[k][j]){
					a[k][j]=max(a[k][j],2);
					k--;
				}
				p=j+1;
				while(a[i][p]){
					a[i][p]=max(a[i][p],2);
					p++;
				}
				p=j-1;
				while(a[i][p]){
					a[i][p]=max(a[i][p],2);
					p--;
				}
			}
		}
	} 
	
	//for(i=0;i<d.size();++i)cout<<d[i].first<<" "<<d[i].second<<endl;
	int qm=d.size();//顶点个数
	for(i=1;i<=n;++i){
		for(j=1;j<=m;++j){
			if(a[i][j]==2){
				if((a[i-1][j]>=2 or a[i+1][j]>=2)and(a[i][j-1]>=2 or a[i][j+1]>=2)){ 
					a[i][j]=4;//中继点 
					id[i][j]=d.size();
					d.push_back(make_pair(i,j));
				}
			}
		}
	} 
	
	//for(i=0;i<d.size();++i)cout<<d[i].first<<" "<<d[i].second<<" "<<a[d[i].first][d[i].second]<<endl;
	//for(i=1;i<=n;++i){
	//	for(j=1;j<=m;++j)cout<<a[i][j];
	//	cout<<endl;
	//}
	int qq=d.size();
	int dis[qq][qq];
	memset(dis,0,sizeof(dis));
	
	for(r=0;r<qq;++r){
		
		i=d[r].first;
		j=d[r].second;
		//cout<<i<<" "<<j<<endl;
		
		k=i+1;
		while(a[k][j]==2)k++;
		if(k<=n and a[k][j]>2)//{
			dis[r][id[k][j]]=k-i;
			//cout<<k<<" "<<j<<" "<<k-i<<endl;
		//} 
		
		
		k=i-1;
		while(a[k][j]==2)k--;
		if(k and a[k][j]>2)//{
			dis[r][id[k][j]]=i-k;
			//cout<<k<<" "<<j<<" "<<i-k<<endl;
		//}
		
		p=j+1;
		while(a[i][p]==2)p++;
		if(p<=m and a[i][p]>2)//{
			dis[r][id[i][p]]=p-j;
			//cout<<i<<" "<<p<<" "<<p-j<<endl;
		//}
		
		
		p=j-1;
		while(a[i][p]==2)p--;
		if(p and a[i][p]>2)//{
			dis[r][id[i][p]]=j-p;
			//cout<<i<<" "<<p<<" "<<j-p<<endl;
		//}
		
	}
	
	//for(i=0;i<qm;++i)
	//for(j=0;j<qm;++j)
	//cout<<d[i].first<<" "<<d[i].second<<"  "<<d[j].first<<" "<<d[j].second<<"  "<<dis[i][j]<<endl;
	
	//floyd
	for(k=0;k<qq;++k)
	for(i=0;i<qq;++i)
	for(j=0;j<qq;++j)
	if(i!=j and dis[i][k] and dis[k][j] and(dis[i][j]==0 or (dis[i][j]>dis[i][k]+dis[k][j])))dis[i][j]=dis[i][k]+dis[k][j];
	
	int ans=0;
	for(i=0;i<qm;++i)
	for(j=0;j<qm;++j)//{
		//cout<<d[i].first<<" "<<d[i].second<<"  "<<d[j].first<<" "<<d[j].second<<"  "<<dis[i][j]<<endl;
		ans=max(ans,dis[i][j]);
	//}

	
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 896
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;

static class MainClass
{
    public static void Main(string[] args)
    {
        var nk = Console.ReadLine().SplittedStringToInt32List();
        var n = nk[0];
        var k = nk[1];
        var kosuu = n / 2;
        var amari = n % 2;
        kosuu += amari;
        if (kosuu >= k)
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }

        Console.ReadLine();
    }
    

    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<long> SplittedStringToInt64List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    public const int INF = int.MaxValue / 2;
    public const long LONGINF = long.MaxValue / 2;

        // 素因数分解
    public static List<long> PrimeFactorize(long n)
    {
        var bases = n;
        var num = (long)Math.Pow(n, 0.5);
        var ls = new List<long>();
        for (int i = 2; i <= num; i++)
        {
            if (n % i == 0)
            {
                n = n / i;
                ls.Add(i);
                i--;
                continue;
            }
        }
        long nnn = 1;
        foreach (var item in ls)
        {
            nnn = nnn * item;
        }
        if (nnn != bases)
            ls.Add(n);
        return ls;
    }


    public static List<long> MakeDivisors(long n)
    {
        var ls = new List<long>();
        // ls.Add(1);
        for (int i = 1; i * i <= n; i++)
        {
            if (n % i == 0)
            {
                ls.Add(i);
                if (i != 1 && i * i != n)
                {
                    ls.Add(n / i);
                }
            }
        }
        return ls;
    }

    public static void PrintArray(int[,] array)
    {
        for (int i = 0; i < array.GetLength(0); i++)
        {
            var sb = new StringBuilder();
            for (int j = 0; j < array.GetLength(1); j++)
            {
                sb.Append(array[i, j]).Append(" ");
            }
            Console.WriteLine(sb.ToString());
        }
    }

    #endregion
}



Measured memory_bytes: 11348
num = int(input())
l = [int(i) for i in input().split(" ")]
 
deny = False
 
for ele in l:
  if ele%2==0:
    if ele%3!=0 and ele%5!=0:
      print("DENIED")
      deny = True
      break;
 
if not deny:
  print("APPROVED")

Measured memory_bytes: 2940
/**********************************************************************
   File hoge.cpp
   Author  harunaya
   Date   2020-04-29(Wed)
   note   
**********************************************************************/

#include <bits/stdc++.h>
using namespace std;

int main() {
  int a, p, sigma_p, ans; 
  cin >> a >> p;
  
  sigma_p = a * 3 + p; //リンゴのかけらの総和
  ans = sigma_p / 2;
  cout << ans << endl;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())

S,T = [str(_) for _ in input().split()]

S_char =[ i for i in S]
T_char =[ i for i in T]
new_S = []
for i in range(2*N):
    if i%2 == 0:
        new_S = np.append(new_S,S_char[int(i/2)])
    elif i%2 != 0:
        new_S = np.append(new_S,T_char[int((i-1)/2)])
        
ans = str(''.join(map(str,new_S)))
print(ans)

Measured memory_bytes: 12440
def check(i, j, k, l):
    if (j, k, l) in {(0, 1, 2), (0, 2, 1), (1, 0, 2)} or (i, k, l) == (0, 1, 2) or (i, j, l) == (0, 1, 2):
        return False
    return True


def main():
    N = int(input())
    MOD = 10 ** 9 + 7

    dp = [[[[0 for l in range(4)] for k in range(4)] for j in range(4)] for i in range(N+1)]

    for i in range(4):
        for j in range(4):
            for k in range(4):
                dp[3][i][j][k] = 1

    dp[3][0][1][2] = dp[3][1][0][2] = dp[3][0][2][1] = 0

    for i in range(2, N):
        for j in range(4):
            for k in range(4):
                for l in range(4):
                    for m in range(4):
                        if check(j, k, l, m):
                            dp[i+1][k][l][m] = (dp[i+1][k][l][m] + dp[i][j][k][l]) % MOD

    ans = 0
    for i in range(4):
        for j in range(4):
            for k in range(4):
                ans = (ans+dp[N][i][j][k]) % MOD

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 45936
#include "stdio.h"

typedef struct
{
	int ban;
	int iro;
}nara;

nara q[100000];

int ans[1000];

int main()
{
	int nww = 0;
	while(1)
	{
		int n;
		scanf("%d",&n);
		if(n == 0)
		{
			break;
		}
		int ni = 2;
		int nb = 0;
		int w;
		for(int i = 0; i < n; i++)
		{
			scanf("%d",&w);
			if(w != ni)
			{
				if((i + 1) % 2 == 1)
				{
					q[nb].ban = i;
					q[nb].iro = w;
					nb++;
				}
				else
				{
					if(nb == 1)
					{
						q[0].iro = w;
					}
					else
					{
						nb--;
					}
				}
				ni = w;
			}
		}
		int all = 0;
		for(int i = 0; i < nb; i++)
		{
			if(q[i].iro == 0)
			{
				if(i == nb - 1)
				{
					all = all + n - q[i].ban;
				}
				else
				{
					all = all + q[i + 1].ban - q[i].ban;
				}
			}
		}
		ans[nww] = all;
		nww++;
	}
	for(int i = 0; i < nww; i++)
	{
		printf("%d\n",ans[i]);
	}
	return 0;
}

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


using namespace std;


void atcoder_beginner_contest999()
{
  string n;
  cin >> n;

  for (int i = 0; i < n.size(); ++i)
  {
    if (n[i] == '1') n[i] = '9';
    else if (n[i] == '9') n[i] = '1';
  }
  cout << n << "\n";
}


void programming_education()
{
  int n;
  cin >> n;
  
  if (n == 1)
  {
    cout << "Hello World\n";
    return;
  }
  else
  {
    int a, b;
    cin >> a >> b;
    cout << a + b << "\n";
  }
}

void discount_fare()
{
  int x, y;
  cin >> x >> y;

  cout << x + y / 2 << "\n";
}


void A_114()
{
  int x;
  cin >> x;

  if (x == 3 || x == 5 || x == 7) cout << "YES\n";
  else cout << "NO\n";
}


void christmas_eve_eve_eve()
{
  int d;
  cin >> d;

  if (d == 25) cout << "Christmas\n";
  else if (d == 24) cout << "Christmas Eve\n";
  if (d == 23) cout << "Christmas Eve Eve\n";
  if (d == 22) cout << "Christmas Eve Eve Eve\n";
}


void right_triangle()
{
  int a, b, c;
  cin >> a >> b >> c;

  cout << a * b / 2 << "\n";
}


void entrance_examination()
{
  int t, x;
  cin >> t >> x;

  cout << (double)t / (double)x << "\n";
}


void A_118()
{
  int a, b;
  cin >> a >> b;

  if (b % a == 0) cout << a + b << "\n";
  else cout << b - a << "\n";
}


int main()
{
  //atcoder_beginner_contest999();
  //programming_education();
  //discount_fare();
  //A_114();
  //christmas_eve_eve_eve();
  //right_triangle();
  //entrance_examination();
  A_118();
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#define ll long long
using namespace std;
ll get(ll arr[],ll n)
{
	ll s=0;
for(ll i=0;i<n;i++)
{cin>>arr[i]; s+=arr[i];}
return s;
}
int main()
{
	ll n,k;
	cin>>n>>k;
	ll r= n/k;
	n = n - r*k;
	ll temp = abs(n-k);
	if(temp<n)
	cout<<temp;
	else 
	cout<<n;
}



Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
/*        string[] input = ReadLine().Split(' ');
        long a = long.Parse(input[0]);
        long b = long.Parse(input[1]);
        long c = long.Parse(input[2]);
        long d = long.Parse(input[3]);*/
//        string temp = ReadLine();
//        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
//        int c = int.Parse(ReadLine());
//        int d = int.Parse(ReadLine());
        string a = ReadLine();
//        string b = ReadLine();
//        string c = ReadLine();
//        string[] input = ReadLine().Split(' ');
//        string ko = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        int b = a.Length;
        if(b==2){
            WriteLine(a);
        }else{
            WriteLine($"{a[2]}{a[1]}{a[0]}");
        }
    }
}

Measured memory_bytes: 13140
N = int(input())
nums = [0 for _ in range(N+1)]
A = list(map(int, input().split(' ')))
A.insert(0, 0)

for i in range(N, 0, -1):
    s = sum([nums[j] for j in range(i, N+1, i)])
    if s % 2 != A[i]:
        nums[i] = 1

print(sum(nums))
print(' '.join([str(i) for i, num in enumerate(nums) if num == 1]))

Measured memory_bytes: 89652
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]
a = [[False]*3 for i in range(3)]
for i in range(3):
    for j in range(3):
        for b in B:
            if A[i][j]==b:
                a[i][j]=True

bingo=False
for i in range(3):
    if a[i][0] and a[i][1] and a[i][2]:
        bingo=True
for j in range(3):
    if a[0][j] and a[1][j] and a[2][j]:
        bingo=True
if a[0][0] and a[1][1] and a[2][2]:
    bingo=True
if a[2][0] and a[1][1] and a[0][2]:
    bingo=True
print("Yes" if bingo else "No")


Measured memory_bytes: 3064
use std::collections::BTreeSet;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let k: usize = sc.read();
    let p: Vec<u64> = sc.vec(n);
    let mut set = BTreeSet::new();
    let mut same_as_next = vec![];
    for i in 0..n {
        if set.len() < k {
            set.insert(p[i]);
            continue;
        }
        let max = *set.iter().next_back().unwrap();
        let min = *set.iter().next().unwrap();
        if max < p[i] && min == p[i - k] {
            same_as_next.push(i - k);
            //            eprintln!("{:?}", set);
        }
        set.insert(p[i]);
        set.remove(&p[i - k]);
    }

    let mut same_as_nothing = BTreeSet::new();
    let mut i = 0;
    while i < n {
        let mut to = i;
        for j in (i + 1)..n {
            if p[j - 1] < p[j] {
                to = j;
            } else {
                break;
            }
        }
        for from in i.. {
            if from + k - 1 > to {
                break;
            }
            same_as_nothing.insert(from);
        }
        i = to + 1;
    }

    //    eprintln!("{:?}", same_as_next);
    //    eprintln!("{:?}", same_as_nothing);
    let ignore1 = same_as_next
        .into_iter()
        .filter(|i| !same_as_nothing.contains(i))
        .count();
    let ignore2 = if same_as_nothing.is_empty() {
        0
    } else {
        same_as_nothing.len() - 1
    };
    println!("{}", n - k + 1 - ignore1 - ignore2);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 12540