akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second > secondElof.second;
}
 
int main() {
    ll n, m;
    cin>>n>>m;

    priority_queue<ll, vector<ll>, greater<ll>> A;
    vector<P> BC;
    for(int i = 0; i < n; i++ ){
        ll a;
        cin>>a;
        A.push(a);
    }

    for(int i = 0; i < m; i++) {
        ll b, c;
        cin>>b>>c;
        BC.push_back(P(b, c));
    }
    sort(BC.begin(), BC.end(), pairCompare);

    for(int i = 0; i < m; i++) {
        const auto& p = BC[i];
        bool is_ret = false;
        for(int k = 0; k < p.first; k++) {
            if(p.second <= A.top()) {
                is_ret = true;
                break;
            }
            A.pop();
            A.push(p.second);
        }
        if(is_ret) break;
    }

    ll sum = 0;
    while (!A.empty())
    {
        sum += A.top();
        A.pop();
    }
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main(){
	int a;
	int b;
	cin >> a;
	cin >> b;
	if (a<b){
		cout << "a < b" << endl;
	}
	if (a > b){
		cout << "a > b" << endl;
	}
	if (a == b){
		cout << "a == b"<< endl;
	}



	return 0;
}


Measured memory_bytes: 3088
let k = Int(readLine()!)!

var modulos = Set<Int>()

var current = 0
var count = 0
while true {
  current = (current * 10 + 7) % k
  count += 1
  if modulos.contains(current) {
    count = -1
    break
  }
  if current == 0 {
    break
  }
  modulos.insert(current)
}
print(count)

Measured memory_bytes: 32356
n,m=map(int,input().split())
lis=[[int(i) for i in input().split()] for i in range(m)]

for i in range(1000):
    i=str(i)
    if len(i)!=n:
        continue
    for x,y in lis:
        if i[x-1]!=str(y):
            break
    else:
        print(i)
        exit()
print(-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, m;
    cin >> n >> m;
    
    if (abs(n-m) >= 2) {
        cout << 0 << endl;
        return 0;
    } else if (abs(n-m) == 1) {
        mint ans = 1;
        for (ll i = 1; i <= n; ++i) {
            ans *= i;
        }
        for (ll i = 1; i <= m; ++i) {
            ans *= i;
        }
        cout << ans << endl;
    } else {
        mint ans = 2;
        for (ll i = 1; i <= n; ++i) {
            ans *= i;
        }
        for (ll i = 1; i <= m; ++i) {
            ans *= i;
        }
        cout << ans << endl;
    }

}

Measured memory_bytes: 256
import itertools
n=int(input())
p=list(map(int,input().split()))

q=list(map(int,input().split()))
g=list(itertools.permutations([i for i in range(1,n+1)]))

kai=1

for i in range(n):
    kai*=i+1

for i in range(kai):
    if all(p[w]==g[i][w] for w in range(n)):
        a=i+1
for i in range(kai):
    if all(q[w]==g[i][w] for w in range(n)):
        b=i+1
print(abs(a-b))


    
        
        
    
    
    
    
        


Measured memory_bytes: 13860
N = int(input())
S1 = input()
S2 = input()

MOD = 1000000007

if S1[0] == S2[0]:
    ans = 3
    idx = 1
    yoko = False
else:
    ans = 6
    idx = 2
    yoko = True
    
while idx < N:
    if S1[idx] == S2[idx]:
        if yoko:
            ans *= 1 
        else:
            ans *= 2
        idx += 1
        yoko = False
    else:
        if yoko:
            ans *= 3
        else:
            ans *= 2
        idx += 2
        yoko = True
    
    ans %= MOD
    
print(ans%MOD)

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

#define MOD 1000000007

int h,w;
char a[1005][1005];
int dp[1005][1005];

int main(){

    cin>>h>>w;
    for(int i=1;i<=h;i++)
        cin>>(a[i]+1);

    dp[0][1]=1;
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)

            if(a[i][j]=='#')
                dp[i][j]=0;
            else
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;


    cout<<dp[h][w];

}


Measured memory_bytes: 5120
N = int(input())
S = list(input())

R = [None] * S.count("R")
G = [None] * S.count("G")
B = [None] * S.count("B")

ri = 0
gi = 0
bi = 0
for i in range(N):
    if S[i] == "R":
        R[ri] = i+1
        ri+=1
    elif S[i] == "G":
        G[gi] = i+1
        gi += 1
    else:
        B[bi] = i+1
        bi += 1
R = set(R)
G = set(G)
B = set(B)

c = 0
for r in R:
    for g in G:
        for d in [(r + g) / 2, 2 * r - g, 2 * g - r]:
            if d in B:
                c += 1

ans = len(R) * len(G) * len(B) - c
print(ans)


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, k;
  while (cin >> n >> k) {
    vector<int> a(n);
    each (i, a) cin >> i;

    int sum = 0;
    sum += (n - 1) / (k - 1);
    if ((n - 1) % (k - 1)) ++sum;
    cout << sum << endl;
   }
  
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main(void){
    int n=0;
    int Y=0,M=0,D=0;
    scanf("%d",&n);
    int array[n];
    for(int i=0;i<n;i++){
        array[i]=0;
    }
    for(int i=0;i<n;i++){
        scanf("%d %d %d",&Y,&M,&D);
        for(;Y<1000;Y++){
            if(Y%3==0){
                
                for(;M<=10;M++){
                    for(;D<=20;D++){
                        array[i]+=1;
                        
                    }
                    D=1;
                }
            }
            else {
                for(;M<=10;M++){
                    
                    if(M%2==0){
                        for(;D<=19;D++){
                            array[i]+=1;
                        }
                    }
                    else {
                        for(;D<=20;D++){
                            
                            array[i]+=1;
                        }
                    }
                    D=1;
                }
            }
            M=1;
            
        }
    }
    for(int i=0;i<n;i++){
    printf("%d\n",array[i]);
    }
    return 0;
}


Measured memory_bytes: 2036
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
 
/* Coding Space*/
int main(){
  int n; cin >> n;
  int x; cin >> x;
  vi a(n);
  rep(i,n){
    cin >> a[i];
  }
  vi b = a;
  ll ans = LLINF;
  rep(i,n){
    ll t_ans = i*x;
    rep(j,n) b[j] = min(b[j],a[(j-i+n)%n]);
    rep(j,n) t_ans += b[j];

    ans = min(ans,t_ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (ll)(v).size()
#define int long long
#define mod 1000000007

int day;
int c[27];
int d[366][26], ansday[366];

void read_input() {
        //freopen("b1.in", "r", stdin);
        cin >> day;
        for (int i= 0; i< 26; i++) {
                cin >> c[i];
        }
        for (int i= 0; i< day; i++) {
                for (int j= 0; j< 26; j++) {
                        cin >> d[i][j];
                }
        }
}

void read_ans() {
        for (int i= 0; i< day; i++) {
                int x; cin >> x;
                ansday[i]= x- 1;
        }
}

void simu() {
        int lastuse[27]= {};
        int finalscore= 0;
        for (int i= 0; i< day; i++) {
                int choose= ansday[i];
                int score= d[i][choose];
                lastuse[choose]= i+ 1;
                int dec= 0;
                for (int j= 0; j< 26; j++) {
                        dec+= c[j]* ((i+ 1)- lastuse[j]);
                }
                finalscore+= score- dec;
                cout << finalscore<< "\n";
        }

}

void query() {
        int m; cin >> m;
        vector<pair<int, int>> vp;
        for (int i= 0; i< m; i++) {
                int a, b; cin >> a>> b;
                vp.push_back({a, b});
        }
        for (int i= 0; i< m; i++) {
                int wday= vp[i].first- 1;
                int wc= vp[i].second- 1;
                ansday[wday]= wc;
                simu();
        }
}

void sol() {
        int lastuse[27]= {};
        for (int i= 0; i< day; i++) {
                vector<pair<int, int>> r;
                for (int j= 0; j< 26; j++) {
                        int dec= 0;
                        for (int k= 0; k< 26; k++) {
                                if (k== j) continue;
                                dec+= c[k]* ((i+ 1)- lastuse[k]);
                        }
                        r.push_back( { (d[i][j]- dec), j } );
                }
                sort(all(r));
                reverse(all(r));
                ansday[i]= r[0].second;
                lastuse[r[0].second]= i;
        }
        for (int i= 0; i< day; i++) {
                cout << ansday[i]+ 1<< "\n";
        }
}

void solve() {
        read_input();
        //sol();
        read_ans();
        simu();
        //query();
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while ( t-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 3672
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	if ((B - A) % 2 == 0) {
		cout << "Alice" << endl;
	}
	else {
		cout << "Borys" << endl;
	}
	return 0;
}

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

int main(){
    int d, t, s;
    cin >> d >> t >> s;
    if(d<=t*s){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
// Problem : C - Sentou
// Contest : AtCoder - AtCoder Beginner Contest 060
// URL : https://atcoder.jp/contests/abc060/tasks/arc073_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

#define spc ' '
#define endl '\n'

using namespace std;


int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, t, d;
	long long ans = 0ll;
	cin >> n;
	cin >> t;
	vector<int> a(n);
	for(int i = 0; i < n; i ++){
	    cin >> a[i];
	    if(i!=0){
	        d = a[i]-a[i-1];
	        if(d>=t){
	            ans+=t;
	        }
	        else{
	            ans+=d;
	        }
	    }
	}
	cout << ans+t;
	return 0;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
public class    Main      {
	public static void main(String[] args) 
	{
		InputReader in = new InputReader(System.in);
		PrintWriter w = new PrintWriter(System.out);
		Scanner sc = new Scanner(System.in);
		int n = in.nextInt();
		int k=in.nextInt();
		int res=k*2-n;
		w.println(res);
		w.close();
		sc.close();
	}
	static class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		public InputReader(InputStream st) {
			this.stream = st;
		}
		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}
		
		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
		
		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
		
		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}
		
		public String readString() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}
		
		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}
		
		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
		
		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}
		
	}
	
}

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

int main()
{
    long long n, m;
    cin >> n >> m;

    vector<int> penaList(n, 0);
    vector<bool> isAcList(n, false);

    for (int i = 0; i < m; ++i)
    {
        int qNum;
        string result;
        cin >> qNum >> result;

        qNum--;

        if (result == "AC")
        {
            isAcList.at(qNum) = true;
        }
        else if (isAcList.at(qNum) == false)
        {
            penaList.at(qNum)++;
        }
    }

    long long penaNum = 0;
    long long acNum = 0;
    for (int i = 0; i < n; ++i)
    {
        if (isAcList.at(i) == true)
        {
            acNum++;
            penaNum += penaList.at(i);
        }
    }

    cout << acNum << " " << penaNum << endl;
}

Measured memory_bytes: 640
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
vector<int>g[1100];
int v[1100];
int t[1100];
int pr[1100];
int I[1100];
int O[1100];
int va[1100];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		int p,q;scanf("%d%d",&p,&q);
		p--;q--;
		g[p].push_back(q);
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<a;j++)v[j]=-1;
		for(int j=0;j<a;j++)pr[j]=-1;
		queue<int>Q;
		for(int j=0;j<g[i].size();j++){
			Q.push(g[i][j]);
			pr[g[i][j]]=i;
			v[g[i][j]]=1;
		}
		while(Q.size()){
			int at=Q.front();
			Q.pop();
			for(int j=0;j<g[at].size();j++){
				int to=g[at][j];
				if(!~v[to]){
					v[to]=v[at]+1;
					pr[to]=at;
					Q.push(to);
				}
			}
		}
		if(v[i]==-1)continue;
		vector<int>f;
		int now=i;
		do{
			f.push_back(now);
			now=pr[now];
		}while(now!=i);

		for(int j=0;j<a;j++)I[j]=O[j]=va[j]=0;
		for(int j=0;j<f.size();j++)va[f[j]]=1;
		for(int j=0;j<a;j++){
			if(!va[j])continue;
			for(int k=0;k<g[j].size();k++){
				if(!va[g[j][k]])continue;
				I[g[j][k]]++;
				O[j]++;
			}
		}
		bool ok=true;
		for(int j=0;j<a;j++){
			if(va[j]&&(I[j]!=1||O[j]!=1))ok=false;
		}
		if(ok){
			printf("%d\n",(int)f.size());
			for(int j=0;j<f.size();j++)printf("%d\n",f[j]+1);
			return 0;
		}
	}
	printf("-1\n");
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const long long N = 1e6 + 17;
ll cnt, ans, lnt, n, l1, x, y, a[N];
ll bg[N], en[N];
pair<ll,ll>pr[N];
vector<ll>v,v2,v3;
map<ll,ll>mp;
bool used[N];
vector<string>sv;

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);


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

    bg[1] = a[1];
    for ( int i = 2; i <= n; i ++ )
        bg[i] = __gcd( bg[i - 1], a[i] );
    en[n] = a[n];
    for ( int i = n - 1; i >= 1; i -- )
        en[i] = __gcd( en[i + 1], a[i] );;;;;
    for ( int i = 1; i <= n; i ++ )
        ans = max( ans, __gcd( bg[i - 1], en[ i + 1] ) );
    cout << ans;
}



Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
int main()
{
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   
   int n,m;
   cin>>n>>m;
   
   vector<int> hei(n+1);
   
   for(int i=1;i<=n;i++)
   cin>>hei[i];
   
   
   vector<int>vec[200001];
   
   for(int i=0;i<m;i++)
   {
       int x,y;
       cin>>x>>y;
       
       vec[x].push_back(y);
       vec[y].push_back(x);
   }
   
   
   int cnt=0;
   
   for(int i=1;i<=n;i++)
   {
       int flag=0;
       
       for(auto x : vec[i])
       {
           if(hei[i]<=hei[x])
           {
               flag=1;
               break;
           }
       }
       
       if(flag==0)
       cnt++;
   }
   
   
   cout<<cnt<<endl;
   
   
   return 0;
}


Measured memory_bytes: 11056
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        int t = sc.nextInt();
        while(t-->0){
            int n = sc.nextInt();
            int max1 = 0, max2 = 0;
            int before = sc.nextInt();
            for(int i=1; i<n; i++){
                int num = sc.nextInt();
                max1 = Math.max(max1, num - before);
                max2 = Math.max(max2, before - num);
                before = num;
            }
            System.out.println(max1+" "+max2);
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 27540
#include <iostream>
using namespace std;
  
int main(){
    int n[4][3][10]= {},add[4],num;
    cin >> num;
    for(int i = 0; i< num; i++){
        for(int j = 0; j < 4; j++)
            cin >> add[j];
        n[add[0]-1][add[1]-1][add[2]-1] += add[3];
    }
    for(int i = 0; i<4; i++){
        for(int j = 0; j<3; j++){
            for(int k = 0; k<10; k++){
                cout << ' ' << n[i][j][k];
            }
            cout << endl;
        }
        if(i < 3){
        for(int n = 0; n < 20; n++)
            cout << '#';
        cout << endl;
        }
    }
return 0;
}


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

int main() {
    int N,M;
    int count =0;
    cin >>N>>M;
    map<int,int> mp;
    for(int i=0;i<N;i++){
        int K;
        cin >>K;
        for(int j=0;j<K;j++){
            int A;
            cin >>A;
            mp[A]++;
        }
    }for(int i=1;i<=M;i++){
        if(mp[i]==N)count++;
    }
    cout << count <<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def lcm(x, y): return (x * y) // gcd(x, y)

N, M = MAP()
A = LIST()

l = 1
for a in A:
    l = lcm(l, a)
    if l > M*2:
        print(0)
        exit()

for a in A:
    if l // a % 2 != 1:
        print(0)
        exit()
ans = M*2 // l + 1
print(ans // 2)


Measured memory_bytes: 89580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define len(array) (sizeof(array) / sizeof(array[0]))
#define asort(array) sort(array, array + len(array))

int main() {
  int n;cin>>n;
  vector<int> an(100100);
  int a;
  rep(i,n) {
    cin>>a;
    an[a]++;
  }
  int x = an[0]+an[1]+an[2];
  int mx = x;
  rep(i,100000) {
    x = x - an[i] + an[i+3];
    mx = max(mx,x);
  }
  cout << mx;
}


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();

            if (str != null)
            {
                int countStr = str.Length;
                int checkCnt = countStr / 2;
                char[] strArray = str.ToCharArray();
                int changeCnt = 0; 

                int startCnt = 0;
                int endCnt = countStr - 1;
                for (int i = 0; i < checkCnt; i++){
                    if (!strArray[startCnt].Equals(strArray[endCnt]))
                    {
                        changeCnt = changeCnt + 1;
                    }

                    startCnt = startCnt + 1;
                    endCnt = endCnt - 1;
                }

                Console.WriteLine(changeCnt.ToString());
                
            }
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




int main() {
    
    
    int n, a, b;
    cin >> n >> a >> b;
    if ((b - a) % 2 == 0) out("Alice");
    else out("Borys");
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
int main() {
    int n, m; cin >> n >> m;
    int a[m];
    rep(i, m) cin >> a[i];
    sort(a, a + m, greater<int>());
    int hon[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    int dp[n + 1]; //ちょうどi本でつくれる最大桁数
    rep(i, n + 1) dp[i] = -10000; //10^4本で全て1(2本)でも作れないような
    dp[0] = 0;
    for (int i = 2; i <= n; ++i) {
        int mmax = dp[i];
        rep(j, m) {
            if (i - hon[a[j]] < 0) continue;
            mmax = max(mmax, dp[i - hon[a[j]]] + 1);
        }
        dp[i] = mmax;
    }
    /*
     rep(i, n + 1) cout << dp[i] << " ";
     cout << endl;
     */
    //dp[n] : ちょうどn本を使ってつくれる最大桁数
    int keta = dp[n];
    for (int i = 0; i < keta; ++i) { //各桁
        for (int j = 0; j < m; ++j) {
            if (n - hon[a[j]] < 0) continue;
            if (dp[n - hon[a[j]]] == dp[n] - 1) {
                cout << a[j];
                n -= hon[a[j]];
                break;
            }
        }
    }
    cout << endl;
}







Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define 	pi 				3.14159265358979
#define 	mod 			1000000007
#define 	ll  			long long int
#define 	rep(i, a, b) 	for(ll i = a ; i < b ; i++)
#define     repn(i, a, b)   for(ll i = a ; i > b ; i--)
#define 	mod1 			1000003
#define     mod2            998244353
#define     inf             2e18
#define 	hi   			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define     sz              size()
#define     len             length()
#define 	F 				first
#define 	S 				second
#define 	PB 				push_back
#define 	MP				make_pair
#define 	B 				begin()
#define     RB              rbegin()
#define 	E 				end()
#define     UB              upper_bound
#define     LB              lower_bound
#define     present(k, m)   (m.find(k)!=m.end())?1:0
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define     pll             pair<ll, ll>
#define     vll             vector<ll>
#define     vpll            vector<pll>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define     sqr(a)          ((a)*(a))
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	print3(a) 		for(auto i : a)cout<<i<<nl;
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

// ostringstream str1;
// str1 << n;
// string tmp = str1.str();
// get<0>(v[i])
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
 
bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }
 
double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }
 
vll pwx(40);
void cal(ll x){ pwx[0] = 1; rep(i, 1, 40)pwx[i] = x*pwx[i-1]; }
 
/* ################################################################ */

#define space 200005

void solve(){
	ll a, v, b, w, t;
	cin>>a>>v;
	cin>>b>>w;
	cin>>t;

	if(v > w && abs(b-a) <= t*(v-w)){
		cout<<"YES\n";
	}
	else
	cout<<"NO\n";
}
 
int main(){
    // boost;
    // cal(3);
    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
int n,k,a[100005],b[100005];
int main(){
	cin>>n;
	for(int i=1;i<=3500;i++){
		for(int j=1;j<=3500;j++){
			ll down = 1LL*n*i*j;
			ll up = 4LL*i*j-1LL*n*j-1LL*n*i;
			ll hoge = __gcd(up,down);
			up/=hoge; down/=hoge;
			if(up == 1){
				cout<< i << " " << j << " " << down << endl;return 0;
			}
		}
	}
}

Measured memory_bytes: 384
N = int(input())
cnt = 0
anslst = [0] * (N + 1)
for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            ans = i ** 2 + j ** 2 + k ** 2
            ans += i * j + j * k + k * i
            if N >= ans:
                anslst[ans] += 1

for i in anslst[1:]:
    print(i)

Measured memory_bytes: 9388
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;

typedef long long ll;
const int mod = 1e9 + 7;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
 
	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい]
	}
 
	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;
 
		return true;
	}
};

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(M), B(M);
    rep(i, M) cin >> A[i] >> B[i];
    rep(i, M) {
        A[i]--;
        B[i]--;
    }

    vector<ll> ans(M);

    ans[M - 1] = N * (N - 1) / 2;

    UnionFind uf(N);

    // M - 1 回
    for (ll i = M - 1; i >= 1; i--) {
       ans[i - 1] = ans[i];
       if (uf.root(A[i]) != uf.root(B[i])) {
            ans[i - 1] -= uf.size(A[i]) * uf.size(B[i]);
            uf.connect(A[i], B[i]);
       }
    }

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

Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits> 
#include <time.h>

int main(void){
    long N,K;
    std::cin >> N >> K;
    long A[200000];
    for(long i=0; i<N; i++){
        std::cin >> A[i];
    }

    long B[200000]={};

    long num=41;
    for(long i=0; i<std::min((long)50,K); i++){
        for(long j=0; j<N; j++){
            long l=std::max((long)0,j-A[j]);
            long r=std::min((long)(N-1),j+A[j]);
            B[l]++;
            if(r+1<N){
                B[r+1]--;
            }
        }
        for(long j=1; j<N; j++){
            B[j]+=B[j-1];
        }

        for(long j=0; j<N; j++){
            A[j]=B[j];
        }

        for(long j=0; j<N; j++){
            B[j]=0;
        }
    }
    
    for(long i=0; i<N; i++){
        std::cout << A[i];
        if(i!=N-1){
            std::cout << " ";
        }else{
            std::cout << std::endl;
        }
    }

    return 0;
}

Measured memory_bytes: 6752
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define saken string
#define erba continue
#define vl vector<ll>
#define vi vector<int>
#define vli vector <pair <ll, int> >
#define vll vector <pair <ll, ll> >
using namespace std;

ll a, b, c;

int main(){

cin >> a >> b >> c;

ll to = min(b, c);

ll ans = to * 2;

b -= to;
c -= to;

if(b == 0) {

    ans += min(a, c);

    to = min(a, c);

    a -= to;
    c -= to;

}

else {

    ans += min(a, b);

    to = min(a, b);

    a -= to;
    b -= to;
}



if(c) {ans++;}

cout << ans;

return 0;
}


Measured memory_bytes: 256
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

from math import sqrt

N = INT()
tmp = N
fact = {}

for n in range(2, int(sqrt(N)) + 1):
    if tmp == 1:
        break
    
    e = 0
    while 1:
        if tmp % n != 0:
            break
        tmp //= n
        e += 1
    
    if e == 0:
        continue

    fact[n] = e

if tmp != 1:
    fact[tmp] = 1

if fact == {}:
    fact[N] = 1

ans = 0

for p in fact.keys():
    e = 1
    z = p
    
    if N == 1:
        break
    
    while 1:
        if N % z != 0:
            break
        N //= z
        e += 1
        z = pow(p, e)
        ans += 1
        
print(ans)

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

int main(){
    int n;
    cin>>n;
    vector<int> A(n);
    rep(i,n) cin>>A[i];
    vector<int> a(n);
    rep(i,n) a[i]=A[i]-i-1;
    sort(a.begin(),a.end());
    int h=n/2;
    int b=a[h];
    ll ans=0;
    rep(i,n) ans+=abs(A[i]-b-i-1);
    cout<<ans<<endl;
    return 0;
}


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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int X;
	cin >> X;
	if (X == 3 || X == 7 || X == 5) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  char a, b;
  readf("%s %s\n", &a, &b);

  if (a == 'H' && b == 'H') {
    writeln("H");
  } else if (a == 'H' && b == 'D') {
    writeln("D");
  } else if (a == 'D' && b == 'H') {
    writeln("D");
  } else {
    writeln("H");
  }
}


Measured memory_bytes: 256
// D - Moving Piece
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define chmax(x,y) x = max(x,y)

int main(){
	int N, K; cin>>N>>K;
	vector<int> P(N), C(N);
	rep(i, N) cin>>P[i], P[i]--;
	rep(i, N) cin>>C[i];

	int64_t score = -1e18;
	rep(st, N){
		int64_t lap_sc = 0, sum_sc = 0;
		int nx = st, lap_cn = 1;
		for(; lap_cn<=N; ++lap_cn){
			lap_sc += C[nx];
			if(st == (nx = P[nx])) break;
		}
		chmax(lap_sc, 0L);

		for(int k_cn=1; k_cn<=K; ++k_cn){
			sum_sc += C[nx];
			chmax(score, sum_sc + lap_sc * ((K - k_cn) / lap_cn));
			if(st == (nx = P[nx])) break;
		}
	}
	cout<< score <<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define mod 1000003
#define MAX_N 1000005
long long inv[MAX_N];

void GetInv(){
    for (int i = 1; i < MAX_N; i++) {
        if (i == 1) inv[i] = 1;
        else {
            inv[i] = (mod - (mod / i) * inv[mod % i]) % mod;
            if (inv[i] < 0) inv[i] += mod;
        }
    }
}

long long modpow(int n, int r) {
    long long ret = 1; long long tmp = (long long) n;
    while (r != 0) {
        if (r % 2) ret *= tmp;
        tmp *= tmp; tmp %= mod; ret %= mod;
        r /= 2;
    }
    return ret;
}

int main(){
    GetInv();
    int q; cin >> q;
    vector<long long> fact(1000005, 1);
    for (long long i = 0; i < 1000003; i++) {
        fact[i+1] = fact[i] * (i+1) % mod;
    }
    while (q--) {
        long long x, d, n; cin >> x >> d >> n;
        
        if (d == 0) cout << modpow(x, n) << endl;
        else {
            long long t = inv[d] * x % mod;
            if (t + n - 1 >= 1000003 || x == 0) cout << 0 << endl;
            else {
                long long c = fact[t+n-1] * inv[fact[t-1]] % mod;
                c = c * modpow(d, n) % mod;
                cout << c << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 16512
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define zoom ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define precise cout.precision(8); cout << fixed;
#define seed srand(chrono::steady_clock::now().time_since_epoch().count());
const double PI = acos(-1);
using namespace std;

void solve() {
	string S, T; cin >> S >> T;
	int i, tot = (int)S.size(), ans = 0;
	for(i = 0; i < tot; i += 1) {
		if(S[i] != T[i]) {
			ans += 1;
		}
	}
	cout << ans;
}

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

Measured memory_bytes: 3908
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	int a[] = { 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 };
	int x; cin >> x;
	cout << a[x - 1] << endl;
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
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; }
/* next combination */
int next_combination(int sub) {
    int x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}

int main()
{
    int n, k; cin >> n >> k;
    int bit = (1<<k)-1;
    for(; bit < (1<<n); bit=next_combination(bit)){
        vector<int> s;
        rep(i, n){
            if(bit & (1<<i)) s.push_back(i);
        }
        printf("%d: ", bit);
        prvec(s);
    }
    return 0;}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

//#define DEBUG


int main(void)
{
  int N;
  cin >> N;
  
  bool judge=true;
  
  vector<int> A(N);
  for(int i=0;i<N;i++)
  {
    cin >> A[i];
    
    // 偶数の場合、falseになるかも
    if( A[i]%2 ==0)
    {
      // 3 で割り切れない　、かつ 5 で割り切れない
      if( A[i]%3!=0 && A[i]%5!=0)
      {
        judge = false;
      }
    }
  }
  
  if(judge == false)
  {
    cout << "DENIED";
  }
  else
  {
    cout << "APPROVED";
  }
  
  return 0;
} 

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

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

    int N;
    cin >> N;

    vector<double> t(N);
    vector<double> v(N);

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

    vector<double> x(N + 1);

    x[0] = 0;
    x[N] = 0;

    for(int i = 1; i < N; i++) {
        x[i] = min(v[i - 1], v[i]);
    }

    for(int i = 1; i < N; i++) {
        x[i] = min(x[i], x[i - 1] + t[i - 1]);
        x[N - i] = min(x[N - i], x[N - i + 1] + t[N - i]);
    }

    double ans = 0;

    for(int i = 0; i < N; i++) {
        double d = t[i] - (v[i] - x[i]) - (v[i] - x[i + 1]);
        double f = min(x[i], x[i + 1]);
        double b = max(x[i], x[i + 1]);
        if(d >= 0) {
            ans += t[i] * v[i];
            ans -= (v[i] - f) * (v[i] - f) / 2.0;
            ans -= (v[i] - b) * (v[i] - b) / 2.0;
        } else {
            ans += t[i] * f;
            ans += t[i] * t[i] / 2.0;
            ans -= (f + t[i] - b) * ((f + t[i] - b) / 2.0) / 2.0;
        }
    }

    cout << fixed << setprecision(60) << ans << endl;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    string a, b;cin >> a >> b;
    int n = a.size();
    int m = b.size();
    string ans;
    if(n == m){
        ans = "EQUAL";
        inc(i, 0, n){
            if(a[i] < b[i]){
                ans = "LESS";
                break;
            }
            if(a[i] > b[i]){
                ans = "GREATER";
                break;
            }
        }
    }else if(n < m){
        ans = "LESS";
    }else if(n > m){
        ans = "GREATER";
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define E(a) cout << #a << ' ' << a << '\n'


const ll M=5e5+5,LG=17,inf=1e18;

int n,m;

ll a[M];

int main()
{
	cin >> n;
	For(i,0,n)
	{
		ll x;
		cin >> x;
		if (x==0)
		{
			a[0]++;
			a[1]++;
		}
		else
		{
			a[x-1]++;
			a[x]++;
			a[x+1]++;
		}
	}
	ll mx=0;
	For(i,0,M)
	{
		smax(mx,a[i]);
	}
	cout << mx;
}


Measured memory_bytes: 1024
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);

		String yohou[] = sc.nextLine().split("");
		String zisseki[] = sc.nextLine().split("");

		int cnt = 0;
		for(int i = 0;i < yohou.length ;i++) {
			cnt += (yohou[i].equals(zisseki[i])) ? 1 : 0;
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 23380
from collections import Counter
n = int(input())
a = Counter(list(map(int, input().split())))
a = [list(x) for x in a.items() if x[1]>=2]
a.sort(reverse=True, key=lambda x: (x[0], x[1]))
count = 0
base = 4
for i in range(len(a)):
    if count == 1:
        print(l*a[i][0])
        exit()
    else:
        l = a[i][0]
        count += 1

    if a[i][1]>=4:
        print(a[i][0]*a[i][0])
        exit()

print(0)

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

using namespace std;
using ll = long long;
using vec = vector<int>;

#define rep(i, n)  for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
#define pout(n, a) cout << fixed << setprecision(n) << (a)
#define Cast(dig, n) static_cast<std::bitset<(dig)>>(n)

const int INF = 2147483647;
const ll  MOD = 1000000007;

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

    vec peaks(n);
    rep(i, n) cin >> peaks[i];

    int ans = 0;

    vector<bool> isHigher(n);
    rep(i, n) isHigher[i] = true;

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

        a--;
        b--;

        if(peaks[a] <= peaks[b]) isHigher[a] = false;
        if(peaks[b] <= peaks[a]) isHigher[b] = false;
    }

    for(auto itr: isHigher) {
        if(itr) ans++;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 3788
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < 3; i++) {
			sb.append(sc.next().charAt(i));
		}
		System.out.println(sb);
	}
}


Measured memory_bytes: 23124
import sys
input=sys.stdin.readline

a,b,c,x,y=map(int,input().split())
minxy=min(x,y)
deff=max(x,y)-minxy
if a+b<=2*c:
    print(a*x+b*y)
else:
    half=2*c*minxy
    if max(x,y)==x and a<=2*c:
        print(half+deff*a)
    elif max(x,y)==y and b<=2*c:
        print(half+deff*b)
    else:
        print(half+deff*2*c)

Measured memory_bytes: 3064
import java.util.*;

class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      
	  int n = sc.nextInt();
      int[] a = new int[n+1];
      int[] mate = new int[n+1];
      for(int i=1;i<=n;i++){
      	a[i] = sc.nextInt();
      }
     for(int i=1;i<=n;i++){
     	mate[a[i]] = i;
     }
      
    for(int i=1;i<=n;i++){
      	System.out.print(mate[i] + " ");
      }
      
     
    }
}

Measured memory_bytes: 61560