akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,k;
    cin >> n >> k;
    vi v(n);
    cin >> v;
    int ans = 0;
    rep(l,n+1) rep(r,n+1) {
        if(l+r > k) continue;
        if(l+r > n) continue;
        vi nv;
        rep(i,l) nv.pb(v[i]);
        rep(i,r) nv.pb(v[n-1-i]);
        sort(rall(nv));
        int nk = k-l-r;
        while(nk > 0 && nv.size() > 0 && nv[nv.size()-1] < 0) {
            nv.pop_back();
            nk--;
        }
        int sum = 0;
        for(auto i : nv) sum += i;
        chmax(ans,sum);
    }
    cout << ans << endl;
}

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

int A[21], B[21], C[21];
int  main(void)
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> A[i];
	for (int i = 1; i <= n; i++)
		cin >> B[i];
	for (int i = 1; i <= n-1; i++)
		cin >> C[i];

	int ans = B[A[1]];
	for (int i = 2; i <= n; i++)
	{
		int num = A[i];
		ans += B[num];
		if (A[i] - A[i - 1] == 1)
			ans += C[A[i - 1]];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static class UnionFind {
		int[] param;
		int[] rank;
		int N;
		int xlen;
		
		public UnionFind(int n) {
			N=n;
			param = new int[N];
			rank = new int[N];
			for(int i=0; i<N; i++)
				param[i] = i;
		}
		
		public void init() {
			for(int i=0; i<N; i++)
				param[i] = i;
			Arrays.fill(rank, 0);
		}
		
		public UnionFind(int x, int y) {
			this(x*y);
			xlen=y;
		}
		
		public boolean same(int a, int b) {
			return getRoot(a)==getRoot(b);
		}
		
		public boolean same(int x1, int y1, int x2, int y2) {
			return same(x1*xlen+y1, x2*xlen+y2);
		}
		
		public int getRoot(int a) {
			if(param[a]==a) return a;
			else return (param[a] = getRoot(param[a]));
		}
		
		public void unite(int a, int b) {
			a = getRoot(a);
			b = getRoot(b);
			if(a==b)
				return;
			
			if(rank[a] < rank[b]) {
				param[a] = b;
			} else {
				param[b] = a;
				if(rank[a]==rank[b])
					rank[a]++;
			}
		}
		
		public void unite(int x1, int y1, int x2, int y2) {
			unite(x1*xlen+y1, x2*xlen+y2);
		}
	}

	public static class Point {
		int idx;
		int x, y;

		public Point(int idx, int x, int y) {
			this.idx = idx;
			this.x = x;
			this.y = y;
		}
	}
	public static class Road {
		int cost;
		int a, b;
		
		public Road(int cost, int a, int b) {
			this.cost = cost;
			this.a = a;
			this.b = b;
		}

	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		Point[] p = new Point[N];
		for(int i=0; i<N; i++)
			p[i] = new Point(i, sc.nextInt(), sc.nextInt());
		
		ArrayList<Road> roads = new ArrayList<>();
		
		Arrays.sort(p, new Comparator<Point>() {
			public int compare(Point p1, Point p2) {
				return p1.x - p2.x;
			}
		});
		for(int i=0; i<N-1; i++)
			roads.add(new Road(p[i+1].x - p[i].x, p[i].idx, p[i+1].idx));
		
		Arrays.sort(p, new Comparator<Point>() {
			public int compare(Point p1, Point p2) {
				return p1.y - p2.y;
			}
		});
		for(int i=0; i<N-1; i++)
			roads.add(new Road(p[i+1].y - p[i].y, p[i].idx, p[i+1].idx));
		
		Collections.sort(roads, new Comparator<Road>() {
			public int compare(Road r1, Road r2) {
				return r1.cost - r2.cost;
			}
		});
		
		long ans = 0;
		
		UnionFind uf = new UnionFind(N);
		for(Road r : roads) {
			if(!uf.same(r.a, r.b)) {
				uf.unite(r.a, r.b);
				ans += r.cost;
			}
		}
		
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 96452
#include <stdio.h>
#include <stdlib.h>
#define ll long long int


int main(){

    ll n, a, b;
    scanf("%lld %lld %lld", &n, &a, &b);

    ll answer = n/(a+b)*a;
    if(n%(a+b)>=a){
        answer += a;
    }else{
        answer += n%(a+b);
    }

    printf("%lld",answer);

   return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const ll inf = 10010010010010010;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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(){
    int n,k;
    cin >>n >> k;
    int x[100100];
    rep(i,n) cin >> x[i];
    ll mi = inf;
    rep(i,n-k+1){
        ll d = (ll)x[i+k-1]-x[i];
        mi = min({llabs(x[i])+d,llabs(x[i+k-1])+d,mi});
    }
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int s = Integer.parseInt(sc.next());
        
        Set<Integer> set = new HashSet();
        
        int count = 1;
        set.add(s);
        while(true){
            count++;
            if(s%2 == 0){
                s = s/2;
                if(set.contains(s)){
                    break;
                }
                set.add(s);
            }else{
                s = s*3+1;
                if(set.contains(s)){
                    break;
                }
                set.add(s);
            }
        }
        
        System.out.println(count);
    }
}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* struct for mod Calculation*/
struct mint {
        ll x;
        mint(ll x = 0):x((x % mod + mod) % mod) {}
        mint operator-() const { return mint(-x); }
        mint& operator+=(const mint a) {
            if ((x += a.x) >= mod) x -= mod;
            return *this;
        }
        mint& operator-=(const mint a) {
            if ((x += mod - a.x) >= mod) x -= mod;
            return *this;
        }
        mint& operator*=(const mint a) {
            (x *= a.x) %= mod;
            return *this;
        }
        mint operator+(const mint a) const {
            mint res(*this);
            return res += a;
        }
        mint operator-(const mint a) const {
            mint res(*this);
            return res -= a;
        }
        mint operator*(const mint a) const {
            mint res(*this);
            return res *= a;
        }
        mint pow(ll t) const {
            if (!t) return 1;
            mint a = pow(t >> 1);
            a *= a;
            if (t & 1) a *= *this;
            return a;
        }
        // for prime mod
        mint inv() const {
            return pow(mod - 2);
        }
        mint& operator/=(const mint a) {
            return (*this) *= a.inv();
        }
        mint operator/(const mint a) const {
            mint res(*this);
            return res /= a;
        }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<mint> a(N);
    for (int i = 0; i < N; i++) {
        int b; cin >> b;
        a[i] = b;
    }

    vector<mint> sum(N+1);
    sum[0] = 0;
    for (int i = 0; i < N; i++) {
        sum[i+1] += sum[i] + a[i];
    }

    mint ans = 0;
    for (int i = 0; i < N-1; i++) {
        ans += a[i] * (sum[N] - sum[i+1]);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 6420
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  string s; cin >> s;
  int k; cin >> k;
  rep(i,s.size()){
    if(('z'-s[i]+1)%26 <= k){
      k -= ('z'-s[i]+1)%26;
      s[i] = 'a';
    }
  }
  s.back() = (s.back()-'a'+k)%26+'a';
  cout << s;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define NMAX 200002
using namespace std;
vector<int >v;
int N,K,M = 0,m = 0,ans = 0;
bool able(int a){
	int cou = 0;
	for(auto&& i : v) {
		int b = i;
		if(b <= a) break;
		if(b>a){
			cou = cou + b/a - (b%a == 0);
		}
	}
	// cout << a << ":" << cou << endl;
	if(cou > K) return false;
	else return true;
}
int main(){
	cin >> N >> K;
	for (int i = 0; i < N; ++i)
	{
		int a;
		cin >> a;
		v.push_back(a);
		M = max(M,a);
	}
	sort(v.begin(), v.end(),greater<int>());
	while(M - m > 1){
		int k = (M+m)/2;
		if(able(k)) M = k;
		else m = k;
	}
	cout << M << endl;
}

Measured memory_bytes: 4276
#include <iostream>
#include <map>

using namespace std;

map <string,int> m;
map <string,int>::iterator i;
string s;
int Max,N;

int main()
{
    cin >> N;
    while(N--)
    {
        cin >> s;
        m[s]++;
    }
    cin >> N;
    while(N--)
    {
        cin >> s;
        m[s]--;
    }
    for(i = m.begin(); i != m.end(); ++i)
        if(i -> second  >= 1)
            Max = max(Max,i -> second);
    cout << Max;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        int res = 0;
        for (int i = 1; i <= n; i++) {
            int sum = sumDigits(i);
            if (a <= sum && sum <= b) res += i;
        }

        System.out.println(res);
    }

    private static int sumDigits(int num) {
        int sum = 0;// 10進数の各桁の和
        while (num > 0) {
            sum = sum + (num % 10);
            num /= 10;
        }

        return sum;
    }
}


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

#include <map>
#include <vector>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
using namespace std;

int main() {
  int n;
  cin >> n;
  map<string, int> mp;
  string tmp;
  rep(i, n) {
    cin >> tmp;
    if (mp.count(tmp) == 0) {
      mp[tmp] = 1;
    } else {
      mp[tmp]++;
    }
  }
  cout << "AC x " << mp["AC"] << endl;
  cout << "WA x " << mp["WA"] << endl;
  cout << "TLE x " << mp["TLE"] << endl;
  cout << "RE x " << mp["RE"] << endl;
}

Measured memory_bytes: 3632
n = int(input())
A = list(map(int, input().split()))
def test(L, sgn):
  count = 0
  s = 0
  for i in L:
    sgn *= -1
    s += i
    if s*sgn > 0:
      continue
    if sgn > 0:
      count += (1 - s)
      s = 1
    else:
      count += (s + 1)
      s = -1
  return count

ans = min(test(A, 1), test(A, -1))
print(ans)

Measured memory_bytes: 14332
#include<bits/stdc++.h>
#define ll long long
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define f(i,s,e) for(ll i=s;i<e;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
vector<int> poww;

int main(){
    fast;

    int n,k;
    cin>>n>>k;

    double ans = 0.0;
    for(int i=1;i<=n;i++){
        double now = 1.0/n;
        int ff = i;
        while(ff<k){
            ff*=2;
            now/=2.0;
        }
        ans+=now;
    }

    printf("%.12f\n",ans);
}


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

int main() {
    int N;
    cin >> N;
    vector<double> x(N), y(N);
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i];
    double ans = 999999;
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            for (int k = j+1; k < N; k++) {
                double a = x[i], b = y[i], c = x[j], d = y[j], e = x[k], f = y[k];
                if ((c-a)*(f-b)==(e-a)*(d-b)) continue;
                double px, py;
                py = ((e-a)*(a*a+b*b-c*c-d*d) - (c-a)*(a*a+b*b-e*e-f*f));
                py /= 2*(e-a)*(b-d) - 2*(c-a)*(b-f);
                if (a != c) {
                    px = 2*(b-d)*py - a*a - b*b + c*c + d*d;
                    px /= 2*(c-a);
                }else{
                    px = 2*(b-f)*py - a*a - b*b + e*e + f*f;
                    px /= 2*(e-a);
                }
                double dmax = 0;
                for (int l = 0; l < N; l++) dmax = max(dmax, sqrt((px-x[l])*(px-x[l])+(py-y[l])*(py-y[l])));
                ans = min(ans, dmax);
            }
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            double px = (x[i]+x[j])/2, py=(y[i]+y[j])/2;
            double dmax = 0;
            for (int l = 0; l < N; l++) dmax = max(dmax, sqrt((px-x[l])*(px-x[l])+(py-y[l])*(py-y[l])));
            ans = min(ans, dmax);
        }
    }
    printf("%.10lf\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M, K, a, res=0;
  cin >> N >> M;
  vector<int> A(M);
  for (int i=0; i<N; i++) {
    cin >> K;
    for (int j=0; j<K; j++) {
      cin >> a;
      A.at(a-1)++;
    }
  }
  for (int i=0; i<M; i++) {
    if (A.at(i) == N)
      res++;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

}



Measured memory_bytes: 26380
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main() {

	int counter = 0;
	char s[100];
	
	int stack[100];
	

	while( scanf("%s", s) != EOF ) {
		if ( s[0] == '+' ) {
			stack[counter - 2] = stack[counter - 2] + stack[counter - 1];
			counter--;
		} else if ( s[0] == '-' ) {
			stack[counter - 2] = stack[counter - 2] - stack[counter - 1];
			counter--;
		} else if ( s[0] == '*' ) {
			stack[counter - 2] = stack[counter - 2] * stack[counter - 1];
			counter--;
		} else {
			stack[counter] = atoi(s);
			counter++;
		}
	}
	printf("%d\n",stack[0]);
	return 0;
}


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

#pragma GCC diagnostic warning "-Wconversion"

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) begin(a), end(a)
#define has(a, b) (a.find(b) != a.end())
#define fora(i, n) for(int i = 0; i < n; i++)
#define forb(i, n) for(int i = 1; i <= n; i++)
#define forc(a, b) for(const auto &a : b)
#define ford(i, n) for(int i = n; i >= 0; i--)
#define maxval(t) numeric_limits<t>::max()
#define minval(t) numeric_limits<t>::min()
#define imin(a, b) a = min(a, b)
#define imax(a, b) a = max(a, b)

#define dbgs(x) #x << " = " << x
#define dbgs2(x, y) dbgs(x) << ", " << dbgs(y)
#define dbgs3(x, y, z) dbgs2(x, y) << ", " << dbgs(z)
#define dbgs4(w, x, y, z) dbgs3(w, x, y) << ", " << dbgs(z)

using ll = long long;

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

        int n;
        ll a, b, c, d;
        cin >> n >> a >> b >> c >> d;

        fora(i, n)
        {
                ll ma = a + i * d - (n - i - 1) * c;
                ll mi = a + i * c - (n - i - 1) * d;

                if (b <= ma && b >= mi)
                {
                        cout << "YES" << endl;
                        return -0;
                }
        }

        cout << "NO" << endl;
}


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

using namespace std;

const int N = 2e6 + 10;
const int MOD = 1e9 + 7;

void add(int &x, const int &y) { x += y; x -= x >= MOD ? MOD : 0; }
void sub(int &x, const int &y) { x -= y; x += x < 0 ? MOD : 0; }
int mul(const int &x, const int &y) { return 1ll * x * y % MOD; }

int Pow(int x, int y) {
    if (!y) return 1;
    if (y == 1) return x % MOD;
    int ret = Pow(x, y / 2);
    ret = mul(ret, ret);
    return y % 2 ? mul(ret, x) : ret;
}

int n, k;
string str;
int fact[N], rfact[N];

int C(int x, int y) { return mul(fact[x], mul(rfact[x - y], rfact[y])); }

int main() {
    fact[0] = rfact[0] = 1;
    for (int i = 1; i <= (int)(2e6); i++) {
        fact[i] = mul(fact[i - 1], i);
        rfact[i] = Pow(fact[i], MOD - 2);
    }
    cin >> k >> str;
    n = (int)(str.size());
    int res = 0;
    for (int i = n; i <= n + k; i++) {
        add(res, mul(Pow(26, n + k - i), mul(C(i - 1, n - 1), Pow(25, i - n))));
    }
    cout << res;
}


Measured memory_bytes: 20876
import sys
from collections import deque
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5+10)
# input処理を高速化する
input = lambda: sys.stdin.readline().rstrip()

N, M = map(int, input().split())
p = list(map(int, input().split()))
p_inv = [0]*(N+1)
for i in range(1, N+1):
    p_inv[p[i-1]] = i

graph = [[] for _ in range(N+1)]
for i in range(M):
    x, y = map(int, input().split())
    graph[x].append(y)
    graph[y].append(x)

stack = deque()
is_checked = [0] * (N+1)
links = [[] for _ in range(N+1)]
for i in range(1, N+1):
    stack.append(i)
    while stack:
        node = stack.pop()
        if is_checked[node]:
            continue

        links[i].append(node)
        for next in graph[node]:
            stack.append(next)

        is_checked[node] = 1

ans = 0
for l in links:
    check = set()
    for num in l:
        check.add(p_inv[num])
    l = set(l)
    ans += len(l & check)

print(ans)


Measured memory_bytes: 53180
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <string.h>
#include <string>
#include <cmath>
#include <cstdio>
#include <functional>
#include <map>
#include <typeinfo>
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<double, double> pd;
// from https://www.geeksforgeeks.org/print-all-prime-factors-of-a-given-number/

vector<int> factorization[10000];
int reslcm[1000000];
vector<int> primes;

void prime_factors(int idx, int n)  
{  
    // Print the number of 2s that divide n  
  int temp = 0;
  while (n % 2 == 0)  
  {  
    temp++;
    n = n/2; 
    factorization[idx].push_back(2);
  }
  reslcm[2] = max(reslcm[2], temp);

  // n must be odd at this point. So we can skip  
  // one element (Note i = i +2)  
  for (int i = 3; i <= sqrt(n); i = i + 2)  
  {  
      // While i divides n, print i and divide n
    temp = 0;
    while (n % i == 0)  
    {  
      temp++;
      n = n/i;  
      factorization[idx].push_back(i);
      if(find(primes.begin(), primes.end(), i) == primes.end())
        primes.push_back(i);
    }
    reslcm[i] = max(temp, reslcm[i]);
  }  

  // This condition is to handle the case when n  
  // is a prime number greater than 2  
  if (n > 2)  
  {
    reslcm[n] = max(1, reslcm[n]);
    factorization[idx].push_back(n);
    if(find(primes.begin(), primes.end(), n) == primes.end())
      primes.push_back(n);
  }
}

int a[10000];

int main()
{
  int n;
  scanf("%d", &n);
  
  primes.push_back(2);

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

  ll res = 0;
  for(int i = 0; i < n; i++)
  {
    ll temp_lcm = 1;
    for(int j = 0; j < primes.size(); j++)
    {
      int temp_prime = reslcm[primes[j]];
      auto it = find(factorization[i].begin(), factorization[i].end(), primes[j]);
      while(it != factorization[i].end())
      {
        it = factorization[i].erase(it);
        temp_prime--;
        it = find(factorization[i].begin(), factorization[i].end(), primes[j]);
      }
      
      temp_lcm *= (ll)pow(primes[j], temp_prime) % mod;
      temp_lcm %= mod;
    }
    
    //printf("%lldaa\n", temp_lcm);
    res += temp_lcm % mod;
    res %= mod;
  }

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

Measured memory_bytes: 4480
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 1 << 30
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int MOD = 1000000007;


int main(){
    std::ios_base::sync_with_stdio(false);

    string s,t; cin >> s >> t;

    for(int i=s.length()-t.length(); i>=0 ;--i){
        bool p = true;
        for(int j=0; j<t.length(); j++){
            if(s[i+j]!=t[j] && s[i+j] != '?'){
                p= false;
                break;
            }
        }

        if(p){

            string ans = "";
            for(int k =0; k<s.length(); k++){
                if(k==i){
                    ans += t;
                    k = i+t.length()-1;
                } else if(s[k] == '?') {
                    ans += 'a';
                } else {
                    ans += s[k];
                }
            }
            cout << ans << endl;
            return 0;

        }

    }

    cout << "UNRESTORABLE" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
n,m = map(int,input().split())
ls = set(int(input()) for _ in range(m))
dp = [0]*(n+1)
dp[0] = 1
for i in range(1,n+1):
    if i not in ls:
        dp[i] = (dp[i-1]+dp[i-2])
        if dp[i] >= 10**9+7:
            dp[i] %= 10**9+7 
    else:
        if i-1 in ls:
            print(0)
            sys.exit()
print(dp[-1])

Measured memory_bytes: 87444
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


A, B = list(map(int, input().split()))


# def f(x):
#     if x % 4 == 3:
#         return 0
#     elif x % 4 == 0:
#         return x
#     elif x % 4 == 1:
#         return x ^ (x-1)
#     elif x % 4 == 2:
#         return x ^ (x-1) ^ (x-2)


def f(n):
    if (n % 4 == 0):
        return n
    elif (n % 4 == 1):
        return (n ^ (n-1))
    elif (n % 4 == 2):
        return (n ^ (n-1) ^ (n-2))
    else:
        return 0


print(f(A-1) ^ f(B))


Measured memory_bytes: 21148
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


a, b, q = LI()
s_list = [-INF] + IR(a) + [INF]
t_list = [-INF] + IR(b) + [INF]
x_list = IR(q)


for x in x_list:
    right_shrine_index = bisect_left(s_list, x)
    left_shrine_index = right_shrine_index - 1
    right_temple_index = bisect_left(t_list, x)
    left_temple_index = right_temple_index - 1
    ret = INF
    ret = min(ret, max(s_list[right_shrine_index], t_list[right_temple_index]) - x)
    ret = min(ret, x - min(s_list[left_shrine_index], t_list[left_temple_index]))
    ret = min(ret, min(s_list[right_shrine_index] - x, x - t_list[left_temple_index]) * 2 + max(s_list[right_shrine_index] - x, x - t_list[left_temple_index]))
    ret = min(ret, min(t_list[right_temple_index] - x, x - s_list[left_shrine_index]) * 2 + max(t_list[right_temple_index] - x, x - s_list[left_shrine_index]))
    print(ret)

Measured memory_bytes: 141660
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
  using u64 = std::int_fast64_t;
public:
  u64 a;
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
#pragma endregion

int main() {
  cin >> N;
  ll sum = 0;
  ll num;
  ll sum_count = 0;
  rep(i, N){
    cin >> num;
    sum += num;
    if(num == 0) {
      sum_count += sum / 2;
      sum = 0;
    }
  }
  sum_count += sum / 2;
  cout << sum_count;
} 



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

template<class T> class rollinghash {
	const ull mask30 = (1LL << 30) - 1;
	const ull mask31 = (1LL << 31) - 1;
	const ull mod61 = (1LL << 61) - 1;
	vector<ull> base;
	vector<vector<ull>> hashvalue, basepower;
	int length, basesize;
	ull multiply(ull a, ull b) {
		ull au = a >> 31; ull ad = a & mask31;
		ull bu = b >> 31; ull bd = b & mask31;
		ull mid = ad * bu + au * bd;
		ull midu = mid >> 30; ull midd = mid & mask30;
		return au * bu * 2 + midu + (midd << 31) + ad * bd;
	}
	ull modulo(ull a) {
		ull au = a >> 61; ull ad = a & mod61;
		ull res = au + ad; if (res >= mod61) res -= mod61;
		return res;
	}
public:
	rollinghash(T s) {
		length = s.size();
		base = { 200001,200004,200015 };
		basesize = base.size();
		hashvalue = vector<vector<ull>>(length + 1, vector<ull>(basesize));
		for (int j = 0; j < basesize; j++) {
			for (int i = 0; i < length; i++) {
				hashvalue[i + 1][j] = modulo(multiply(hashvalue[i][j], base[j]) + s[i]);
			}
		}
		basepower = vector<vector<ull>>(length + 1, vector<ull>(basesize));
		for (int j = 0; j < basesize; j++) {
			basepower[0][j] = 1;
			for (int i = 1; i <= length; i++) {
				basepower[i][j] = modulo(multiply(basepower[i - 1][j], base[j]));
			}
		}
	}
	ull hash(int l, int r, int i) {
		assert(l < r && 0 <= l && l < length && 0 < r && r <= length);
		return modulo(hashvalue[r][i] + mod61 - modulo(multiply(hashvalue[l][i], basepower[r - l][i])));
	}
	bool same(int al, int ar, int bl, int br) {
		bool res = true;
		for (int i = 0; i < basesize; i++) {
			if (hash(al, ar, i) != hash(bl, br, i)) res = false;
		}
		return res;
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	string s;
	cin >> s;
	rollinghash<string> rol(s);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			while (i + ans < j && j + ans < n) {
				if (!rol.same(i, i + ans + 1, j, j + ans + 1)) break;
				ans++;
			}
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 768
#include<stdio.h>

int main(){
	int H,W;
	scanf("%d %d",&H,&W);
	char a[H][W];
	for(int i=0;i<H;i++)scanf("%s",a[i]);
	
	int comph[H],compw[W];
  	for(int i=0;i<H;i++)comph[i]=0;
  	for(int j=0;j<W;j++)compw[j]=0;
	
	for(int i=0;i<H;i++){
		int tmp=0;
		for(int j=0;j<W;j++){
			if(a[i][j]=='#')tmp++;
		}
		if(tmp==0)comph[i]=1;
	}
	
	for(int j=0;j<W;j++){
		int tmp=0;
		for(int i=0;i<H;i++){
			if(a[i][j]=='#')tmp++;
		}
		if(tmp==0)compw[j]=1;
	}
	
	for(int i=0;i<H;i++){
		if(comph[i]==1)continue;
		for(int j=0;j<W;j++){
			if(compw[j]==1)continue;
			printf("%c",a[i][j]);
		}
		printf("\n");
	}
	
	return 0;
}


Measured memory_bytes: 128
'use strict'

function main(inp) {
  inp = inp.trim().split(' ').map(n => Number(n));
  if (inp[0] > inp[2]) {
    inp[0] = inp[0] - inp[2]
    inp[2] = 0
  } else {
    inp[2] = inp[2] - inp[0]
    inp[0] = 0
    inp[1] = inp[1] > inp[2] ? inp[1] - inp[2] : 0
  }

  console.log(inp[0] + ' ' + inp[1])
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

signed main() {
  int n;
  cin >> n;

  int cnt = 0;
  vector<pair<int,int>> P;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if(n % 2 == 1 && i + j == n) continue;
      if(n % 2 == 0 && i + j == n + 1) continue;
      P.emplace_back(i,j);
      cnt++;
    }
  }
  
  cout << cnt<< endl;
  for (auto it: P){
    cout << it.first << " " << it.second << endl;
  }
  return 0;
}



Measured memory_bytes: 3668
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Globalization.CultureInfo;

public class Program{
    public static void Main(){
        var a = Console.ReadLine();
        var b = Console.ReadLine();
        var ans = "";
        if(a.Count()>b.Count()) ans = "GREATER";
        else if(a.Count()<b.Count()) ans = "LESS";
        else{
            for(var i=0; i<a.Count(); i+=10){
                var ta = long.Parse(string.Join("", a.Skip(i).Take(10)));
                var tb = long.Parse(string.Join("", b.Skip(i).Take(10)));
                
                if(ta<tb){
                    ans = "LESS";
                    break;
                }
                if(ta>tb){
                    ans = "GREATER";
                    break;
                }
            }
            if(ans=="") ans = "EQUAL";
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11220
from collections import Counter
N = int(input())
D = [int(i) for i in input().split()]
M = int(input())
T = [int(i) for i in input().split()]

cD = Counter(D)

for t in T:
    if cD.get(t,0) == 0:
        print('NO')
        exit()
    else:
        cD[t] -= 1

print("YES")

Measured memory_bytes: 41564
#include<iostream>
#include<string>

using namespace std;

string hyo[]={".,!? ",
	      "abc",
	      "def",
	      "ghi",
	      "jkl",
	      "mno",
	      "pqrs",
	      "tuv",
	      "wxyz",};

main(){
  string in;
  int n;
  cin>>n;
  while(n--){
    cin>>in;
    string out;
    int zen='0';
    int c=0;
    for(int i=0;i<in.size();i++){
      if(in[i]=='0' && zen!='0'){
	zen-='1';
	int s=hyo[zen].size();
	--c;
	c%=s;
	out+=hyo[zen][c];
	c=0;
	zen=in[i];
      }else if(in[i]=='0' && zen=='0'){
	continue;
      }else if(zen=='0' && in[i]!=0){
	c=1;
	zen=in[i];
      }else if(in[i]==zen){
	++c;
      }
    }
    cout<<out<<endl;
  }
}

Measured memory_bytes: 0
#import random
import numpy as np
def main():
  d=int(input())
  c=np.array(list(map(int,input().split())))
  s=[None]*d
  r0=[None]*d
  r1=[None]*d
  cm=np.array([0]*26)
  cd=np.array([0]*26)
#t=[None]*d
  for i in range(d):
    s[i]=list(map(int,input().split()))
  s=np.array(s)
#for i in range(d):
#  t[i]=int(input())-1
  for j in range(d):  
    #rand = np.random.randint(26, size = 10) 
    #print(np.argmax(s[j])+1)
    r_i=np.argmax(s[j])
    cd=c*cm
    if np.max(cd>s[i][r_i]):
      r_i=np.argmax(cd)
    r0[j]=r_i
    for k in range(26):
      cm[k]+=1
    cm[r_i]=0
  #r_i+=1
  #print(r_i)
  cm=np.array([0]*26)
  cd=np.array([0]*26)  
  rand = np.random.randint(100, size = d) 
  for j in range(d):  
    #print(np.argmax(s[j])+1)
    r_i=r0[j]
    cd=c*cm
    if rand[j]>80:
      r_i=np.argmax(cd)
    r1[j]=r_i
    for k in range(26):
      cm[k]+=1
    cm[r_i]=0
#r0=t
  score0=0
  cm=np.array([0]*26)
  cd=np.array([0]*26)  
  for j in range(d):
    r0_j=r0[j]
    score0+=s[j][r0_j]
    for k in range(26):
      cm[k]+=1
      cm[r0_j]=0
    cd=c*cm
    score0+=-np.sum(cd)
  score1=0
  cm=np.array([0]*26)
  cd=np.array([0]*26)  
  for j in range(d):
    r0_j=r1[j]
    score1+=s[j][r0_j]
    for k in range(26):
      cm[k]+=1
      cm[r0_j]=0
    cd=c*cm
    score1+=-np.sum(cd)
  if score1>score0:
    r0=r1
    score0=score1
  #score1=0
  cm=np.array([0]*26)
  cd=np.array([0]*26)  
  rand = np.random.randint(100, size = d) 
  for j in range(d):  
    #print(np.argmax(s[j])+1)
    r_i=r0[j]
    cd=c*cm
    if rand[j]>75:
      r_i=np.argmax(cd)
    r1[j]=r_i
    for k in range(26):
      cm[k]+=1
    cm[r_i]=0
  
  score1=0
  cm=np.array([0]*26)
  cd=np.array([0]*26)  
  for j in range(d):
    r0_j=r1[j]
    score1+=s[j][r0_j]
    for k in range(26):
      cm[k]+=1
      cm[r0_j]=0
    cd=c*cm
    score1+=-np.sum(cd)
  if score1>score0:
    r0=r1
    score0=score1
    
  cm=np.array([0]*26)
  cd=np.array([0]*26)  
  rand = np.random.randint(100, size = d) 
  for j in range(d):  
    #print(np.argmax(s[j])+1)
    r_i=r0[j]
    cd=c*cm
    if rand[j]>60:
      r_i=np.argmax(cd)
    r1[j]=r_i
    for k in range(26):
      cm[k]+=1
    cm[r_i]=0
  
  score1=0
  cm=np.array([0]*26)
  cd=np.array([0]*26)  
  for j in range(d):
    r0_j=r1[j]
    score1+=s[j][r0_j]
    for k in range(26):
      cm[k]+=1
      cm[r0_j]=0
    cd=c*cm
    score1+=-np.sum(cd)
  if score1>score0:
    r0=r1
    score0=score1
    
    cm=np.array([0]*26)
  cd=np.array([0]*26)  
  rand = np.random.randint(100, size = d) 
  for j in range(d):  
    #print(np.argmax(s[j])+1)
    r_i=r0[j]
    cd=c*cm
    if rand[j]>50:
      r_i=np.argmax(cd)
    r1[j]=r_i
    for k in range(26):
      cm[k]+=1
    cm[r_i]=0
  
  score1=0
  cm=np.array([0]*26)
  cd=np.array([0]*26)  
  for j in range(d):
    r0_j=r1[j]
    score1+=s[j][r0_j]
    for k in range(26):
      cm[k]+=1
      cm[r0_j]=0
    cd=c*cm
    score1+=-np.sum(cd)
  if score1>score0:
    r0=r1
    score0=score1

  for j in range(d):  
    print(r0[j]+1) 
 
main()
  
    



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

//Nの約数が8個あるかどうか判定
int main(){
int N;
cin >> N;

int count = 0;//１以上N以下の、正の約数を８個もつ奇数の数
  for(int i = 105; i<=N; i+=2){
    int c = 0;//約数の数
  for(int j =1 ;j<=i; j++){
    if(i%j == 0) c++;
   }
    if(c == 8) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;

int sort(const void *a, const void *b){
  int A = *(int *)a, B = *(int *)b;
  if(A > B) return  1;
  if(A < B) return -1;
  return 0;
}

int
main(int argc, char *argv[])
{
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  printf("%d\n", Max(c - (a - b), 0));
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String S = in.nextLine();
         if (S.equals("ABC")){
          System.out.println("ARC");
         }
         else {System.out.println("ABC");
                }
        }
    }

Measured memory_bytes: 35528
//#include <bits/stdc++.h>
 
#include <iostream>
#include <algorithm>
 
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <cstring>
#include <string>
#include <utility>
#include <array>
#include <complex>
#include <valarray>
 
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>
 
 
using namespace std;
#define int long long
 
typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;
 
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
 
const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll INFLL = 1LL<<62;
const double EPS = 1e-12;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;
 
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod
#define inside(y, x, h, w) (0 <= (y) && (y) < (h) && 0 <= (x) && (x) < (w)) ? true : false

int n;
int a[100000 + 5];
map<int, int> cnt;


signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		cnt[a[i]] += 1;
	}
	int ans = 0;
	for (auto mp : cnt) {
		if (mp.fi <= mp.se) ans += mp.se - mp.fi;
		else ans += mp.se;
	}
	cout << ans << endl;
}


Measured memory_bytes: 7040
n,k,q = (int(x) for x in input().split())
players = [k] * n
result = [0] * n
for i in range(q):
  player = int(input())
  result[player-1] = result[player-1] + 1
for i in range(n):
  if players[i] - q + result[i] > 0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 5448
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    vector<int> ABC;
    rep (i, 0, 3) {
        int in; cin >> in;
        ABC.push_back(in);
    }
    int K, ans; cin >> K;
    std::vector<int>::iterator iter = std::max_element(ABC.begin(), ABC.end());
    size_t index = std::distance(ABC.begin(), iter);
    rep (i, 0, K) {
        ABC[index] = ABC[index] * 2;
    }
    ans = std::accumulate(ABC.begin(), ABC.end(), 0);
    cout << ans << endl;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
sum = 0
0.upto(n-1) do |i|
	minj = i
	i.upto(n-1) do |j|
		minj = j if a[j]<a[minj]
	end
	if a[i] != a[minj] then
	    v = a[i]
	    a[i] = a[minj]
	    a[minj] = v
	    sum += 1
	end
end
puts a.join(' ')
puts sum


Measured memory_bytes: 6868
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <time.h>
#define MAXT 10
#define MOD 1000000007
using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;

	printf("%d", c - (a - b) > 0 ? c - (a - b) : 0);

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}


int main(){
	int n;
	cin>>n;
	vector<ll> a(n); rep(i, n) cin>>a[i];
	sort(all(a));
	ll x = 0, y = 0;
	while(a.size()>=2){
		if(a[a.size()-1]!=a[a.size()-2]){
			a.pop_back();
			continue;
		} else {
			x = a[a.size()-1];
			if(y) break;
			swap(x, y);
			a.pop_back();
			a.pop_back();
		}
	}
	cout<<x*y<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> G[111111];
int ans=0;
int dfs(int v){
  if(!G[v].size()) return 0;
  int res=0;
  vector<int> vv;
  for(int i=0;i<(int)G[v].size();i++){
    int k=dfs(G[v][i]);
    res=max(res,k);
    vv.push_back(k);
  }
  sort(vv.begin(),vv.end());
  for(int i=0;i<(int)vv.size();i++){
    res=max(res,vv[i]+(int)vv.size()-i);
  }
  return res;
}
int main(){
  int n;
  cin>>n;
  int a[n];
  a[0]=-1;
  for(int i=1;i<n;i++){
    cin>>a[i];
    G[a[i]-1].push_back(i);
  }
  cout<<dfs(0)<<endl;
  return 0;
}


Measured memory_bytes: 15744
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

vector<P> prime_fact(ll n) {
	if (n == 1) return vector<P>(1, {1, 0});
	vector<P> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			res.rbegin()->second++;
			n /= i;
		}
	}
	if (n > 1) res.emplace_back(n, 1);
	return res;
}

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

	ll N;
	cin >> N;
	vector<P> pf = prime_fact(N);
	ll res = 0;
	for (auto &p : pf) {
		int k = 1;
		while (k <= p.second) {
			res++;
			p.second -= k;
			++k;
		}
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 3676
h,w=map(int,input().split())
r=[]
for i in range(h):
    r.append(list(input()))
t=[]
for i in range(h):
    for j in range(w):
        if r[i][j]=='#':
            t.append([i,j])
op=[[[0,0]]]
for i in range(h+w-2):
    tmp=[]
    for j in op:
        tmp.append(j+[[j[-1][0]+1,j[-1][1]]])
        tmp.append(j+[[j[-1][0],j[-1][1]+1]])
    op=tmp
for i in op:
    if sorted(i)==sorted(t):
        print('Possible')
        exit()
print('Impossible')


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

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


int main(){
	int n,x;
	cin>>n>>x;
	vector<int> arr(n);
	for(int i = 0; i < n; i++){
	 int t;cin>>t;
	 arr[i] = abs(t-x);
	}

	int res = arr[0];
    for(int i = 0; i < n; i++){
    	res = gcd(res,arr[i]);
    } 
    cout<<res;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



string s;

signed main() {
	cin >> s;
	if (s.size()==3) reverse(all(s));
	cout << s << endl;
}

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

int main() {
  vector<long long> vec(100);
  vec.at(0) = 2;
  vec.at(1) = 1;
  for (int i = 2; i < 100; i++) {
    vec.at(i) = vec.at(i-1) + vec.at(i-2);
  }
  
  int N;
  cin >> N;
  cout << vec.at(N) << endl;

}

Measured memory_bytes: 256