akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cctype>
using namespace std;

int main(){
  char ch;

  while(1){
    scanf("%c", &ch);
    if(isalpha(ch)){
      if(islower(ch)){
        printf("%c", toupper(ch));
      }else {
        printf("%c", tolower(ch));
      }
    }else {
      printf("%c", ch);
    }

    if(ch == '\n') break;
  }

  return 0;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=1;i<(n);i++)
int dp[100001];

int main(){
  int n,ans=0;cin>>n;
  dp[0]=0;
  dp[1]=dp[6]=dp[9]=1;
  for(int i=1;i<=n;i++){
    int m=1e9;
    REP(j,6) if(i-j>=0) m=min(m,dp[i-j]+j);
    REP(j,7){
      int t=pow(6,j);
      REP(k,6) if(i-t*k>=0) m=min(m,dp[i-t*k]+k);
    }
    REP(j,6){
      int t=pow(9,j);
      REP(k,9) if(i-t*k>=0) m=min(m,dp[i-t*k]+k);
    }
    dp[i]=m;
  }
  cout<<dp[n];
}

Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        Long[] A = new Long[N];
        for (int i = 0; i < N; i++) {
            A[i] = Long.parseLong(sc.next());
        }

        long sum = solve(N, K, A);
        System.out.println(sum);
    }

    public static long solve(int n, int k, Long[] a) {
        Arrays.sort(a, Comparator.reverseOrder());
        Queue<Long> queue = new PriorityQueue<>(Comparator.reverseOrder());
        for (int i = 0; i < n; i++) {
            queue.add(a[i]);
        }

        while (k > 0) {
            Long poll = queue.poll();
            long in = poll / 2;
            queue.add(in);
            k--;
        }

        long sum = 0L;
        while (!queue.isEmpty()) {
            sum += queue.poll();
        }
        return sum;
    }
}



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

using namespace std;
typedef long long ll;
void read(ll &x){
	char ch = getchar();x = 0;
	for (; ch < '0' || ch > '9'; ch = getchar());
	for (; ch >='0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
}
const ll N = 1e6+100;
ll s1[N],t1[N];
int main(){
	ll n,m,q;
	read(n);
	read(m);
	read(q);
	for(ll i=1;i<=n;i++) read(s1[i]);
	for(ll i=1;i<=m;i++) read(t1[i]);
	sort(s1+1,s1+n+1);
	sort(t1+1,t1+m+1);
	ll st;
	while(q--){
		ll dis=0x3f3f3f3f3f3f3f3f;
		read(st);
		ll rs=lower_bound(s1+1,s1+n+1,st)-s1;
		if(rs!=n+1){
			ll rt=lower_bound(t1+1,t1+m+1,s1[rs])-t1;
//			cout<<rs<<" "<<rt<<endl;
			if(rt!=m+1){
				dis=min(dis,t1[rt]-st);
//				cout<<dis<<endl;
			}
			ll lt=rt-1;
//			cout<<lt<<endl;
			if(lt){
				if(st<=t1[lt]) dis=min(dis,s1[rs]-st);
				else dis=min(dis,s1[rs]-t1[lt]+min(st-t1[lt],s1[rs]-st));
			}
		}
		ll ls=rs-1;
		if(ls){
			ll rt=lower_bound(t1+1,t1+m+1,s1[ls])-t1;
			if(rt!=m+1){
				if(t1[rt]>=st) dis=min(dis,t1[rt]-s1[ls]+min(st-s1[ls],t1[rt]-st));
				else dis=min(dis,st-s1[ls]);
			}
			ll lt=rt-1;
			if(lt){
				dis=min(dis,st-t1[lt]);
			}
		}
		ll rt=lower_bound(t1+1,t1+m+1,st)-t1;
		if(rt!=m+1){
			ll rs=lower_bound(s1+1,s1+n+1,t1[rt])-s1;
//			cout<<rt<<" "<<rs<<endl;
			if(rs!=n+1){
				dis=min(dis,s1[rs]-st);
			}
			ll ls=rs-1;
			if(ls){
				if(st<=s1[ls]) dis=min(dis,t1[rt]-st);
				else dis=min(dis,t1[rt]-s1[ls]+min(abs(s1[ls]-st),abs(t1[rt]-st)));
			}			
		}
//		cout<<dis<<endl;
		ll lt=rt-1;
		if(lt){
			ll rs=lower_bound(s1+1,s1+n+1,t1[lt])-s1;
			if(rs!=n+1){
				if(s1[rs]<=st) dis=min(dis,st-t1[lt]);
				else dis=min(dis,s1[rs]-t1[lt]+min(st-t1[lt],s1[rs]-st));
			}
			ll ls=rs-1;
			if(ls){
				dis=min(dis,st-s1[ls]);
			}				
		}
		cout<<dis<<endl;
	}
	return 0;
}

Measured memory_bytes: 6144
main :: IO ()
main = do
  l1 <- getLine
  let [a, b, x] = map read $ words l1 :: [Int]

  if a*a*b`div`2 > x
    then print $ 90 - 180/pi*(atan2 (fromIntegral $ 2*x) (fromIntegral $ b*a*b))
    else print $ 180/pi*(atan2 (fromIntegral $ 2*(a*a*b - x)) (fromIntegral $ a*a*a))

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Lib
//

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int N; cin >> N;

    int oddnum = 0;
    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        if (a % 2 == 1){
            ++oddnum;
        }
    }

    if (oddnum % 2 == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
X = int(input())
 
ans = None
 
for i in range(120):
  for j in range(120):
    if i ** 5 - j ** 5 == X:
      ans = (i, j)
    elif (i*-1) ** 5 - j ** 5 == X:
      ans = (-i, j)
    elif i ** 5 - (j*-1) ** 5 == X:
      ans = (i, -j)
print(ans[0],ans[1])

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int h, n;
    cin >> h >> n;
    int a = 0;
    rep(i, n)
    {
        int b;
        cin >> b;
        a += b;
    }
    if (a >= h)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, m = rm()
print((m*1900 + (n-m)*100) * 2**m)















Measured memory_bytes: 27172
#include <bits/stdc++.h>
using namespace std;
int main() {
    int h, w, mod = 1000000007;
    cin >> h >> w;
    string s[h];
    for (int i = 0; i < h; i++) cin >> s[i];
    int p[h][w];
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (i == 0 && j == 0) p[i][j] = 1;
            else if (s[i][j] == '#') p[i][j] = 0;
            else
            {
                if (i == 0) p[i][j] = p[i][j - 1];
                else if (j == 0) p[i][j] = p[i - 1][j];
                else p[i][j] = (p[i - 1][j] + p[i][j - 1]) % mod;
            }
        }
    }
    cout << p[h - 1][w - 1];
}

Measured memory_bytes: 9308
#include<iostream>

using namespace std;


int main(void){
	int a =0;int b=0; int c=0; int d =0;
	cin>>a>>b>>c>>d;
	if(c-a>0) ;
	else{
		int tmp = 0;
		tmp =a;
		a = c;
		c = tmp;
		tmp =b;
		b = d;
		d = tmp;
	}
	if (c-b >0) cout << 0;
	else if(d<b) cout <<d-c;
	else cout<<b-c;
}

Measured memory_bytes: 256
use itertools::iproduct;
use proconio::{input, marker::*};
use std::collections::VecDeque;

fn main() {
    input!(
        h: usize,
        w: usize,
        start: (Usize1, Usize1),
        goal: (Usize1, Usize1),
        grid: [Bytes; h]
    );

    let mut dist = vec![vec![None; w]; h];
    let mut deq = VecDeque::from(vec![start]);
    dist[start.0][start.1] = Some(0);

    while let Some((i, j)) = deq.pop_front() {
        for (di, dj) in iproduct!(-2_isize..=2, -2_isize..=2) {
            let da = di.abs() + dj.abs();
            let cost = match da {
                0 => continue,
                1 => 0,
                _ => 1,
            };
            let ni = i as isize + di;
            let nj = j as isize + dj;
            let ok = (0..h as isize).contains(&ni)
                && (0..w as isize).contains(&nj)
                && grid[ni as usize][nj as usize] == b'.';
            if ok {
                let alt = dist[i][j].unwrap() + cost;
                let nd = dist[ni as usize][nj as usize].get_or_insert(u64::max_value());
                if *nd <= alt {
                    continue;
                }
                *nd = alt;
                match cost {
                    0 => deq.push_front((ni as usize, nj as usize)),
                    _ => deq.push_back((ni as usize, nj as usize)),
                }
            }
        }
    }

    let ans = dist[goal.0][goal.1].map_or(-1, |d| d as i64);

    println!("{}", ans);
}


Measured memory_bytes: 20024
n = int( raw_input( ) )
minv = int( raw_input( ) )
maxv = 0 - 1000000000
  
for j in range( n-1 ):
  num = int( raw_input( ) )  
  diff = num - minv
  if maxv < diff:
    maxv = diff
  if num < minv:
    minv = num
  
print maxv

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	int n;
	cin >> n;
	int sum = 0;
	ll x = INF;
	for(int i=0; i<n; i++){
		ll t;
		cin >> t;
		if(t % 10 != 0){
			x = min(x, t);
		}
		sum += t;
	}

	if(sum % 10 != 0){
		cout << sum << endl;

	}else{
		if(x != INF){
			cout << sum - x << endl;
		}else{
			cout << 0 << endl;
		}
	}

	
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
	int a,b,h,m;
	double shi,fen,j;
	scanf("%d%d%d%d",&a,&b,&h,&m);
	shi=0.5*(h*60+m);
	fen=6*m;
	j = fabs(shi-fen);
	if(j>180)j=360-j;
	printf("%.20f",sqrt(a*a+b*b-2*cos(j*M_PI/180)*a*b));
	return 0;
}

Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;
// a^n mod を計算する
//ただしmとaが互いにその時のみ
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    string s;
    cin >> s;
    ll N=s.size();

    vector<ll> vec(N+1,0);
    for(ll i=0;i<N;i++){
        vec[i+1]=s[i]-'0';
    ;}

    //until[i]はi桁目以降を見て、2019で割ったあまり
    vector<ll> until(N+2,0);

    for(ll i=N;i>=1;i--){
        until[i]=(until[i+1]+vec[i]*modpow(10,N-i+1,2019))%2019;
    ;}
    vector<ll> counter(2019,0);
    for(ll i=1;i<=N+1;i++){
        counter[until[i]]++;
    ;}
    ll ans=0;
    for(ll i=0;i<2019;i++){
        ll k=counter[i];
        ans+=k*(k-1)/2;
    ;}
    cout<<ans<<endl;

    return 0;
}


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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

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

string decode(string S) {
    set<char> set{'a', 'i', 'u', 'e', 'o'};

    size_t index = 0;
    string ret = "";
    while(index < S.size() - 1) {
        auto itr = set.find(S[index]);
        if(itr != set.end()) {
            ret += S[index + 1];
        }
        index++;
    }
    return ret;
}

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

    while(true) {
        int N;
        std::cin >> N;
        if(N == 0) break;

        size_t max_decoded = 0;
        vector<string> S(N);
        REP(i, N) {
            string s;
            std::cin >> s;
            S[i] = s.front() + decode(s);
            max_decoded = max(max_decoded, S[i].size());
        }

        size_t code_length = 1;
        while(true) {
            set<string> set;
            REP(i, N) {
                auto s = S[i].substr(0, code_length);
                auto itr = set.find(s);
                if(itr == set.end()) {
                    set.insert(s);
                }
                else {
                    break;
                }
            }

            if(set.size() == S.size()) {
                std::cout << code_length << std::endl;
                break;
            }
            else if(code_length == max_decoded) {
                std::cout << -1 << std::endl;
                break;
            }
            code_length++;
        }
    }

    return 0;
}



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

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

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()


void solve(long long N, long long K, std::vector<long long> a){
    vector<i64> b;
    rep(i, N){
        i64 sum = 0;
        rep(j, i, N){
            sum += a[j];
            b.emplace_back(sum);
        }
    }
    vector<bool> f(b.size(), true);
    i64 ans = 0;
    for(i64 i = 60; i >= 0; --i){
        i64 cnt = 0;
        rep(j, b.size()) if(((1LL<<i) & b[j]) && f[j]) ++cnt;
        if(cnt >= K){
            rep(j, b.size()) if(((1LL<<i) & b[j]) == 0) f[j] = false;
            ans += 1LL << i;
        }
    }
    cout << ans << endl;
}

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, K, std::move(a));
    return 0;
}


Measured memory_bytes: 6516
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	private int totalVertex;
	private int totalEdges;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Main() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		totalEdges = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for (int i = 0; i < totalVertex; i++) {
			adjList.add(new LinkedList<Integer>());
		}
		
		for (int i = 0; i < totalEdges; i++) {
			int s = in.nextInt();
			int t = in.nextInt();
			LinkedList<Integer> tmp = adjList.get(s);
			tmp.add(t);
		}
		
		in.close();
	}
	
	public LinkedList<Integer> getTopSort() {
		LinkedList<Integer> L = new LinkedList<Integer>();
		int[] C = new int[totalVertex];
		LinkedList<Integer> Q = new LinkedList<Integer>();
		
		
		for (int i = 0; i < totalVertex; i++) {
			LinkedList<Integer> neighbors = adjList.get(i);
			for (int j : neighbors) {
				C[j]++;
			}
		}
		
		for (int i = 0; i < totalVertex; i++) {
			if (C[i] == 0) {
				Q.add(i);
			}
		}
		while (Q.size() > 0) {
			int u = Q.remove(0);
			L.add(u);
			LinkedList<Integer> neighbors = adjList.get(u);
			for (int v : neighbors) {
				C[v]--;
				if (C[v] == 0) {
					Q.add(v);
				}
			}
		}
		return L;
	}
	
	public static void main(String args[]) {
		Main s = new Main();
		s.loadAdjList();
		LinkedList<Integer> result = s.getTopSort();
		for (Integer i : result) {
			System.out.println(i);
		}
	}
}



Measured memory_bytes: 73344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
vector<int> G[maxn];
vector<int> T[maxn];
int goin[maxn],inq[maxn],id[maxn],cnt;
int dis[maxn],fa[maxn];
int main()
{
	int n,m;scanf("%d%d",&n,&m);
	for(int i=0;i<n-1+m;i++)
	{
		int a,b;scanf("%d%d",&a,&b);
		G[a].push_back(b);
		goin[b]++;
	}
	queue<int> que;
	while(!que.empty())que.pop();
	for(int i=1;i<=n;i++)
	{
		if(goin[i]==0)
		{
			que.push(i);
			break;
		}
	}
	while(!que.empty())
	{
		int x=que.front();que.pop();
		id[x]=cnt;
		inq[cnt++]=x;
		for(int i=0;i<G[x].size();i++)
		{
			int to=G[x][i];
			goin[to]--;
			if(goin[to]==0)
			{
				que.push(to);
			}
		}
	}
	
	fa[inq[0]]=0;dis[inq[0]]=0;
	for(int i=0;i<cnt;i++)
	{
		int v=inq[i];
		for(int x=0;x<G[v].size();x++)
		{
			int to=G[v][x];
			if(dis[to]<dis[v]+1)
			{
				dis[to]=dis[v]+1;
				fa[to]=v;
			}
		}
	}
	for(int i=1;i<=n;i++)
		printf("%d\n",fa[i]);
	return 0;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define EPS ((ld)(1e-9))
 
#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, e) for (int i = 0, _##i = (e); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repr(i, s, e) for (int i = (s)-1, _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))
#define ARR(...) vector<int>({__VA_ARGS__})
#define ARS(...) vector<string>({__VA_ARGS__})
 
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef complex<double> base;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    for (auto p : v) cout << p << ",";
    cout << "]";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const set<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
#ifndef __SOULTCH
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif
 
template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

int N;
int A[3001];
ll  S[3001];
ll  dp[3001][3001];

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> N;
    repp(i, 1, N+1) cin >> A[i], S[i] = S[i-1]+A[i];
    repp(i, 1, N+1) dp[i][i] = A[i];
    repp(d, 1, N) {
        repp(i, 1, N-d+1) {
            dp[i][i+d] = S[i+d]-S[i-1]-min(dp[i][i+d-1], dp[i+1][i+d]);
        }
    }

    cout << 2*dp[1][N]-S[N] << endl;
}

Measured memory_bytes: 70144
#include<stdio.h>
int main()
{
	int a;
	long long b,n;
	scanf("%d%lld%lld",&a,&b,&n);
	if(n>=b)
	{
		printf("%lld\n",(long long)(a*(b-1)/b));
		
	 } 
	else
	{
		printf("%lld\n",(long long)(a*n/b));
	}
	
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=2000+10;
const int inf=1e18;
int n,a[maxn],b[maxn],x,sum,ans=inf;

signed main()
{
    scanf("%lld%lld",&n,&x);
n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;n++;n--;
    for(int i=0;i<n;i++) scanf("%lld",&a[i]);
    for(int i=0;i<n;i++) b[i]=inf;
    for(int i=0;i<n;i++){
        sum=0;
        for(int j=0;j<n;j++) b[j]=min(b[j],a[(j-i+n)%n]);
        for(int j=0;j<n;j++) sum+=b[j];
        ans=min(ans,sum+i*x); 
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
n=int(input())
p=[]
for i in range(n):
  p.append(list(map(int,input().split())))

v=[1,1]
for i in p:
  r=max((v[0]-1)//i[0],(v[1]-1)//i[1])+1
  v=[i[0]*r,i[1]*r]

print(v[0]+v[1])

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


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

    string S;
    cin >> S;
    int N=S.size();
    string ans="yes";
    for(int i=1;i<N;i++){
        rep(j,i){
            if(S[i]==S[j]){
                ans="no";
                break;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef pair<ut,ut> prs;
const int SIZE=2*1e5;
const LL p=7+1e9;
LL N;
VI edges[SIZE];
inline void IN(ut &x){cin >> x;}
inline void INA(ut n,ut x[]){REP(i,n) cin >> x[i];}
inline void INE(ut m,VI edges[]){
	ut a,b;
	REP(i,m){
		cin >> a >> b;
		edges[a].PB(b);
		edges[b].PB(a);
	}
}
inline void INEC(ut m,Vpr edges[]){
	ut a,b,c;
	REP(i,m){
		cin >> a >> b >> c;
		edges[a].PB(pr(c,b));
		edges[b].PB(pr(c,a));
	}
}
int reached[SIZE];
LL counted[SIZE];
bool solve(){
	cin >> N;
	INE(N-1,edges);
	queue<int> qu;
	FOR(i,1,N+1){
		if(edges[i].size()<=1){
			qu.push(i);
		}
	}
	bool last=false;
	while(!qu.empty()){
		int now=qu.front();
		qu.pop();
		if(counted[now]>=2){
			return true;
		}
		last=counted[now]==0;
		REP(i,edges[now].size()){
			int next=edges[now][i];
			reached[next]++;
			if(counted[now]==0) counted[next]++;
			if(reached[next]==edges[next].size()-1){
				qu.push(next);	
			}
		}
	}
	return last;
}
int main(){
	if(solve()) cout << "First" << endl;
	else cout << "Second" << endl;

	return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// INSERT ABOVE HERE
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, k;
    cin >> n >> k;
    vector<int> as(n), fs(n);
    REP(i, n) cin >> as[i];
    REP(i, n) cin >> fs[i];
    sort(ALL(as));
    sort(ALLR(fs));

    auto check = [&](int x) -> bool {
        int cnt = 0;
        REP(i, n) {
            if (cnt > k)
                return false;
            int ub = x / fs[i];
            cnt += max(0LL, as[i] - ub);
        }
        return cnt <= k;
    };

    int L = -1, R = 1e12 + 1;
    while (L + 1 < R) {
        int M = (L + R) / 2;
        if (check(M))
            R = M;
        else
            L = M;
    }
    cout << R << endl;
    return 0;
}


Measured memory_bytes: 3456
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 300010


int main(){
  int n, m[SIZE];
  vector<int> s[SIZE];

  scanf("%d", &n);

  for(int i=0;i<n;i++){
    scanf("%d", m+i);
    for(int j=0;j<m[i];j++){
      int w;
      scanf("%d", &w);
      s[i].push_back(w);
    }
  }

  priority_queue<int> pq;
  ll ans = 0;
  
  for(int i=n-1;i>=0;i--){
    for(int j=0;j<m[i];j++) pq.push(s[i][j]);

    ans += pq.top();
    pq.pop();
  }

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



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

using namespace std;

#define ll              long long
#define l1(i, n)        for (ll i = 1; i <= n; i++)
#define l0(i, n)        for (ll i = 0; i < n; i++)
#define lo(i, s, n)     for (ll i = s; i <= n; i++)
#define pb              push_back
#define mp              make_pair
#define sorted(x)       sort(x.begin(), x.end())
#define reversed(x)     reverse(x.begin(), x.end())
#define cas (tc)        cout << "Case " << tc << " :"
#define nl              cout << "\n";
#define pi              acos(-1)
#define mod             1000000007
#define inf             9999999999999999

const ll sz = 2e5;




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

        ll d, n;
        cin>>d>>n;
        vector<ll> x;
        l0(i,n){
            ll it;
            cin>>it;
            x.pb(it);
        }
        sorted(x);
        ll m=0;
        for(ll i=1; i<n; i++){
            m=max(m, x[i]-x[i-1]);
        }
        m=max(m, x[0]-x[n-1]+d);

        cout<<d-m;
        nl
          
    return 0;
}

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

// # DEFINES # //
#define ll long long
#define M (ll)1e9+7
#define EPS 1e-9

using namespace std;


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

    ll n;

    cin >> n;

    vector<int> arr(n);

    for(int i = 0; i < n; i++)
        cin >> arr[i];
    
    int minimo = 0, res = 100;
    for(int i = 0; i < n; i++) {
        int s1 = 0, s2 = 0;
        for(int j = 0; j < i+1; j++) {
            s1 += arr[j];
        }
        for(int j = i+1; j < n; j++) {
            s2 += arr[j];
        }
        res = min((int)abs(s1-s2), res);
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
/*#include <sstream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include<climits>
#include <bitset>
#include <ctime>
#include <cassert>
#include <functional>
#include <iomanip>
#include <vector>
#include <stack>
#include <fstream>*/
// priority_queue<int,vector<int>,greater<int> >vec;
//long long fix(int n){return ((n%mod)+mod)%mod;}
#define mod 1000000007
//std::ifstream cin("input.txt");
//std::ofstream cout("output.txt");
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
//cout<<fixed<<setprecision(*)<<***<<endl;
//a=97  A=65 z=122 Z=90
/*scanf("%d",&..);
printf("%d",..);*/

using namespace std;
vector<int>adj[10];
int vis[10]={0},c;
void dfs(int cur)
{
    for(int i=0;i<adj[cur].size();i++){
        int ch=adj[cur][i];
        if(!vis[ch]){
            vis[ch]=1;
            c++;
            dfs(ch);
        }
    }
    if(c==4){
        cout<<"YES"<<endl;
        exit(0);
    }
    else{
        cout<<"NO"<<endl;
        exit(0);
    }
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie();
	int a,b;
	for(int i=0;i<3;i++){
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
	}
	for(int i=1;i<=4;i++){
        if(adj[i].size()==1){
            c=1; vis[i]=1; dfs(i); break;
        }
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  	int ans = 0;
  	int i, j;
  	int N, K;
  	int Okasi[100][100];
  	int d[100];
  	int binary[100] = {0};
  
  	scanf("%d%d", &N, &K);
  	for(i=0;i<K;i++){
      scanf("%d", &d[i]);
      for(j=0;j<d[i];j++){
        scanf("%d", &Okasi[i][j]);
      }
    }
  
  	for(i=0;i<K;i++){
      for(j=0;j<d[i];j++){
        binary[Okasi[i][j]-1] = 1;
      }
    }
  
  	for(j=0;j<N;j++){
      if(binary[j] == 0){
        ans++;
      }
    }
  
  	printf("%d\n", ans);
  	
	return 0;
}

Measured memory_bytes: 1720
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))
n=int(input())
a=a1+a2+a3
b=set([int(input()) for _ in range(n)])

c1=set(a[0::3])
c2=set(a[1::3])
c3=set(a[2::3])
c4=set([a1[0],a2[1],a3[2]])
c5=set([a1[2],a2[1],a3[0]])
c=[set(a1),set(a2),set(a3),c1,c2,c3,c4,c5]
j = any(len(b&x)==3 for x in c)
print('Yes' if j else 'No')

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <vector>
#include <cmath>
#include <bitset>
#include <set>
#include <complex>
#include <queue>
#include <stack>


#define mp make_pair
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

const ld pi = acos(-1.0);
const ld e  = exp(1.0);


int main(){
	
	int N;
	cin >> N;
	int a = 1;
	while(2*a <= N) a*=2;
	cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n, a, res = 0;
    cin>>n;
    set<int> s;
    while(n--) {
        cin>>a;
        if(s.find(a) != s.end()) {
            cout<<"NO"<<endl;
            return 0;
        }
        s.insert(a);
    }
    cout<<"YES"<<endl;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    ll res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}
ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}

ll f[200001];
 
ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a; 
 while(b > 0)
    {
        if(b%2 == 1)
    {
        x=(x*y);
        if(x>MOD) x%=MOD;
    }
    y = (y*y);
    if(y>MOD) y%=MOD; 
    b /= 2;
    }
 return x;
}
 
/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}
 
ll C(ll n, ll r, ll MOD)
{
 
 return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}
 


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector <int> v(5);
    generate(all(v),nxt);
    for(int i=1;i<=5;i++)
    {
        if(!v[i-1])
        {
            cout<<i<<endl;
            return 0;
        }
    }


    return 0;   
}


 
 


Measured memory_bytes: 3612
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
 
template <intmax_t X = 943681729, intmax_t MOD = 1000000007>
class rolling_hash {
  std::vector<intmax_t> hash, offset;
 
public:
  rolling_hash(const std::string& s): hash(s.length()+1), offset(s.length()+1) {
    for (size_t i = 0; i < s.length(); ++i)
      hash[i+1] = (hash[i]*X+s[i]) % MOD;
 
    offset[0] = 1;
    for (size_t i = 1; i <= s.length(); ++i)
      offset[i] = offset[i-1] * X % MOD;
  }
 
  intmax_t get_base() const { return X; }
  intmax_t get_mod() const { return MOD; }
 
  intmax_t prefix(size_t i) const {
    // hash of prefix s[0..i-1] (inclusive)
    assert(0 < i);
    return hash[i];
  }
 
  intmax_t substr(size_t i, size_t j) const {
    // hash of substring s[i..j-1] (inclusive)
    assert(i < j);
    intmax_t res = hash[j];
    res = (res - offset[j-i]*hash[i]) % MOD;
    if (res < 0) res += MOD;
    return res;
  }
 
  intmax_t inserted(size_t i, int ch) const {
    intmax_t res = 0;
    if (i > 0) res += prefix(i);
    res = (res*X + ch) % MOD;
    size_t n = hash.size()-1;
    if (i < n) res = (res*offset[n-i] + substr(i, n)) % MOD;
    return res;
  }
 
  void debug() const {
    for (size_t i = 0; i < hash.size(); ++i)
      fprintf(stderr, "%jd%c", hash[i], i+1<hash.size()? ' ':'\n');
  }
};
 
int testcase_ends() {
  char buf[4096];
  if (scanf("%s", buf) == EOF) return 1;
  std::string s = buf;
  scanf("%s", buf);
  std::string t = buf;
 
  if (s.length() > t.length()) std::swap(s, t);
 
  size_t n = s.length();
  size_t m = t.length();
 
  rolling_hash<> rs(s), rt(t);
 
  size_t lb = 0;
  size_t ub = n+1;
  while (ub-lb > 1) {
    size_t w = (lb+ub) >> 1;
    std::set<intmax_t> rl;
    bool found = false;
    for (size_t i = 0; i+w <= n; ++i)
      rl.insert(rs.substr(i, i+w));

    for (size_t i = 0; i+w <= m; ++i)
      if (rl.count(rt.substr(i, i+w))) {
        found = true;
        break;
      }

    (found? lb:ub) = w;
  }

  printf("%zu\n", lb);
  return 0;
}
 
int main() {
  while (!testcase_ends()) {}
}



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

int main(){
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n; i++) cin >> b[i];
  for(int i = 0; i < n; i++) cin >> c[i];
  sort(a.begin(), a.end());
  sort(c.begin(), c.end());
  
   long long ans = 0;
  
  for(int i = 0; i < n; i++){
  
  	long long x = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
  	long long y = upper_bound(c.begin(), c.end(), b[i]) - c.begin();
    
    ans += x*(n-y);
  }
  
  cout << ans << endl;
}


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

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n, m = mi()
    a = lmi()
    s = sum(a)
    print(n-s) if n-s>=0 else print(-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 10076
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1000000007;
const llint big=(llint)(2.19e15)+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
using pli=pair<llint,int>;
using daic=priority_queue<pli,vector<pli>,greater<pli>>;
class seg_tree{public:
	//セグ木
	vector<llint>val;
	seg_tree(void){val.res(524288);}
	//両側からアクセスするので、bitテクが使える
	//    1    
	// 2     3  
	//4  5  6  7
	
	//偶数ナンバーは、(短縮時間+x) を記録
	//奇数ナンバーは、(短縮時間-x) を記録
	llint que(llint bas,llint mae){
		llint time=-abs(bas-mae);//短縮
		int bi=bas-1+262144;
		while(bi>1){
			if(bi%2==0){maxeq(time,val[bi+1]+bas);}
			bi/=2;
		}
		bi=bas+1+262144;
		while(bi>1){
			if(bi%2==1){maxeq(time,val[bi-1]-bas);}
			bi/=2;
		}
		time+=abs(bas-mae);
		bi=mae+262144;
		while(bi>1){
			if(bi%2==0){maxeq(val[bi],time+mae);}
			if(bi%2==1){maxeq(val[bi],time-mae);}
			bi/=2;
		}
		return time;
	}
};
int main(void){
	seg_tree ki;
	int n,q;cin>>n>>q;
	int A;cin>>A;
	int mae;cin>>mae;
	int bi=A+262144;
	while(bi>1){
		if(bi%2==0){maxeq(ki.val[bi],big+A);}
		if(bi%2==1){maxeq(ki.val[bi],big-A);}
		bi/=2;
	}
	llint ans=0,wa=big;
	while(q--){
		llint x;cin>>x;
		maxeq(ans,ki.que(x,mae));
		wa+=abs(mae-x);
		mae=x;
		
	}
	cout<<wa-ans<<endl;RE;
}

Measured memory_bytes: 4352
#include<stdio.h>

int main(void)
{
 int a;
 int b;
 

	scanf("%d %d\n", &a,&b);
	
 int c=a*b;
 int d=(a+b)*2;
	
	printf("%d %d\n", c,d);
	

   return 0;
   
}

Measured memory_bytes: 2576
#include<stdio.h>

static const int MAX = 500;
static const int INFTY = (1<<21);

main(){
  int n, i, j;
  int u,v,c,k,l;
  int M[MAX][MAX],d[MAX],N[MAX];

  scanf("%d", &n);
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      M[i][j] = INFTY;
    }
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    for ( j = 0; j < k; j++ ){
      scanf("%d %d", &v, &c);
      M[u][v] = c;
    }
  }

  for(i=0;i<n;i++)
    {
      N[i]=0;
      d[i]=INFTY;
    }
  d[0]=0;

  while(1)
    {
      l=INFTY;
      u=-1;
      for(i=0;i<n;i++)
	{
	  if(d[i]<l&&N[i]==0)
	    {
	      u=i;
	      l=d[i];
	    }
	}

      if(u==-1) break;

      N[u]=1;

      for(v=0;v<n;v++)
	{
	  if(d[v]>=d[u]+M[u][v])
	    {
	      d[v]=d[u]+M[u][v];
	    }
	}
    }
 

  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i, (d[i]==INFTY?-1:d[i]));
  }

  return 0;
}

Measured memory_bytes: 800
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 11;
int n, a[N], ma; 
int main(){
    cin>>n;
    for(int i = 1;i <= n; i++){
        scanf("%d", &a[i]);
        ma = max(ma, a[i]);
    }
    int dl = 0;
    for(int i = 1;i <= n; i++){
        if(ma - a[i] > 1){
            puts("No");
            return 0;
        }
        else if(ma - a[i])dl++;
    }
    if(dl == 0){
        if(ma == n - 1 || ma * 2 <= n)puts("Yes");
        else puts("No");
    }
    else{
        if(n - dl < 2 * (ma - dl) || ma <= dl) puts("No");
        else puts("Yes");
    }
    return 0;
}


Measured memory_bytes: 640
// date: July 05 2020
// author: Tibbarnit

#include <bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define endl "\n"
typedef long long ll;
int a[200020];
bool visited[1000020];

void solve(int i,int temp)
{
    for (int j=1;j<=temp;++j) visited[a[i]*j]=true;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    int n,res=0;
    cin>>n;
    for (int i=1;i<=n;++i)
        cin>>a[i];
    sort(a+1,a+n+1);
    for (int i=1;i<=n;++i)
    {
        if (visited[a[i]]) continue;
        if (a[i-1]==a[i] || a[i+1]==a[i])
        {
            int temp=1000000/a[i];
            solve(i,temp);
            continue;
        }
        ++res;
        int temp=1000000/a[i];
        solve(i,temp);
    }
    cout<<res;
    return 0;
}
//    sort(a+1,a+n+1);
//    for (int i=1;i<=n;++i)
//    {
//        bool wrong=false;
//        if (a[i-1]==a[i] || a[i+1]==a[i])
//            wrong=true;
//        for (int j=i-1;j>0 && !wrong;--j)
//        {
//            if (a[i]%a[j]==0)
//            {
//                wrong=true;
//                break;
//            }
//        }
//        if (!wrong) ++res;
//    }


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

void judgePrime(int *,int);

int main(){
    int n,i;
    int *array;

    scanf("%d",&n);
    array=(int *)malloc(n*sizeof(int));
    
    for(i=0;i<n;i++){
     scanf("%d",&array[i]);
    }
    judgePrime(array,n);
    return 0;
}

void judgePrime(int *array,int n){
  int i,j,count=0;
    for(i=0;i<n;i++){
    for(j=2;j*j<=array[i];j++){
        if(array[i]%j==0){
        count++;
        break;
        }
    }
    }
    printf("%d\n",n-count);
}



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

int f(const void *a,const void *b){
  return *(int*)a-*(int*)b;
}

int main(){
  int A[200002];
  int N,c=1;
  scanf("%d\n",&N);
  for(int i=0;i<N;i++)
    scanf("%d",A+i);
  qsort(A,N,sizeof(int),f);
  for(int i=0;i<N-1;i++){
    if(A[i]==A[i+1]){
      c=0;
      break;
    }
  }
  if(c==1) printf("YES\n");
  else printf("NO\n");
  return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
using namespace std;
int i,j,k,m,n,A=0,B=0,C=0,N;
int X[10005];
int Y[10005];
int main()
{
	cin>>N;
	for(i=1;i<=(N-1);i++)
	{
		cin>>Y[i];
		if(i==1)
		X[i]=Y[i];
		else
		X[i]=min(Y[i],Y[i-1]);
	}
	X[N]=Y[N-1];
	for(j=1;j<=N;j++)
	{
		A+=X[j];
	}
	cout<<A;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a;
double b;
int main(){
    cin>>a;
    for(int i=a;i>=0;i--){
        b=sqrt(i);
        if(int(sqrt(i))==b){
            cout<<i<<endl;
            return 0;
        }
    }
  
}

Measured memory_bytes: 256
import math


def resolve():
    a, b, x = map(int, input().split())
    s = x / a

    if s <= a * b / 2:
        rad = math.atan(b / (2 * s / b))
    else:
        rad = math.atan(2 * (a * b - s) / a**2)

    print(rad * 180 / math.pi)

resolve()

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

typedef long long ll;

#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define clr(a, b) memset(a, b, sizeof(a))
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ )

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef LOCAL
    clock_t tStart = clock();
#endif
    ll x, y;
    cin >> x >> y;
    ll res = 0ll;
    if(x == 1) res += 300000;
    if(x == 2) res += 200000;
    if(x == 3) res += 100000;
    if(y == 1) res += 300000;
    if(y == 2) res += 200000;
    if(y == 3) res += 100000;
    if(x == 1 && y == 1)
        res += 400000;
    cout << res << "\n";

#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * (clock() - tStart)/ CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
struct data{
    int a,b,c;
};

//昇順
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
#define MAXSIZE 200000
int list[MAXSIZE];
int tail;

void Init(void){
    tail=0;
}
int Top(void){
    return 0;
}

int Next(int pos){
    if(pos<tail-1){
        return pos+1;
    }else{
        return -1;
    }
}
int Count(void){
    return tail;
}

int Item(int pos){
    if((pos>=0)&&(pos<tail)){
        return list[pos];
    }else{
        return 0;
    }
}
void Add(int value){
    if(tail<MAXSIZE){
        list[tail]=value;
        tail++;
    }
}
void Delete(int pos){
    if((pos>=0)&&(pos<tail)){
        int i;
        for(i=pos;i<tail-1;i++){
            list[i]=list[i+1];
        }
        tail--;
    }
}

int main(){
    int N,K;
    scanf("%d%d",&N,&K);
    int chil[N];
    int sum=0;
    rep(i,N){
        scanf("%d",&chil[i]);
    }
    int j=0;
    qsort(chil,N,sizeof(int),compare_int);
    for(j=0;j<N && sum<=K ;j++){
        sum+=chil[j];
    }
    if(j==N && sum==K){
        printf("%d",N);
        return 0;
    }else if(j==N && sum!=K){
        printf("%d",N-1);
        return 0;
    }else if(j!=N){
        printf("%d",j-1);
        return 0;
    }
}


Measured memory_bytes: 1692