akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define plll pair<pll,ll>
#define ppll pair<pll, pll>
#define pii pair<int, int> 
#define piii pair<pii, int>
#define pb push_back
const ll llinf = 2e18 + 7;
const int inf = 2e9 + 7;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 7;
const ld pi = 3.14159265358979; 

void solve() {
    vector<int> a(5);
    for(int i=0;i<5;i++) {
        cin>>a[i];
    }
    for(int i=0;i<5;i++) {
        if(!a[i]){
            cout<<i+1;
            return ;
        }
    }
}

int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    // cin>>t;
    while(t--) {
        solve();
        // cout<<"\n";
    }
    return 0; 

}


Measured memory_bytes: 3608
package main

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

type Tuple struct {
	A int
	B int
}

func main() {
	sc := NewScanner()
	N, M := sc.NextInt(), sc.NextInt()
	A := sc.NextIntArray()

	mp := map[int]int{}

	for i := 0; i < N; i++ {
		mp[A[i]]++
	}

	K := make(SortInterFace, M)
	for i := 0; i < M; i++ {
		B, C := sc.NextInt(), sc.NextInt()
		K[i] = Tuple{B, C}
	}

	for k, v := range mp {
		K = append(K, Tuple{v, k})
	}

	sort.Sort(K)

	c := 0
	total := 0
	for _, v := range K {
		c += v.A
		total += v.A * v.B
		//fmt.Println(c, i, v, total)
		if c >= N {
			total -= (c - N) * v.B
			break
		}
	}
	fmt.Println(total)
}

type SortInterFace []Tuple

func (s SortInterFace) Len() int {
	return len(s)
}
func (s SortInterFace) Less(i, j int) bool {
	return s[i].B > s[j].B
}
func (s SortInterFace) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
};

int main() {
  int n, d, a;
  cin >> n >> d >> a;
  vector<P> p(n);
  rep(i,n) cin >> p[i].first >> p[i].second;
  sort(p.begin(), p.end());

  ll ans = 0;
  BIT<ll> bit(n+1);
  rep(i,n) {
    ll x = p[i].first;
    ll h = p[i].second;
    h -= bit.sum(i);
    if (h <= 0) continue;
    ll num = (h+a-1)/a;
    ans += num;
    ll damage = num*a;
    bit.add(i, damage);
    int rx = min(x+d*2,1000000000LL);
    int j = upper_bound(p.begin(), p.end(), P(rx+1,-1)) - p.begin();
    bit.add(j, -damage);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define ll long long int 
#define PI 3.1415926535897932384626

using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	cout<<n*n;
	return 0;
}

Measured memory_bytes: 3588
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt(); //整数の数
    int[] x = new int[n];
    for (int i=0; i<n; i++) {
        x[i] = sc.nextInt();
    }
    int count = 0; //素数の数
    for (int a:x) {
        if(prime(a)) count++;
    }
    System.out.println(count); //最大公約数を出力
    }

    /**
     * 素数判定
     */
     public static boolean prime(int x) {
            for (int i=2; i<=Math.sqrt(x); i++) {
                if (x%i==0) return false;
            }
            return true;
     }
}


Measured memory_bytes: 40632
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<set>
#include<algorithm>
#include<cmath>
#include<stack>
#include<math.h>
#include<queue>
#define mem(x) memset(x,0,sizeof(x)) 
#define sca(x) scanf("%d",&x)
#define scaa(x,y) scanf("%d%d",&x,&y)
#define prt(x) printf("%d\n",x)
#define inf 0x7f7f7f7f
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#pragma GCC optimize(2)
using namespace std;
const double pi=acos(-1); 
const double eps=1e-10;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<string,string> pcc;
typedef pair<double,double> pbb;
vector<int> v[3003];
int main()
{
	int n,d,ans=0;
	cin>>n>>d;
	for(int i=0;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		if(abs(sqrt(x*x+y*y)-(double)d)<eps)
		ans++;
		else if(sqrt(x*x+y*y)<(double)d)
		ans++;
	}
	cout<<ans<<endl;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main(){
    int a;
    REP(i, 5){ 
        cin >> a;
        if(a == 0) { 
            cout << i + 1 << en;
            return;
        }
    }
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


Measured memory_bytes: 3492
#include <iostream>
using namespace std;
typedef long long LL; 
int main()
{
	string s;
	cin>>s;
	LL n=s.length(),a[100005],sum=0;
	for(LL i=0;i<=n;i++)
		a[i]=1;
	for(LL i=1;i<=n;i++)
	{
		if(s[i]==s[i-1])a[i]=a[i-1]+1;
	}
	/*for(int i=0;i<n;i++)
		printf("%d ",a[i]);
	printf("\n");*/
	if(n==1)sum=0;
	else{
		LL pre=0;
		for(LL i=0;i<n;i++)
		{
			if(s[i]=='B'){
				pre++;
			}
			else{
				sum+=pre;
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int, int>;

ll mod = 1e9+7;

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

    ll n;
    cin >> n;
    vll c(n), b;
    REP(i, n) cin >> c[i];
    b.push_back(c[0]);
    REP(i, n - 1){
        if(c[i + 1] != c[i]) b.push_back(c[i + 1]);
    }
    n = b.size();
    vll dp(n + 1); // dp[i] : i 文字目までで何通りあるか.
    dp[0] = 1;
    vll latest(2 * 1e5 + 1);
    REP(i, n){
        dp[i + 1] = dp[i];
        if(latest[b[i]]) dp[i + 1] += dp[latest[b[i]]];
        dp[i + 1] %= mod;
        latest[b[i]] = i + 1;
    }
    cout << dp[n] << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back

int main()
{
    ll N;
    cin >> N;
    PR(N*(N-1)/2);

    return 0;
}

/*

1 2 3 4 5 6 7
2 3 4 5 6 7 1

*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fori(i,a,n) for(i=a;i<=n;i++)
#define ford(i,n,a) for(i=n;i>=a;i--)
typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned long long ull;
int n,m,ans,a[2000];
double k;
int i;
int main()
{
	cin>>n>>m;
	fori(i,1,n)
	{
		scanf("%d",&a[i]);
		ans+=a[i];
	}
	sort(a+1,a+1+n);
	k=(double)((double)ans/(double)(4*m));
	ford(i,n,n-m+1)
	if (a[i]<k) 
	{
		puts("No");
		return 0;
	}
	puts("Yes");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
  int N,K,sum,x;
  cin>>N>>K;
  sum=0;
  for(int i=0;i<N;i++){
    cin>>x;
    if(K-x>x){
      sum+=2*x;
    }
      else{
        sum+=2*(K-x);
      }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 3616
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn main() {
    let (x, a) = {
        let a: Vec<i32> = get_input()
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect();
        (a[0], a[1])
    };

    println!("{}", if x < a {"0"} else {"10"});
}

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


void solve(long long N, long long M, std::vector<std::string> S){
    // 0-NM = tile(even/odd)
    // NM = s
    // NM+1 = t
    long long NM = N * M;
    int s_index = NM;
    int t_index = NM + 1;
    int dx[4] = {0, 1, 0, -1};
    int dy[4] = {1, 0, -1, 0};
    mf_graph<long long> g(NM + 2);
    map<int, tuple<int, int, int, int>> tiles;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            bool is_even = (i + j) % 2 == 0;
            int v_index = i * M + j;
            if (is_even) {
                g.add_edge(s_index, v_index, 1);
            } else {
                g.add_edge(v_index, t_index, 1);
            }
            if (S[i][j] == '#') {
                continue;
            }
            if (is_even) {
                for (int k = 0; k < 4; k++) {
                    int nx = i + dx[k];
                    int ny = j + dy[k];
                    if (nx < 0 || nx >= N || ny < 0 || ny >= M) {
                        continue;
                    }
                    if (S[nx][ny] == '#') {
                        continue;
                    }
                    int u_index = nx * M + ny;
                    int edge = g.add_edge(v_index, u_index, 1);
                    tiles[edge] = {i, j, nx, ny};
                }

            }
        }
    }
    int result = g.flow(s_index, t_index);
    cout << result << endl;
    auto es = g.edges();
    for (int i = 0; i < es.size(); i++) {
        auto e = es[i];
        // printf("%d %d %d %d\n", e.from, e.to, e.cap, e.flow);
        if (tiles.count(i) && e.flow > 0) {
            auto t = tiles[i];
            int x = get<0>(t);
            int y = get<1>(t);
            int nx = get<2>(t);
            int ny = get<3>(t);
            // printf("%d %d %d %d\n", x, y, nx, ny);
            if (nx == x) {
                if (ny < y) {
                    swap(ny, y);
                }
                S[x][y] = '>';
                S[nx][ny] = '<';
            } else {
                if (nx < x) {
                    swap(nx, x);
                }
                S[x][y] = 'v';
                S[nx][ny] = '^';
            }
        }
    }
    for (int i = 0; i < N; i++) {
        cout << S[i] << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, M, std::move(S));
    return 0;
}


Measured memory_bytes: 7584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
using ping = pair<ll, ll>;

int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> A(M);
    for (int i = 0; i < M; i++) cin >> A[i];
    ll cnt = 0;
    for (int i = 0; i < M; i++) cnt += A[i];
    if(cnt<=N) cout << N-cnt << endl;
    else cout << -1 << endl;
    return 0;
}

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

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

    return gcd(b, a % b);
}

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

    ll ac = (a+c-1)/c;
    ll ad = (a+d-1)/d;
    ll cd_gcd = gcd(c, d);
    ll aab = (a+c*d/cd_gcd-1)/(c*d/cd_gcd);

    ll bc = b/c;
    ll bd = b/d;
    ll bab = b/(c*d/cd_gcd);

    ll c_num = max(bc - ac+1, ll(0));
    ll d_num = max(bd - ad+1, ll(0));
    ll cd_num = max(bab - aab+1, ll(0));

    ll sum = b - a + 1;

    ll ans = sum - (c_num + d_num - cd_num);

    cout << ans << endl;

    return 0;
}


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

int main(){
  long long x,k;
  cin >> x;
  k = x%11;
  if(k <= 6 && k > 0) k = 1;
  else if(k  >= 7) k = 2;
  cout << ((long long)(x/11))*2+k << endl;
  return 0;
}

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

#define N 200123
#define mod 1000000007

int main(){
 ios::sync_with_stdio(false);
 cin.tie(0);
 if(fopen("input.in", "r")){
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int n, m, a, sum=0; cin >> n >> m;
    for(int i=0;i<m;i++){
    	cin >> a;
    	sum += a;
    }
    if(sum > n) cout << "-1\n";
    else cout << n - sum << endl;
 return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n,k;
  cin>>n>>k;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  sort(h.begin(),h.end());
  int ans=1000000009;
  for(int i=0;i<n-k+1;i++){
    ans=min(ans,h[i+k-1]-h[i]);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int[][] a = new int[3][3];
		boolean[][] f = new boolean[3][3];

		@SuppressWarnings("resource")
		Scanner scanner = new Scanner(System.in);
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				a[i][j] = scanner.nextInt();
			}
		}

		int n = scanner.nextInt();
		for (int i = 0; i < n; i++) {
			int b = scanner.nextInt();
			find(a, f, b);
		}

		boolean result = check(f);
		System.out.println((result) ? "Yes" : "No");
	}

	private static void find(int[][] a, boolean[][] f, int b) {
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (b == a[i][j]) {
					f[i][j] = true;
					return;
				}
			}
		}
	}

	private static boolean check(boolean[][] f) {
		boolean diagonalUpFlag = true;
		boolean diagonalDownFlag = true;
		for (int i = 0; i < 3; i++) {
			boolean horizontalFlag = true;
			boolean verticalFlag = true;
			for (int j = 0; j < 3; j++) {
				horizontalFlag &= f[i][j];
				verticalFlag &= f[j][i];
			}
			if (horizontalFlag || verticalFlag) {
				return true;
			}
			diagonalUpFlag &= f[i][2 - i];
			diagonalDownFlag &= f[i][i];
		}
		if (diagonalUpFlag || diagonalDownFlag) {
			return true;
		}
		return false;
	}

}


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


int main()
{
	int r;
	cin>>r;
	cout<<3*r*r<<endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
a_list = list(map(int, input().split()))

money = 1000
stock = 0

for i in range(N-1):
    if a_list[i] < a_list[i+1]:
        stock += money // a_list[i]
        money %= a_list[i]
        
    elif a_list[i] > a_list[i+1]:
        money += stock * a_list[i]
        stock = 0
    else:
        continue
money += stock * a_list[N-1]
print(money)

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

int main(){
  int N,M,X;
  cin>>N>>M>>X;
  vector<pair<int,vector<int>>> A(N,make_pair(0,vector<int>(M)));
  for(auto &i:A){
    cin>>i.first;
    for(int &j:i.second)
      cin>>j;
  }
  int p=1200001;
  for(int i=0;i<(1<<N);i++){
    bitset<12> B(i);
    int j=0;
    vector<int> C(M);
    for(int k=0;k<N;k++){
      if(!B.test(k))
        continue;
      j+=A[k].first;
      for(int l=0;l<M;l++)
        C[l]+=A[k].second[l];
    }
    bool bo=true;
    for(int k:C)
      if(k<X){
        bo=false;
        break;
      }
    if(bo)
      p=min(p,j);
  }
  if(p==1200001)
    cout<<-1<<endl;
  else
    cout<<p<<endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	int n; cin >> n;
    int cnt[55][50];
    rep(i, 55) rep(j, 50) cnt[i][j] = 0;
    rep(i, n) {
        string s; cin >> s;
        int m = (int)s.size();
        rep(j, m) {
            cnt[i][s[j] - 'a'] ++;
        }
    }
    string ans;
    rep(j, 26) {
        int num = inf;
        rep(i, n) {
            chmin(num, cnt[i][j]);
        }
        rep(k, num) {
            ans += ('a' + j);
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> P(N),Q(N);
  for(int i = 0; i < N; i++) cin >> P.at(i);
  for(int i = 0; i < N; i++) cin >> Q.at(i);
  int cntP,cntQ,cnt=0;
  vector<int> v(N);
  iota(v.begin(), v.end(), 1);
  do {
    int idx=0,fP=0,fQ=0;
    cnt++;
    for(auto x : v){
      //cout << x << " ";
      if(P.at(idx)!=x)fP++;
      if(Q.at(idx)!=x)fQ++;
      idx++;
    }
    if(fP==0) cntP=cnt;
    if(fQ==0) cntQ=cnt;
    //cout << "\n";
  } while( next_permutation(v.begin(), v.end()) );
  cout << abs(cntP-cntQ) << endl;
}


Measured memory_bytes: 256
import numpy as np
def isprime(x):
  if x<=1:return False
  if x==2:return True
  for i in range(2,int(x**0.5)+1):
    if x%i==0:return False
  return True

#リスト作成
prime=[isprime(i) for i in range(10**5+1)]

def like2017(x):
  return (prime[x] and prime[(x+1)//2])

a=[like2017(i) for i in range(10**5+1)]

ac=np.cumsum(a)

q=int(input())
for i in range(q):
  l,r=map(int,input().split())
  print(ac[r]-ac[l-1])


Measured memory_bytes: 17144
from collections import deque
S = list(input())
Q = int(input())

d = deque()
d.extend(S)
cnt = 0
for i in range(1, Q+1):
    query = input()
    if len(query) == 1:
        cnt += 1
    else:
        n, F, C = query.split()
        if cnt % 2 == 0:  # 反転cntが偶数,F=1で末尾
            if F == '1':
                d.appendleft(C)
            else:
                d.append(C)
        else:  # 反転cntが偶数,F=1で先頭
            if F == '1':
                d.append(C)
            else:
                d.appendleft(C)

if cnt % 2 == 1:  # cnt奇数の場合、反転
    d.reverse()
else:
    pass

l = list(d)
S = ''.join(l)
print(S)


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

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

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

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

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 1024
// https://beta.atcoder.jp/contests/abc071

#include <bits/stdc++.h>
using namespace std;

int main() {
    int x, a , b;
    cin >> x >> a >> b;
    if (abs(x - a) < abs(x - b)) cout << "A" << endl;
    else cout << "B" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
const int ININF = 1000000;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {

    string S;
    int Q;
    cin >> S >> Q;
    vector<int> a;
    vector<string> cve;
    bool jun = true;
    list<int> li;
    li.push_front(-1);
    int henko = 0;
    rep(i, 0, Q) {
        int t;
        cin >> t;
        if(t == 2) {
            int f;
            cin >> f;
            string c;
            cin >> c;
            cve.push_back(c);
            if(jun) {
                if(f == 2) {
                    li.push_back((cve.size() - 1));
                } else {
                    li.push_front((cve.size() - 1));
                }
            } else {
                if(f == 1) {
                    li.push_back((cve.size() - 1));
                } else {
                    li.push_front((cve.size() - 1));
                }
            }
        } else {
            if(jun) {
                jun = false;
            } else {
                jun = true;
            }
        }
        // for(auto p : li) {
        //     if(p == -1) {
        //         if(jun) {
        //             cout << S;
        //         } else {
        //             reverse(S.begin(), S.end());
        //             cout << S;
        //         }
        //     } else {
        //         string out = cve[p];

        //         cout << out;
        //     }
        // }
        // cout << endl;
    }
    string res;
    for(auto p : li) {
        if(p == -1) {
            res += S;
            // if(jun) {
            //     cout << S;
            // } else {
            //     reverse(S.begin(), S.end());
            //     cout << S;
            // }
        } else {
            res += cve[p];
        }
    }
    if(!jun) {
        reverse(res.begin(), res.end());
    }
    cout << res << endl;
}


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

const int INF = pow(2, 31) - 1;
#define ll long long
#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  ll ans = 2 * max(X, Y) * C + X * A + Y * B;
  FOR(i, 0, max(X, Y)) {
    ll cost = 2 * i * C + max((ll)0, (X - i)) * A + max((ll)0, (Y - i)) * B;
    ans = min(ans, cost);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int area = a * b;
        int length = 2*a + 2*b;

        System.out.println(area + " " + length);
        sc.close();
    }
    
}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define ternary(condition, x, y) ((condition) ? x : y) 
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static llong MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

llong dp[210000][5];

int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    map<int, int> M;
    rep(i, n) {
        int num;
        cin >> num;
        rep(j, num) {
            int tmp;
            cin >> tmp;
            ++M[tmp];
        }
    }

    int ans = 0;
    stl_rep(itr, M) {
        if (itr->second == n) ++ans;
    }

    cout << ans << endl;
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    if (s == "abc" || s == "acb" || s == "bac" || s == "bca" || s == "cab" || s == "cba") {
        cout << "Yes" << endl;  
    } 
    else {
        cout << "No" << endl;   
    }
    return 0;
}


Measured memory_bytes: 256
from heapq import heappush,heappop

def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int, ss_raw()))


def runLength(in_str):
    kukan = 1
    start = 0
    ret = []
    for i in range(1,len(in_str)):
        if in_str[i-1]!=in_str[i]:
            ret.append([in_str[i-1],kukan,start])
            start = i
            kukan=0
        kukan+=1
    ret.append([in_str[-1],kukan,start])
    return ret

A,B,C = ints_raw()

def main():

    if (A < C and C <B) or (A>C and C>B):
        return "Yes"
    else:
        return "No"

print(main())



Measured memory_bytes: 3064
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, ans int
	fmt.Scan(&n)
	cards := make([]int, n)
	for i := range cards {
		fmt.Scan(&cards[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(cards)))
	// fmt.Println(cards)
	if n%2 == 0 {
		for i := 0; i < n/2; i++ {
			ans += cards[2*i]
		}
		for i := 0; i < n/2; i++ {
			ans -= cards[2*i+1]
		}
		fmt.Println(ans)
	} else {
		for i := 0; i <= n/2; i++ {
			ans += cards[2*i]
		}
		for i := 0; i < n/2; i++ {
			ans -= cards[2*i+1]
		}
		fmt.Println(ans)
	}
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define All(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
template<class T> T gcd(T a,T b) {return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b) {return a/gcd(a,b)*b; }
template<class T> bool isPrime(T num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (T i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

using namespace std;

ll d(ll mid){return to_string(mid).size();}

main()
{
    int x,y;
    cin>>x>>y;

    int ans=0;
    if(x==1)ans+=300000;
    if(x==2)ans+=200000;
    if(x==3)ans+=100000;
    if(y==1)ans+=300000;
    if(y==2)ans+=200000;
    if(y==3)ans+=100000;
    if(x==1&&y==1)ans+=400000;

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
	int n;
	cin >> n;
	vec(a,n);
	REP(i,n){
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	int h=1;
	int ans=1;
	FOR(i,1,n){
		if(a[i] != a[i-1]){
			ans++;
			if(h%2 == 0){
				ans--;
			}
			h=1;
		}
		else{
			h++;
		}
	}
  if(h%2 == 0){
				ans--;
			}
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
  long long N;cin>>N;
  long long ans=N+1;
  for(long long i=1;i<=sqrt(N);i++){
    if(N%i==0)ans=min(ans,i+(N/i));
  }
  cout<<ans-2<<endl;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
S=[0]*N
for _ in[0]*K:a,b=map(int,input().split());S[a-1]=b
dp=[0]*9
st,nd=S[:2]
if st:
 if nd:dp[st*2+~-nd]=1
 else:dp[st*2:st*3]=[1]*3
elif nd:dp[~-nd::3]=[1]*3
else:dp=[1]*9
for i in range(2,N):
 cur=S[i]-1;tmp=[0]*9
 if cur+1:
  for k in range(3):tmp[k*3+cur]=sum(dp[k::3])-dp[cur*4]*(k==cur)
 else:
  for cur in range(3):
   for k in range(3):tmp[k*3+cur]=sum(dp[k::3])-dp[cur*4]*(k==cur)
 dp=tmp[:]
print(sum(dp)%10000)


Measured memory_bytes: 5604
import bisect

n = int(input())
A = sorted(list(map(int, input().split())))
c = 0
temp = 0
for i in sorted(list(set(A))):
  d = bisect.bisect_right(A, i)
  if d-temp >= i:
    c += d-temp - i
  else:
    c += d-temp
  temp = d
print(c)

Measured memory_bytes: 14712
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int h,w,x,y;
  cin >> w >> h >> x >> y;
  cout << fixed << setprecision(10) << (double)h * (double)w / 2.0 << " ";
  cout << (x*2==w && y*2==h ? 1 : 0);
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}

const int MOD = INF+7;

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

    bool f = false;
    if(s[0]=='7')f = true;
    if(s[1]=='7')f = true;
    if(s[2]=='7')f = true;
    cout<<(f?"Yes":"No");
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n; cin>>n; int ans=0;
    for(int i=1; i<=n; i++)ans+=i;
    cout<<ans<<endl;
}

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

using namespace std;
#define ff(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define rep(i, a, b) for(int i = (a), _b = (b); i < _b; ++i)
#define fd(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define SZ(x) ((int)(x).size())
#define db(x) cout << #x << " == " << x << endl
#define _ << ", " << 
#define X first
#define Y second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define endl '\n'
#define pc putchar
#define gc getchar 
#define bit(i) (1<<(i))

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;

const int N=205,INF=1e9;
int n,m,r,a[N],dp[N][N];

void enter(){
	cin>>n>>m>>r;
	
	ff(i,1,n) ff(j,1,n) dp[i][j]=INF;
	
	ff(i,1,r) cin>>a[i];
	
	int u,v,w;
	while (m--){
		cin>>u>>v>>w;
		dp[u][v]=min(dp[u][v],w);
		dp[v][u]=dp[u][v];
	}
}

void Floyd(){
	ff(k,1,n) ff(i,1,n) ff(j,1,n) dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
}

void process(){
	Floyd();

	ll ans=INF*1LL*INF;
	
	int p[10];

	ff(i,1,r) p[i]=i;
	do {
		ll cur=0;
		ff(i,2,r) cur+=dp[a[p[i]]][a[p[i-1]]];
		ans=min(ans,cur);
	} while (next_permutation(p+1,p+r+1));
	cout<<ans<<endl;
}


int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	//freopen("test.inp","r",stdin);
	//freopen("test.out","w",stdout);

	enter();
	process();	

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;


int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, m, k, x, y;
	cin >> n >> m >> k;
	cin >> x >> y;
	string p1, p2;
	cin >> p1 >> p2;
	
	int rx1 = 1, rx2 = n;
	int ry1 = 1, ry2 = m;
	
	char c;
//	cout << rx1 << " " << rx2 << " ";
//	cout << ry1 << " " << ry2 << endl;
	for (int i = k-1; i >= 0; --i) {
		// Player 2
		c = p2[i];
		if (c == 'U') {
			rx2 = min(n, rx2+1);
		} else if (c == 'D') {
			rx1 = max(1, rx1-1);
		} else if (c == 'L') {
		  	ry2 = min(m, ry2+1);
		} else if (c == 'R') {
			ry1 = max(1, ry1-1);
		}
		
		
		// Player 1
		c = p1[i];
		
		if (c == 'U') {
			rx1++;
		} else if (c == 'D') {
			rx2--;
		} else if (c == 'L') {
			ry1++;
		} else if (c == 'R') {
			ry2--;
		}
		
//		cout << rx1 << " " << rx2 << " ";
//		cout << ry1 << " " << ry2 << endl;
		if (ry2 < ry1 || rx2 < rx1) break;
	}
	
	
	if (rx1 <= x && x <= rx2 && ry1 <= y && y <= ry2) {
	  cout << "YES\n";
	} else {
	  cout << "NO\n";
	} 	
  	return 0;
}

Measured memory_bytes: 920
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    // auto B = A.map!(x => BigInt(x)).array;
    auto l = lcm(A);
    long ans;
    foreach (a; A)
    {
        long x = (l * invmod(a, MOD)) % MOD;
        ans = (ans + x) % MOD;
    }
    writeln(ans);
}

T invmod(T = long)(T x, T m)
{
    T powmod(T = long)(T x, T n, T m)
    {
        if (n < 1)
            return 1;
        if (n & 1)
        {
            return x * powmod(x, n - 1, m) % m;
        }
        T tmp = powmod(x, n / 2, m);
        return tmp * tmp % m;
    }

    return powmod(x, m - 2, m);
}

long lcm(long[] A)
{
    long[long] f;
    foreach (a; A)
    {
        auto d = factorize(a);
        foreach (key, value; d)
        {
            f[key] = max(f.get(key, 0), value);
        }
    }
    // writeln(f);
    long ans = 1;
    foreach (key, value; f)
    {
        ans = powmod(key, value, MOD) * ans % MOD;
    }
    return ans;
}

/// x^^n % m
T powmod(T = long)(T x, T n, T m)
{
    if (n < 1)
        return 1;
    if (n & 1)
    {
        return x * powmod(x, n - 1, m) % m;
    }
    T tmp = powmod(x, n / 2, m);
    return tmp * tmp % m;
}

/// 素因数分解
long[long] factorize(long x)
{
    assert(0 < x, "x is negative");
    long[long] ps;
    while ((x & 1) == 0)
    {
        x /= 2;
        ps[2] = (2 in ps) ? ps[2] + 1 : 1;
    }
    for (long i = 3; i * i <= x; i += 2)
        while (x % i == 0)
        {
            x /= i;
            ps[i] = (i in ps) ? ps[i] + 1 : 1;
        }
    if (x != 1)
        ps[x] = (x in ps) ? ps[x] + 1 : 1;
    return ps;
}


Measured memory_bytes: 3452
import math

def curve(inp):
    ret = []
    n = len(inp)
    cos60 = math.cos(math.radians(60))
    sin60 = math.sin(math.radians(60))
    for i in range(n - 1):
        p1x, p1y = inp[i]
        p2x, p2y = inp[i+1]
        
        diffx = (p2x - p1x) / 3
        diffy = (p2y - p1y) / 3
        sx, sy = p1x + diffx, p1y + diffy
        ux = sx + diffx * cos60 - diffy * sin60
        uy = sy + diffx * sin60 + diffy * cos60
        tx, ty = p2x - diffx, p2y - diffy
        
        ret.extend([(p1x, p1y), (sx, sy), (ux, uy), (tx, ty)])
    ret.append(inp[-1])
        
    return ret
      
      
if __name__=="__main__":
    inp = [(0.0, 0.0), (100.0, 0.0)]
    N = int(input())
    for i in range(N):
        inp = curve(inp)
    for i in inp:
      print(*i)


Measured memory_bytes: 6328
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<ll> a(3*n);
    rep(i,3*n) cin >> a[i];
    vector<ll> mx,mn;
    priority_queue<ll,vector<ll>,greater<ll>> pq;
    ll sum = 0;
    rep(i,n){
        pq.push(a[i]);
        sum += a[i];
    }
    mx.push_back(sum);
    for(int i=n;i<2*n;i++){
        if(pq.top() < a[i]){
            sum -= pq.top();
            sum += a[i];
            pq.pop();
            pq.push(a[i]);
        }
        mx.push_back(sum);
    }

    priority_queue<ll> pq1;
    sum = 0;
    rep(i,n){
        pq1.push(a[3*n-i-1]);
        sum += a[3*n-i-1];
    }
    mn.push_back(sum);
    for(int i=2*n-1;i>=n;i--){
        if(pq1.top() > a[i]){
            sum -= pq1.top();
            sum += a[i];
            pq1.pop();
            pq1.push(a[i]);
        }
        mn.push_back(sum);
    }
    reverse(mn.begin(),mn.end());

    ll ans = -LINF;
    rep(i,n+1){
        ans = max(ans,mx[i] - mn[i]);
    }
    cout << ans << endl;

    /*
    rep(i,n+1){
        cout << mx[i] << " " << mn[i] << endl;
    }
    */

    return 0;
}

Measured memory_bytes: 6516
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define M 1000000007
#define ff first
#define ss second
#define pb push_back  
#define INF 1000000000000

									// nestedcode


 int main(){
   ios::sync_with_stdio(0);
   cin.tie(0); cout.tie(0);
   ll a,b,i;
   cin>>a>>b;
   if(a<=b){
   	for(i=0;i<b;i++){
   		cout<<a;
	   }
   }else{
   	for(i=0;i<a;i++){
   		cout<<b;
	   }
   }
   
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
N,H=map(int,input().split())
l=[[-1]*2 for i in range(N)]
A=[]
B=[]

for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
    
A.sort(reverse=True)
B.sort(reverse=True)

count=0
is_killed=False

for i in range(N):
    if B[i]>A[0]:
        H-=B[i]
        count+=1
    if H<1:
        is_killed=True
        break

if is_killed:
    print(count)
else:    
    print(count-(-H//A[0]))



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

int main() {
    int N, K;
    std::cin >> N >> K;

    double p = 0.0;
    for (int i = 1; i <= N; ++i) {
        if (i >= K) {
            p += 1.0;
            continue;
        }

        int now = i;
        int cnt = 0;
        while (now < K) {
            now *= 2;
            ++cnt;
        }

        p += std::pow(0.5, cnt);
    } 

    std::printf("%.15lf\n", p / N);

    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int a[3 * n];
    for (int i = 0; i < 3 * n; i++) {
        cin >> a[i];
    }
    sort(a, a + 3 * n);
    long ans = 0;
    for (int i = n; i < 3 * n; i += 2) {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
int main()
{
    int n, m, k;
    cin >> n >> m;
    /* --- 模範解答（優先度付きキュー） --- */
    priority_queue<int> a;
    for(int i = 0; i < n; i++){
        scanf("%d", &k);
        a.push(k);
    }
    while(m--){
        k = a.top();
        a.pop();
        a.push(k/2);
    }
    long long ans = 0;
    while(a.size()){
        ans += a.top();
        a.pop();
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007


typedef long long ll;
typedef pair<ll,ll> P;

int main()
{
	string a,b;
	cin >> a >> b;
	if(a.size() > b.size()){
		cout << "GREATER" << endl;
		return 0;
	}
	
	if(a.size() < b.size()){
		cout << "LESS" << endl;
		return 0;
	}
	
	for(int i = 0;i < a.size();i++){
		if(a[i] > b[i]){
			cout << "GREATER" << endl;
			return 0;
		}
		if(a[i] < b[i]){
			cout << "LESS" << endl;
			return 0;
		}
	}
	
	cout << "EQUAL" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
long long c = 0;
 
void merge(int A[], int left, int mid, int right) {
  int i,j,k;
 
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1];
  int R[n2];
 
  for (i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }
 
  for (i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }
  L[n1] = 1000000001;
  R[n2] = 1000000001;
 
  i = 0;
  j = 0;
  for (k = left; k < right; k++) {
    if (L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
      c += n1 - i;
    }
  }
}
 
void mergeSort(int A[], int left, int right) {
  int i = 0;
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  int n;
  int A[200000];
 
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
 
  mergeSort(A, 0, n);
 
  cout << c <<endl;
 
  return 0;
}

Measured memory_bytes: 4692
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int main(){

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

    vector<vector<int>> a(N, vector<int>(M));
    rep(i, N)rep(j, M){
        cin >> a[i][j];
        a[i][j]--;
    }

    int ans = N;
    vector<int> done(M, false);

    rep(loop, M){
        vector<int> use(M, 0);
        rep(i, N)rep(j, M){
            if(!done[a[i][j]]){
                use[a[i][j]]++;
                break;
            }
        }
        int maximum = -1, pos = -1;
        rep(i, M)if(chmax(maximum, use[i]))pos = i;
        chmin(ans, maximum);
        done[pos] = true;
    }

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;

#include <math.h>
#define PI 3.14159265358979323846264338327950L



int main() {
    int a, b;
    cin >> a >> b;
    if (a > 9 || b > 9) {
        cout << -1 << endl;
    }
    else {
        cout << a * b;
    }
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
#define endl '\n'
#define _ << ' '
#define min3(a, b, c) min(a, min(b, c))
#define min4(a, b, c, d) min(min(a, d), min(b, c))

using namespace std;
const ll mod = (ll)1e9+7;
const ll INF = (ll)1e9+1;

int a[100001];
int b[100001];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("B.txt", "r", stdin);
    #endif
    int n, ans=0;
    cin >> n;
    for(int i=1; i<=n; i++)
    {
        cin >> a[i];
    }
    for(int i=1; i<n; i++)
    {
        if(a[i]==i)
        {
            swap(a[i], a[i+1]);
            ans++;
        }
    }
    if(a[n]==n) ans++;
    cout << ans;
}


Measured memory_bytes: 640
def hoge(t, i):
	global data
	C, S, F = int(data[i][0]), int(data[i][1]), int(data[i][2])
	if S > t:
		t = S
	if t % F != 0:
		t += F - t % F
	return t + C

if __name__ == '__main__':
	N = int(input())
	data = list()

	for i in range(N - 1):
		l = input().split()
		data.append(l)

	for i in range(N - 1):
		t = 0
		for j in range(i, N - 1):
			t = hoge(t,j)
		print(t)
	print(0)

Measured memory_bytes: 3188