akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#define MN 400001
using namespace std;
 
int read_p,read_ca;
inline int read(){
    read_p=0;read_ca=getchar();
    while(read_ca<'0'||read_ca>'9') read_ca=getchar();
    while(read_ca>='0'&&read_ca<='9') read_p=read_p*10+read_ca-48,read_ca=getchar();
    return read_p;
}
const int MOD=1e9+7;
int n,a[MN],m=0,mmh=0,x,y,l[MN],r,st[MN],top=0,_st[MN],_top=0,num;
struct na{int y,ne;}b[MN<<1];
inline void in(int x,int y){b[++num].y=y;b[num].ne=l[x];l[x]=num;}
bool bo[MN];
void dfs(int p){
	st[++top]=p;
	bo[p]=1;
	for (int i=l[p];i;i=b[i].ne)
	if (!bo[b[i].y]) {dfs(b[i].y);break;}
}
void _dfs(int p){
	_st[++_top]=p;
	bo[p]=1;
	for (int i=l[p];i;i=b[i].ne)
	if (!bo[b[i].y]) {_dfs(b[i].y);break;}
}
int main(){
	int i;
	n=read();m=read();
	for (i=1;i<=m;i++) x=read(),y=read(),in(x,y),in(y,x);
	dfs(1);
	_dfs(1);
	printf("%d\n",top+_top-1);
	for (i=top;i;i--) printf("%d ",st[i]);
	for (i=2;i<=_top;i++) printf("%d ",_st[i]);
}

Measured memory_bytes: 8448
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>

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

using namespace std;

typedef long long ll;

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

  ll n; cin >> n;
  ll ans = n-1;

  for (ll i = 1; i*i <= n; i++) {
    if (n % i == 0) {
      ans = min(ans, i+(n/i)-2);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a[5],i,j,count = 0;
	
	for(i = 0; i < 5; i++){
		scanf("%d\n",&a[i]);
	}
	
	int k;
	
	scanf("%d\n",&k);
	
	for(i = 0; i < 5; i++){
		for(j = 4; j > i; j--){
			int flag = a[j] - a[i];
			
			if(flag <= k){
				count = count + 1;
				
			}else{
				break;
			}
		}
	}
	
	if(count == 10){
		printf("Yay!\n");
	}else{
		printf(":(\n");
	}
	
	return 0;
}
	
	
	
	
				
	
	
	
	
	
	

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

int main(void){
   int A,B;
   cin>>A>>B;
   if(A%3==0||B%3==0||(A+B)%3==0){
      cout<<"Possible"<<endl;
   }else{
      cout<<"Impossible"<<endl;
   }
   return 0;
}



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


using namespace std;

int main() {
    int a, b, c, k;
    int sum;
    sum = 0;
    cin >> a >> b >> c >> k; 
    if(k >= a) {
        sum += a;
        k -= a;
        k -= b;
        if(k > 0) {
            sum -= k;
        }
    }
    else {
        sum += k;
    }
    cout << sum << "\n";
}

Measured memory_bytes: 3640
#include <stdio.h>

#define MAX(a,b) ((a)>(b)?(a):(b))

int n, w;
int W[100];
int V[100];
long long int dp[100001];

int main(){
  int i, j;
  scanf("%d%d", &n, &w);
  for(i=0;i<n;i++) scanf("%d%d", W+i, V+i);
  for(i=0;i<n;i++){
    for(j=w;j>=W[i];j--)
      dp[j] = MAX(dp[j], dp[j-W[i]]+V[i]);
  }
  printf("%lld\n", dp[w]);

  return 0;
}


Measured memory_bytes: 896
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

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

	for(int n, m, p; cin >> n >> m >> p, n;) {
		vector<int> num(n);
		for(int i = 0; i < n; ++i)
			cin >> num[i];

		const int sum = accumulate(num.begin(), num.end(), 0);
		if(num[m - 1])
			cout << sum * (100 - p) / num[m - 1] << endl;
		else
			cout << 0 << endl;
	}

	return EXIT_SUCCESS;
}

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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__);
#else
#define dbg(...) 
#endif

int main() {
	ios_base::sync_with_stdio(false);
	int n; cin >> n;
	ll k; cin >> k;
	vector<int> a(n);
	for(int i=0; i<n; i++){
		cin >> a[i];
		a[i]--;
	}

	vector<int> visit(n, -1);
	vector<int> xs;
	int x = 0;
	int i = 0;
	while(visit[x]<0){
		visit[x]=i++;
		xs.push_back(x);
		x = a[x];
	}
	int l = i-visit[x];
	int b = visit[x];
	int ans;
	if(k<i){
		ans = xs[k];
	} else {
		ans = xs[(k-b)%l+b];
	}


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


Measured memory_bytes: 5896
mod = 10 ** 9 + 7
MAX = 2 * 10 ** 5

fact = [1] * (MAX + 1)
for i in range(1, MAX + 1):
    fact[i] = (fact[i-1] * i) % mod

inv = [1] * (MAX + 1)
for i in range(2, MAX + 1):
    inv[i] = inv[mod % i] * (mod - mod // i) % mod

fact_inv = [1] * (MAX + 1)
for i in range(1, MAX + 1):
    fact_inv[i] = fact_inv[i-1] * inv[i] % mod


def comb(n, k):
    if n < k:
        return 0
    return fact[n] * fact_inv[n-k] * fact_inv[k] % mod


n, m, k = map(int, input().split())

ans = 0
cmb = comb(m * n - 2, k - 2)
for i in range(1, m):
    ans += i * (m - i) * n * n * cmb
    ans %= mod

for i in range(1, n):
    ans += i * m * m * (n - i) * cmb
    ans %= mod

print(ans)


Measured memory_bytes: 26740
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int K=gi();
	    int T=gi();
	    int[] A=new int[T];
	    
	    int max=0;
	    int s=0;
	    for (int i=0; i<T;i++) {
	    	A[i]=gi();
	    	s+=A[i];
	    	if(max<A[i]) {
	    		max=A[i];
	    	}
	    }
	    

        System.out.println(Math.max(max*2-s-1, 0));
//	    if(max>s-max) {
//	    	System.out.println(s-max-1);
//	    }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35776
object Main extends App {

  val In = io.StdIn.readLine()
  val A = In.split(" ")
  val N: Long = A(0).toLong
  val K: Long = A(1).toLong
  var sum: Long = 0

  if (K == 0) {
    sum = N * N
  } else {
    for (b <- K + 1 to N) {
      var p: Long = N / b
      val r: Long = N % b

      sum += p * (b - K)
      sum += (r - K + 1).max(0)
    }
  }

  print(sum)

}


Measured memory_bytes: 30020
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)

void solve(){
	int a,b,c,x,cnt=0;
	cin>>a>>b>>c>>x;
	rep(i,0,a+1)
		rep(j,0,b+1)
			rep(k,0,c+1)
				if(i*500+j*100+k*50==x) cnt++;
	cout<<cnt<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>                                                         
#include<queue>                                                          
#include<string>                                                         
using namespace std;                                                     
                                                                         
int main() {                                                             
        queue<pair<string, int> >       tasks, completed;                
        int     nTasks, nQuant, nTime, nCurrent;                         
        char    sName[11];                                               
                                                                         
        scanf("%d %d", &nTasks, &nQuant);                                
        for(int i=0; i<nTasks; ++i) {                                    
                scanf("%s", sName);                                      
                scanf("%d", &nTime);                                     
                tasks.push(pair<string, int>(sName, nTime));             
        }                                                                
                                                                         
        nCurrent = 0;                                                    
        while(tasks.size() != 0) {                                       
                auto curTask = tasks.front();                            
                tasks.pop();                                             
                                                                         
                if(curTask.second > nQuant) {                            
                        curTask.second -= nQuant;                        
                        tasks.push(curTask);                             
                        nCurrent += nQuant;                              
                } else {                                                 
                        nCurrent += curTask.second;                      
                        curTask.second = nCurrent;                       
                        completed.push(curTask);                         
                }                                                        
        }                                                                
                                                                         
        while(completed.size() != 0) {                                   
                auto task = completed.front();                           
                                                                         
                completed.pop();                                         
                printf("%s %d\n", task.first.c_str(), task.second);      
        }                                                                
}                                                                        

Measured memory_bytes: 5876
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0);
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define gg exit(0);
main(){
    #define task "TASK"
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    fasty;

    int n; cin>>n;
    vector<int> a(n);
    forv(i,a) cin>>i;
    sort(all(a));
    forinc(i,1,n-1){
        if(a[i]==a[i-1])
            return cout<<"NO",0;
    }
    cout<<"YES\n";
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int X = sc.nextInt();
		int ans = X;
		for (int i = 0; i < N; i++) {
			int A = sc.nextInt();
			if (D / A * A + 1 <= D) {
				ans += D / A + 1;
			} else {
				ans += D / A;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 23764
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	int a;
	in(a);
	cout<<a+a*a+a*a*a<<en;
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


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

int main(){    
  ll A,V,B,W,T;
  double D,S;
  cin >> A >> V >> B >> W >> T;
  D = abs(A*1.0 - B*1.0);
  S = V*1.0 - W*1.0;
  if(S <= 0) cout << "NO" << endl;
  else if(T >= D / S) cout << "YES" << endl;
  else cout << "NO" << endl;
  
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


int N, K;
int h[100000];

signed main(){
    cin >> N >> K;
    REP(i, N) cin >> h[i];
    int ans = 0;
    REP(i, N) ans += (h[i] >= K);
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
int main(){
        int n,d,e,f=0;
        scanf("%d %d",&n,&d);
        e=2*d+1;
        f=n%e;
        if(f!=0){
                printf("%d",n/e+1);
        }else{
                printf("%d",n/e);
        }
        return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
using namespace std;
void solve()
{
		set<string>s;
		int n;cin>>n;
		string str;
		for(int i=0;i<n;i++){
			cin>>str;
			s.insert(str);
		}
		cout<<s.size();
}
int main()
{
	//int t;cin>>t;
	//while(t--)
	solve();
}

Measured memory_bytes: 19160
#include <stdio.h>
#include <string.h>

int main(void) {
  char text[1200];
  int i = 0;
  int length = 0;

  scanf("%[^\n]", text);

  length = strlen(text);

  for (i = 0; i < length; i++) {
    if (text[i] >= 'a' && text[i] <= 'z') {
      text[i] = text[i] - 'a' + 'A';
    } else if (text[i] >= 'A' && text[i] <= 'Z') {
      text[i] = text[i] - 'A' + 'a';
    }
  }

  printf("%s\n", text);

  return 0;
}



Measured memory_bytes: 2060
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n, K; cin >> n >> K;
    vll a(n); for(auto& e : a) cin >> e;

    ll res = inf;
    rep(k, 1 << n){
        ll h = a[0] - 1;
        int cnt = 0;
        ll cost = 0LL;
        rep(i, n){
            if(a[i] > h){
                h = a[i];
                cnt++;
                continue;
            }
            if((k >> i) & 1) continue;

            h++;
            cost += h - a[i];
            cnt++;
        }

        if(cnt >= K){
            chmin(res, cost);
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#define MAX_N 1000000000
typedef long long ll;
using namespace std;
int main(){
  ll n,z,w;
  ll a,b;
  cin>>n>>z>>w;
  for(int i=0; i<n;i++){
    if(i<n-2)cin>>a;
    if(i==n-2)cin>>a;
    if(i==n-1)cin>>b;
  }
  if(n==1)a=b; 
  cout<<max(abs(w-b), abs(a-b))<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
typedef long long lint;
const int N=1e5+5;
const int mod=1e9+7;
int n,pre_dp[N][2];
lint lim_a,lim_b,val[N];

template <class T> inline T nxi(){
	T x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return x;
}

inline int get_dp(int l,int r,bool type){
	if(l>r) return 0;
	return (pre_dp[r][type]-(l>0?pre_dp[l-1][type]:0)+mod)%mod;
}

int main(){
	n=nxi<int>();
	lim_a=nxi<lint>(),lim_b=nxi<lint>();
	for(int i=1; i<=n; ++i){
		val[i]=nxi<lint>();
	}
	val[0]=-2e18;
	val[n+1]=2e18;
	pre_dp[0][0]=pre_dp[0][1]=1;
	for(int ptl_a=0,ptl_b=0,ptr_a=-1,ptr_b=-1,i=1; i<=n; ++i){
		if(val[i]-val[i-1]<lim_a) ptl_a=i-1;
		if(val[i]-val[i-1]<lim_b) ptl_b=i-1;
		while(ptr_a<i-1&&val[i+1]-val[ptr_a+1]>=lim_b) ++ptr_a;
		while(ptr_b<i-1&&val[i+1]-val[ptr_b+1]>=lim_a) ++ptr_b;
		//pre_dp[i][0]=get_dp(ptl_a,ptr_a);
		//pre_dp[i][1]=get_dp(ptl_b,ptr_b);
		pre_dp[i][0]=(pre_dp[i-1][0]+get_dp(ptl_a,ptr_a,1))%mod;
		pre_dp[i][1]=(pre_dp[i-1][1]+get_dp(ptl_b,ptr_b,0))%mod;
	}
	const int ans_0=(pre_dp[n][0]-pre_dp[n-1][0]+mod)%mod;
	const int ans_1=(pre_dp[n][1]-pre_dp[n-1][1]+mod)%mod;
	printf("%d\n",(ans_0+ans_1)%mod);
	return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int N,R;
    cin>>N>>R;
    if(N>=10) cout<<R<<endl;
    else cout<<(R+100*(10-N))<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int W,H,x,y,r;
  cin >> W >> H >> x >> y >>r;
  if ( (H-r)>=y && (W-r)>=x && x>=r && y>=r) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}


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

using namespace std;

using ll = long long int;
using vi = vector<int>;
#define f(n) for(int i = 0; i < n; i++)
#define fj(n) for(int j = 0; j < n; j++)
#define fk(n) for(int k = 0; k < n; k++)
#define ci(n) cin >> n;
#define ic(n) int n; cin >> n;
#define lc(n) int n; cin >> n;
#define all(a) a.begin(), a.end()
#define pri(a, n) for(int i = 0; i < n; i++) cout << a[i] << " "; cout << "\n";
#define sc(a, n) int a[n] = {0}; for(int i = 0; i < n; i++) cin >> a[i];
#define scl(a, n) ll a[n] = {0}; for(int i = 0; i < n; i++) cin >> a[i];
#define pb push_back
#define eb emplace_back
#define int long long
const int inf = 2e9, mxp = 10, maxn = 1e5;



void solve(int ci)
{
    ic(n)
    sc(a, n)
    sort(a, a + n);
    reverse(a, a + n);
    int ans = 0;
    f(n - 1) ans += a[(i + (i & 1ll)) >> 1ll];
    cout << ans;
}

signed main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
    //cin >> t;
    f(t) solve(i + 1);
}


Measured memory_bytes: 5236
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    long a,b,c,minimum,i,count;
    cin>>a>>b>>c;
    minimum=min(min(a,b),c);
    count=0;
    
    for(i=a;i<=b;i++)
    {
        if( c/i*i==c)
        {
        count++;
        }
    }
    
    
    
    cout<<count<<endl;
    

    
    
    
    
    return 0;
    
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
const unsigned int M = 1000000007; 
#define all(v) (v).begin(), (v).end()
#define rall(v) v.rbegin(),v.rend()
#define  pb push_back
#define mpp make_pair
#define int  long long
#define N 100002
#define endl "\n"
#define fr(i,n) for(int i=0;i<n;i++)
int power(int x,int y){int res=1;while(y>0){if(y&1)res=x*res; y=y>>1;x=x*x;}return res;}
int power(int x,int y,int mod){int res=1;while(y>0){if(y&1)res=x*res%mod; y=y>>1;x=x*x%mod;}return res;}

using namespace std;


void nik()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
}




 signed main()
{
//nik();

int t=1;
//cin>>t;

while(t--)
{	
	int n,k;
	cin>>n>>k;
	int a[n+1];
	for(int i=1;i<=n;i++)cin>>a[i];
		
	int dp[n+1]={0};
dp[0]=1e17;
	for(int i=2;i<=n;i++)
	{
		dp[i]=1e17;
		for(int j=1;j<=k;j++)
		{
			if(i-j>=0){
			dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
			}
		}
		
		
	}

	cout<<dp[n]<<endl;
	//for(int i:dp)cout<<i<<" ";

}
 return 0;
}



Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
int m[9]={1,2,3,4,5,6,7,8,9};
int n[9]={1,2,3,4,5,6,7,8,9};
int i,j,k;
for(i=0;i<9;i++){
for(j=0;j<9;j++){
k = m[i]*n[j];
printf("%dx%d=%d\n",m[i],n[j],k);
}
}
return 0;
}

Measured memory_bytes: 524
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            DateTime a = DateTime.Parse(Console.ReadLine());
            if (a <= DateTime.Parse("2019/04/30"))
            {
                Console.WriteLine("Heisei");
            }
            else
            {
                Console.WriteLine("TBD");
            }
        }

    }

}


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

#include <atcoder/math>
using namespace atcoder;

void solve(long long T, std::vector<long long> N, std::vector<long long> M, std::vector<long long> A, std::vector<long long> B){
    for (int i = 0; i < T; i++) {
        cout << floor_sum(N[i], M[i], A[i], B[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 T;
    scanf("%lld",&T);
    std::vector<long long> N(T-1-0+1);
    std::vector<long long> M(T-1-0+1);
    std::vector<long long> A(T-1-0+1);
    std::vector<long long> B(T-1-0+1);
    for(int i = 0 ; i < T-1-0+1 ; i++){
        scanf("%lld",&N[i]);
        scanf("%lld",&M[i]);
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(T, std::move(N), std::move(M), std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 5256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		List<Integer> list=new ArrayList<Integer>();
		//Integer[] array = new Integer[m];
        int n = sc.nextInt();
        long count=0;
        int mai=0;
        int min=1000000000;
        for(int i=0;n>i;i++) {
        	int a = sc.nextInt();
        	if(a<0) {
        		list.add(-a);
        		count=count+-a;
        		mai++;
        		if(-a<min)
        			min=-a;
        	}
        	else {
        		list.add(a);
        		count=count+a;
        		if(a<min)
        			min=a;
        	}
        }
        if(mai%2==0)
        	System.out.println(count);
        else {
        	System.out.println(count-2*min);
        }

	}
}

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

using namespace std;

const int MAX_N = 1000010;
int N;
int A[MAX_N];
bool sieve[1010];
vector <int> primes;
int prime_count[1000010];

void compute_primes() {
	fill(sieve + 2, sieve + 1000, true);
	for (int i = 2; i <= 1000; i++) {
		if (sieve[i]) {
			for (int j = 2; i * j <= 1000; j++)
				sieve[i * j] = false;
		}
	}
	
	for (int i = 2; i <= 1000; i++)
		if (sieve[i]) primes.push_back(i);
}

void process(int x) {
	for (int i = 0; i < (int)primes.size() && x > 1; i++) {	
		if (x % primes[i] == 0) {
			++prime_count[primes[i]];
			while (x % primes[i] == 0)
				x /= primes[i];
		}
	}
	if (x > 1)
		++prime_count[x];
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> A[i];
	
	compute_primes();
	
	for (int i = 0; i < N; i++)
		process(A[i]);
	
	bool pairwise = true, setwise = true;
	for (int i = 2; i <= 1000000; i++) {
		if (prime_count[i] > 1)
			pairwise = false;
		if (prime_count[i] == N)
			setwise = false;
	}
	
	if (pairwise) cout << "pairwise coprime\n";
	else if (setwise) cout << "setwise coprime\n";
	else cout << "not coprime\n";
	
	return 0;
}


Measured memory_bytes: 11460
use std::io::BufRead;
const DEBUG: bool = false;
fn main() {
    let mut f = read_field();
    let mut col = 0;
    while col < f.w as usize {
        while col < f.w as usize && f.is_column_empty(col) {
            f.remove_column(col);
        }
        col += 1;
    }
    let mut row = 0;
    while row < f.h as usize {
        while row < f.h as usize && f.is_row_empty(row) {
            f.remove_row(row);
        }
        row += 1;
    }
    f.show();
}

fn read_field() -> Field {
    let stdin = std::io::stdin();
    let mut input = stdin.lock();
    let mut l = String::new();
    let _ = input.read_line(&mut l);
    let hw: Vec<u32> = l
        .split_whitespace()
        .map(|n| n.parse().expect("readnumerror!"))
        .collect();
    let h = hw[0];
    let w = hw[1];
    let mut f: Vec<Cell> = Vec::with_capacity((h * w) as usize);
    for line in input.lines() {
        for c in line.expect("read line error").trim().chars() {
            match c {
                '.' => f.push(false),
                '#' => f.push(true),
                _ => panic!(format!("unexpected char {}", c)),
            }
        }
    }
    Field {
        h: h,
        w: w,
        field: f,
    }
}

struct Field {
    h: u32,
    w: u32,
    field: Vec<Cell>,
}

impl Field {
    fn is_column_empty(&self, n: usize) -> bool {
        let mut i = n;
        while i < self.field.len() {
            if self.field[i] {
                return false;
            }
            i += self.w as usize;
        }
        true
        // !self
        //     .field
        //     .iter()
        //     .skip(n)
        //     .step_by(self.w as usize)
        //     .any(|&b| b)
    }
    fn is_row_empty(&self, n: usize) -> bool {
        if DEBUG {
            println!(
                "DEBUG: n {} f w{:?} h{:?}, f{:?}",
                n, self.w, self.h, self.field
            );
        }
        !self
            .field
            .iter()
            .skip(n * self.w as usize)
            .take(self.w as usize)
            .any(|&b| b)
    }
    fn remove_column(&mut self, n: usize) {
        if DEBUG {
            self.show();
            println!("|||||||||||@@@@");
        }
        let mut l = n;
        for _ in 0..self.h {
            self.field.remove(l);
            l += self.w as usize - 1;
        }
        self.w -= 1;
    }
    fn remove_row(&mut self, n: usize) {
        if DEBUG {
            self.show();
            println!("@@@@@@@@@@@@@@@");
        }
        for _ in 0..self.w {
            self.field.remove(n * self.w as usize);
        }
        self.h -= 1;
    }

    fn show(&self) {
        for y in 0..self.h as usize {
            let line: String = self.field[y * self.w as usize..(y + 1) * self.w as usize]
                .iter()
                .map(|&c| if c { '#' } else { '.' })
                .collect();
            println!("{}", line);
        }
    }
}

type Cell = bool;


Measured memory_bytes: 4352
#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 INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

unsigned GetDigit(unsigned num){
  return to_string(num).length();
}

int main()
{
  int N;
  cin >> N;
  vector<vector<int>> cnt(9,vector<int>(9,0));
  FOR(i,1,10){
    if(i<=N){
      cnt[i-1][i-1]++;
    }
  }
  FOR(i,1,10){
    FOR(j,1,10){
      string s = "";
      s=to_string(i)+s+to_string(j);
      int x = stoi(s);
      if(x<=N){
        cnt[i-1][j-1]++;
      }
    }
  }
  REP(i,4){
    FOR(j,0,pow(10,i+1)){
      string S;
      S=to_string(j);
      REP(k,i+1-GetDigit(j)){
        S='0'+S;
      }
      FOR(k,1,10){
        FOR(l,1,10){
          string s = S;
          s=to_string(k)+s+to_string(l);
          int x = stoi(s);
          if(x<=N){
            cnt[k-1][l-1]++;
          }
        }
      }
    }
  }

  ll ans = 0;
  REP(i,9){
    FOR(j,i,9){
      if(i!=j){
        ans+=2*cnt[i][j]*cnt[j][i];
      }else{
        ans+=cnt[i][j]*cnt[j][i];
      }
    }
  }
  // REP(i,9){
  //   REP(j,9){
  //     cout << cnt[i][j];
  //   }
  //   cout << endl;
  // }
  cout << ans << endl;
}

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

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

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}


int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c>=22)puts("bust");
    else puts("win");
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N = II()
    R = []
    for i in range(N):
        x, l = MI()
        R.append((x - l, x + l))
    R = sorted(R, key=lambda x: x[1])
    # print(R)

    rc = -INF
    ans = 0
    for (l, r) in R:
        if rc <= l:
            rc = r
            ans += 1
    print(ans)



if __name__ == '__main__':
    solve()


Measured memory_bytes: 24788
n = int(input())


def gcd(a,b):
  if a % b == 0:
    return b
  return gcd(b, a%b)


ans = 0
d = [0] * (n+1)
for i in range(1,n+1):
  for j in range(1,n+1):
    d[gcd(i,j)] += 1

for i in range(1,n+1):
    for j in range(1,n+1):
        ans += gcd(i,j) * d[i]
print(ans)

Measured memory_bytes: 9148
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
   int r , d , x;
   cin >> r >> d >> x;
   for(int i = 0;i < 10;i++){
       x = r * x - d;
       cout << x << endl; 
   }
  }



Measured memory_bytes: 256
#include<iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int count=0;
void merge(int a[],int left,int mid,int right){
    int n1=mid-left,n2=right-mid;
    int l[n1+1],r[n2+1];
    for(int i=0;i<n1;i++){
	    l[i]=a[left+i];
	}
    for(int i=0;i<n2;i++) {
	   r[i]=a[mid+i];
	}
    l[n1]=1000000000; 
    r[n2]=1000000000;
    int i=0,j=0;
    for(int k=left;k<right;k++){
        count++;
        if(l[i]<=r[j]){
            a[k]=l[i];
            i++;
        }
        else{
            a[k]=r[j];
            j++;
        }
    }
}
void mergesort(int a[],int left,int right){
    if(left+1<right){
        int mid=(left+right)/2;
        mergesort(a,left,mid);
        mergesort(a,mid,right);
        merge(a,left,mid,right);
    }
}
 
int main(){
    int n;  
    cin>>n;
    int data[n];
    for(int i=0;i<n;i++){
        cin>>data[i];
    }
    mergesort(data,0,n);
    printf("%d",data[0]);
    for(int i=1;i<n;i++){
		 printf(" %d",data[i]);
	}  
    printf("\n%d\n",count);
    return 0;
}


Measured memory_bytes: 7016
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
const long long INF = 1LL << 60;

int main(){
    int H, W, h, w;
    scanf("%d %d %d %d", &H, &W, &h, &w);
    if(h*w == 1){
        printf("No\n");
        return 0;
    }
    long long plus = 999999999/(h*w - 1);
    long long minus = -plus*(h*w - 1) - 1;
    if(plus*(H*W - (H/h*h)*(W/w*w)) - (H/h)*(W/w) < 0) printf("No\n");
    else{
        printf("Yes\n");
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                if(j) printf(" ");
                printf("%lld", ((i + 1) % h == 0 && (j + 1) % w == 0) ? minus : plus);
                if(j == W - 1) printf("\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define int long long 
using namespace std;
signed main(){
  int n,a[100][1000],b[10000],c[100000]={};
  int z=0;
  for(int i=1;i<=3;i++){
    for(int j=1;j<=3;j++){
      cin>>a[i][j];
    }
  }
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>b[i];
  }

  for(int k=1;k<=n;k++){
    for(int i=1;i<=n;i++){
       for(int j=1;j<=n;j++){
        if(b[k]==a[i][j]){
          a[i][j]=1;
        }
      }
    }
  }

  if(a[1][1]==1 && a[2][2]==1 && a[3][3]==1){
    z++;
  }else if(a[2][1]==1 && a[2][2]==1 && a[2][3]==1){
    z++;
  }else if(a[3][1]==1 && a[3][2]==1 && a[3][3]==1){
    z++;
  }else if(a[1][1]==1 && a[2][1]==1 && a[3][1]==1){
    z++;
  }else if(a[1][2]==1 && a[2][2]==1 && a[3][2]==1){
    z++;
  }else if(a[1][3]==1 && a[2][3]==1 && a[3][3]==1){
    z++;
  }else if(a[1][1]==1 && a[2][2]==1 && a[3][3]==1){
    z++;
  }else if(a[3][1]==1 && a[2][2]==1 && a[1][3]==1){
    z++;
  }

  if(z>0){
    cout<<"Yes\n";
  }else {
    cout<<"No\n";
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int c = b - a;
		if (c <= 0) {
			System.out.println("delicious");
		} else if (c <= x) {
			System.out.println("safe");
		} else {
			System.out.println("dangerous");
		}
	}

}

Measured memory_bytes: 21716
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define FRE freopen("in.txt", "r", stdin);
#define endl "\n"
#define PI acos(-1.0)
typedef long long LL;
typedef pair<int, int> PII;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 2e5 + 10, M = 17;

int a[N];
int dp[N];
vector<int> e[N];
vector<int> vec;

void dfs(int u, int fa) {
	for(int i = 0; i < e[u].size(); i++) {
		int v = e[u][i];
		if(v == fa) continue;
		int l = 0, r = vec.size() - 1, x = -1;
		while(l <= r) {
			int mid = l + r >> 1;
			if(vec[mid] >= a[v]) {
				x = mid;
				r = mid - 1;
			} else l = mid + 1;
		}
		int tmp;
		if(x == -1) {
			vec.push_back(a[v]);
			int num = vec.size();
			dp[v] = max(num, dp[u]);
		}
		else {
			tmp = vec[x];
			vec[x] = a[v];
			dp[v] = max(x + 1, dp[u]);
		}
		dfs(v, u);
		if(x == -1) vec.pop_back();
		else vec[x] = tmp;
	}
}

void solve() {
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for(int i = 1; i < n; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		e[u].push_back(v);
		e[v].push_back(u);
	}
	dp[1] = 1;
	vec.push_back(a[1]);
	dfs(1, 0);
	for(int i = 1; i <= n; i++) printf("%d\n", dp[i]);
}

int main() {
//	FRE;
//	int t; scanf("%d", &t); while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 33312
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define INF_MAX INT_MAX
#define INF_MIN ((int)1<<31)-1
using namespace std;
class Segtree{
    vector<int> tree;
    int n=1,m,Inf;
    void Set(vector<int> vec){
        rep(i,n*2-2)tree[i+1]=Inf;
        rep(i,vec.size())tree[i+n]=vec.at(i);
        update(0,n-1);
    }
    int sum(int a,int b){
        if(m==0)return max(a,b);
        else if(m==1)return min(a,b);
        else if(m==2)return a+b;
        else return a*b;
    }
    int query(int a,int b,int x,int l,int r){
        if(r<a||b<l)return Inf;
        if(a<=l&&b>=r)return tree[x];
        return sum(query(a,b,x*2,l,(l+r)/2),query(a,b,x*2+1,(l+r)/2+1,r));
    }
    void update(int l,int r){
        l+=n,r+=n;
        l/=2,r/=2;
        while(1){
            if(l==0)break;
            int xl=l;
            for(;xl<=r;xl+=2){
                tree[xl]=sum(tree[xl*2],tree[xl*2+1]);
            }
            l/=2,r/=2;
        }
    }
public:
    void Max(vector<int> vec){
        m=0;
        Inf=INF_MAX;
        Set(vec);
    }
    void Min(vector<int> vec){
        m=1;
        Inf=INF_MIN;
        Set(vec);
    }
    void Add(vector<int> vec){
        m=2;
        Inf=0;
        Set(vec);
    }
    void Multiply(vector<int> vec){
        m=3;
        Inf=1;
        Set(vec);
    }
    Segtree(int in){
        for(;in>n;n*=2);
        tree.resize(n*2);
    }
    void Set(int a,int b){
        tree[a+n]=b;
        update(a,a);
    }
    int query(int a,int b){
        return query(a,b,1,0,n-1);
    }
};
class Union_Find{
private:
    vector<int> t,s;
public:
    Union_Find(int max_length){
        rep(i,max_length+1){
            t.push_back(i);
            s.push_back(1);
        }
    }
    void Union(int x,int y){
        if(same(x,y))return;
        int tx=Find(x),ty=Find(y);
        if(s[tx]<s[ty]){
            s[ty]+=s[tx];
            t[tx]=ty;
        }
        else if(s[tx]>s[ty]){
            s[tx]+=s[ty];
            t[ty]=tx;
        }
        else if(tx>ty){
            t[tx]=ty;
            s[ty]+=s[tx];
        }
        else{
            t[ty]=tx;
            s[tx]+=s[ty];
        }
    }
    int Find(int n){
        if(t[n]==n)return n;
        else return t[n]=Find(t[n]);
    }
    bool same(int x,int y){
        return Find(x)==Find(y);
    }
};
signed main(){
    int n,m,x[100000],ans=0,memo[100000];
    cin>>n>>m;
    rep(i,m){
        cin>>x[i];
    }
    sort(x,x+m);
    if(m==1)cout<<0<<endl;
    else{
        rep(i,m-1){
            memo[i]=x[i+1]-x[i];
            ans+=x[i+1]-x[i];
        }
        sort(memo,memo+m-1);
        rep(i,n-1){
            ans-=memo[m-i-2];
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;

int n;

char a[10];

void f(int i, int mx) {
    if (i == n) {
        for (int j = 0; j < i; j++) cout << a[j];
        cout << '\n';
    } else {
        for (int v = 0; v <= mx; v++) {
            a[i] = v + 'a';
            f(i + 1, mx);
        }
        if (mx != n) {
            a[i] = mx + 'a' + 1;
            f(i + 1, mx + 1);
        }
    }
}

void PUNKS_NOT_DEAD() {
    cin >> n;
    f(0, -1);
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    PUNKS_NOT_DEAD();
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;



template <typename T> T gcd(T a, T b) {if(b == 0) return a;return gcd(b,a%b);}
template <typename T> T lcm(T a, T b) {return a*b/gcd(a,b);}

int main()
{
    int N;
    cin >> N;
    vl T(N);
    in(N,T);
    
    ll ans = T[0];
    rep(i,N){
        ll a = gcd(T[i],ans);
        T[i] /= a;
        ans /= a;
        ans = T[i]*ans*a;
        
    }
    out(ans);

    


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main(){
	int i,n,m,j;
	int a[11][11];
	cin>>n>>m;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++)cin>>a[i][j];
	}
	int s=0;
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			int ans=0;
			for(int k=0;k<m;k++){
				ans+=pow(abs(a[i][k]-a[j][k]),2);
			}
			if(sqrt(ans*1.0)==int(sqrt(ans)))s++;
		}
	}
	cout<<s;
	return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)

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

	char s;
	cin >> s;
	char t = toupper(s);
	if (t == s) cout << "A" << endl;
	else cout << "a" << endl;
 	return 0;
}


Measured memory_bytes: 3632
#a,b = (int(i) for i in input().split())
def kouyaku(a,b):
    if a<b:
        temp = a
        a = b
        b = temp
    if b == 0:
        return a
    r = a%b
    if r == 0:
        return b
    else:
        return kouyaku(b,r)

if __name__ == "__main__":
    a,b = (int(i) for i in input().split())
    s = kouyaku(a,b)
    if s == 1:
        print(1)
        exit()
    ans = 1
    for i in range(2, int(s**0.5)+1):
        if s == 1: 
            break
        if s%i == 0:
            ans += 1
            while s%i == 0:
                s = s/i
    if s>int(s**0.5):
        ans += 1
    print(ans)

Measured memory_bytes: 3064
I = input().split()
a = int(I[0])
b = int(I[1])
c = int(I[2])
0 <= a,b,c <=100
if (b < a) : 
    n = a
    a = b
    b = n
if (c < b) : 
    n = b 
    b = c
    c = n
if (b < a) :
    n = a
    a = b
    b = n
print(str(a)+" "+str(b)+" "+str(c))


Measured memory_bytes: 5600
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define pb push_back
#define f first
#define s second
#define double long double
const int MAX=2e5+5;
const int MAX2=2e5+4;
const int MAAX=2e18;
const int MOD=1e9+7;
in main()
{
string s;
int n,k;
cin>>n>>k;
cin>>s;
s[k-1]=tolower(s[k-1]);
cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back 
#define mp make_pair
using namespace std;

const int maxn=2e5+7;
typedef long long ll;

ll n,m,ans,k;
ll a[maxn],pre[maxn],t[maxn];

void mergesort(ll l,ll r)
{
	ll i,j,k,m;
	m=(l+r)/2;
	if(l==r) return;
	
	mergesort(l,m);
	mergesort(m+1,r);
	
	k=i=l,j=m+1;
	while(i<=m&&j<=r)
	{
		if(a[i]<=a[j])
		{
			ans+=r-j+1;
			t[k++]=a[i++];
		}
		else t[k++]=a[j++];
	}
	
	while(i<=m) t[k++]=a[i++];
	while(j<=r) t[k++]=a[j++];
	for(i=l;i<=r;++i) a[i]=t[i];
}

int main()
{
	int i,j;
	scanf("%lld%lld",&n,&k);
	
	for(i=1;i<=n;++i)
	{
		scanf("%lld",&a[i]);
		pre[i]=pre[i-1]+a[i];
		a[i]=pre[i]-i*k;
	}
	/*
	for(i=0;i<=n;++i)
	{
		printf("%lld ",a[i]);
	}
	printf("\n");
	*/
	mergesort(0,n);
	/*
	for(i=0;i<=n;++i)
	{
		printf("%lld ",a[i]);
	}
	printf("\n");
	*/
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 4992
/*
AizuOnline A1129
Title Hanafuda shuffle
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int yama[100];   // 0:ue n-1:shita
int buf[100];
int c[100],p[100];
int n,r;
//
init()
{
  int i;
  for(i=0;i<n;i++)
    yama[n-1-i]=i+1;
}
show()
{
  int i;
  for(i=0;i<n;i++)
    printf("%d:",yama[i]);
  printf("\n");
}
shuffle(int * y,int n,int c,int p)
{
  memmove(buf,y+p-1,c*sizeof(int));
#ifdef DEBUG
  show();
#endif
  memmove(y+c,y, (p-1)*sizeof(int));
#ifdef DEBUG
  show();
#endif
  memmove(y,buf,c*sizeof(int));
}

main()
{
  int i;

  while(EOF!=scanf("%d %d",&n,&r) && (n||r))
    {
      init();
      for(i=0;i<r;i++)
	scanf("%d %d",&p[i],&c[i]);
#ifdef DEBUG
      show();
#endif
      for(i=0;i<r;i++)
	{
	  shuffle(yama,n,c[i],p[i]);
#ifdef DEBUG
	  show();
#endif
	}
      printf("%d\n",yama[0]);
    }
return(0);
}

Measured memory_bytes: 624
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
p = LIST()

ans = 0

for i in range(N):
	p[i] = (p[i]+1)/2

l = 0
r = K-1
ans = 0

for i in range(K):
	ans += p[i]

anss = copy(ans)

for i in range(N-K):
	anss -= p[i]
	anss += p[i+K]
	ans = max(ans, anss)

print(ans)


Measured memory_bytes: 27256