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

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

int N, D;
vector<int> C;
vector<vector<int>> S;

int ans_score;
vector<int> ans;

void Read(bool local = false) {
  N = 26;
  if (local) {
    D = 365;
  } else {
    cin >> D;
  }
  C.resize(N);
  for (int i = 0; i < N; i++) {
    if (local) {
      C[i] = rnd() % 100;
    } else {
      cin >> C[i];
    }
  }
  S.resize(D);
  for (int i = 0; i < D; i++) {
    S[i].resize(N);
    for (int j = 0; j < N; j++) {
      if (local) {
        S[i][j] = rnd() % 20000;
      } else {
        cin >> S[i][j];
      }
    }
  }
  ans.assign(D, 0);
}

void Write() {
  for (auto i : ans) {
    cout << i + 1 << "\n";
  }
}

int Arithmetic(int n) {
  return n * (n - 1) / 2;
}

vector<set<int>> Build(vector<int> a) {
  vector<set<int>> occ(N);
  for (int i = 0; i < D; i++) {
    occ[a[i]].insert(i);
  }
  for (int i = 0; i < N; i++) {
    occ[i].insert(-1);
    occ[i].insert(D);
  }
  return occ;
}

int Evaluate(vector<int> a) {
  vector<int> last(N, -1);
  int score = 0;
  for (int i = 0; i < D; i++) {
    score += S[i][a[i]];
    last[a[i]] = i;
    for (int j = 0; j < 26; j++) {
      score -= C[j] * (i - last[j]);
    }
  }
  return score;
}

int Evaluate(int init_score, const vector<int> &a, const vector<set<int>> &occ, int d, int q) {
  if (a[d] == q) return init_score;
  const set<int> &cur = occ[a[d]];
  auto pos = cur.lower_bound(d);
  int lst = *prev(pos);
  int nxt = *next(pos);

  int score = init_score;
  score += C[a[d]] * (Arithmetic(nxt - d) + Arithmetic(d - lst) - Arithmetic(nxt - lst));

  pos = occ[q].upper_bound(d);
  lst = *prev(pos);
  nxt = *pos;
  score -= C[q] * (Arithmetic(nxt - d) + Arithmetic(d - lst) - Arithmetic(nxt - lst));

  score -= S[d][a[d]];
  score += S[d][q];

  return score;
}

void Change(int &init_score, vector<int> &a, vector<set<int>> &occ, int d, int q) {
  int new_score = Evaluate(init_score, a, occ, d, q);
  init_score = new_score;
  occ[a[d]].erase(d);
  a[d] = q;
  occ[a[d]].insert(d);
}

void Solve(int t) {
  ans_score = Evaluate(ans);

  vector<int> a(D);
  for (int i = 0; i < D; i++) {
    a[i] = (t == 0 ? i % N : rnd() % N);
  }
  int score = Evaluate(a);
  vector<set<int>> occ = Build(a);

  double temp = 100000;
  double cooling_rate = 0.99997;
  double absolute_zero = 0.001;

  while (temp > absolute_zero) {
    int d = rnd() % D;
    int q = rnd() % N;
    int delta = Evaluate(score, a, occ, d, q) - score;
    if (delta > 0 || exp(delta / temp)) {
      Change(score, a, occ, d, q);
      if (t > 0 && score > ans_score) {
        ans = a;
        ans_score = score;
      }
    }
    temp *= cooling_rate;
  }
  if (ans_score < score) {
    ans = a;
  }
}

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

  Read();
  for (int rep = 0; rep < 10; rep++) {
    Solve(rep);
  }
  Write();
  // cerr << Evaluate(ans) << "\n";
  return 0;
}


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

namespace TYC
{
	typedef long long ll;
	const int N = 105;

	int n, dep[N], fa[N], deg[N], mxd[N];
	vector<int> E[N];

	void dfs(const int u, const int f)
	{
		dep[u] = dep[fa[u] = f] + 1;
		for (int v : E[u])
			if (v != f)
				dfs(v, u);
	}

	inline void add(const int u, const int v)
	{
		E[n].clear();
		E[n].push_back(u);
		E[n].push_back(v);
		E[u].erase(find(E[u].begin(), E[u].end(), v));
		E[v].erase(find(E[v].begin(), E[v].end(), u));
	}

	inline void restore(const int u, const int v)
	{
		E[n].clear();
		E[u].push_back(v);
		E[v].push_back(u);
	}

	ll solve(const int o)
	{
		dfs(o, 0);
		memset(mxd, 0, sizeof(int[n + 1]));
		int len = 0;
		for (int i = 1; i <= n; i++)
		{
			len = max(len, dep[i]);
			mxd[dep[i]] = max(mxd[dep[i]], deg[i] - (i != o));
		}
		ll ans = 1;
		for (int i = len - 1; i; i--)
			ans = ans * mxd[i];
		return ans;
	}

	void work()
	{
		scanf("%d", &n);
		for (int i = 1, u, v; i < n; i++)
		{
			scanf("%d%d", &u, &v);
			deg[u]++, deg[v]++;
			E[u].push_back(v);
			E[v].push_back(u);
		}
		int s = 1, t = 1;
		dfs(1, 0);
		for (int i = 2; i <= n; i++)
			if (dep[s] < dep[i])
				s = i;
		dfs(s, 0);
		for (int i = 2; i <= n; i++)
			if (dep[t] < dep[i])
				t = i;
		int o = t;
		while (dep[o] > (dep[t] + 1) / 2)
			o = fa[o];
		printf("%d ", dep[o]);
		if (dep[t] & 1)
		{
			ll ans = solve(o);
			deg[++n] = 2;
			vector<int> P;
			for (int p : E[o])
				P.push_back(p);
			for (int p : P)
			{
				add(o, p);
				ans = min(ans, solve(n));
				restore(o, p);
			}
			printf("%lld\n", ans);
		}
		else
		{
			int p = t;
			while (fa[p] != o)
				p = fa[p];
			deg[++n] = 2;
			add(o, p);
			printf("%lld\n", solve(n));
		}
	}
}

int main()
{
	TYC::work();
	return 0;
}


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

int main(int argc, char const* argv[])
{
  int i, n, m;
  char dest, target;

  while (true) {
    cin >> n;
    map<char, char> table;

    if (n == 0) { break; }

    for (i = 0; i < n; i++) {
      cin >> dest;
      cin >> target;
      table[dest] = target;
    }

    cin >> m;

    for (i = 0; i < m; i++) {
      cin >> target;

      if (table.find(target) != table.end()) {
        cout << table[target];
      } else {
        cout << target;
      }
    }
    cout << endl;
  }

  return 0;
}

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

using namespace std;

int main() {
  string S;
  cin >> S;
  string T;
  for (char c : S) {
    if (c == '1') {
      T += '9';
    } else if (c == '9') {
      T += '1';
    } else {
      T += c;
    }
  }
  cout << T << endl;

  return 0;
}


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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni(), k = in.ni();
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int x = in.ni();
            ans += Math.min(x, k-x);
        }
        out.println(ans*2);
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 21204
#include<iostream>
using namespace std;
int subZeller(int m,int d){
	int y=2004;
	if(m<3){
		y--;
		m+=12;
	}
	return(y+y/4-y/100+y/400+(13*m+8)/5+d)%7;
}

int main(){
	
	int month,day;
	char *dayname[]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
	while(cin>>month>>day){
		if(month!=0&&day!=0){
			cout<<dayname[subZeller(month,day)]<<endl;
		}
		else
			break;
	}
}

Measured memory_bytes: 1156
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

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

int main() {
	while (true) {
		int n, m;
		cin >> n >> m;
		if (n == 0 && m == 0)break;

		VI s(n);
		rep(i, n)cin >> s[i];
		VI t(m);
		rep(i, m)cin >> t[i];

		int taro = accumulate(all(s), 0);
		int hanako = accumulate(all(t), 0);

		bool flag = false;
		rep(i, n) {
			rep(j, m) {
				int S = s[i], T = t[j];
				if (taro - S + T == hanako - T + S && !flag) {
					cout << S << " " << T << endl;
					flag = true;
					break;
				}
			}
			if (flag)break;
		}
		if (!flag)cout << -1 << endl;
	}
}


Measured memory_bytes: 3004
def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n
def lcm(m, n):
    return m//gcd(m, n)*n
while 1:
    N = int(input())
    if N == 0:
        break
    X = []
    D = []; V = []
    for i in range(N):
        d, v = map(int, input().split())
        g = gcd(d, v)
        d //= g; v //= g
        D.append(d); V.append(v)
    vg = V[0]
    for v in V:
        vg = gcd(vg, v)
    dl = 1
    for d in D:
        dl = lcm(dl, d)
    for d, v in zip(D, V):
        print(v//vg*dl//d)



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

using ll = long long;

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)

using namespace std;

//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

void solve()
{
    int h, w;
    cin >> h >> w;

    string board[50];

    for (int i = 0; i < h; ++i) cin >> board[i];

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

    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            if (board[i][j] == '#') continue;

            int num = 0;
            for (int d = 0; d < 8; ++d)
            {
                const int ni = i + dy[d];
                const int nj = j + dx[d];

                if (ni < 0 or h <= ni) continue;
                if (nj < 0 or w <= nj) continue;
                if (board[ni][nj] == '#') num++;
            }

            board[i][j] = char(num + '0');
        }
    }

    for (int i = 0; i < h; ++i)
        cout << board[i] << endl;
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000007;
constexpr int INF = 2000000000;
using namespace std;

std::vector<int> prime;
void MakePrime(int n) {
	prime.emplace_back(2);
	for (int i = 3; i < n; i += 2) {
		bool a = false;
		for (int j = 3; j <= std::sqrt(i); j += 2) {
			if (i%j == 0) {
				a = true;
			}
		}
		if (a == false) {
			prime.emplace_back(i);
		}
	}
}
int main() {
	MakePrime(10000);
	bool p[10001] = { false };
	for (int i = 0; i < prime.size(); i++) {
		p[prime[i]] = true;
	}
	int n;
	while (cin >> n&&n != 0) {
		for (int i = n; i >= 0; i--) {
			if (p[i] && p[i - 2]) {
				cout << i - 2 << " " << i << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 3056
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0]*n
dp[1] = abs(h[1]-h[0])
for i in range(2, n):
    temp = []
    for j in range(0, min(k, i)):
        temp.append(abs(h[i]-h[i-j-1])+dp[i-j-1])
    dp[i] = min(temp)
print(dp[n-1])

Measured memory_bytes: 52448
# cook your dish here
a,b,c = map(int, input().split())
k = int(input())
c1, c2 = 0, 0
while b<=a:
    b=b*2
    c1 = c1 + 1
while c <= b:
    c=c*2
    c2 = c2 +1
if c1 + c2 <= k:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9096
/*------------------------------------------------,
|  __                                       __    |
| |  |--.-----.---.-.----.----.-----.-----.|  |_  |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _| |
| |_____|_____|___._|____|____|_____|   __||____| |
|                                   |__|          |
`------------------------------------------------*/
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;
using namespace std;
#define INF 2147483647
#define MOD 10000007
#define REP(count_ver, lower, upper) for (long long count_ver = lower; count_ver < upper; count_ver++)

int gcd(int a, int b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool isPrime(int a) {
  if (a == 1)     return false;
  if (a == 2)     return true;
  if (a % 2 == 0) return false;
  for (int i = 3; i < sqrt(a) + 1; i += 2) if (a != i and a%i==0) return false;
  return true;
}

void execute(){

  string s,t;
  cin>>s>>t;
  int ans=0;
  REP(i,0,s.size()){
    if(s[i]!=t[i])ans++;
  }
  cout<<ans<<endl;

}
int main() {

  cin.tie(0);
  ios::sync_with_stdio(0);
  //cout<<fixed<<setprecision(20);

  execute();

  return 0;
}


Measured memory_bytes: 3808
import java.util.*;

public class Main {
	int[][] arr;
	public Main(String a, String b) {
		arr = new int[a.length() + 1][b.length() + 1];
		arr[0][0] = 0;
	}
	
	int LCS(String a, String b){
		int max  = 0;
		
		for(int i = 1; i < a.length(); i++) {
			for(int j = 1; j < b.length(); j++) {
				if(a.charAt(i) == b.charAt(j)) {
					this.arr[i][j] = 1 + this.arr[i-1][j-1];
				}
				else {
					this.arr[i][j] = Math.max(this.arr[i - 1][j], this.arr[i][j -1]);
				}
				
				if(this.arr[i][j] > this.arr[i][ j -1]) {
					max = this.arr[i][j];
				}
			}
		}
		
		return max;
		
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int q = in.nextInt();
		
		for(int i=0; i<q; i++) {
			String a = " " + in.next();
			String b = " " + in.next();
			
			Main program = new Main(a, b);
			System.out.println(program.LCS(a, b));
			
		}
		

	}

}



Measured memory_bytes: 64464
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))


n,m = map(int,input().split())

st = []
for i in range(n):
    st.append(list(map(int,input().split())))

pl = []
for i in range(m):
    pl.append(list(map(int,input().split())))


for i in range(n):
    dis = 10**9
    ans = 1
    for j in range(m-1,-1,-1):
        dis = min(dis,abs(st[i][0]-pl[j][0])+abs(st[i][1]-pl[j][1]))
        if dis == abs(st[i][0]-pl[j][0])+abs(st[i][1]-pl[j][1]):
            ans = j+1
    print(ans)



Measured memory_bytes: 3064
#include<cstdio>

const int max_n = 100000; 
int main(){
	long int n;
	long long int a[max_n];long long int b[max_n];
	long int i,j;
	long long int counter=0;
	
	scanf("%ld",&n);
	for(i=0;i<n;i++){
		scanf("%lld %lld",&a[i],&b[i]);
		//printf("%lld %lld\n",a[i],b[i]);
	}

	for(i=n-1;i>=0;i--){
		//printf("when i = %ld, a[%ld],b[%ld] = %lld,%lld\n",i,i,i,a[i],b[i]);
		long long int module = a[i] % b[i];
		//printf("module=%lld\n",module);
		long long int times = b[i] - module;
		//printf("times=%lld\n",times);
		if(module!=0)
		counter += times;
		//printf("counter=%d\n",counter);
		if(i!=0){
			a[i-1] += counter;
		}
	}

	printf("%lld\n",counter);
	return 0;
}


Measured memory_bytes: 1664
N, K = map(int, input().split())
lst = list(map(int, input().split()))
ans = 0
for l in range(K+1):
    for r in range(K+1-l):
        if l + r > N:
            break
        get = lst[:l]
        get.extend(lst[N-r:])
        cnt = sum(get)
        get.sort()
        for i in range(min(K-l-r, l+r)):
            if get[i] >= 0:
                break
            cnt -= get[i]
        ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
 
/*
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
*/
using namespace std;
 
#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const LL MOD = 1000000000 + 7;
const LD EPS = 0.0000001 ;
#define MPP(a, b, c) MP(MP(a, b), c)
#define PII pair<pair<LL,LL>, LL>
 
LL pows(LL a, LL b)
{
	if (b == 0) return 1LL;
	LL temp = pows(a, b / 2);
	temp = (temp * temp) % MOD;
	if (b % 2) temp = (temp * a) % MOD;
	return temp;
}

const int N = 101;
const int K = 100000 + 1;

LL dp[K];
LL arr[N];
int n;

bool solve(int k)
{
	if (k < 0) return false;
	if (dp[k] != -1) return dp[k];
	dp[k] = false;
	for (int i = 1; i <= n; i++){
	    if (k < arr[i]) continue;
		dp[k] |= !solve(k - arr[i]);
	}
	return dp[k];
}

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    int k; cin >> k;
    for (int i = 1; i <= n; i++) cin >> arr[i];
    memset(dp, -1, sizeof(dp));
    if (solve(k)) cout << "First" << endl;
    else cout << "Second" << endl;

	return 0;
}

Measured memory_bytes: 5760
#include <stdio.h>
#include <math.h>

int main(void){
    int counter = 0;
    int N;
    scanf("%i", &N);
    int A[N], B[N - 1];
    for (int i = 0; i < N - 1; i++){
        scanf("%i", &B[i]);
    }
    A[0] = B[0];
    A[N - 1] = B[N - 2];
    for (int i = 1; i < N - 1; i++){
        A[i] = fmin(B[i - 1], B[i]);
    }
    for (int i = 0; i < N; i++){
        counter += A[i];
    }
    printf("%i\n", counter);
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;
typedef long long ll;

ll XOR(ll a) {
	int p = 1;
	ll i = 4, b, ans = 1;
	if (a % 4 < 2)
		ans = 0;
	while (i < (a << 1)) {
		b = (a % i) - (i >> 1);
		if (b > 0 && (b & 1))
			ans += 1ll << p;
		i <<= 1;
		p++;
	}
	return ans;
}

int main(void) {
	ll a, b;
	cin >> a >> b;
	a = XOR(a);
	b = XOR(b + 1ll);
	printf("%lld\n", a ^ b);
	return 0;
}

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

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;

#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define int long long
#define sz(v) (int)v.size()
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define f(i,l,r) for(long long i=l;i<=r;i++)
#define rf(i,r,l) for(long long i=r;i>=l;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }


const int N=1e6+5,mod=1e9+7,bit=61;

int fq[N],a[N];

template<typename T>
class dsu
{
	public:
		vector<T> par,sz;
		ll n;
		dsu(ll n_)
		{
			n=n_;
			par.resize(n+1);
			sz.resize(n+1);
			for(int i=0;i<=n;i++)
			{
				par[i]=i;
				sz[i]=1;
			}
		}
		T getp(T x)
		{
			while(par[x]!=x)
			{
				par[x]=par[par[x]];
				x=par[x];
			}
			return x;
		}
		void merge(T a,T b)
		{
			T p1=getp(a),p2=getp(b);
			if(p1==p2)
			{
				return;
			}
			if(sz[p2]>sz[p1])
			{
				swap(p1,p2);
			}
			par[p2]=p1;
			sz[p1]+=sz[p2];
			sz[p2]=0;
		}
};

signed main()
{
    fast;

    int t=1;
    //cin>>t;
    f(tc,1,t)
    {
        int n;
        cin>>n;
        f(i,1,n)
        {
            cin>>a[i];
            fq[a[i]]++;
        }
        int mx=0;
        f(i,2,N-1)
        {
            int curr=0;
            for(int j=i;j<N;j+=i)
            {
                curr+=fq[j];
            }
            mx=max(mx,curr);
        }
        if(mx<=1)
        {
            cout<<"pairwise coprime"<<endl;
        }
        else if(mx>=2 and mx<n)
        {
            cout<<"setwise coprime"<<endl;
        }
        else
        {
            cout<<"not coprime"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 19112
#include <cstdint>
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

pair<vector<int64_t>, vector<int64_t>> MakeVec(
  unordered_map<int64_t, int64_t>& nodes, int64_t st) {
  vector<int64_t> vec;
  vec.push_back(st);
  vector<int64_t> sums(2, 0);
  sums[1] = st;
  int64_t cur = nodes[st];
  while (cur != st) {
    vec.push_back(cur);
    sums.push_back(sums.back() + cur);
    cur = nodes[cur];
  }
  return {vec, sums};
}

int main() {
  int64_t N, X, M;
  cin >> N >> X >> M;

  unordered_map<int64_t, int64_t> nodes;
  vector<int64_t> loop, sums;
  int64_t sum = X;
  int64_t pre = X;
  int64_t n = 1;
  for (; n < N; ++n) {
    int64_t cur = pre * pre % M;
    if (nodes.count(cur)) {
      if (cur != pre) nodes[pre] = cur;
      tie(loop, sums) = MakeVec(nodes, cur);
      break;
    }
    nodes[pre] = cur;
    pre = cur;
    sum += cur;
  }
  if (n == N) {
    cout << sum << endl;
  } else {
    int64_t rest = N - n;
    cout << sum + sums.back() * (rest / loop.size()) + sums[rest % loop.size()] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 6904
#include <iostream>

using namespace std;

int N;

long int my_abs(long int a) {
    if(a<0) return -a;
    return a;
}

int main() {
    cin >> N;
    
    int h[N];
    for(int i=0; i<N; i++) {
        cin >> h[i];
    }
    
    long int dp[N];
    dp[0] = 0;
    dp[1] = my_abs(h[0]-h[1]);
    
    for(int i=2; i<N; i++) {
        long int tmp;
        dp[i] = my_abs(h[i-1]-h[i]) + dp[i-1];
        tmp = my_abs(h[i-2]-h[i]) + dp[i-2];
        if(tmp<dp[i]) dp[i]=tmp;
    }
    
    cout << dp[N-1] << endl;

    return 0;
    
}

Measured memory_bytes: 1408
N=int(input())
H=list(map(int,input().split()))
ans=0
_=0
for i in range(N-1):
  if H[i]>=H[i+1]:
    _+=1
  else:
    if _>ans:
      ans=_
    _=0
if _>ans:
  ans=_
print(ans)    



Measured memory_bytes: 14224
#include<iostream>
#include<cstring>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<map>

using namespace std;

typedef pair<int, int> p;

const int mod = 1e9+7;
const int AC=100010;

long long n,ans,res=1;
long long a[AC],b[AC],t[AC],s[AC];

inline void read(long long &x)
{
	long long f=1;
	char s=getchar();
	x=0;
	while ( s<'0' || s>'9' )
	{
		if ( s=='-' ) f=-1;
		s=getchar();
	}
	while ( s>='0' && s<='9' )
	{
		x=x*10+s-'0';
		s=getchar();
	}
	x*=f;
}

inline long long quick(long long a,long long b)
{
	long long base=a,ans=1;
	while ( b )
	{
		if ( b&1 ) ans=ans*base%mod;
		base=base*base%mod;
		b>>=1;
	}
	return ans;
} 

long long inv(long long n){
	return quick(n, mod-2);
}

int main(){
	read(n);
	for ( int i=1;i<=n;i++ )
	{
		read(a[i]);
	}
	for ( int i=1;i<=n;i++ )
	{
		s[i]=(s[i-1]+inv(i))%mod;
	}
	for ( int i=1;i<=n;i++ )
	{
		b[i]=(s[n-i+1]+s[i]-1)%mod;
	}	
	for ( int i=1;i<=n;i++ )
	{
		t[i]=(b[i]*a[i])%mod;
	}
	for ( int i=1;i<=n;i++ )
	{
		ans=(ans+t[i])%mod;
	}
	for (int i=1;i<=n;i++ )
	{
		res=(res*i)%mod;
	}
	ans=(ans*res)%mod;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3328
import numpy as np
import fractions
from functools import reduce

N,M = map(int,input().split())
A = np.array(list(map(int,input().split())))
A = A // 2

def lcmb(x,y):
    return (x*y)//fractions.gcd(x,y)
def lcm(L):
    return reduce(lcmb, L, 1)
    
T = lcm(A)

flg = False
for a in A:
    if (T//a)%2 == 0:
        flg = True
        break

m = M//T
if flg:
    ans = 0
elif m%2 == 0:
    ans = m//2
else:
    ans = m//2 + 1
print(ans)

Measured memory_bytes: 24928
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const int INF=1000000000;
const int MOD=1000000007;

int main()
{
 int n, m, sum=0;;
 cin >> n >> m;
 int a[n];
 for(int i=0;i<n;i++){
 	cin >> a[i];
    sum+=a[i];
 }
 sort(a, a+n, greater<int>());
// cout << (double)sum/(double)(4*m) << endl;
 if(a[m-1]>=(double)sum/(double)(4*m)) cout << "Yes";
 else  cout << "No";
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define P (3)

int b64(char ch) {
    if('A'<=ch && ch<='Z') return ch-'A';
    if('a'<=ch && ch<='z') return ch-'a'+26;
    if('0'<=ch && ch<='9') return ch-'0'+52;
    return ch=='+' ? 62 : 63;
}

int w, h, p, f[1024][1024], m[128][128], tmp[128][128];
char tf[1000][200], tm[100][20];
typedef unsigned long long hash;
hash hori[1024][1024], hs[8];

int main() {
    for(;;) {
        scanf("%d%d%d", &w, &h, &p);
        if(w==0 && h==0 && p==0) return 0;
        rep(i, h) scanf(" %s", tf[i]);
        rep(i, p) scanf(" %s", tm[i]);
        memset(f, 0, sizeof(f));
        rep(i, h) for(int j=0; tf[i][j]; j++) {
            const int x = b64(tf[i][j]);
            rep(k, 6) if(x&(1<<k)) f[i][j*6+5-k] = 1;
        }
        memset(m, 0, sizeof(m));
        rep(i, p) for(int j=0; tm[i][j]; j++) {
            const int x = b64(tm[i][j]);
            rep(k, 6) if(x&(1<<k)) m[i][j*6+5-k] = 1;
        }
        rep(d, 8) {
            memcpy(tmp, m, sizeof(m));
            rep(i, p) rep(j, p) m[p-1-j][i] = tmp[i][j];
            if(d==4) {
                memcpy(tmp, m, sizeof(m));
                rep(i, p) rep(j, p) m[i][p-1-j] = tmp[i][j];
            }
            hs[d] = 0;
            rep(i, p) rep(j, p) hs[d] = hs[d]*P+m[i][j];
        }
        sort(hs, hs+8);
        hash t = 1;
        rep(i, p) t *= P;
        rep(i, h) {
            hash k = 0;
            rep(j, w) {
                k = k*P+f[i][j];
                if(j>=p) k -= t*f[i][j-p];
                hori[i][j] = k;
            }
        }
        hash tt = 1;
        rep(i, p) tt *= t;
        int ans = 0;
        for(int i=p-1; i<w; i++) {
            hash k = 0;
            rep(j, h) {
                k = k*t+hori[j][i];
                if(j>=p) k -= tt*hori[j-p][i];
                if(j>=p-1 && binary_search(hs, hs+8, k)) ans++;
            }
        }
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 0
readInt() = parse.(Int,split(readline()))

function dfs(G,v,p,cnt)
    for u in G[v]
        u==p && continue
        cnt[u]+=cnt[v]
        dfs(G,u,v,cnt)
    end
end

function solve()
    N,Q = readInt()
    cnt = zeros(Int,N)
    G = Vector{Vector{Int}}(undef,N)
    for i in 1:N
        G[i] = Vector{Int}(undef,0)
    end
    for i in 1:N-1
        a,b = readInt()
        push!(G[a],b)
        push!(G[b],a)
    end
    for i in 1:Q
        p,x = readInt()
        cnt[p]+=x
    end
    dfs(G,1,0,cnt)
    for i in 1:N
        println(cnt[i])        
    end
end
solve()

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

#define MOD 1000000007
#define f first
#define s second
#define es " "
#define pb push_back
#define endl "\n"
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long int
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int main(){
    fastio;
    int a, b;
    cin >> a >> b;
    if(2*b>=a){
        cout << 0 << endl;
    }else{
        cout << a-2*b << endl;
    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> h(n+1000);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  vector<int> dp(n+1000,1000000000);
  dp[0]=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<i+1+k;j++){
      dp[j]=min(dp[j],abs(h[j]-h[i])+dp[i]);
    }
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <limits>
#include <cfenv>
#include <cmath>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <tuple>
#include <queue>
#include <vector>
#include <cmath>
#include <random>
#include <math.h>
#include <list>
#include <random>
#include <functional>


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

using lli = long long int;
using pii = std::pair<int, int>;

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


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// k : n = k(k-1) + 1

// * k = 1 : n = 1
// 1

// * k = 2 : n = 3
// 1 2
// 2 3
// 3 4

// * k = 3 : n = 7
// 1 2 3
// 1 4 5
// 1 6 7
// -----
// 2 4 6
// 2 5 7
// 3 5 6
// 3 4 7

// * k = 4 : n = 13
// 1  2  3  4
// 1  5  6  7
// 1  8  9  10
// 1  11 12 13
// -----------
// 2  5  8  11 +0
// 2  6  9  12 +0
// 2  7  10 13 +0
// 3  5  9  13 +1
// 3  6  10 11 +1
// 3  7  8  12 +1
// 4  5  10 12 +2
// 4  6  8  13 +2
// 4  7  9  11 +2

// 33, 1057
constexpr int K = 38;
constexpr int N = K * (K - 1) + 1;
std::array<std::array<int, K>, N> A;

int main(void){
    int idx, val = 2;
    for(idx = 0; idx < K; ++idx){
        A[idx][0] = 1;
        for(int j = 1; j < K; ++j) A[idx][j] = val++;
    }
    for(val = 2; val <= K; ++val){
        for(int lp = 0; lp < K - 1; ++lp){
            int row = (val - 1) * (K - 1) + lp + 1;
            A[row][0] = val;
            int hd = lp;
            for(int j = 1; j < K; ++j){
                A[row][j] = A[j][hd + 1];
                hd += (val - 2); if(hd >= K - 1) hd -= (K - 1);
            }
        }
    }

    printf("%d %d\n", N, K);
    REP(i, N){
        REP(j, K){
            printf("%d", A[i][j]);
            putchar(j == K - 1 ? '\n' : ' ');
        }
    }
    /*
    REP(i, N){
        std::set<int> S;
        REP(j, K) S.insert(A[i][j]);
        REP(j, N) if(i < j){
            int cnt = 0;
            REP(k, K) if(S.find(A[j][k]) != S.end()) cnt++;
            if(cnt != 1) printf("%d : (%d, %d)\n", cnt, i, j);
        }
    }
    */
    

    

    return 0;
}



Measured memory_bytes: 640
#include<stdio.h>

int main(void)
{
	int a[10000], i, count = 0;
	for(i=0; i<10000; i++)
	{
		scanf("%d", &a[i]);
		if(a[i] == 0)
			break;
		count++;
	}

	for(i=0; i<count; i++)
	{
		printf("Case %d: %d\n", i+1, a[i]);
	}

	return 0;
}


Measured memory_bytes: 2044
# seishin.py
N = int(input())
*P, = map(int, input().split())
M = [0]*(N+1)
for i, p in enumerate(P):
    M[p] = i

INF = 10**9
def init(P, n):
    n0 = 2 ** (n-1).bit_length()
    data = [INF]*(n0*2)
    data[n0-1:n0+n-1] = P
    for i in range(n0-2, -1, -1):
        data[i] = min(data[2*i+1], data[2*i+2])
    return data

def get_data(data, l, r):
    n0 = len(data)//2
    l += n0
    r += n0
    while l < r:
        if r&1:
            r -= 1
            yield data[r-1]
        if l&1:
            yield data[l-1]
            l += 1
        l >>= 1
        r >>= 1

def get(data, l, r):
    return min(get_data(data, l, r))

d0 = init(P[0::2], N//2)
d1 = init(P[1::2], N//2)

def query_x(l, r):
    if l % 2 == 0:
        x = get(d0, l//2, r//2)
    else:
        x = get(d1, l//2, r//2)
    return x
def query_y(l, r):
    if l % 2 == 0:
        y = get(d1, l//2, r//2)
    else:
        y = get(d0, (l+1)//2, (r+1)//2)
    return y

from heapq import heappush, heappop
que = [(query_x(0, N), 0, N)]
ans = []
while que:
    x, l, r = heappop(que)
    if l+2 < r:
        xi = M[x]
        y = query_y(xi, r)

        yi = M[y]

        # [l, xi)
        if l < xi:
            heappush(que, (query_x(l, xi), l, xi))
        # [xi+1, yi)
        if xi+1 < yi:
            heappush(que, (query_x(xi+1, yi), xi+1, yi))
        # [yi+1, r)
        if yi+1 < r:
            heappush(que, (query_x(yi+1, r), yi+1, r))
    else:
        y = P[r-1]

    ans.append("%d %d" % (x, y))
print(*ans)

Measured memory_bytes: 129860
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef vector<int> vi;
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
int main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	rep(i,n)in[i]%=3;
	vi co(3);
	rep(i,n)co[in[i]]++;
	if(co[1]+co[2]==0)cout<<1<<endl;
	else if(co[1]==0)cout<<co[0]+min(3,co[2])<<endl;
	else{
		//1 (1 2)*?
		vi a=co;
		a[1]--;
		int t=min(a[1],a[2]);
		int out1=1+a[0]+2*t;
		out1+=min(2,a[1]-t);
		out1+=min(1,a[2]-t);
		//2 (2 1)*?
		a=co;
		a[2]--;
		t=min(a[1],a[2]);
		int out2=1+a[0]+2*t;
		out2+=min(1,a[1]-t);
		out2+=min(2,a[2]-t);
		cout<<max(out1,out2)<<endl;
	}
}

Measured memory_bytes: 3120
#include<iostream>
#include<bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i<b; i++)
using namespace std;
int main() {
    int n;
    cin >> n;
    long long a[n];
    FOR(i, 0, n){
        cin >> a[i];
    }
    long long dp[n][n];
    memset(dp, 0, sizeof(dp));
    long long sum[n][n];
    memset(sum, 0, sizeof(sum));
    // dp[n-2][n-1] = a[n-2] + a[n-1];
    
        FOR(i, 0, n) {
            long long sum_1 = 0;
            FOR(j, i, n){
                sum_1 += a[j];
                sum[i][j] = sum_1;
            }
        } 
    
    FOR(i, 0, n){
        dp[i][i] = 0;
    }

    for(int i = n-2; i>=0 ; i--){
        for(int j = i+1; j<n; j++) {
            long long min_value = LONG_LONG_MAX;
            for(int k = i; k < j; k++){
                if(dp[i][k] + sum[i][k] + dp[k+1][j] + sum[k+1][j] < min_value){
                    min_value = dp[i][k] + sum[i][k] + dp[k+1][j] + sum[k+1][j];
                }
            }
            dp[i][j] = min_value;
        }
    }
    // FOR(i, 0, n)  {
    //     FOR(j , 0, n) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // } 
    cout << dp[0][n-1] << endl;
}

Measured memory_bytes: 2688
n = int(input())
h = [0] + list(map(int, input().split()))

tmp = 0
for i in range(n):
    if h[i] < h[i + 1]:
        h[i + 1] -= 1
    if h[i] > h[i + 1]:
        print("No")
        exit()
print("Yes")
 

Measured memory_bytes: 63984
#include <stdio.h>

int main(void){
    // Your code here!
    char O[51],E[51];
    char *pO=O,*pE=E;
    
    scanf("%50s%50s",O,E);
    
    while(*pO !='\0'){
        printf("%c",*pO++);
        if(*pE != '\0'){
            printf("%c",*pE++);
        }
    }
}


Measured memory_bytes: 128
# coding: utf-8

num = int(input())
number = input().split()
count, count2 = 0, 0
table = list(number)
for i in number:
    if int(i) % 2 == 0:
        count += 1
        if int(i) % 3 == 0 or int(i) % 5 == 0:
            count2 += 1

if count == count2:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
vector<int> a[100005];
priority_queue<int> q;
int main(){
	int ans=0,n,m,x,y;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>x>>y;
		if(x>m)continue;
		a[m-x+1].push_back(y);
	}
	for(int i=m;i>=1;i--){
		if(a[i].size()>0){
			for(int j=0;j<a[i].size();j++)q.push(a[i][j]);
		}
		if(!q.empty()){
			ans+=q.top();q.pop();
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5632
N = int(input())
from itertools import groupby, accumulate, product, permutations, combinations
def solve(N):
    pairs = []
    if N%2==1: #和がN
        total = N
        pairs.append([N])
        ans = N-1
    else: #和がN+1
        total = N+1
        ans = 0
    for i in range(1,(total+1)//2):
        pairs.append([i,total-i])
        ans += 2*(N-2)
    print(ans//2)
    for pair1, pair2 in combinations(pairs,2):
        for i in pair1:
            for j in pair2:
                print(i,j)
    return
solve(N)

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main() {
    int h,w,s=0,k,i,j;
    cin>>h>>w;
    int c[10][10];
    for(i=0;i<10;++i)
        for(j=0;j<10;++j)
            cin>>c[i][j];

    for(k=0;k<10;++k)
        for(i=0;i<10;++i)
            for(j=0;j<10;++j)
                if(c[i][k] + c[k][j] < c[i][j])c[i][j] = c[i][k] + c[k][j];
    for (i=0;i<h;++i)
    {
        for(j=0;j<w;++j)
        {
            cin >>k;
            if (k!=-1)s+=c[k][1];
        }
    }
    cout<<s;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,x,y) for(int i=(int)(x);i<(int)(y);++i)
#define FORE(i,x,y) for(int i=(int)(x);i<=(int)(y);++i)
#define FORD(i,x,y) for(int i=(int)(x);i>=(int)(y);--i)
#define PB push_back
#define MP make_pair
#define ST first
#define ND second
typedef long long ll;
typedef pair<int,int> pii;
const int INF=2e9;
const int MOD=1e9+7;
const int MAXN=5e5+7;

int ans=0;
int n,m,k,q;
string s;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key)
{
  NodePointer t;

  for(t = nil->next ; t != nil && t->key != key ; t = t->next);
  return t;
}

void init()
{
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList()
{
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t)
{
 t->prev->next = t->next;
 t->next->prev = t->prev;
}

void deleteFirst()
{
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast()
{
  NodePointer t;

  t = nil->prev;
  
  if(t == nil) return;
  deleteNode(t);
}

void delete(int key)
{
  NodePointer t;
  t = listSearch(key);
  if(t == nil) return;
  deleteNode(t);
}


void insert(int key)
{
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;

}

int main()
{
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  
  scanf("%d", &n);
  
  init();
  
  for ( i = 0; i < n; i++ )
    {
      scanf("%s", com);
      if ( com[0] == 'i' )
	{
	  scanf("%d",&key);
	  insert(key); np++; size++;
	}
      else if ( com[0] == 'd' )
	{
	  if (strlen(com) > 6)
	    {
	      if ( com[6] == 'F' ) deleteFirst();
	      else if ( com[6] == 'L' ) deleteLast();
	    }
	  else
	    {
	      scanf("%d",&key);
	      delete(key); nd++; 
	    }
	  size--;
	}
    }

  printList();
  return 0;
}



Measured memory_bytes: 36084
#include<iostream>
using namespace std;
int main() {
	int N, X;
	cin >> N >> X;
	int m[N];
	int ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> m[i];
	}
	//入力と主な変数宣言
	for (int i = 0; i < N; i++) {
		X = X - m[i];
		ans++;
	}//ドーナツを一つずつ作る
	int min = 100000;//必要なお菓子の素の最小を探す変数
	for (int i = 0; i < N; i++) {
		if (min > m[i]) {
			min = m[i];
		}
	}//全部見て小さい奴に更新していく
	ans = ans + X / min;
//残ったお菓子の素でドーナツを作る
	cout << ans << endl;//出力
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/10>0){i++;d++;}return d;}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll h,w;
 cin>>h>>w;
 char t[10],s[10]="snuke";
 rep(i,0,h){
  rep(j,0,w){
   sc(t);
   if(!strcmp(s,t)){
    char c='A'+j;
    cout<<c<<i+1<<endl;
    return 0;
   }
  }
 }

return 0;}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int n, m;

int main() {
    cin >> n >> m;
    int ans = (1900 * m + 100 * (n - m)) * pow(2, m);
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC148_d solver = new ABC148_d();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC148_d {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int a[] = new int[N + 1];

            for (int i = 1; i <= N; i++) {
                a[i] = in.nextInt();
            }
            int broke = 0;
            boolean isNoanswer = true;
            for (int i = 1; i <= N; i++) {
                for (int j = i + broke; j <= N; j++) {
                    if (a[j] == i) {
                        isNoanswer = false;
                        break;
                    } else {
                        broke++;
                    }
                }
            }
            if (isNoanswer) {
                out.println(-1);
            } else {
                out.println(broke);
            }
        }

    }
}



Measured memory_bytes: 85680
/**********************************************************
* @Author: 			   Maple
* @Date:   			   2020-03-07 20:24:22
* @Last Modified by:   Maple
* @Last Modified time: 2020-03-07 20:34:02
* @Remark: 
**********************************************************/
#include <bits/stdc++.h>
#define lowbit(x) (x&(-x))
#define CSE(x,y) memset(x,y,sizeof(x))
#define INF 0x3f3f3f3f
#define Abs(x) (x>=0?x:(-x))
#define FAST ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll , ll> pll;

const int maxn=1e5+100;
int q;
char str[maxn];

int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("in.in","r",stdin);
	// #endif
	FAST;
	int reverse=0;
	cin>>str;
	cin>>q;
	std::vector<char> bg,ed;
	while(q--){
		int t;
		cin>>t;
		if(t==1)
			reverse++;
		else{
			int f;
			char c;
			cin>>f>>c;
			if(f==1){
				if(reverse&1)
					ed.push_back(c);
				else
					bg.push_back(c);
			}
			else{
				if(reverse&1)
					bg.push_back(c);
				else
					ed.push_back(c);
			}
		}
	}
	if(reverse&1){
		int len=ed.size();
		for(int i=len-1;i>=0;i--)
			cout<<ed[i];
		len=strlen(str);
		for(int i=len-1;i>=0;i--)
			cout<<str[i];
		for(int i=0;i<bg.size();i++)
			cout<<bg[i];
		cout<<endl;
	}
	else{
		int len=bg.size();
		for(int i=len-1;i>=0;i--){
			cout<<bg[i];
		}
		cout<<str;
		for(auto i:ed)
			cout<<i;
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()


int main(){
    ll x;
    cin >> x;
    for(ll a = 1; ; ++a){
        const ll a5 = a * a * a * a * a;
        const ll b5 = a5 - x;

        const ll y = floor(pow(abs(b5), 0.2));
        for(ll b = y - 1; b <= y + 1; ++b){
            if(b * b * b * b * b == abs(b5)){
                if(b5 < 0){
                    cout << a << ' ' << -b << endl;
                }else{
                    cout << a << ' ' << b << endl;
                }
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Cin(type, val) type val; cin >> val;
#define Cout(val) cout << (val) << "\n";
#define Range(container) container.begin(), container.end()
using namespace std;
using ll = long long;

int main(void){
    Cin(int, s);
    if(s == 1 || s == 2 || s == 4){ Cout(4); return 0; }
    int i = 4;
    while(s != 4){ s = (s % 2 == 0) ? s/2 : 3*s+1; i ++; }
    
    Cout(i);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
int x,y,w;
int main()
{
	cin>>w>>x>>y;
	cout<<max(0,abs(y-x)-w);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
int main(){
    int n ;
    string s ;
    cin >> n ;
    cin >> s ;
    int ans = 0 ;
    for( int i = 1 ; i < n ; i++ )
        if ( s[i] == 'E' ) ans++ ;
    int res = ans ;
    if ( s[0] == 'W' ) res++ ;
    for( int i = 1 ; i < n ; i++ ){
        if ( s[i] == 'E' ) res-- ;
        ans = min( ans , res ) ;
        if ( s[i] == 'W' ) res++ ;
    }
    cout << ans << endl ;
    return 0 ;
}

Measured memory_bytes: 1028