akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i<N ; i++){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end(), greater<int>());
    int ans = 0;
    for(int i = 0; i < N ; i++){
        ans += a.at(i) * (((i%2) * 2 - 1) * (-1));
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
int main() {
	std::cout << std::fixed << std::setprecision(20);
	int a, b[1000];
	while (std::cin >> a && a != 0) {
		double sum = 0, c = 0;
		for (int i = 0;i < a;++i) {
			std::cin >> b[i];
			sum += b[i];
		}
		sum /= a;
		for (int i = 0;i < a;++i) {
			c += (b[i] - sum) * (b[i] - sum);
		}
		std::cout << sqrt(c / a) << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3268
get_string(String) :-
  current_input(Input),
  read_string(Input, ' \n', '', _, String).
 
get_number(Number) :-
  get_string(String),
  number_string(Number, String).

main :-
  get_number(S),
  get_number(W),
  (S > W -> writeln('safe') ; writeln('unsafe')).

Measured memory_bytes: 8084
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int A,B,C;
  
  cin >> A >> B >> C;
  
  if (A == B && B == C && C == A) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
} 
  

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

int main() {
int N;
int flag = 0;
  cin >> N;
  
  for (int i = 0; i < N; ++i){
    string S;
    cin >> S;
    if (S == "Y"){
      flag = 1;
    }
  }
  if(flag == 1){
    cout << "Four" << endl;
  }
  else{
    cout << "Three" << endl;
  }
    
}


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

#define rep(i,n) for (int i=0; i<(int)n; i++)

int N;
int W[100];

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

    cin >> N;
    vector<int> a(N);
    int sum = 0;
    rep(i, N) {
        cin >> a[i];
        sum += a[i];
    }

    int prefix = 0;
    int res = sum;

    rep(i, N) {
        prefix += a[i];
        res = min(res, abs(prefix - (sum - prefix)));
    }

    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x,y;
  cin >> x >> y;
  if((x==1||x==3||x==5||x==7||x==8||x==10||x==12)and(y==1||y==3||y==5||y==7||y==8||y==10||y==12))cout << "Yes" << endl;
  else if((x==4||x==6||x==9||x==11)and(y==4||y==6||y==9||y==11))cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <string>

using namespace std;

int main(int argc, char* argv[]) {
  long long N;
  cin >> N;

  string s;
  cin >> s;

  long long ret = 0;
  for (int i = 0; i < 1000; ++i) {
    string tmp = to_string(i);
    char tar[3];

    if (tmp.size() < 3)
      tar[0] = '0';
    else
      tar[0] = tmp[0];

    if (tmp.size() == 3)
      tar[1] = tmp[1];
    else if (tmp.size() == 2)
      tar[1] = tmp[0];
    else
      tar[1] = '0';

    if (tmp.size() == 3)
      tar[2] = tmp[2];
    else if (tmp.size() == 2)
      tar[2] = tmp[1];
    else
      tar[2] = tmp[0];

    int k = 0;
    bool ok = true;
    for (int j = 0; j < 3; ++j) {
      bool found = false;
      for (; k < N; ++k) {
        if (tar[j] == s[k]) {
          found = true;
          ++k;
          break;
        }
      }
      if (!found) {
        ok = false;
        break;
      }
    }
    if (ok)
      ++ret;
  }

  cout << ret << endl;

  return 0;
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
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);
        BProblemSet solver = new BProblemSet();
        solver.solve(1, in, out);
        out.close();
    }

    static class BProblemSet {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            HashMap<Integer, Integer> hm = new HashMap<>();
            for (int i = 0; i < n; i++) {
                hm.merge(in.nextInt(), 1, Integer::sum);
            }
            int m = in.nextInt();
            for (int i = 0; i < m; i++) {
                int need = in.nextInt();
                if (hm.containsKey(need) && hm.get(need) > 0) {
                    hm.merge(need, -1, Integer::sum);
                } else {
                    out.println("NO");
                    return;
                }
            }
            out.println("YES");


        }

    }
}



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

int d, g;
vector<int> p, c;
int ans = 100000;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> d >> g;
	for(int i=0; i<d; ++i){
		int a, b;
		cin >> a >> b;
		p.push_back(a);
		c.push_back(b);
	}
	for(int i=0; i<(1<<d); ++i){
		int a = 0, b = 0;
		int t = i;
		for(int j=0; (t>>j)>0; ++j){
			if(((t>>j)&1) == 1){
				a += p[j];
				b += c[j];
				b += p[j] * 100 * (j+1);
			}
		}
		if(b >= g) ans = min(ans, a);
		else{
			for(int j=d-1; j>=0; --j){
				if(((t>>j)&1) == 0){
					for(int k=1; k<p[j]; ++k){
						++a;
						b += 100 * (j+1);
						if(b >= g){
							break;
						}
					}
				}
				if(b >= g){
					ans = min(ans, a);
					break;
				}
			}
		}
	}
	cout << ans << "\n";
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  map<ll,ll> m;
  rep(i,n){
    ll a; cin>>a;
    a/=400;
    if(a<8) m[a]++;
    else m[8]++;
  }
  ll min=0,max=0;
  rep(i,8){
    if(m[i]){
      min++;
      max++;
    }
  }
  max+=m[8];
  if(min==0) min=1;
  
  cout<<min <<" "<<max<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

int n,a[200010],b[200010];
map<int,int> mp,now;
deque<int> vec;
vector<int> res[200010];

signed main()
{
	ios::sync_with_stdio(false);
	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;i++){
		mp[a[i]]++;mp[b[i]]++;now[b[i]]++;
		vec.push_back(a[i]);
	}
	for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++){
		if((it->second)>n){
			cout<<"No"<<endl;
			return 0;
		}
	}
	priority_queue<pair<int,int> > q;
	for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++){
		q.push(make_pair(it->second,it->first));
	}
	while(!q.empty()){
		pair<int,int> t=q.top();q.pop();
		if(mp[t.second]!=t.first) continue;
		if(now[t.second]==0) continue;
		int val;
		if(vec.front()!=t.second){
			val=vec.front();vec.pop_front();
		}
		else{
			val=vec.back();vec.pop_back();
		}
		res[val].push_back(t.second);
		mp[t.second]--;now[t.second]--;mp[val]--;
		if(mp[t.second]) q.push(make_pair(mp[t.second],t.second));
		if(mp[val]) q.push(make_pair(mp[val],val));
	}
	cout<<"Yes"<<endl;
	for(int i=1;i<=n;i++){
		cout<<res[a[i]].back()<<" ";
		res[a[i]].pop_back();
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 36788
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1073741823;
const ll LINF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	ll n, k; cin >> n >> k;
	VI a(n);
	REP(i,n){
		cin >> a[i];
		a[i]--;
	}
	VI p(n,-1);
	p[0]=0;
	int now=0;
	for(int i=1;i<=k;i++){
		now=a[now];
		if(p[now]!=-1){
			int rp=i-p[now];
			k-=i; k%=rp;
			REP(j,k)
				now=a[now];
			cout << now+1 << endl;
			return 0;
		}
		else
			p[now]=i;
	}
	cout << now+1 << endl;
	return 0;
}

Measured memory_bytes: 6428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll inv[1000000];
ll FactorialInv[1000000];
ll Factorial[1000000];
ll beki(ll a, ll b){
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}
void init_combination(){
    inv[1] = 1;
    FactorialInv[1] = 1;
    Factorial[1] = 1;
    Factorial[0] = 1;
    FactorialInv[0] = 1;
    inv[0] = 1;
    for(int i = 2; i < 1000000; i++){
        inv[i] = beki(i, mod - 2);
        Factorial[i] = Factorial[i - 1] * i % mod;
        FactorialInv[i] = FactorialInv[i - 1] * inv[i] % mod;
    }
}
ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    init_combination();
    ll N, A, B, C;
    cin >> N >> A >> B >> C;
    ll factor = 100 * inv[100 - C];
    factor %= mod;
    cerr << factor << endl;
    //ll Awin = A * inv[factor] % mod;;
    ll Awin = A * inv[A + B] % mod;
    ll Bwin = B * inv[A + B] % mod;
    cerr << Awin << " " << Bwin << endl;
    ll ans = 0;
    for(int a = 0; a < N; a++) {
        ll sum = a + N-1;
        ll now = combination(sum, a) * (a + N) % mod;
        //cerr << now << endl;
        now *= beki(Awin, a);
        now %= mod;
        now *= beki(Bwin, N - 1);
        now %= mod;
        now *= Bwin % mod;
        now %= mod;
        //cerr << a << " " << now << " " << (double)now / mod << endl;
        ans += now;
        ans %= mod;
    }
    cerr << beki(inv[2], 4) << endl;
    for(int a = 0; a < N; a++) {
        ll sum = a + N-1;
        ll now = combination(sum, a) * (a + N) % mod;
        now *= beki(Bwin, a);
        now %= mod;
        now *= beki(Awin, N - 1);
        now %= mod;
        now *= Awin % mod;
        ans += now;
        ans %= mod;
    }
    cout << ans * factor % mod << endl;
    return 0;
}


Measured memory_bytes: 23808
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String args[])throws IOException{
//        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//        int x = Integer.parseInt(br.readLine());
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
        StringBuilder sb = new StringBuilder();
        int count=0;
        int a=1,b;
        if(x>=3 && x<=10000){
            for(; count<x; count++){
                 b = a/10;
                    if(a%3==0){
                        sb.append(" ");
                        sb.append(a);
                    }else{
                        b = a;
                        while(b!=0){
                            if(b%10==3){
                                sb.append(" ");
                                sb.append(a);
                                break;
                            }
                            b /= 10;
                        }
                    }
                    a++;
            }
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 27516
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,m,cnt=0,aa[110000],h;
pair<int,int> p[110000];
string s;
char c;
signed main(){
    cin>>h>>n;
    rep(i,n){
        cin>>aa[i];
        cnt+=aa[i];
    }
    if(cnt<h){
        cout<<"No";
    }else{
        cout<<"Yes";
    }
}

Measured memory_bytes: 1024
S=input().strip()
r_S = S[::-1]
a = S[:int(((len(S)-1)/2)):]
b = S[int(((len(S)+1)/2))::]
r_a = S[int(((len(S)-3)/2))::-1]
r_b = S[:int(((len(S)-1)/2)):-1]

if a == r_a and b == r_b and S == r_S:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
inta = input().split(" ")
int_list = [int(a) for a in inta]
num1 = int_list[0] // int_list[1]
num2 = int_list[0] // int_list[3]
if int_list[0] % int_list[1] == 0:
    m = 1
if int_list[0] % int_list[3] == 0:
    m = 2
if int_list[0] % int_list[1] != 0:
    num1 += 1
if int_list[0] % int_list[3] != 0:
    num2 += 1
num1 *= int_list[2]
num2 *= int_list[4]
if num1 >= num2:
    print(num2)
elif num1 <= num2:
    print(num1)


Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;

    vector<int> cnt(26, 0);
    for (int i = 0; i < n; i++) {
        cnt[s[i] - 'a']++;
    }

    long long res = 1;
    for (int i = 0; i < 26; i++) {
        res *= cnt[i] + 1LL;
        res %= 1000000007;
    }

    cout << res - 1 << endl;
}


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

#define rep(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define SZ(x) ((int) (x).size())
typedef long long ll;

const int N = 300000 + 5;
const long long INF = -1 * (~0ULL >> 2);
int a[N];
long long sumPreMax[N], sumSucMin[N];
int main() {
    //freopen("d.in", "r", stdin);
    int n;
    cin >> n;
    rep(i,1,3*n+1) cin >> a[i];
    priority_queue<int,  vector<int>, greater<int>> pMin;
    priority_queue<int> qMax;
    rep(i,1,n+1) {
        pMin.push(a[i]);
        sumPreMax[n] += a[i];
    }
    for(int i=3*n;i>2*n;--i) {
        qMax.push(a[i]);
        sumSucMin[2*n+1] += a[i];
    }
    rep(i,n+1,2*n+1) {
        sumPreMax[i] = sumPreMax[i-1];
        int minV = pMin.top();
        if(minV < a[i]) {
            pMin.pop();
            pMin.push(a[i]);
            sumPreMax[i] += a[i] - minV;
            //cout << a[i] <<" " << minV << endl;
        }
    }
    for(int i=2*n;i>n;--i) {
        sumSucMin[i] = sumSucMin[i+1];
        int maxV = qMax.top();
        if(maxV > a[i]) {
            qMax.pop();
            qMax.push(a[i]);
            sumSucMin[i] += a[i] - maxV;
        }
    }
    long long ans = INF;
    rep(i,n,2*n+1) {
        ans = max(ans, sumPreMax[i] - sumSucMin[i+1]);
    }
//    rep(i,1,3*n+1) cout << sumPreMax[i] <<" "; cout << endl;
//    rep(i,1,3*n+1) cout << sumSucMin[i] <<" "; cout << endl;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5240
import heapq

n = int(input())

INF = 2147483647
G = [[] for i in range(n)]
check, dist = [0 for i in range(n)], [INF for i in range(n)]


def dijkstra(s):
    dist[s], pq = 0, []
    heapq.heappush(pq, (0, s))

    while len(pq) != 0:
        u = heapq.heappop(pq)
        check[u[1]] = 2

        if dist[u[1]] < u[0]:
            continue

        for v in G[u[1]]:
            if check[v[0]] != 2:
                if dist[u[1]] + v[1] < dist[v[0]]:
                    dist[v[0]], check[v[0]] = dist[u[1]] + v[1], 1
                    heapq.heappush(pq, (dist[v[0]], v[0]))


def main():
    for i in range(n):
        data = list(map(int, input().split()))
        for j in range(data[1]):
            G[data[0]].append((data[2*(j+1)], data[2*(j+1)+1]))

    dijkstra(0)

    for i in range(n):
        print(i, dist[i])


if __name__ == '__main__':
    main()



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

void testCase(){
    int n, m, x;
    cin>>n>>m>>x;
    vector<int> price(n, 0);
    vector<vector<int> > know(n, vector<int>(m, 0));
    vector<int> totalKnow(m, 0);
    bool flag = true;
    for(int i = 0; i < n; i++){
        cin>>price[i];
        for(int j = 0; j < m; j++){
            cin>>know[i][j];
            totalKnow[j] += know[i][j];
        }
    }
    for(int i = 0; i < m; i++){
        if(totalKnow[i] < x) flag = false;
    }

    if(flag){
        int mini = INT_MAX;
        for(int i = 0; i < pow(2, n); i++){
            vector<int> temp(m, 0);
            int cost = 0;
            for(int j = 0; j < n; j++){
                if(i >> j & 1){
                    for(int k = 0; k < m; k++){
                        temp[k] += know[j][k];
                    }
                    cost += price[j];
                }
            }
            bool flag1 = true;
            for(auto i : temp) if(i < x) flag1 = false;
            if(flag1){
                mini = min(cost, mini);
            }
        }
        cout<<mini<<endl;
    }
    else{
        cout<<"-1"<<endl;
    }
}

int main(){
    int t;
    t = 1;
    // cin>>t;
    while(t--){
        testCase();
    }
}



Measured memory_bytes: 4080
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  int ans=1;
  int a,b;
  cin>>a>>b;

  REP(i,20){
	  if (ans<b){
		  ans-=1;
		  ans+=a;
	  }else{
		  cout<<i<<endl;
		  return 0;
	  }
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


int wires[31];

void swap(int nth, int mth){
  int tmp;
  tmp = wires[nth];
  wires[nth] = wires[mth];
  wires[mth] = tmp;
  return;
}

int main(){
  int w;
  int n;
  int i;
  int a, b;

  scanf("%d", &w);
  for (i=1; i<=w;i++){
    wires[i] = i;
  }

  scanf("%d", &n);
  for (i = 0; i<n ;i++){
    scanf("%d,%d", &a, &b);
    swap(a, b);
  }


  for (i=1; i<=w;i++){
    printf("%d\n", wires[i]);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  	int a, b;
  	cin >> a >> b;
 
  	vector<string> v;
  	for (int i = 0; i < a; i++) {
      	string s;
      	cin >> s;
      	v.push_back(s);
    }
  	sort(v.begin(), v.end());
  	for ( auto t : v ) {
      	cout << t;
    }
  	cout << endl;
}

Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 100000000

typedef  long long ll;

using namespace std;

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return r;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}

void solve(void){
    int a,b,k;
    cin >> a>> b>> k;
    vector<int> ans;
    for(int i=1;i<=min(a,b);i++){
        if(a%i==0 && b%i==0) ans.push_back(i);
    }
    reverse(ans.begin(),ans.end());

    cout << ans[k-1] << endl;

}

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

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void)
{
	int m;
	int n[4]={0};
	while(cin >> m){
		char c[5];
		cin >> c;
		if(c[1]=='A'){
			if(c[2]=='B') n[2]++;
			else n[0]++;
		}else if (c[1] == 'B') n[1]++;
		else n[3]++;
	}
	for(int i=0; i<4; i++){
		cout << n[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1 + 1e5;
typedef long long LL;
typedef pair < int, int > II;
typedef pair < int, II > III;

int n, a[MAXN][3], f[MAXN][3];

int main()
{
    #define TASK "ABC"
  //  freopen(TASK".inp","r",stdin);
 //   freopen(TASK".out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    for (int i = 0; i < n; i++){
        for (int j = 0; j < 3; j++){
            for (int k = 0; k < 3; k++){
                if (j == k)continue;
                f[i][j] = max (f[i][j] , f[i-1][k] + a[i][j]);
            }
        }
    }
    cout << max (f[n-1][0] , max (f[n-1][1] , f[n-1][2]));
    return 0;
}




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

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(1e18)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii >

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){cerr << name << " = " << arg1 << endl;}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args){
const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);}

template< typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2> &q){ in >> q.F >> q.S; return in;}
template< typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){out << q.F << " " << q.S; return out;}
template< typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){return {p1.F+p2.F, p1.S+p2.S};}
template< typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){return {p1.F-p2.F, p1.S-p2.S};}

void solve() {
    int n;
    cin >> n;
    int a[n+1];
    for(int i = 0; i <= n; i++){
        cin >> a[i];
    }
    if(n == 0){
        if(a[n] == 1)cout << 1 << endl;
        else cout << -1 << endl;
        return;
    }
    if(a[0] != 0){
        cout << -1 << endl;
        return;
    }
    int sum[n+2] = {0};
    for(int i = n; i >= 0; i--){
        sum[i] = sum[i+1]+a[i];
    }
    int ans = 0, cur = 1;
    for(int i = 1; i <= n; i++){
        if(cur*2 < a[i]){
            cout << -1 << endl;
            return;
        }
        cur = min(sum[i], cur*2);
        ans += cur;
        cur -= a[i];
    }
    cout << ans+1 << endl;
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;
    start = clock(); 

    cout << fixed << setprecision(20);

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    // freopen("error.txt", "w", stderr);
    // #endif
   
    // cin >> t;
    
    for(int i = 1; i <= t; ++i){
        //cout << "Case #" << i << ": "; 
        solve();
        //cout << endl;
    }
    //cerr << time(start);
    return 0;
}


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

//#pragma gcc optimize("O3,unroll-loop")
//#pragma gcc target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,abm,mmx,popcnt,tune=native")
#define int long long
//#define double long double
#define MOD 1000000007LL

int dp[10000][10001] = {};

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

    int s;
    cin >> s;

    for (int j = 0; j <= s; j++)
        dp[0][j] = 1;
    for (int i = 1; i < 1000; i++)
    {
        for (int j = 3; j <= s; j++)
            dp[i][j] = dp[i - 1][j - 3] % MOD;
        for (int j = 0; j <= s; j++)
            dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
    }

    int ans = 0;
    for (int i = 1; i < 1000; i++)
        ans = (ans + dp[i][s] - dp[i][s - 1] + MOD * 10) % MOD;
    cout << ans << '\n';

    return 0;
}

//      *   *  *****  *   *  *   *   ****  ****    ****     **    **
//     *   *  *      **  *  *   *  *      *   *  *        * *   * *
//    *****  *****  * * *  *   *  *      ****   *       *  *     *
//   *   *      *  *  **  *   *  *      *  *   *       *****    *
//  *   *  *****  *   *   ***    ****  *   *    ****     *   *****

//      *****  *****  *   *  *      *****  *   *  *****  *****
//        *   *   *  *   *  *        *    **  *    *    *   *
//       *   *   *  *****  *        *    * * *    *    *****
//   *  *   *   *    *    *        *    *  **    *    *
//  ****   *****    *    *****  *****  *   *    *    *


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

int main(){
    int k;
    cin>>k;
    if(k%7==0) k/=7;

    if(__gcd(10,k)!=1){
        cout<<"-1\n";
        return 0;
    }

    long long v=1%k;
    int len=1;
    while(v!=0){
        v = (10*v + 1)%k;
        len++;
    }
    cout<<len<<"\n";
}

Measured memory_bytes: 3624
def even_case(input_list) -> int:
    input_list.sort()

    if input_list[0] == 0: return 0


    for i in range(1, len(input_list), 2):
        if input_list[i] % 2 == 0 or input_list[i] != input_list[i-1]:
            return 0

    ans = 2 ** (n//2)

    return ans


def odd_case(input_list) -> int:
    input_list.sort()

    if input_list[0] != 0: return 0

    if len(input_list) == 1: return 1

    if input_list[1] == 0: return 0

    for i in range(2, len(input_list), 2):
        if input_list[i] % 2 == 1 or input_list[i] != input_list[i-1]:
            return 0

    ans = 2 ** ((n-1) // 2)

    return ans

n = int(input())
input_list = list(map(int, input().split()))
math = 10 ** 9 + 7

if n % 2 == 0:
    result = even_case(input_list)
else:
    result = odd_case(input_list)

print(result % math)

Measured memory_bytes: 14008
def solve(d, c, s):
    return [1]*d


def main():
    d = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for i in range(d)]
    answer = solve(d, c, s)
    print(*answer, sep='\n')


if __name__ == "__main__":
    main()


Measured memory_bytes: 9500
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

// constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
// constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VVI d(n,VI(2));
    REP(i,0,n) REP(j,0,2) cin >> d[i][j];
    REP(i,2,n) {
        bool b = true;
        REP(j,0,3) {
            if (d[i-j][0] != d[i-j][1]) {
                b = false;
                break;
            }
        }
        if (b == true) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

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

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (ll i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using ld=long double;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
const long double PI = acos(-1.0);
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){//cout<<fixed<<setprecision(20);
  string a="ACL";
  int k;
  cin>>k;
  string ans="";
  rep(i,0,k){
    ans+=a;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//--<for debugging>
#define whatis(x) cout << #x << " is " << x<<" ";
#define whatisl(x) cout << #x << " is " << x<<"\n";
#define parr(array,end)for(ll loop=0;loop<end;loop++)cout<<array[loop]<<" ";cout<<"\n";
#define lline cout<<"\n";
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"\n";}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"___";}
    
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a <<" , ";
    err(++it, args...);
}
//--</for debugging> 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define testcase ll tt; cin >> tt; while(tt--)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define vars ll h,i,j,k,d,l,p,q,r,x,y,a,b,c,v,var,n,m,z,s,ans,ind1,ind2,flag,limit1,limit2,limit3,mod;
#define vll vector<ll>
#define pll pair<ll,ll>
#define sll set<ll>
#define pint pair<int,int>
const ll INF=1e9+7;
const ll MOD=1e9+7;
int main()
{
    boost vars
    cin>>n>>m;
    ans=0;
    ll arr[n],maxi[n]={0};
    for(i=0;i<n;i++)cin>>arr[i];
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        x--;y--;
        maxi[x]=max(maxi[x],arr[y]);
        maxi[y]=max(maxi[y],arr[x]);
    }
    for(i=0;i<n;i++)if(maxi[i]<arr[i])ans++;
    cout<<ans;
}

Measured memory_bytes: 5204
import java.util.*;

public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        while(true){
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
            
            if(("?").equals(op)){
                break;
            }else{
                if((op).equals("+")){
                    System.out.println(a + b);
                }else if((op).equals("-")){
                    System.out.println(a - b);
                }else if((op).equals("*")){
                    System.out.println(a * b);
                }else{
                    System.out.println(a / b);
                }
                
            }
        }
    }
}


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

int main () {
  char c;
  cin >> c;
  
  bool A = c == 'a';
  bool B = c == 'e';
  bool C = c == 'i';
  bool D = c == 'o';
  bool E = c == 'u';
  
   if (A || B || C || D || E) {
     cout << "vowel" << endl;
   }
   else {
     cout << "consonant" << endl;
   }

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  map<string, int> mp;
  cin >> n;
  REP(i, n) {
    string s;
    cin >> s;
    mp[s]++;
  }

  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: 3660
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * 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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char x = in.nextString().toCharArray()[0];
            char y = in.nextString().toCharArray()[0];
            out.println(x < y ? "<" : x > y ? ">" : "=");
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 23508
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int a[] = new int[n];

		if (n % 2 == 0) {
			int k = n / 2;
			int g = n / 2 - 1;
			for (int i = 1; i <= n; i++) {
				if (i % 2 == 1) {
					a[k] = scanner.nextInt();
					k++;
				} else {
					a[g] = scanner.nextInt();
					g--;
				}
			}
		} else {
			int k = n / 2;
			int g = n / 2 + 1;
			for (int i = 1; i <= n; i++) {
				if (i % 2 == 1) {
					a[k] = scanner.nextInt();
					k--;
				} else {
					a[g] = scanner.nextInt();
					g++;
				}
			}
		}

		for (int tar : a) {
			System.out.println(tar);
		}

	}
}

Measured memory_bytes: 93996
n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(1,len(p)-1):
    if (p[i-1]<p[i] and p[i] < p[i+1]) or (p[i-1] > p[i] and p[i] > p[i+1]):
        count+=1

print(count)

Measured memory_bytes: 3060
def main():
    N,D = map(int,input().split())
    X = [0 for i in range(N)]
    Y = [0 for i in range(N)]
    for i in range(N):
        X[i],Y[i] = list(map(int,input().split()))
    
    ans = 0
    for i in range(N):
        if (X[i]**2+Y[i]**2)**0.5 <= D:
            ans += 1
    
    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 24756
#include<bits/stdc++.h>
using namespace std;
#define V vector
#define L long long
#define W V<L>
#define R(n) for(L i=0;i<n;i++)
W S(V<W>&p,L E){if(!E){return{1,0};}V<V<W>>T(2);for(W x:p){T[x[1]&1].push_back({x[0]/2,x[1]/2});if(x[0]&1){T[(x[1]+1)&1].push_back({x[0]/2,(x[1]+1)/2});}}R(2){L c=0;for(W x:T[!i]){L Q=(2*x[0]+x[1])%3;c^=(Q+1);}if(!c){W A=S(T[i],E-1);A[0]*=2;A[1]*=2;A[1]+=i;return A;}}for(W&v:p){v[0]++;}W A=S(p,E);A[0]--;return A;}
int main(){L M=2e17;L n;cin>>n;V<W>p(n);R(n){L a,b;cin>>a>>b;p[i]={a+M,b+M};}W Q=S(p,70);cout<<Q[0]-M<<" "<<Q[1]-M;}

Measured memory_bytes: 37052
import math
N, Y = map(int, input().split())
if Y % 1000 == 0:
    Y = Y // 1000
else:
    print('-1,-1,-1')
    exit()
for i in range(Y // 10 + 1):
    for j in range((Y-i*10) // 5 + 1):
        if i * 10 + j * 5 + (N - i - j) == Y and N-i-j >= 0:
            print(i, j, (N - i - j))
            exit()
print(-1, -1, -1)


Measured memory_bytes: 3188
S = input()
T = input()
MIS = len(S)
for TS in range(0,len(S)-len(T)+1):
    LS = S[TS:TS+len(T)]
    Count = sum(True if LS[TT]!=T[TT] else False for TT in range(0,len(T)))
    MIS = min(MIS,Count)
print(MIS)

Measured memory_bytes: 8916
#include<stdio.h>
int main(void){
  int n,l,r,s,i;
  scanf("%d",&n);
  s=0;
  for(i=0;i<n;i++){
    scanf("%d%d",&l,&r);
    s=s+r-l+1;
  }
  printf("%d",s);
  return(0);
}

Measured memory_bytes: 128
n,m,x = map(int,input().split())

listA=[] #appendのために宣言が必要
for _ in range(n):
    listA.append(list(map(int,input().split())))

kanoucost = []
for i in range(2**n):
    ls = [0]*n
    for j in range(len(ls)):
        if (i >> j) & 1:
            ls[j] = 1
    ability = [0]*(m+1)
    for k in range(len(ls)):
        new = [n * ls[k] for n in listA[k]]
        ability = [x + y for (x, y) in zip(ability, new)]

    if min(ability[1:]) >= x:
        kanoucost.append(ability[0])

if kanoucost == []:
    print("-1")
else:
    print(min(kanoucost))

Measured memory_bytes: 9308
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <tgmath.h>
#include <time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))
#define mod 1000000007

double a, b;

main()
{
    scanf("%lf%lf", &a, &b);
    printf("%.7f\n", a * b / (a + b));
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<algorithm>
using namespace std;
long long gcd(long long m,long long n){
    if(n==0){
        return m;
    }else{
        return gcd(n,m%n);
    }
}
int main(void){
    long long N,i;
    cin>>N;
    long long A[N],B[N],C[N];
    for(i=0;i<N;i++){
        cin>>A[i];
        B[i]=0;C[i]=0;
    }
    B[0]=A[0];
    for(i=0;i<N-1;i++){
        B[i+1]=gcd(B[i],A[i+1]);
    }
    C[N-1]=A[N-1];
    for(i=N-2;i>-1;i--){
        C[i]=gcd(C[i+1],A[i]);
    }
    long long ans;
    ans=max(C[1],B[N-2]);
    for(i=1;i<N-1;i++){
        ans=max(ans,gcd(B[i-1],C[i+1]));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>

class Solver {
public:
    void solve();
};


void Solver::solve() {
    // 入力
	int n;
	std::cin >> n;
	int h[109];
	for (int i = 0; i < n; ++i) {
		std::cin >> h[i];
	}
	int count = 1;
	for (int i = 1; i < n; ++i) {
		bool flag = true;
		for (int j = 0; j < i; ++j) {
			if (h[j] > h[i])
				flag = false;
		}
		if (flag)
			count++;
	}
	std::cout << count << std::endl;
}

int main() {
    Solver solver = Solver();
    solver.solve();
    return 0;
}

Measured memory_bytes: 256
<?php
while (($input = trim(fgets(STDIN))) !== "0 0") {
	$height_width = explode(" ", $input);
	$height = $height_width[0];
	$width = $height_width[1];

	for ($i=0; $i < $height; $i++) { 
		for ($j=0; $j < $width; $j++) { 
			if(($j % 2 === 0 && $i % 2 === 0) || ($j % 2 !== 0 && $i % 2 !== 0))
				echo "#";
			else
				echo ".";
		}
		echo "\n";
	}
	echo "\n";
};

Measured memory_bytes: 6584
#include <bits/stdc++.h>
#define ll long long int
#define pr pair<ll, ll>
#define tp tuple<ll, ll, ll>
using namespace std;
long long int mod = 1e9 + 7;

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

    ll n, x, y;
    cin >> n >> x >> y;
    vector<ll> v[n + 1];
    ll ans[n + 1];
    memset(ans, 0, sizeof(ans));
    for (ll i = 1; i < n; i++)
    {
        v[i].push_back(i + 1);
        v[i + 1].push_back(i);
    }
    v[x].push_back(y);
    v[y].push_back(x);
    for (ll i = 1; i <= n; i++)
    {
        ll explored[n + 1];
        memset(explored, 0, sizeof(explored));
        queue<pr> q;
        q.push({i, 0});
        explored[i] = 1;
        while (!q.empty())
        {
            pr node = q.front();
            q.pop();
            ans[node.second]++;
            for (ll j = 0; j < (ll)v[node.first].size(); j++)
            {
                if (explored[v[node.first][j]] == 0)
                {
                    explored[v[node.first][j]] = 1;
                    q.push({v[node.first][j], node.second + 1});
                }
            }
        }
    }
    for (ll i = 1; i < n; i++)
        cout << ans[i] / 2 << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n;
    string s;cin>>s;
    stack<char> stk;
    ll req=0;
    for(ll i=0;i<s.size();i++){
        if(s[i]=='(')stk.push('(');
        else{
            if(stk.empty())req++;
            else stk.pop();
        }
    }
    while(!stk.empty())stk.pop(),s+=")";
    while(req-->0)cout<<"(";cout<<s;
}


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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

#include <cstdint>

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_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;
  }
};







using mint = modint<1000000007>;

int N;
vector<ll> C;



int main2(){
	
	cin >> N;
	C.resize(N);
	
	for ( int i = 0; i < N; i++ ){
		cin >> C[i];
	}
	sort(C.rbegin(), C.rend());
	
	
	vector<mint> pow(N+1);
	mint a = 1;
	for ( int i = 0; i <= N; i++ ){
		pow[i] = a;
		a *= 2;
	}
	
	// S と T の両方に (XOR T)をかけると、Sだけを考えて結果を2^N倍すればいい
	// 先にCを逆順にソートする  変更コストの軽いビットから順に変更する.
	// Ci の変更コストは Ciより手前に1のビットがj個あるとすると
	//   Σ COM(i,j)*(j+1)*2^(N-i-1)
	//   (2^i+i*2^(i-1))*2^(N-i-1)
	
	mint sum = 0;
	for ( int i = 0; i < N; i++ ){
		mint s = 0;
		mint powi1 = ((i==0) ? 0 : pow[i-1]);
		s = pow[i]+powi1*i;
		sum += s * C[i] * pow[N-i-1];
	}
	
	sum *= pow[N];
	
	return sum.value();
}

int main(){
	COMinit();
	int result = main2();
	cout << result << endl;
	return 0;
}




Measured memory_bytes: 15360
s=list(input())
t=list(input())
a=-1

for i in range(len(s)-len(t)+1):
    for j in range(len(t)):
        if s[j+i]!=t[j] and s[j+i]!='?':
            break
        if (s[j+i]==t[j] or s[j+i]=='?') and j==len(t)-1:
            a=i

if a<0:
    print('UNRESTORABLE')
else:
    for i in range(len(s)):
        if i>=a and i-a<len(t):
            s[i]=t[i-a]
        if s[i]=='?':
            s[i]='a'
    print(''.join(s))

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

using namespace std;

typedef long long ll;


bool f(long long l, long long r, long long a, long long b) {
    long long A = max(l, a);
    long long B = min(r, b);
    return B - A > 0;
}

int main() {
    long long A, B;
    long long C, D;

    long long N;
    cin >> N;
    cin >> A >> B >> C >> D;

    long long X = abs(A - B);
    for (int i = 0; i <= N - 1; i++) {
        long long L = C * i;
        long long R = D * i;
        long long U = (N - 1 - i) / 2;
        L -= U * (D - C);
        R += U * (D - C);
        if ((N - 1 - i) % 2 == 0) {
            if (L <= X && X <= R) {
                cout << "YES" << endl;
                return 0;
            }
        } else {

            if (f(L, R, X - D, X - C) || f(L, R, X + C, X + D)) {
                cout << "YES" << endl;
                return 0;
            }

        }
    }
    cout << "NO" << endl;
}


Measured memory_bytes: 256