akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<int, int>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w, k;
    cin, h, w, k;
    vector<string> S(h);
    REP(i, 0, h) {
        cin, S[i];
    }
    ll ans = 1LL << 30;
    REP(bit, 0, 1 << (h - 1)) {
        vector<vector<int>> cut;
        vector<int> tmp(w, 0);
        REP(i, 0, h) {
            REP(j, 0, w) {
                tmp[j] += S[i][j] == '1';
            }
            if (i + 1 == h || (bit >> i) & 1) {
                cut.push_back(tmp);
                tmp.assign(w, 0);
            }
        }
        ll cnt = 0;
        vector<int> a(cut.size(), 0);
        REP(i, 0, w) {
            bool ok = true;
            REP(j, 0, cut.size()) {
                if (a[j] + cut[j][i] > k) {
                    ok = false;
                }
            }
            if (!ok) {
                a.assign(cut.size(), 0);
                cnt++;
            }
            bool flag = false;
            REP(j, 0, cut.size()) {
                a[j] += cut[j][i];
                if (a[j] > k) {
                    cnt = 1LL << 30;
                    flag = true;
                    break;
                }
            }
            if (flag) {
                break;
            }
        }
        dump(cut.size(), cnt);
        chmin(ans, (int)cut.size() + cnt - 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
<?php
$n = intval(trim(fgets(STDIN)));
$size = getSize($n);
if($size === false){
    echo "No";
}else{
    $num = 1;
    for($i = 1; $i <= $size; $i++){
        for($j = 1; $j <= $size-$i+1; $j++){
            $map[$i][$j] = $num++;
        }
    }
    echo "Yes\n";
    echo $size + 1,"\n";
    for($i = 1; $i <= $size; $i++){
        echo $size," ";
        for($j = 1; $j <= $size; $j++){
            echo $map[min($i,$size+1-$j)][min($j, $size+1-$i)];
            if($j != $size)echo " ";
        }
        echo "\n";
    }
    echo $size," ";
    for($i = 1; $i <= $size; $i++){
        echo $map[$i][$size+1-$i];
        if($i != $size)echo " ";
    }
    echo "\n";
}

function getSize($n){
    for($i = 1; $i < 10000; $i++){
        if($n == ($i*($i+1)/2)){
            return $i;
        }
    }
    return false;
}

Measured memory_bytes: 11896
#include<bits/stdc++.h>
using namespace std;
const long long maxn=1005;
const long long inf=0x3f3f3f3f;
long long dp[maxn][maxn]; 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	long long k;
	cin>>k;
	for(long long i=0;i<=9;i++)
		dp[1][i]=1;
	for(long long i=2;i<=10;i++)
		for(long long j=0;j<=9;j++)
			dp[i][j]=dp[i-1][j]+dp[i-1][j-1]+dp[i-1][j+1];
	long long l,r,flag=0;
	for(long long i=1;i<=10;i++)
	{
		for(long long j=1;j<=9;j++)
		{
			if(dp[i][j]>=k)
			{
				l=i;
				r=j;
				flag=1;
				break;
			}
			k-=dp[i][j];
		}
		if(flag==1)
			break;
	}
	queue<long long> q;
	q.push(r);
	for(int i=l-1;i>=1;i--)
	{
		if(dp[i][r-1]>=k)
		{
			r--;
			q.push(r);
		}
		else
		{
			k-=dp[i][r-1];
			if(dp[i][r]>=k)
				q.push(r);
			else
			{
				k-=dp[i][r];
				r++;
				q.push(r);
			}
		}
	}
	while(!q.empty())
	{
		cout<<q.front();
		q.pop();
	}
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

int main()
{
    int n;
    cin >> n;
    double odd = 0;
    for(int i = 1; i <= n; i++){
        if(i % 2 == 1){
            odd++;
        }
    }
    double k = n;
    cout << odd/k;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(n,a) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265


void f(int n,int m){
  int a[1000000];
  rep(i,n){
    cin>>a[i];
  }
  a[n]=0;

  vector<int> b;
  rep(i,n+1){
    FOR(j,i,n+1){
      b.push_back(a[i]+a[j]);
    }
  }
  sort(all(b));
  int ans = 0;

  for(int c : b){
    if(c>m) continue;
    int x =*(lower_bound(b.begin(),b.end(),m-c)-1);
    ans = max(ans,x+c);
  }

  cout<<ans<<endl;

}
int main(){
  int n,m;
  while(1){
    cin>>n>>m;
    if(n==0) break;
    f(n,m);
  }
}


Measured memory_bytes: 6840
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean isPrime = false;
		n--;
		while2: while(!isPrime) {
			n++;
			for(int i=2;i<=Math.sqrt(n);i++) {
				if(n % i == 0) {
					continue while2;
				}
			}
			System.out.println(n);
			return;

		}
	}

}


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

int main() {
  int N;
  char S;
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> S;
    if (S == 'Y') {
      break;
    }
  }

  if (S == 'Y') {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray()[0];
            var Hi = Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();
            if(N==1)
            {
                Console.WriteLine("Yes");
                return;
            }

            for(var i = N-1;0<i;i--)
            {
                if (Hi[i - 1] > Hi[i])
                {
                    Hi[i-1]--;
                }
                if (Hi[i - 1] > Hi[i])
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 31452
#include <stdio.h>

int rot[24][7] = {
	{ 0,1,2,3,4,5,6 },{ 0,1,3,5,2,4,6 },{ 0,1,4,2,5,3,6 },{ 0,1,5,4,3,2,6 },
	{ 0,2,6,3,4,1,5 },{ 0,2,3,1,6,4,5 },{ 0,2,1,4,3,6,5 },{ 0,2,4,6,1,3,5 },
	{ 0,3,1,2,5,6,4 },{ 0,3,2,6,1,5,4 },{ 0,3,5,1,6,2,4 },{ 0,3,6,5,2,1,4 },
	{ 0,4,1,5,2,6,3 },{ 0,4,2,1,6,5,3 },{ 0,4,5,6,1,2,3 },{ 0,4,6,2,5,1,3 },
	{ 0,5,1,3,4,6,2 },{ 0,5,3,6,1,4,2 },{ 0,5,4,1,6,3,2 },{ 0,5,6,4,3,1,2 },
	{ 0,6,2,4,3,5,1 },{ 0,6,3,2,5,4,1 },{ 0,6,5,3,4,2,1 },{ 0,6,4,5,2,3,1 } };
int assign[7];

int main()
{
	int i, j;
	int a[7], b[7], dice[7];

	for (i = 1; i <= 6; i++) scanf("%d", assign+i);
	for (i = 1; i <= 6; i++) scanf("%d", a+i);
	for (j = 0; j < 24; j++) {
		for (i = 1; i <= 6; i++) dice[i] = rot[j][i];
		for (i = 1; i <= 6; i++) b[i] = assign[dice[i]];
		for (i = 1; ; i++) {
			if (i > 6) { puts("Yes"); return 0; }
			if (a[i] != b[i]) break;
		}
	}
	puts("No");
	return 0;
}


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

from typing import *



# def solve(a: int, b: int, c: int, d: int) -> int:
def solve(a, b, c, d):
    ans=[a*c, a*d, b*c, b*d]
    return max(ans)

def main():
    a, b, c, d = map(int, input().split())
    a1 = solve(a, b, c, d)
    print(a1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 10260
import sys
input=sys.stdin.readline
sys.setrecursionlimit(200000)
n=int(input())
l=[int(input()) for i in range(n-1)]
d=[[] for i in range(n+1)]
for i,j in enumerate(l,2):
    d[j].append(i)
l.clear()
def f(a):
    if len(d[a])==0:
        return 0
    l=[f(i) for i in d[a]]
    l.sort(reverse=True)
    return max([i+l[i]+1 for i in range(len(l))])
print(f(1))

Measured memory_bytes: 251528
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,x,y,d,sum=0;
	int n[200];
	int minv=1000;
	cin>>a>>b;
	for(int i=1;i<=a;i++){
		n[i-1]=i+b-1;
		sum+=n[i-1];
	}
	for(int i=0;i<a;i++)
	{
	  x=max(n[i],0);
		y=min(n[i],0);
		d=x-y;
		minv=min(minv,d);
	}
	for(int i=0;i<a;i++)
		if(n[i]==minv)
		{
			cout<<sum-minv<<endl;
			return 0;
		}
	cout<<sum+minv<<endl;
	return 0;
}

Measured memory_bytes: 384
from collections import deque

def push(a, d, x):
    if d == 0: a.appendleft(x)
    elif d == 1: a.append(x)
def randomAccess(a, p):
    print(a[p])
def pop(a, d):
    if d == 0: _=a.popleft()
    elif d == 1: _=a.pop()

a = deque()
q = int(input())
for _ in range(q):
    query = list(map(int, input().split()))
    if query[0]==0: push(a, query[1], query[2])
    elif query[0]==1: randomAccess(a, query[1])
    elif query[0]==2: pop(a, query[1])
        
    


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, tmp, cnt = 0;
  string s;
  bool b[26] = {};
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    tmp = 0;
    for (int j = 0; j < i; j++) {
      b[s[j] - 'a'] = true;
    }
    for (int j = i; j < n; j++) {
      if (b[s[j] - 'a']) {
        tmp++;
        b[s[j] - 'a'] = false;
      }
    }
    cnt = max(cnt, tmp);
  }
  cout << cnt << '\n';
  return 0;
}


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


/**
 * AIZU ONLINE JUDGE
 * 0641
 *  2020/5/5
 */
public class Main {


    boolean main() throws IOException {

        Scanner sc = new Scanner(systemin);

        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();

        int k1 = (N + A - 1) / A * B;
        int k2 = (N + C - 1) / C * D;
        result.printf("%d\n",  Math.min(k1, k2));

        sc.close();
        return false;
    }



    PrintStream log;
    PrintStream result = System.out;
    BufferedReader systemin;

    static Main instance = new Main();

    Main() {
        systemin = new BufferedReader(new InputStreamReader(System.in));
        log = new PrintStream(new OutputStream() { public void write(int b) {} } );
    }

    public static void main(String[] args) throws IOException {

        instance.main();
        instance.systemin.close();
    }


}




Measured memory_bytes: 26560
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define len(x) ((int)(x).size())
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long ll;

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

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

int main(){

	fastio;
    ll sum = 0;
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
    	if(i%3 == 0 or i%5 == 0) continue;
    	else{
    		sum += i;
    	}
    }
	cout << sum << '\n';
	return 0;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;

template <class T>
class Dijkstra {
 public:
  Dijkstra(int node_size) : node_size_(node_size) { Initialize(); }
  void Add_Edge(int from, int to, T cost) {
    graph_[from].push_back({to, cost});
  }
  void Solve(int source) {
    std::priority_queue<std::pair<T, int>, std::vector<std::pair<T, int>>,
                        std::greater<std::pair<T, int>>> pq;
    distance_[source] = 0;
    pq.push({0, source});

    while (!pq.empty()) {
      std::pair<T, int> top = pq.top();
      pq.pop();
      int v = top.second;
      if (distance_[v] < top.first) continue;
      for (const auto& e : graph_[v]) {
        if (distance_[e.to] > distance_[v] + e.cost) {
          distance_[e.to] = distance_[v] + e.cost;
          pq.push({distance_[e.to], e.to});
        }
      }
    }
  }
  T operator[](int to) const { return distance_[to]; }

 private:
  struct edge {
    int to;
    T cost;
  };
  int node_size_;
  std::vector<T> distance_;
  std::vector<std::vector<edge>> graph_;
  void Initialize() {
    distance_.assign(node_size_, std::numeric_limits<T>::max() / 2);
    graph_.resize(node_size_);
  }
};

template<class T> inline void fastin(T &num) {
  bool negative = false;
  T c;
  num = 0;
  c = getchar_unlocked();
  if (c == '-') {
    negative = true;
    c = getchar_unlocked();
  }
  for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num << 3) + (num << 1) + c - 48;
  if (negative) num *= -1;
}

int main() {
  int n, u, v; fastin(n); fastin(u); fastin(v);
  --u; --v;

  Dijkstra<int> dij_t(n);
  Dijkstra<int> dij_a(n);

  for (int i = 0; i < n - 1; ++i) {
    int a, b; fastin(a); fastin(b);
    --a; --b;
    dij_a.Add_Edge(a, b, 1);
    dij_a.Add_Edge(b, a, 1);
    dij_t.Add_Edge(a, b, 1);
    dij_t.Add_Edge(b, a, 1);
  }

  dij_t.Solve(u);
  dij_a.Solve(v);

  int mx = -1;
  int ans = 0;

  for (int i = 0; i < n; ++i) {
    if (dij_t[i] < dij_a[i] && dij_a[i] > mx) {
      mx = dij_a[i];
      ans = dij_a[i] - 1;
    }
  }

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

  return 0;
}

Measured memory_bytes: 13464
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //c
  long long x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  long long to_p = x % d;
  long long to_n = to_p - d;
  if ((x - to_p) / d >= k) {
    cout << (x - k * d) << endl;
    return 0;
  }
  long long cp = (x - to_p) / d;
  long long cn = (x - to_n) / d;
  long long ans = abs(x - k * d);
  if (cp <= k) {
    if ((k - cp) % 2 == 0) ans = min(ans, abs(to_p));
  }
  if (cn <= k) {
    if ((k - cn) % 2 == 0) ans = min(ans, abs(to_n));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3648
// header {{{
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <complex>
#include <utility>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;

#define ALPHABET    26
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)
#define INF         1000000005

typedef long long ll;
typedef unsigned long long ull;
// }}}
// number {{{
#define SIZE 1000005
#define MOD  1000000007LL

// べき乗
// verified AOJ NTL_1_B
ll pow(ll a, ll b) {
    if(b == 0) return 1;
    ll aa = pow(a, b/2);
    return aa*aa%MOD*(b%2 == 1 ? a : 1)%MOD;
}

// 階乗と階乗の逆元
// ARC077D
ll fact[SIZE] = {1, 1};
ll finv[SIZE] = {1, 1};

void initFact() {
    // fact
    for(ll i=2;i<SIZE;i++){
        fact[i] = fact[i-1]*i%MOD;
    }

    // finv
    finv[SIZE-1] = pow(fact[SIZE-1], MOD-2);
    for(ll i=SIZE-1;i>=3;i--){
        finv[i-1] = finv[i]*i%MOD;
    }
}

// 組み合わせの数
// ARC077D
ll comb(int n, int r) {
    if(r > n) return 0;
    return fact[n]*(finv[r]*finv[n-r]%MOD)%MOD;
}

// 最小公約数
ll gcd(ll x, ll y) {
    return y ? gcd(y, x%y) : x;
}

// 素数判定 (エラトステネスのふるい)
bool isPrime[SIZE];
void initIsPrime() {
    for(int i=0;i<SIZE;i++){
        isPrime[i] = true;
    }
    isPrime[0] = false;
    isPrime[1] = false;
    for(int i=2;i*i<=SIZE;i++){
        if(isPrime[i]){
            for(int j=i*i;j*j<=SIZE;j+=i){
                isPrime[j] = false;
            }
        }
    }
}

// 素因数分解
// verified AOJ NTL_1_A
vector<pair<int, int>> factor(int n) {
    vector<pair<int, int>> ret;
    for(int i=2;i*i<=n;i++){
        if(isPrime[i]){
            int count = 0;
            while(n%i == 0){
                count++;
                n /= i;
            }
            if(count > 0){
                ret.push_back({i, count});
            }
        }
    }
    if(n != 1){
        ret.push_back({n, 1});
    }
    return ret;
}
//}}}

int main() {
    initFact();
    ll H, W, A, B;cin >> H >> W >> A >> B;
    ll ans = 0;
    for(ll i = B+1;i<=W;i++){
        ans += comb(H-A+i-2LL, i-1)*comb(A+W-i-1LL, A-1) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15872
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()

int main() {
    ll A,B,C;
    scanf("%lld%lld%lld",&A,&B,&C);
    if (C <= A+B+1)
        printf("%lld\n",B+C);
    else
        printf("%lld\n",A+B+1+B);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(A) for A in input().split()]
cnt = 0
for i in range(N):
    A_min = i
    for j in range(i, N):
        if A[A_min] > A[j]:
            A_min = j
    if i != A_min:
        t = A[i]
        A[i] = A[A_min]
        A[A_min] = t
        cnt += 1

for i in range(N):
    if i == N - 1:
        print(A[i])
    else:
        print("{}".format(A[i]), end=' ')

print(cnt)

Measured memory_bytes: 7728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please


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

	int N, M;
	cin >> N >> M;

	co((N - 1)*(M - 1));

	Would you please return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include <string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<math.h>

#define ok printf("ok\n");
#define MAX 1000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define pb push_back

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

int main()
{
	int X,A,B;
	cin >> X >> A >> B;
	if((A-B)>=0)
		puts("delicious");
	else if((B-A)>=(X+1))
		puts("dangerous");
	else
		puts("safe");
 
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>
#include<set>
#include<vector>
using namespace std;

int n = 100010;
vector<int> prime;
void eratos(){
  prime = vector<int>(n, 0);
  prime[1]=1;
  for(int i=2; i<n; i++){
    if(prime[i]!=0) continue;
    for(int j=1; j*i<n; j++){
      prime[i*j] = i;
    }
  }
  /*
  for(int i=0; i<n; i++){
    cout << i << " " << prime[i] << endl;
  }*/
}

int solve(){
  vector<int> div(n, 0);
  eratos();

  for(int i=0; i<2; i++){
    int inp;  cin >> inp;
    vector<int> tmp(n, 0);
    while(inp>1){
      tmp[prime[inp]]++;
      inp/=prime[inp];
    }
    for(int j=0; j<n; j++)  {
      div[j]=max(div[j], tmp[j]);
    }
  }
  long long ans=1;
  for(int i=2; i<n; i++) ans*= pow(i, div[i]);

  cout << ans << endl;
}

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


Measured memory_bytes: 1408
#include <stdio.h>

int main(void){
	int N,T;
	int c[100],t[100];
	int n = 0;
	int c_good = 1001;

	scanf("%d %d",&N,&T);

	while(scanf("%d %d",&c[n],&t[n]) != EOF){
		n++;
	}

	for(int i=0;i<=n;i++){
		if(T >= t[i] && t[i] >= 1 && t[i] <= 1000){
			if(c_good > c[i] && c[i] >= 1 && c[i] <= 1000){
				c_good = c[i];
			}
		}
	}

	if (c_good == 1001){
		printf("TLE\n");
	}else{
		printf("%d\n",c_good);
	}
	return 0;
}

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

int main(){
 vector<int>vec(3);
  for(int i = 0; i < 3 ;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  cout << 10 * vec.at(2) + vec.at(0) + vec.at(1);
}

                  
                 
                

Measured memory_bytes: 256
import sys

while True:
    n = int(input())
    if n == 0:
        break;
    x = {}
    for i in range(n):
        k,v = input().split()
        x[k] = v
    y = []
    for i in range(int(input())):
        a = sys.stdin.readline().rstrip()
        if a in x:
            y.append(x[a])
        else:
            y.append(a)
    print(''.join(y))

Measured memory_bytes: 8604
#include<iostream>
using namespace std;
int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    for(int i = 0; i < k; i++){
        if(i % 2 == 0){
            if(a % 2 == 1) a -= 1;
            b += a / 2;
            a /= 2;
        }
        else{
            if(b % 2 == 1) b -= 1;
            a += b / 2;
            b /= 2;
        }
    }
    cout << a << ' ' << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a,b,d,r;
    double f;
    scanf("%d%d", &a, &b);
    d=a/b;
    r=a%b;
    f=(double)a/b;

    printf("%d %d %f", d, r, f);

    return 0;
}



Measured memory_bytes: 2084
import sys
l,r = map(int,input().split())
a=[]

for i in range(l,r):
	for j in range(i+1,r+1):
		a.append((i*j)%2019)

		if (i*j)%2019 == 0:
			print(0)
			sys.exit()
print(min(a))

Measured memory_bytes: 6888
#include<iostream>
#include<fstream>

using namespace std;

#define MAX 1000000

int ans[MAX];
int ans_odd[MAX];

int square(int n){
    return n * (n + 1) * (n + 2) / 6;
}

int calc(int n){

    if(ans[n] != MAX)return ans[n];


    int num = 0;
    while(square(num) <= n){
        ans[square(num)] = 1;
        num++;
    }
    num--;

    for(int i = num; i > 0; i--){
        int tmp = calc(n - square(i));
        if(ans[n] > tmp + 1)ans[n] = tmp + 1;
    }

    return ans[n];
}

int calcOdd(int n){
    if(ans_odd[n] != MAX)return ans_odd[n];


    int num = 1;
    while(square(num) <= n){
        ans_odd[square(num)] = 1;
        num+=4;
    }
    num-=4;

    for(int i = num; i > 0; i-=4){
        int tmp = calcOdd(n - square(i));
        if(ans_odd[n] > tmp + 1)ans_odd[n] = tmp + 1;
    }

    return ans_odd[n];
}

int main(){
//    ifstream fin("in.txt");
    int n = 0;

    for(int i = 0; i < MAX; i++){
        ans[i] = ans_odd[i] = MAX;
    }


    while((cin >> n), n){

        cout << calc(n) << " " << calcOdd(n) << endl;
    }

    return 0;
}

Measured memory_bytes: 10896
from fractions import gcd
import numpy as np
n = int(input())
a = list(map(int, input().split()))
l = np.zeros(n)
r = np.zeros(n+1)
r[n] = 0
for i in range(n):
    if i == 0:
        l[0] = 0
    else:
        l[i] = gcd(l[i-1],a[i-1])
for j in range(n-1, -1, -1):
        r[j] = gcd(r[j+1],a[j])
m = 0
for i in range(n):
    m = max(gcd(l[i],r[i+1]),m)
print(int(m))

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

int main(){
  int N, K;
  cin >> N >> K;
  std::vector<int> l(N);
  for (int i = 0; i < N; i++) {
    cin >> l.at(i);
  }
  sort(l.begin(), l.end());
  int ans=0;
  for (int i = N-1; i > N-1-K; i--) {
    ans += l.at(i);
  }
  cout << ans << endl;
}


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

int main(){
    int n;
    cin >> n;
    int L[n][3];
    int T[n];
    int cnt = 0;
    int C,S,F;

    rep(i,n-1){
        cin>>C>>S>>F;
        L[i][0]=C;
        L[i][1]=S;
        L[i][2]=F;
    }
    rep(i,n-1){
        for(int j=i; j<n-1; j++){
            if(j==i){
                cnt = L[i][0]+L[i][1];
            }
            else{
                if(cnt<L[j][1]){
                    cnt=L[j][1];
                }

                if(cnt%L[j][2]!=0){
                    cnt+=L[j][2]-cnt%L[j][2];
                }
                cnt+=L[j][0];
            }
        }

        cout << cnt << endl;
        cnt=0;
    }
    cout << 0 << endl;
    return 0 ;
}

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

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll sum = 0;
    ll r = 0;
    ll ans = 0;
    for (ll l = 0; l < n; l++)
    {
        while (r < n && (sum ^ a[r]) == sum + a[r])
        {
            sum += a[r];
            r++;
        }
        // cout << l << ' ' << r << endl;
        ans += r - l;
        if (r == l)
        {
            r++;
        }
        else
        {
            sum -= a[l];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
n,m,k = map(int, input().split())
a_li = list(map(int, input().split()))
b_li = list(map(int, input().split()))

a_li = [0] + a_li
b_li = [0] + b_li

time = 0
ans = 0
a = 0
temp = 0

a_wa = [0] * (n+10)
b_wa = [0] * (m+10)

s = 0
for i in range(n+1):
    s += a_li[i]
    a_wa[i] = s

s = 0
for i in range(m+1):
    s += b_li[i]
    b_wa[i] = s
    

for i in range(n+1):
    for j in range(max(min(temp-i, m), 0), m+1):
        time = a_wa[i] + b_wa[j]
        if time <= k:
            ans = max(ans, i+j)
            temp = ans
        else:
            break
            
print(ans)


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

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  int t,ans=0;
  for(int i=0;i<n;i++){
    cin>>t;
    if(t<a || b<=t) ans++;
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
for e in iter(input,'0 0'):
 a,b=map(int,e.split())
 m=[[0]*b for _ in[0]*a]
 for _ in[0]*int(input()):
  i,j=map(int,input().split())
  m[~-i][~-j]=-1
 for s in range(a):
  for t in range(b):
   u,v=m[s-1][t],m[s][t-1]
   m[s][t]=(u*(u>0)+v*(v>0))*(m[s][t]!=-1)+(s+t==0)
 print(m[~-a][~-b])


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll K;
    cin >> N >> K;
    vec<ll> A,B;
    ll z = 0;
    for(int i=0;i<N;i++){
        ll a;
        cin >> a;
        if(a>0) A.push_back(a);
        else if(a<0) B.push_back(-a);
        else z++;
    }
    ll n = A.size(),m = B.size();
    if(n*m<K && K<=n*m+(N-z)*z+z*(z-1)/2){
        cout << 0 << "\n";
        return 0;
    }

    auto solve1 = [&](){
        sort(A.begin(),A.end());
        sort(B.begin(),B.end());
        //x以上の数
        auto ok = [&](ll x){
            ll res = 0;
            ll r = m;
            for(int i=0;i<n;i++){
                while(r>=1 && B[r-1]*A[i]>x) r--;
                res += (m-r);
            }
            return res<K;
        };
        
        ll l = 0,r = 1e18+1;
        while(l+1<r){
            ll m = (l+r)>>1;
            (ok(m)? r:l) = m;
        }
        cout << -r << "\n";
    };

    auto solve2 = [&](){
        sort(A.begin(),A.end());
        sort(B.begin(),B.end());
        //x以上の数がいくつあるか
        auto ok = [&](ll x){
            ll res = 0;
            ll r = n;
            for(int i=0;i<n;i++){
                while(r>=1 && A[i]*A[r-1]>x) r--;
                res += (n-r);
            }
            r = m;
            for(int i=0;i<m;i++){
                while(r>=1 && B[i]*B[r-1]>x) r--;
                res += m-r;
            }
            for(int i=0;i<n;i++) res -= (A[i]*A[i]>x);
            for(int i=0;i<m;i++) res -= (B[i]*B[i]>x);
            return res/2>n*(n-1)/2+m*(m-1)/2-K;
        };
        
        ll l = 0,r = 1e18+1;
        while(l+1<r){
            ll m = (l+r)>>1;
            (ok(m)? l:r) = m;
        }
        cout << r << "\n";
    };
    if(K<=n*m) solve1();
    else{
        K -= n*m+(N-z)*z+z*(z-1)/2;
        solve2();
    }
}

Measured memory_bytes: 2420
#include <iostream>
#include <cmath>
#include <vector>
#include <complex>
#include <cstdio>

using namespace std;

typedef complex<double> P;

#define EPS (1e-8)

int main() {
  int n;
  while(cin >> n && n) {
    vector<P> c;
    for(int i=0; i<n; i++) {
      double x, y;
      scanf("%lf,%lf", &x, &y);
      c.push_back(P(x, y));
    }
    
    vector<P> p;
    for(int i=0; i<n-1; i++) {
      for(int j=i+1; j<n; j++) {
	if(norm(c[i]-c[j]) <= 4.0 + EPS) {
	  P cent = (c[i]+c[j]) / 2.0;
	  double len = sqrt(1.0 - norm(c[i]-cent));
	  double ang = arg(c[i]-c[j]);
	  P p1 = cent + polar(len, ang + M_PI/2);
	  P p2 = cent + polar(len, ang - M_PI/2);
	  p.push_back(p1);
	  p.push_back(p2);
	}
      }
    }
    
    int const N = p.size();
    int res = 1;
    for(int i=0; i<N; i++) {
      int cnt = 0;
      for(int j=0; j<n; j++)
	if(norm(p[i]-c[j]) <= 1.0 + EPS)
	  cnt ++;
      res = max(res, cnt);
    }
    
    cout << res << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1396
#include <stdio.h>
#include <math.h>
int main(void) {
	double x1,x2,y1,y2;
	scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
	printf("%lf\n",hypot(fabs(x1-x2),fabs(y1-y2)));
	return 0;
}


Measured memory_bytes: 2032
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <random>
#include <fstream>
#include <time.h>
// #define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;

int n,m;
int a[20];
int l[10] = {0,2,5,5,4,5,6,3,7,6};
string dp[10100];

string maxstr(string a, string b) {
  if(a.size() > b.size()) {
    return a;
  } else if(a.size() < b.size()) {
    return b;
  } else if(a > b){
    return a;
  } else {
    return b;
  }
}

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

  cin>>n>>m;
  rep(i,m) {
    cin>>a[i];
  }
  rep(i,n+1) {
    dp[i] = "#";
  }
  dp[0] = "";
  FOR(i, 1, n+1) {
    rep(j,m) {
      if(i - l[a[j]] >= 0 && dp[i - l[a[j]]] != "#") {
        dp[i] = maxstr(dp[i],dp[i - l[a[j]]] + to_string(a[j]));
      }
    }
  }
  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 32000
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define len(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pll;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
template<typename T>
inline T mod(T n, T mod){ T res = n%mod; if(res < 0) res += mod; return res; }

/// command for char arrays with spaces -> scanf(" %[^\n]", text);
 
////////////////////////// Solution starts below. //////////////////////////////

const ll md = 1e9+7;
const ll MAX = 1e6+5;
ll p[MAX], power[MAX];

void sieve(){
	for(ll i = 2; i < MAX; i++){
		if(p[i] == -1){
			p[i] = i;
			for(ll j = i+i; j < MAX; j += i){
				if(p[j] == -1) p[j] = i;
				else p[j] = min(p[j], i);
			}
		}
	}
}

ll expo(ll base, ll expoente){
	if(base == 0 or expoente == 0) return 1;
	ll x = expo(base, expoente/2);
	return (expoente&1 ? ((x*x)%md*base)%md : (x*x)%md);
}

int main(){
	fastio;
	memset(p, -1, sizeof p);
	sieve();
	int n;
	cin >> n;
	vector<ll> v(n);
	for(ll& x : v) cin >> x;
	for(int i = 0; i < n; i++){
		int aux = v[i];
		while(aux > 1){
			ll primo = p[aux];
			ll k = 0;
			while(aux%primo == 0){
				aux/=primo;
				k++;
			}
			power[primo] = max(power[primo], k);
		}
	}
	ll lcm = 1;
	for(int i = 1; i < MAX; i++){
		lcm = (lcm * expo(i, power[i]))%md;
	}
	ll sum = 0;
	for(int i = 0; i < n; i++){
		sum = (sum + (lcm * expo(v[i], md-2))%md)%md;
	}
	cout << sum << endl;
	return 0;
}

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

int main() {
	int s;
	int n[1000000], i, j;
	scanf("%d",&s);
	n[0]=s;
	for(i=0;;i++) {
		n[i+1]=(n[i]%2==0)?n[i]/2:3*n[i]+1;
		//printf("%d ",n[i]);
		for(j=0;j<i;j++) {
			if (n[j]==n[i]) {
				printf("%d\n",i+1);
				return 0;
			}
		}
	}
	return 0;
}


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

int main(){
  string s;
  cin >> s;
  int count1=0, count2=0;
  vector<char> v1(s.length(),'0');
  vector<char> v2(s.length(),'0');
  r(i,s.length()){if(i%2==0)v1.at(i)='1';}
  r(i,s.length()){if(i%2==1)v2.at(i)='1';}
  r(i,s.length()){if(s.at(i)!=v1.at(i))count1++;}
  r(i,s.length()){if(s.at(i)!=v2.at(i))count2++;}
  cout << min(count1,count2) << endl;
}

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

int bubbleSort(int A[],int n){
	int flag=1,t,k=0;
	while(flag){
		flag=0;
		for(int i=0;i<n-1;i++){
			if(A[i]>A[i+1]){
				t=A[i];
				A[i]=A[i+1];
				A[i+1]=t;
			    flag=1;
				k++;
			}
		}
	}
	return k;
}

void printArray(int A[],int n){
	for(int i=0;i<n-1;i++)
		cout<<A[i]<<" ";
	cout<<A[n-1]<<endl;
}

int main(){
	int n,A[100],time;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>A[i];
	time=bubbleSort(A,n);
	printArray(A,n);
	cout<<time<<endl;
	return 0;
}


Measured memory_bytes: 3112
n, m, x = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
A = [0]
B = [0]

for i in range(len(a)):
	A.append(A[-1] + a[i])
for i in range(len(b)):
	B.append(B[-1] + b[i])

y = len(B) - 1
ans = 0
for i in range(len(A)):
	while A[i] + B[y] > x:
		y -= 1
		if y == -1:
			break
	if y == -1:
		break
	if i + y > ans:
		ans = i + y

print(ans)


Measured memory_bytes: 47456
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    cin>>N>>K;
    if(((N-1)*(N-2)/2)<K){
        cout<<-1<<endl;
        return 0;
    }
    ll nofp = ((N-1)*(N-2)/2) - K;
    M =nofp +N - 1;
    cout<<M<<endl;//Mを出力
    reps(i,2,N+1){
        printf("%d %d\n",1,i);
    }
    int center = 2,to = 3;
    rep(i,nofp){
        printf("%d %d\n",center,to);
        if(to != N){
            ++to;
        }else{
            ++center;
            to = center + 1;
        }
    }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"errors"
	"fmt"
	"log"
	"os"
	"strconv"
)

var (
	errmsg2 = "value is too low"
	errmsg1 = "value is too large"
	N = 0
	a = 0
)

func main()  {

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	str := scanner.Text()
	i, _ := strconv.Atoi(str)
	N = i

	if N <= 999 && N >= 0 {
		a = N % 10

		switch a {
		case 2, 4, 5, 7, 9:
			fmt.Println("hon")

		case 0, 1, 6, 8:
			fmt.Println("pon")

		case 3:
			fmt.Println("bon")
		}
	}else {
		if err := doError(N); err != nil{
			switch err.Error() {
			case errmsg1:
				log.Fatalf(errmsg1)

			case errmsg2:
				log.Fatalf(errmsg2)
			}
		}
	}
}

func doError(a int) error{
	var b bool
	switch b {
	case a < 0:
		return errors.New(errmsg1)

	case a > 999:
		return errors.New(errmsg2)
	}
	return nil
}

Measured memory_bytes: 1816
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cout<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}


using int64 = long long;
using P = pair<int64,int64>;


int main() {
    vector<string> s(3);
    vector<string> player = {"A","B", "C"};

    for (int i=0; i<3; i++) cin >> s[i];
    for (int i=0; i<3; i++) reverse(s[i].begin(), s[i].end());

    int win = -1;
    int current = 0;
    while(true) {
        if (s[current].empty()) {
            win = current;
            break;
        }

        int next = s[current].back() - 'a';
        s[current].pop_back();
        current = next;
    }

    cout << player[win] << endl;
}

Measured memory_bytes: 512
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i + 100*j + 50*k == X:
                count += 1 
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

// #include <unordered_set>
// #include <unordered_map>

#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

#define pb push_back
#define mp make_pair

int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}

typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);


using namespace std;

#define N 1000000
int arr[N];
int a[N];
 
void eratosthenes(){
    REP(i,N){
        arr[i]=1;
    }
 
    for(int i=2;i<sqrt(N);i++){
        if(arr[i]){
            for(int j=0;i*(j+2)<N;j++){
                arr[i*(j+2)]=0;
            }
        }
    }
    arr[0]=0;
    arr[1]=0;
}

signed main(){
 
    string s;
    cin>>s;

    s[3]='8';
    cout<<s<<endl;



}

Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var s = bufio.NewScanner(os.Stdin)

func main() {
	s.Scan()
	a, _ := strconv.Atoi(s.Text())
	s.Scan()
	_, _ = strconv.Atoi(s.Text())
	s.Scan()
	_, _ = strconv.Atoi(s.Text())
	s.Scan()
	_, _ = strconv.Atoi(s.Text())
	s.Scan()
	e, _ := strconv.Atoi(s.Text())
	s.Scan()
	k, _ := strconv.Atoi(s.Text())
	if a+k < e {
		fmt.Println(":(")
		return
	}
	fmt.Println("Yay!")
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

int N;
int u[114514], v[114514], w[114514];

struct hen {
	int to;
	int len;
};

int edgeCount[114514];
struct hen* edges[114514];

void addEdge(int from, int to, int len) {
	edges[from] = realloc(edges[from], sizeof(*edges[from]) * (edgeCount[from] + 1));
	if (edges[from] == NULL) exit(2);
	edges[from][edgeCount[from]].to = to;
	edges[from][edgeCount[from]].len = len;
	edgeCount[from]++;
}

int yakusimaruhiroko[114514];

void dfs(int node, int color) {
	if (yakusimaruhiroko[node] == 0) {
		int i;
		yakusimaruhiroko[node] = color + 1;
		for (i = 0; i < edgeCount[node]; i++) {
			dfs(edges[node][i].to, edges[node][i].len % 2 == 0 ? color : 1 - color);
		}
	}
}

int main(void) {
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N - 1; i++) {
		if (scanf("%d%d%d", &u[i], &v[i], &w[i]) != 3) return 1;
		addEdge(u[i], v[i], w[i]);
		addEdge(v[i], u[i], w[i]);
	}
	dfs(1, 0);
	for (i = 1; i <= N; i++) {
		printf("%d\n", yakusimaruhiroko[i] - 1);
	}
	return 0;
}


Measured memory_bytes: 8192
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    String ans = "No";

    if(n % 10 == 7){
      ans = "Yes";
    } else if((n / 10) % 10 == 7){
      ans = "Yes";
    } else if(n / 100 == 7){
      ans = "Yes";
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 35780
import numpy as np
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
    
b = sorted(a,reverse=True)
maxa = b[0]
submaxa = b[1]
maxid = np.argmax(a)
for i in range(n):
    if i == maxid:
        print(submaxa)
    else:
        print(maxa)

Measured memory_bytes: 23352
# -*- coding:utf-8 -*-
import fractions

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if fractions.gcd(A,B) == 1:
    print(1)
else:
    print(len(factorization(fractions.gcd(A,B)))+1)

Measured memory_bytes: 5176
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))

n = 1
saw = [0] * N
now = 1

while True:
    if a[now-1] == 2:
        break
    else:
        if saw[a[now-1]-1] == 1:
            n = -1
            break
        else:
            now = a[now-1]
            saw[now-1] = 1
            n += 1

print(n)


Measured memory_bytes: 7884
#include<cstdio>
#include<iostream>
#include<cmath>
#include<map>
#include<queue>

using namespace std;
#define N 4
#define N2 16

static const int dx[4] ={0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r', 'u', 'l', 'd'};
int MDT[N2][N2];

struct Puzzle{
  int space, MD, cost, f[N2];

  bool operator < (const Puzzle &p) const{
    for(int i = 0 ; i < N2 ; i++){
      if(f[i] == p.f[i]) continue;
      return f[i] < p.f[i];
    }
    return false;
  }
};

struct State{
  Puzzle puzzle;
  int estimated;
  bool operator < (const State &s) const{
    return estimated > s.estimated;
  }
};

int getAllMD(Puzzle pz){
  int sum = 0;
  for(int i = 0 ; i < N2 ; i++){
    if(pz.f[i] == N2) continue;
    sum += MDT[i][pz.f[i] - 1];
  }
  return sum;
}

int astar(Puzzle s){
  priority_queue<State>PQ;
  s.MD = getAllMD(s);
  s.cost = 0;
  map<Puzzle, bool> V;
  Puzzle u, v;
  State initial;
  initial.puzzle = s;
  initial.estimated = getAllMD(s);
  PQ.push(initial);

  while(!PQ.empty()){
    State st = PQ.top();
    PQ.pop();
    u = st.puzzle;

    if(u.MD == 0) return u.cost;
    V[u] = true;

    int sx = u.space / N;
    int sy = u.space % N;

    for(int r = 0 ; r < 4 ; r++){
      int tx = sx + dx[r];
      int ty = sy + dy[r];
      if(tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
      v = u;

      v.MD -= MDT[tx * N + ty][v.f[tx * N + ty] - 1];
      v.MD += MDT[sx * N + sy][v.f[tx * N + ty] - 1];

      swap(v.f[sx * N + sy], v.f[tx * N + ty]);
      v.space = tx * N + ty;
      if(!V[v]){
        v.cost++;
        State news;
        news.puzzle = v;
        news.estimated = v.cost + v.MD;
        PQ.push(news);
      }
    }
  }

  return -1;
}


int main(){
  int i, j;

  for(i = 0 ; i < N2 ; i++)
    for(j = 0 ; j < N2 ; j++)
      MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);

  Puzzle in;

  for(i = 0 ; i < N2 ; i++){
    cin >> in.f[i];
    if(in.f[i] == 0){
      in.f[i] = N2;
      in.space = i;
    }
  }

  cout<< astar(in)<<endl;

  return 0;
}


Measured memory_bytes: 257644
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12);
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    int a, b;
    cin >> a >> b;
    int ans;
    ans = max(a + b, a - b);
    ans = max(ans, a * b);
    cout << ans << endl;
}



Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>

#define MAX 100000

int partition(int* A, int p, int r)
{
    int i, j, x;
    x = A[r];
    i = p - 1;
    for(j = p; j < r; j++){
		if(A[j] <= x){ i++; std::swap(A[i], A[j]); }
    }
	std::swap(A[i + 1], A[r]);

    return i + 1;
}

int main()
{
    int i, n, A[MAX], q;
    scanf("%d", &n);
    for(i = 0; i < n; i++) scanf("%d", &A[i]);

    q = partition(A, 0, n - 1);

    for(i = 0; i < q; i++){ printf("%d ", A[i]); }

    printf("[%d]", A[q]);

    for(i = q + 1; i < n; i++){ printf(" %d", A[i]); }

    printf("\n");

    return 0;
}

Measured memory_bytes: 1580
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 25, M = 1e6 + 25, oo = 1e9+7, mxmsk = 1 << 16;
const long long OO = 1e18+25;
#define par pair<pair<int,int>, int>
#define f first
#define s second
    
int x,a;

int main()
{
    scanf("%d%d",&x,&a);
    printf("%d",(x<a?0:10));
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <map>

using namespace std;

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(){
	cin.tie(0);                       
   	ios::sync_with_stdio(false);
   	string Sp,T;
   	cin >> Sp;
   	cin >> T;
   	int maxv,count = 0;
   	bool flag = false;
   	for(int i = Sp.length() - 1;i >= 0;i--){
   		if(Sp[i] == '?' or Sp[i] == T[T.length()-1]){
   			int tmp = 0;
   			int l = 0;
   			for(int j = T.length()-1;j >= 0;j--){
   				if(Sp[i - l] != '?' and Sp[i-l] != T[j]) break;
   				tmp = tmp + 1;
   				l = l + 1;
   			}
   			if(tmp == T.length()){
   				int l = 0;
   				for(int k = T.length()-1;k >= 0;k--){
   					Sp[i-l] = T[k];
   					l = l + 1;
   				}
   				flag = true;
   			}
   		}
   		if(flag) break;
	}
	if(flag){
		for(int i = 0;i < Sp.length();i++){
			if(Sp[i] == '?'){
				cout << "a";
			}else{
				cout << Sp[i];
			}
		}
	}else{
		cout << "UNRESTORABLE" ;
	}
	cout << endl;

   	
   	return 0;
}

Measured memory_bytes: 256