akhauriyash/Code-Regression huggingface dataset:
from itertools import combinations
n, k = map(int, input(). split())
l = [i for i in range(n)]
p = []
for i in combinations(l, k):
    num = 0
    for j in i:
        num |= 1 << j
    p.append((num, i))
    
p.sort()
for i, j in p:
    print("{}: ".format(i), end="")
    print(*j)


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

using namespace std;

int main(int argc, char const *argv[]) {
	int N,K;
	std::cin >> N;
	std::cin >> K;
	int x[N];
	for (size_t i = 0; i < N; i++) {
		std::cin >> x[i];
	}

	int sum = 0;

	for (size_t i = 0; i < N; i++) {
		sum = sum + min(x[i], abs(x[i] - K));
	}
	sum *= 2;

	std::cout << sum << '\n';
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int[][] op = new int[][]{{1,1,1},{1,1,-1},{1,-1,1},{-1,1,1},{-1,-1,1},{-1,1,-1},{1,-1,-1},{-1,-1,-1}};
        int[] a = new int[4];
        for(int i=0;i<4;i++){
            a[i] = S.charAt(i)-'0';
        }
        String[] dic = new String[]{"-"," ","+"};
        for(int i=0;i<8;i++){
            int[] cur = op[i];
            int res = a[0]+a[1]*cur[0]+a[2]*cur[1]+a[3]*cur[2];
            if(res == 7){
                StringBuilder sb = new StringBuilder();
                sb.append(a[0]);
                sb.append(dic[cur[0]+1]);
                sb.append(a[1]);
                sb.append(dic[cur[1]+1]);
                sb.append(a[2]);
                sb.append(dic[cur[2]+1]);
                sb.append(a[3]);
                sb.append("=7");
                System.out.println(sb.toString());
                System.exit(0);
            }
        }
    }
}


Measured memory_bytes: 21972
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
int main()
{
long long n;
cin >> n;
string s;
while(n--)
{
s+=('a'+(n+25/26)%26);
n=n/26;
}
reverse(s.begin(),s.end());
cout<<s;
return 0;
}
    

Measured memory_bytes: 3632
#B
N = int(input())
A = [int(x) for x in input().split()]
i = 0
ans = "APPROVED"
while i<N:
    if A[i]%2 == 1:
        i +=1
        continue
    elif A[i]%5 == 0 or A[i]%3 == 0:
        i +=1
        continue
    else:
        ans = "DENIED"
        break
print(ans)

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

const int N = 2e6 + 12;

#define mkp make_pair
#define sz(s) (int)(s.size())
#define eb emplace_back

#define ll long long

#define int ll

int a[N], dp[N];

main () {
	clog << "Ready\n";

	int n;
	cin >> n;
	bool ok = false;
	for (int i = 1; i <= n; ++ i) {
		cin >> a[i];
		if (a[i] == 1)
			ok = true;
	}
	if (!ok)
		return cout << -1, 0;
	int cnt = 0;
	int f = 1;
	for (int i = 1; i <= n; ++ i) {
		if (a[i] == f)
			++cnt, ++f;
	}

	cout << n - cnt;

	cerr << '\n';
	return 0;
}



Measured memory_bytes: 4352
k = int(input())

ans = []

def dfs(d, val):
    ans.append(val)

    if(d==10): return

    for i in range(-1, 2):
        add = (val%10) + i
        if 0 <= add <= 9:
            dfs(d+1, val*10+add)

for i in range(1, 10):
    dfs(1, i)

ans.sort()

print(ans[k-1])


Measured memory_bytes: 19368
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int m = sc.nextInt();
		int n = sc.nextInt();
		String res = "IMPOSSIBLE";
		if (m > n) {
			int tmp = m;
			m = n;
			n = tmp;
		}
		
		for (int i = m; i < n; i++) {
			if (Math.abs(m - i) == Math.abs(n - i)) {
				res = "" + i;
			}
		}
		
		System.out.println(res);
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define N 100
const ll INF=1e15+7;


int main(){
	string s;
	cin>>s;
	ll t=s.size();
	if(s[0]==s[t-1]&&t%2==0){
		cout<<"First"<<endl;
	}else if(s[0]==s[t-1]&&t%2==1){
		cout<<"Second"<<endl;
	}else if(s[0]!=s[t-1]&&t%2==0){
		cout<<"Second"<<endl;
	}else{
		cout<<"First"<<endl;
	}
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

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

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
	string s;
	cin >> s;
	int n = s.size();
	vi v;
	rep(i, n - 1) {
		if(s[i] == 'R' && s[i + 1] == 'L') {
			v.push_back(i);
		}
	}
	int ans[N];
	rep(i, n) ans[i] = 0;
	int j = 0;
	for(int i = 0; i < n; i++) {
		if(s[i] == 'R' && i > v[j]) j++;
		ans[v[j] + abs(v[j] - i) % 2]++;
	}
	rep(i, n - 1) cout << ans[i] << ' ';
	cout << ans[n - 1] << endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
const ll MOD=1000000007,INF=1e18;
 
int N,M;
pint p[100010];

signed main() {
    IOS();
    cin>>N>>M;
    rep(i,0,N)cin>>p[i].fi>>p[i].se;
    sort(p,p+N);
    
    int ans=0,cnt=0;
    rep(i,0,N){
        ans+=p[i].fi*min(M,p[i].se);
        if(M<=p[i].se){
            cout<<ans<<endl;
            return 0;
        }
        M-=p[i].se;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 1792
N = int(input())
A = list(map(int,input().split()))

gu = []
ans = []

for i in range(N):
    if A[i] % 2 == 0:
        gu.append(A[i])
    else:
        pass

for j in range(len(gu)):
    if gu[j] % 3 == 0 or gu[j] % 5 == 0:
        ans.append(gu[j])
    else:
        pass

if gu == ans:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 61980
from sys import stdin
from sys import  setrecursionlimit
setrecursionlimit(10000)

[H, N] = [int(x) for x in stdin.readline().rstrip().split()]
As = []
Bs=[]
for i in range(N):
    [A, B] = [int(x) for x in stdin.readline().rstrip().split()]
    As.append(A)
    Bs.append(B)

INF = 10**10
dp_map = [[INF]*(H+1) for _ in range(N+1)]

#dp_map[i][j]: i番目の魔法までを使って、最低でもjのダメージを与える時に必要なMP
dp_map[0][0]  = 0
for i in range(N):
    for j in range(H+1):
        if j<As[i]:
            dp_map[i+1][j] = min(dp_map[i+1][0]+Bs[i],dp_map[i][j])
        else:
            dp_map[i+1][j] = min(dp_map[i+1][j-As[i]]+Bs[i] ,dp_map[i][j])

print(dp_map[N][H])


Measured memory_bytes: 120300
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int h,w,k,to,del,tot;
string str[7];
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>h>>w>>k;
	for(int i=0;i<h;i++) cin>>str[i];
	for(int m1=0;m1<(1<<h);m1++){
		for(int m2=0;m2<(1<<w);m2++){
			tot=0;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++)
					if((!(((m1>>i)&1)||((m2>>j)&1)))&&(str[i][j]=='#'))
						tot++;
			}
			if(tot==k) to++;
		}
	}
	cout<<to<<endl;
	return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    ll a[n];
    ll ans = 0;
    for(ll i=0;i<n;++i){
        cin>>a[i];
        ans += a[i]-1;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

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

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


int n;
int f[110000];
int s[110000];

int main () {
  cin >> n;
  Rep(i, n) {
    int tmp;
    cin >> tmp;

    if (i % 2 == 0) {
      f[tmp]++;
    } else {
      s[tmp]++;
    }
  }

  int f_num = 0;
  int s_num = 0;
  int f_num_snd = 0;
  int s_num_snd = 0;

  int f_num_ind = 0;
  int s_num_ind = 0;

  rep(i, 100000) {
    if (f_num <= f[i]) {
      f_num_snd = f_num;
      f_num = f[i];
      f_num_ind = i;
    } else if (f_num_snd < f[i]) {
      f_num_snd = f[i];
    }
    if (s_num <= s[i]) {
      s_num_snd = s_num;
      s_num = s[i];
      s_num_ind = i;
    } else if (s_num_snd < s[i]) {
      s_num_snd = s[i];
    }
  }

  //cout << f_num << "\n";
  //cout << s_num << "\n";
  //cout << f_num_snd << "\n";
  //cout << s_num_snd << "\n";

  if (f_num_ind == s_num_ind) {
    cout << min(((n/2)-f_num_snd) + ((n/2)-s_num), ((n/2)-f_num) + ((n/2)-s_num_snd)) << "\n";
  } else {
    cout << ((n/2)-f_num) + ((n/2)-s_num) << "\n";
  }

}

Measured memory_bytes: 1024
import math
import collections
X=int(input())
# N,M=map(int,input().split())
# S=[[]for i in range(N)]
# # for i in range(Q):
# H=list(map(int,input().split()))
# #     S[i]=a
# # ans=0
# # print()
for A in range(-120,120):
    for B in range(-120, 120):
        if A**5-B**5==X:
            print(A,B)
            exit()

Measured memory_bytes: 68052
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
ll exgcd(ll a, ll b, ll & x, ll & y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;	
	}
	ll d = exgcd(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
ll inv(ll a, ll MOD) {
	ll x, y;
	exgcd(a, MOD, x, y);
	x = (x % MOD + MOD) % MOD;
	return x;
}
ll fac[200010];
void init(int p) {
	fac[0] = 1;
	for (int i = 1; i <= p; i++) fac[i] = fac[i - 1] * i % mod;
}
ll lucas2(ll n, ll m) {
	ll ret = 1, a, b;
	while (n && m) {
		a = n % mod, b = m % mod;
		if (a < b) return 0;
		ret = ret * fac[a] % mod * inv(fac[b] * fac[a - b] % mod, mod) % mod;
		n /= mod, m /= mod;
	}
	return ret;
}
int main()
{
	ll x, y, n, m;
	
	scanf("%lld%lld%lld%lld", &n, &m, &x, &y);
	ll ans = 0;
	init(200005);
	ll z = y, p = n + m - 2;
	for (ll i = 0; i <= n - x - 1; i++) {
		ans = ans + lucas2(z + i - 1, i) * lucas2(p - z - i, n - 1 - i) % mod;
		ans %= mod;
		//printf("1  %lld  %lld\n", i, ans);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 1792
//https://atcoder.jp/contests/abc164/tasks/abc164_b
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
  ll A,B,C,D; cin>>A>>B>>C>>D;
  bool ans=false;
  while(true){
    C -= B;
    if(C<=0) {
      ans=true;
      break;
    }
    A -= D;
    if(A<=0){
      break;
    }
  }
  cout<<(ans?"Yes":"No")<<endl;
  return 0;
}

Measured memory_bytes: 3620
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりに作成したソースコード
 * 
 * https://atcoder.jp/contests/abc107/submissions/14509241 にも参考
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] a = new int[n];
			int right = IntStream.range(0, n).map(i -> a[i] = scanner.nextInt()).max().getAsInt();
			int left = Arrays.stream(a).min().getAsInt();
			long mLength = n * (n + 1L) / 2;
			int answer = -1;
			while (left <= right) {
				int middle = (left + right) / 2;
				if (calcNonLessNumber(a, middle) >= (mLength + 1) / 2) {
					answer = middle;
					left = middle + 1;
				} else {
					right = middle - 1;
				}
			}
			System.out.println(answer);
		}
	}

	/**
	 * a の連続部分列 a[l, r] (1 ≤ l ≤ r ≤ N) のうち，(A の個数) ≤ (B の個数) を満たすものは何通りかを計算する
	 * 
	 * 
	 * @param a     配列
	 * @param value 基準となるvalue
	 * @return a の連続部分列 a[l, r] (1 ≤ l ≤ r ≤ n) のうち，(A の個数) ≤ (B の個数) を満たすものは何通りか
	 */
	private static long calcNonLessNumber(int[] a, int value) {
		int[] sum = new int[a.length + 1];
		sum[0] = 0;
		IntStream.rangeClosed(1, a.length).forEach(i -> sum[i] = sum[i - 1] + ((a[i - 1] >= value) ? 1 : -1));
		return calcNonInversionNumber(sum, 0, sum.length - 1);
	}

	/**
	 * 配列の転倒していない数を計算
	 * 
	 * @param a    配列
	 * @param from 開始インデックス
	 * @param to   終了インデックス
	 * @return 配列の転倒していない数
	 */
	private static long calcNonInversionNumber(int[] a, int from, int to) {
		if (from == to) {
			return 0L;
		}
		int middle = (from + to) / 2;
		long result = calcNonInversionNumber(a, from, middle) + calcNonInversionNumber(a, middle + 1, to);
		int[] sorted = new int[to - from + 1];
		int left = from, right = middle + 1, sortedIndex = 0;
		while ((left != middle + 1) || (right != to + 1)) {
			if ((right == to + 1) || ((left != middle + 1) && (a[left] <= a[right]))) {
				result += to - right + 1;
				sorted[sortedIndex++] = a[left++];
			} else {
				sorted[sortedIndex++] = a[right++];
			}
		}
		IntStream.rangeClosed(from, to).forEach(i -> a[i] = sorted[i - from]);
		return result;
	}
}


Measured memory_bytes: 65656
#include<iostream>
using namespace std;
int main(){
int d,n,ans;
  cin>>d>>n;
  if(n%100==0) n=n+1;
  if(d==0){
    ans=n;
    
  }
  if(d==1){
    ans=n*100;

  }
  if(d==2){
    ans=n*10000;
  }
 cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
def alpha2num(alpha):
    num=0
    for index, item in enumerate(list(alpha)):
        num += pow(26,len(alpha)-index-1)*(ord(item)-ord('a')+1)
    return num

def string2num(str):
    _N = len(str)
    num=0
    for n in range(_N):
        num+=alpha2num(str[n])* (26**(_N-1-n))
    return num

if __name__ == "__main__":
    N,L = (int(x) for x in input().split())
    S = []
    S2Num=[]
    for n in range(N):
        _str = input()
        S.append(_str)
        S2Num.append(string2num(_str))
    ans =""
    for key in sorted(range(len(S2Num)), key=lambda k: S2Num[k]):
        ans+=S[key]
    print(ans)

Measured memory_bytes: 3064
N = int(input())
A = list(map(int,input().split()))

def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b,a%b)

ans = 0
L = [0]*(N+1)
for i in range(N):
  L[i+1] = gcd(L[i],A[i])

R = [0]*(N+1)
for i in range(N-1,-1,-1):
  R[i] = gcd(R[i+1],A[i])
  
for i in range(N):
  M = gcd(L[i],R[i+1])
  if ans < M:
    ans = M
    
print(ans)

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

typedef long long ll;
const int INF = 1e9+7;
const int LIM = 1e5+10;

ll fun[LIM][3], pd[LIM][3];
bool calc[LIM][3];

int N;

ll sol(int n, int j){
    
    if(n == N) return 0;
    if(calc[n][j]) return pd[n][j];
    calc[n][j] = 1;
    
    ll ans = 0;
    for(int i=0; i<3; i++){
        if(i != j){
            ans = max(ans, fun[n][i] + sol(n+1, i));
        }
    }
    return pd[n][j] = ans;
}

ll solve(){
    return max(max(sol(0,0), sol(0,1)), sol(0,2));
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> N;
    for(int i=0; i<N; i++){
        for(int j=0; j<3; j++) cin >> fun[i][j];
    }
    cout << solve() << '\n';

    return 0;
}


Measured memory_bytes: 13056
import heapq
N, M = map(int, input().split())

jobs = [[] for _ in range(M+1)]

for i in range(N):
    a, b = map(int, input().split())
    if a <= M:
        jobs[M-a].append(b)

ans = 0
priorityQueue = []
heapq.heapify(priorityQueue)
for i in range(M-1, -1, -1):
    for jobValues in jobs[i]:
        heapq.heappush(priorityQueue, -1*jobValues)
    if len(priorityQueue) > 0:
        ans += heapq.heappop(priorityQueue) * (-1)

print(ans)


Measured memory_bytes: 89096
import heapq
N,M=map(int,input().split())
la=list(map(lambda x:-int(x),input().split()))
heapq.heapify(la)
#la.sort()
for i in range(M):
    ll=heapq.heappop(la)/2
    heapq.heappush(la,ll)
ans=0
for i in range(N):
    ans+=int(-heapq.heappop(la))
print(ans)


Measured memory_bytes: 14180
#include <iostream>
#define MAX_NUM 100

int inputs[MAX_NUM] = {0};

using namespace std;

void swap(int *a, int *b) {
	int temp = 0;
	temp = *a;
	*a = *b;
	*b = temp;
}

void printArray(int *a, int num) {
	for (int i=0; i<num; i++) {
		if (i>0) { cout<<" "; }
		cout<<a[i];
	}
	cout<<endl;
}

int main(int argc, char const *argv[])
{
	int n = 0;
	int swapCount = 0;
	cin >> n;
	for (int i=0; i<n; i++) {
		cin >> inputs[i];
	}

	for (int i=0; i<n-1; i++) {
		int minj = i;
		for (int j=i; j<n; j++) {
			if (inputs[j] < inputs[minj]) {
				minj = j;
			}
		}
		if (i != minj) {
			swap(&inputs[i], &inputs[minj]);
			swapCount ++;
		}
	}


	printArray(inputs, n);
	cout<<swapCount<<endl;
	return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    ll k;
    cin >> k;
    constexpr int n = 50;
    vector<ll> a(n, n - 1);
    ll c = k / n;
    for(int i = 0; i < n; ++i)  a[i] += c;
    k %= n;
    for(int i = 0; i < k; ++i)  a[i] += n - k + 1;
    for(int i = k; i < n; ++i)  a[i] -= k;
    cout << n << '\n';
    for(int i = 0; i < n; ++i){
        cout << a[i];
        cout << ((i == n - 1) ? '\n' : ' ');
    }
}

Measured memory_bytes: 3624
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)

def solve(N: int, A: "List[int]"):
    counts = {}
    for a in A:
        if not a in counts:
            counts[a] = 0
        counts[a] += 1

    M = max(A)
    s = set(A)
    ret = 0
    used = [False] * (M + 1)
    for i in range(1, M + 1):
        if used[i]:
            continue
        if not i in s:
            continue
        if counts[i] == 1:
            ret += 1
        j = 1
        while i * j <= M:
            used[i * j] = True
            j += 1
    print(ret)


def _hoge(N, A):
    for i, v in enumerate(A):
        if used[i]:
            continue
        if not (i < N - 1 and v == A[i + 1]):
            ret += 1
        for j in range(i + 1, N):
            if A[j] % v == 0:
                used[j] = True
    print(ret)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 132724
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,n) for(int i=1;i<=n;i++)
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)
#define ll int64_t
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;

int main() {

ll N; cin >> N ;

vector<ll> A(N);

rep(i,N) cin>>A[i];

map<ll,ll> L,R;

rep(i,N){
  ll x=i+A[i]+1,y=i-A[i]+1;//i+A(i),j-A(j)
  if(L[x]==0) L[x]=1;
  else L[x]++;

  if(R[y]==0) R[y]=1;
  else R[y]++;
}

ll ans=0;

for(auto p : R){
  ll key=p.first; ll value=p.second;

  ans+=value*L[key];

}

cout << ans << endl;

return 0;
}

Measured memory_bytes: 39072
#include<iostream>
#include<cstdio>

int n,m,cnt;
int Map[6000][6000];
int ans[3000000][4];

int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			scanf("%d",&Map[i][j]);
	for (int i=1;i<=n;i++)
		for (int j=1;j<m;j++)
			if (Map[i][j]&1){
				ans[cnt][0]=ans[cnt][2]=i;
				ans[cnt][1]=j;ans[cnt][3]=j+1;
				Map[i][j+1]++;
				cnt++;
			}
	for (int i=1;i<n;i++)
		if (Map[i][m]&1){
			ans[cnt][0]=i;ans[cnt][2]=i+1;
			ans[cnt][1]=ans[cnt][3]=m;
			Map[i+1][m]++;
			cnt++;
		}
	printf("%d\n",cnt);
	for (int i=0;i<cnt;i++)
		printf("%d %d %d %d\n",ans[i][0],ans[i][1],ans[i][2],ans[i][3]);
}

Measured memory_bytes: 18432
#include<bits/stdc++.h>
#define inf 1000000000
#define ll long long
#define N 100005
using namespace std;
ll x,y,z,n,a[N],b[N],c[N],d[N],e[N],s[N],p[N];
priority_queue<ll,vector<ll>,greater<ll> >q;
bool cmp(ll x,ll y)
{
	return d[x]>d[y];
}
int main()
{
	ll Ans=-1e18;
	scanf("%lld%lld%lld",&x,&y,&z);n=x+y+z;
	ll sum=0;
	for (int i=1;i<=n;i++)
	{
		scanf("%lld%lld%lld",&a[i],&b[i],&c[i]);
		sum+=a[i];
		d[i]=b[i]-c[i];
		e[i]=i;
	}
	sort(e+1,e+n+1,cmp);
	ll now=0;
	for (int i=1;i<=y;i++)
		q.push(-inf),now+=-inf;
	for (int i=1;i<=n;i++)
	{
		q.push(b[e[i]]-a[e[i]]);
		now+=b[e[i]]-a[e[i]]-q.top();
		p[i]=now;
		q.pop();
	}
	now=0;
	while(q.size())q.pop();
	for (int i=1;i<=z;i++)
		q.push(-inf),now+=-inf;
	for (int i=n;i>=1;i--)
	{
		q.push(c[e[i]]-a[e[i]]);
		now+=c[e[i]]-a[e[i]]-q.top();
		s[i]=now;
		q.pop();
	//	cout<<p[i-1]<<' '<<s[i]<<endl;
		if (i-1>=y)Ans=max(p[i-1]+s[i],Ans);
	}
	printf("%lld\n",Ans+sum);
}

Measured memory_bytes: 6516
#include<bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)

signed main(){
    int k, a, b;
    cin >> k >> a >> b;

    for(int i = a; i <= b; i++){
        if(i % k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
def seisu(a):
    b = str(bin(int(a//1)))[2:]
    if len(b) > 9:
        print "NA"
        raise ValueError
    else:
        return b
        
def shosu(a):
    c = a - a//1
    f = []
    digit = 0
    while digit < 5:
        new_c = 2 * c
        seisu_part = int(new_c//1)
        shosu_part = new_c - seisu_part      
        f.append(seisu_part)
        if shosu_part == 0:
            return "".join(map(str, f)) 
        c = shosu_part
        digit += 1
    else:
        print "NA"
        raise ValueError

if __name__ == "__main__":
    while True:
        try:
            a = float(raw_input())
        except:
            break
        if a < 0: 
            continue
        try:
            sei = seisu(a) # ??´??°??¨???
            sho = shosu(a) # ?°???°?????\?????¨???
        except ValueError:
            continue
        print sei.zfill(8) + "." + str(sho).ljust(4,"0")

Measured memory_bytes: 6428
import numpy as np
n, k = map(int, input().split())
list_subj = []
for i in range(n):
  x, y, c = input().split()
  if c == "W":
    list_subj.append([int(x) % (2*k), int(y) % (2*k)])
  else:
    list_subj.append([(int(x) + k) % (2*k), int(y) % (2*k)])

imos_field = [[0] * (2*k+1) for _ in range(2*k+1)]
for x, y in list_subj:
  for place in (0, k):
    adj_y = (y + place) % (2 * k)
    if adj_y >= k - 1:
      imos_y = [(adj_y-k+1, adj_y+1)]
    else:
      imos_y = [(0, adj_y+1), (adj_y+k+1, 2*k)]
    adj_x = (x + place) % (2 * k)
    if adj_x >= k - 1:
      imos_x = [(adj_x-k+1, adj_x+1)]
    else:
      imos_x = [(0, adj_x+1), (adj_x+k+1, 2*k)]
    for bottom, top in imos_y:
      for left, right in imos_x:
        imos_field[bottom][left] += 1
        imos_field[top][left] -= 1
        imos_field[bottom][right] -= 1
        imos_field[top][right] += 1

result = np.cumsum(imos_field, axis=1)
result = np.cumsum(result, axis=0)
result = int(np.max(result))
print(result)

Measured memory_bytes: 122592
#include <iostream>
using namespace std;
int main(void){
   string s;
   int nc[26]={};
   
   while(getline(cin,s)){
       for(int i=0;i<(int)s.length();i++){
           if('a'<=s[i]&&s[i]<='z') nc[s[i]-'a']++;
           if('A'<=s[i]&&s[i]<='Z') nc[s[i]-'A']++;
       }
   }
   for(int i=0; i<26 ;i++){
       cout<<(char)('a'+i)<<" : "<<nc[i]<<endl;
   }
   
}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
using namespace std;
int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
  return 0;
}
  

Measured memory_bytes: 3104
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i=0; i<n; i++) cin >> h[i];

    for(int i=n-1; i>=1; i--)
        if(h[i-1] == h[i] + 1) {
            h[i-1]--;
        }

    for(int i=0; i<n-1; i++)
        if(h[i] > h[i+1]){
            cout << "No" << endl;
            return 0;
        }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 640
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n = I()
    x = LI()
    l = I()
    k = int(math.log(n,2))
    f = [[i for j in range(k+1)] for i in range(n)]
    for i in range(n-1):
        j = bisect.bisect_left(x,x[i]+l)
        if j < n:
            if x[j] > x[i]+l:
                f[i][0] = j-1
            else:
                f[i][0] = j
        else:
            f[i][0] = j-1
    po2 = [1]*(k+1)
    for i in range(k):
        po2[i+1] = po2[i]*2
    for j in range(k):
        for i in range(n):
            f[i][j+1] = f[f[i][j]][j]
    q = I()
    for i in range(q):
        a,b = LI()
        a,b = [min(a,b)-1, max(a,b)-1]
        ans = 0
        while a < b:
            i = bisect.bisect_left(f[a],b)
            ans += po2[max(0,i-1)]
            a = f[a][max(0,i-1)]
        print(ans)

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 43936
import sys
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
n=int(input())
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

i=0
j=2
li=[]
while(i<n):
    if is_prime(j*5+1):
        li.append(j*5+1)
        i+=1
    j+=1
print(" ".join(map(str,li)))

Measured memory_bytes: 38384
n, k = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)

def gcd(a, b)
  a, b = b, a if a < b

  while b > 0
    a, b = b, a % b
  end
  a
end

# 最大公約数の倍数の数値は作れる
if a.max < k
  puts 'IMPOSSIBLE'
  exit
end

gcd = a[0]

n.times do |i|
  gcd = gcd(a[i], gcd)
end

 puts k % gcd == 0 ? 'POSSIBLE' : 'IMPOSSIBLE'

Measured memory_bytes: 9476
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>

int main(void) {

	char s[100001], t[50001];
	int i, j=0, sl;
	
	scanf("%s", s);
	sl = strlen(s);

	for (i = 0; i < sl; i += 2) {
		t[j] = s[i];
		j++;
	}
	t[j] = '\0';

	printf("%s", t);

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int h, n;
    cin >> h >> n;
    vector<ll> ans(h+1, INF<ll>);
    ans.back() = 0;
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        for (int j = h; j > 0; --j) {
            ans[max(j-a, 0)] = min(ans[max(j-a, 0)], ans[j]+b);
        }
    }
    cout << ans[0] << "\n";
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <cstdlib>
#include <queue>
#include <vector>
#include <set>
#include <stdio.h>
#include <cstdio>
using namespace std;
int V,E,R,S[500010],T[500010],D[500010];
int C[100010];
const int Inf = 10000*100000+100;

int main() {
	cin >> V >> E >> R;
	for (int i = 0; i < E;i++) {
		cin >>S[i] >> T[i] >> D[i];
	}
	for (int i = 0; i < V;i++) {
		C[i]= Inf;
	}
	C[R]=0;
	for (int i = 0; i < V;i++) {
		bool update = false;
		for (int j=0;j <E;j++) {
			int s= S[j], t=T[j],d=D[j];
			if (C[s] < Inf && C[t] > C[s] + d) {
				C[t] = C[s] + d;
				update = true;
			}
		}
		if(!update) break;
	}
	for (int i =0;i < V;i++){
		if (C[i] == Inf) cout << "INF" << endl;
		else cout << C[i] <<endl;
	}
}

Measured memory_bytes: 7372
/* SANDEEP YADAV*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld double
#define lld long double
#define umap unordered_map<>
#define sz(x) ((ll)((x).size()))
#define all(x) (x).begin(),(x).end()
#define vi vector<int>
#define pi pair<int, int>
#define setp cout<<fixed<<setprecision(6)
#define loop(i,a,b)  for(int i=a;i<b;i++)
#define rloop(i,b,a) for(int i=b-1;i>=a;i--)
#define vl vector<ll>
#define pl pair<ll, ll>
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
ll gcd(ll a,ll b){ if(a<b) { a=a+b; b=a-b; a=a-b;}while(b!=0){ll r=a%b; a=b; b=r;} return a;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long power(long long a, long long b, long long m) {a %= m;long long res = 1;while (b > 0) {if (b & 1)res = res * a % m;a = a * a % m;b >>= 1;}return res;}
const int N=1000005;
void judge()
{
      #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("error.txt","w",stderr);
    #endif
}
struct myhash
{
    static uint64_t fxn(uint64_t x)
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator ()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return fxn(x + FIXED_RANDOM);
    }
};
void solve(int tc)
{
    
    int n,m;
    cin>>n>>m;

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

            if(ch=='.')
                a[i][j]=1;
            else
                a[i][j]=0;
        }
    }
    a[1][1]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {            
            if(a[i][j]==0||(i==1&&j==1))
                continue;
            else 
                a[i][j]=(a[i-1][j]+a[i][j-1])%mod;
        }
        // cerr<<"\n";
    }
    // for(int i=0;i<=n;i++)
    // {
    //     for(int j=0;j<=m;j++)
    //         cerr<<a[i][j];
    //     cerr<<"\n";
    // }
    cout<<a[n][m];

    return;
}
int main()
{
    fastio;
    //judge();

    int T=1;
    // cin>>T;
    for(int tc=1;tc<=T;tc++)
    {
        solve(tc);
    }
    return 0;
}

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

typedef long long int int64;
int n;
int l;
int x[300003],t[300003];
int main()
{
	scanf("%d%d",&n,&l);
	for(int i = 0;i < n;++i) {
		scanf("%d",&x[i]);
	}
	int64 round = 0;
	for(int i = 0;i < n;++i) {
		int tt;
		scanf("%d",&tt);
		round += tt / (2 * l);
		tt %= (2 * l);
		if(tt == 0) {
			t[i] = 0;
		} else {
			// rebound from left, rebound from right
			t[i] = ((2*(l-x[i])>=tt) << 1) | (2*x[i]>=tt);
			++round;
		}
	}
	int p = 0, q = 0;
	for(int i = 0;i < n - 1;++i) {
		if(p > 0 && (t[i] & 2) == 2) {
			if((t[i] & 1) == 1) {
				++q;
			}
			--p;--round;
		} else if(t[i] == 2) {
			if(q > 0) {
				++p;--q;
			}
		} else if((t[i] & 1) == 1) {
			++p;
		}
	}
	if((t[n-1] & 2) == 0) {
		++round;
	}
	printf("%lld\n", (int64)round * 2 * l);
}


Measured memory_bytes: 2560
import sys
sys.setrecursionlimit(int(1e6))

N = int(input())
H = list(map(int, input().split()))
steps = [0] * N

i = 0
s = i
while i < (N-1):
    if H[i] >= H[i+1]:
        i += 1
    else:
        steps[s] = i - s
        i += 1
        s = i
else:
    steps[s] = i - s

print(max(steps))


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

using namespace std;

int main(){
	string s;
	cin>>s;
	int count = 0;
	if((s[0] == s[1])&&(s[1] == s[2])&& (s[0] == s[2]) ) count++;
	if(!count) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;


}

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

#define ALL(v) v.begin(), v.end()
typedef long long ll;



using namespace std;
int main() {
	int n;
	
	cin >> n;
	map<int, int> a;
	for (int i = 0; i < n; i++)
	{
		int temp;
		cin >> temp;
		a[temp] = i+1;
	}

	for (auto az : a) {
		cout << az.second;
		cout << " ";
	}
	

}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

struct SegmentTree {
  vi32 v;
  int n;
  SegmentTree(int size) {
    n = 1;
    while (n < size) n <<= 1;
    v.resize(n * 2, 0);
  }
  void set(int k, int x) {
    v[k + n] = x;
  }
  void build() {
    rrep(i, n) v[i] = (int) gcd(v[i * 2 + 0], v[i * 2 + 1]);
  }
  int query(int a, int b, int k = 1, int l = 0, int r = -1) {
    int ret = 0;
    for (a += n, b += n; a < b; a >>= 1, b >>= 1) {
      if (a & 1) ret = (int) gcd(ret, v[a++]);
      if (b & 1) ret = (int) gcd(ret, v[--b]);
    }
    return ret;
  }
};

void solve() {
  int n; cin >> n;
  auto st = SegmentTree(n);
  rep(i, n) {
    int a; cin >> a;
    st.set(i, a);
  }
  st.build();
  int ans = 1;
  rep(i, n) {
    amax(ans, (int) gcd(st.query(0, i), st.query(i + 1, n)));
  }
  cout << ans << '\n';
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		String T = "";
		sc.close();
		for(int i=0; i<S.length(); i++) {
			char a = S.charAt(i);
			a += N;
			if ('Z' < a) {
                a -= 26;
            }
			T += (char)a;
		}
		System.out.println(T);
	}

}

Measured memory_bytes: 149460
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int compare_int(const void *a, const void *b)
{
    return *(long long*)a - *(long long*)b;
}

int min_comp(int min, int a)
{

}
int max_comp(int max, int a)
{
  if(max>a)    return max;
  else    return a;
}


int main()
{
  int N, X;
  int m[101]={};
  int min;
//  long long N[101]={};
  int i,j;
  int cont=0;
//    int k=0;

  scanf("%d %d", &N ,&X);
//  printf("%c\n", S);
  for(i=0;i<N;i++){
    scanf("%d", &m[i]);
    if(min>m[i]) min =m[i];
    X = X - m[i];
    cont++;
  }
  cont = cont + (X/min);
  
  printf("%d\n", cont);
 
  //  else printf("No\n"); 
return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

#define Max 1000000

void printA(int A[Max], int N) {
	int i;

	for (i = 0; i < N - 1; i++)
		printf("%d ", A[i]);
	printf("%d\n", A[i]);
}

int insertionSort(int A[Max], int N, int g) {
	int i, j, v;
	int cnt = 0;

	for (i = g; i < N; i++) {
		v = A[i];
		j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j + g] = A[j];
			j -= g;
			cnt++;
		}
		A[j + g] = v;
	}

	return cnt;
}

void shellSort(int A[Max], int N) {
	int i = 0;
	int cnt = 0;
	int m = 0;
	int box[20];
	int G[Max];


	box[0] = 1;
	for (i = 1; i < 20; i++) box[i] = 3 * box[i - 1] + 1;

	for (i = 20 - 1; i >= 0; i--) {
		if (box[i] <= N) G[m++] = box[i];
	}

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

	printA(G, m);

	for (i = 0; i < m; i++) cnt += insertionSort(A, N, G[i]);

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

	for (i = 0; i < N; i++) printf("%d\n", A[i]);
}

int main( ) {
	int N, i, j;
	int A[Max];

	scanf("%d", &N);

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

	shellSort(A, N);

	return 0;
}

Measured memory_bytes: 4508
#include <iostream>

using namespace std ;

int main()
{
int a,b,c,d;
cin>>a>>b>>c>>d;
if(a+b>c+d)
    cout<<"Left";
if(a+b<c+d)
    cout<<"Right";
    if(a+b==c+d)
    cout<<"Balanced";
    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

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

// for loop
#define REP(i, n) for ((i) = 0;(i) < (ll)(n);(i)++)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

int solve() {
	double A, B, H, M;
	cin >> A >> B >> H >> M;

	double alpha = (90.0 - (H + M / 60.0) * 30.0) / 360.0 * 2.0 * PI;
	double beta = (90.0 - M * 6.0) / 360.0 * 2.0 * PI;

	double x2 = pow(A * cos(alpha) - B * cos(beta), 2.0);
	double y2 = pow(A * sin(alpha) - B * sin(beta), 2.0);
	double dist = pow(x2 + y2, 0.5);

	cout << fixed;
	cout << setprecision(15) << dist << endl;

	return 0;
}

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

	solve();

	return 0;
}


Measured memory_bytes: 4244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; ++i)
#define INF (2e9)

int main() {
  ll a;
  string b;
  cin >> a >> b;

  ll b1 = b[0]-'0';
  ll b2 = b[2]-'0';
  ll b3 = b[3]-'0';

  ll ans1, ans2, ans3;
  ans1 = a*b1 + a*b2/10 + a*b3/100;
  ans2 = a*b2%10 + a*b3%100/10;
  ans3 = a*b3%10;

  if(ans2 >= 10) {
    ans1 += 1;
    ans2 -= 10;
  }

  cout << ans1 << endl;

  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ft(i,l,r) for(register int i=l;i<=r;i++)
#define fd(i,r,l) for(register int i=r;i>=l;i--)
using namespace std;
int n;
int main()
{
	cin>>n;
	if(n%111==0) cout<<n;
	else cout<<n+(111-n%111);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    double eps = 0.000001;
    if (abs(w / 2.0 - x) < eps && abs(h / 2.0 - y) < eps) {
        cout << (w * h) / 2.0 << " " << 1 << endl;
    }
    else {
        cout << (w * h) / 2.0 << " " << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <cmath>
#include <map>
#include <tuple>
#include <queue>
#include <stack>

#define MOD (1000000007)
using namespace std;

typedef long long ll;

typedef pair<ll, ll> Node;

int main() {
    ll N, Q;
    cin >> N >> Q;

    vector<vector<int>> v(N);

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

        v[a-1].push_back(b-1);
        v[b-1].push_back(a-1);
        // cout << "test" << endl;
    }
    vector<int> v2(N, 0);
    for(int i = 0; i < Q; i++) {
        int p, x;
        cin >> p >> x;

        v2[p-1] += x;
        // cout << "test2" << endl;
    }

    // cout << "test3" << endl;

    stack<Node> s;
    vector<int> ans(N, 0);
    vector<int> parent(N, 0);

    s.push(make_pair(0, v2[0]));
    while(s.size() > 0) {
        Node tmp = s.top();s.pop();
        // cout << get<0>(tmp) << "," << get<1>(tmp);
        ans[get<0>(tmp)] = get<1>(tmp);
        for(int i = 0; i < v[get<0>(tmp)].size(); i++) {
            if(parent[get<0>(tmp)] == v[get<0>(tmp)][i]) continue;
            parent[v[get<0>(tmp)][i]] = get<0>(tmp);
            // cout << v[get<0>(tmp)][i] << "," << get<0>(tmp) << ":" << seen[v[get<0>(tmp)][i]][get<0>(tmp)] <<  " seen" << endl;;
            //cout << v[get<0>(tmp)][i] << "," << get<1>(tmp) + v2[v[get<0>(tmp)][i]] <<" pushed." <<endl;
            s.push(make_pair(v[get<0>(tmp)][i], get<1>(tmp) + v2[v[get<0>(tmp)][i]] ));
        }
    }

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

Measured memory_bytes: 18748
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se 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 rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

typedef pair<int, int> P;
int main(){
    string d;
    cin>>d;
    if(d=="25"){
        cout<<"Christmas"<<endl;
    }
    else if(d=="24"){
        cout<<"Christmas Eve"<<endl;
    }
    else if(d=="23"){
        cout<<"Christmas Eve Eve"<<endl;
    }
    else if(d=="22"){
        cout<<"Christmas Eve Eve Eve"<<endl;
    }
}





Measured memory_bytes: 256