akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main(){
	int n; cin >> n;
	vector<int> a(n);
	map<int,int> mp;
	for(auto &x:a){
		cin >> x;
		mp[x]++;
	}
	sort(a.begin(),a.end());
	unique(a.begin(),a.end());
	if(mp.size()==3){
		if((mp[a[0]]==mp[a[1]]) && (mp[a[1]]==mp[a[2]]) && ((a[0]^a[1])==a[2])){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}
	else if(mp.size()==2){
		if(mp[a[1]]==2*mp[0]){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}
	else if(mp.size()==1){
		if(mp[0]){
			cout << "Yes" << endl; 
		}
		else{
			cout << "No" << endl;
		}
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 4224
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;

fn main() {
    input! {
    n: usize,
    m: usize,
    lr: [(usize, usize); m]
    }
    let (mut s, mut t) = (0, n);
    for i in 0..m {
        let (l, r) = lr[i];
        if l > s {s = l};
        if r < t {t = r};
    }
    let ans = if s > t { 0 } else {t - s + 1};
    println!("{}", ans);
}



Measured memory_bytes: 4604
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define MAXK 205
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,x,s[MAXN];
int fact[MAXN],invf[MAXN];
int dp[MAXK][MAXN];
void add(int &a,int b) {a+=b; if(a>=MOD) a-=MOD;}
int pow_mod(int a,int i)
{
    int s=1;
    while(i)
    {
        if(i&1) s=1LL*s*a%MOD;
        a=1LL*a*a%MOD;
        i>>=1;
    }
    return s;
}
int comb(int n,int k) 
{
    if(n<k) return 0;
    return 1LL*fact[n]*invf[k]%MOD*invf[n-k]%MOD;
}
int main()
{
    fact[0]=invf[0]=1;
    for(int i=1;i<=200;i++) fact[i]=1LL*fact[i-1]*i%MOD;
    invf[200]=pow_mod(fact[200],MOD-2);
    for(int i=199;i>=1;i--) invf[i]=1LL*invf[i+1]*(i+1)%MOD;
    scanf("%d%d",&n,&x);
    for(int i=1;i<=n;i++) scanf("%d",&s[i]);
    sort(s+1,s+n+1);
    for(int j=0;j<=x;j++) dp[0][j]=j;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=x;j++)
        {
            add(dp[i][j],dp[i-1][j%s[i]]);
            add(dp[i][j],1LL*(i-1)*dp[i-1][j]%MOD);
        }
    }
    printf("%d\n",dp[n][x]);
    return 0;
}



Measured memory_bytes: 80128
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let m = read_as_vec::<u32>()[0];

    println!("{}", 48-m);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <limits.h>
using namespace std;

#define Rep(i,n) for(int i = 0; i < n; ++i )
#define For(i,s,e) for(int i = s; i < e; ++i )
#define ll long long

long N;
long H[101] = {0};

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

	cin >> N;
	Rep(i,N) cin >> H[i];
	int c = 0;
	for(int i = 0; i < N; ++i ){
		while( true ){
			if( 0 == H[i] )
				break;
			++c;
			for(int j = i; j < N; ++j ){
				if( H[j] > 0 )
					--H[j];
				else
					break;
			}

		}
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (true) {
			int n = in.nextInt();
			if (n == 0) {
				break;
			}
			int[][] d = new int[10][10];
			for (int i = 0; i < 10; i++) {
				for (int j = 0; j < 10; j++) {
					d[i][j] = (i == j) ? 0 : Integer.MAX_VALUE / 2;
				}
			}
			int m = 0;
			for (; n > 0; n--) {
				int a = in.nextInt();
				int b = in.nextInt();
				int c = in.nextInt();
				d[a][b] = c;
				d[b][a] = c;
				m = Math.max(m, a + 1);
				m = Math.max(m, b + 1);
			}
			
			for (int k = 0; k < m; k++) {
				for (int i = 0; i < m; i++) {
					for (int j = 0; j < m; j++) {
						d[i][j] = Math.min(d[i][j], d[i][k] + d[k][j]);
					}
				}
			}
			int ans = -1, min = Integer.MAX_VALUE;
			for (int i = 0; i < m; i++) {
				int sum = 0;
				for (int j = 0; j < m; j++) {
					sum += d[i][j];
				}
				if (sum < min) {
					ans = i;
					min = sum;
				}
			}
			
			System.out.println(ans + " " + min);
		}
	}
}

Measured memory_bytes: 19688
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 ALL(v) v.begin(), v.end()
int n;
vector<int> a, b, c;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int tempa, tempb, tempc;
        cin >> tempa>>tempb>>tempc;
        a.push_back(tempa);
        b.push_back(tempb);
        c.push_back(tempc);
    }
    int dp[n+1][3];
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(int i=1;i<n;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<"\n";
}


Measured memory_bytes: 2924
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
}
const int N=300+5;
int n,a[N];
int dp[N][N*N];
const int mo=998244353;
void input()
{
	n=read<int>();
	For(i,1,n)a[i]=read<int>();
}
int f[N*N];
void work()
{
	int sum=0;
	For(i,1,n)sum+=a[i];
	dp[0][0]=1;
	f[0]=1;
	For(i,1,n)
	{
		For(j,0,sum/2)
		{
			dp[i][j]=dp[i-1][j];
			if(j>=a[i])dp[i][j]=(dp[i][j]+2ll*dp[i-1][j-a[i]])%mo;
		}
		Fordown(j,sum/2,a[i])f[j]=(f[j]+f[j-a[i]])%mo;
	}
	int ans=1;
	For(i,1,n)ans=3ll*ans%mo;
	For(j,0,sum/2)ans=(ans-3ll*dp[n][j]%mo+mo)%mo;
//	cerr<<f[sum]
	if((sum%2==0))ans=(ans+3ll*f[sum/2])%mo;
	write(ans,'\n');
}
int main()
{

	input();
	work();
	return 0;
}



Measured memory_bytes: 109696
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

inline int read(){
	int sum=0,f=1;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=sum*10+ch-'0';ch=getchar();}
	return f*sum;
}

const int N=5001;
const int Mod=1e9+7;
struct edge{int to,next;}e[N<<1];
int n,tem[N],size[N],f[N][N],x,y;
int g[N],head[N],cnt;

inline void add(int x,int y){
	e[++cnt]=(edge){head[x],y};head[x]=cnt;
}

inline void dfs(int x,int fa){
	f[x][size[x]=1]=1;
	for(int i=head[x];i;i=e[i].to){
		int k=e[i].next;if(k==fa) continue;dfs(k,x);
		for(int i=1;i<=size[x]+size[k];i++) tem[i]=0;
		for(int i=1;i<=size[x];i++)
			for(int j=0;j<=size[k];j++)
				(tem[i+j]+=1ll*f[x][i]*f[k][j]%Mod)%=Mod;
		for(int i=1;i<=size[x]+size[k];i++) f[x][i]=tem[i];
		size[x]+=size[k];
	}
	for(int i=2;i<=size[x];i+=2) (f[x][0]+=Mod-1ll*f[x][i]*g[i]%Mod)%=Mod;
}

int main(){
	n=read();g[0]=1;
	for(int i=2;i<=n;i+=2) g[i]=1ll*(i-1)*g[i-2]%Mod;
	for(int i=1;i<n;i++) x=read(),y=read(),add(x,y),add(y,x);
	dfs(1,0);
	printf("%d\n",Mod-f[1][0]);
	return 0;
}


Measured memory_bytes: 96896
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M=MI()
    if(N&1):
        N+=1
        for i in range(M):
            print(i+1+1,N-i-2+1)
    else:
        used = set()
        for i in range(1,M+1):
            if(i<=N/4):
                print(i,N-i+1)
            else:
                print(i,N-i)

if __name__ == '__main__':
    main()

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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

ll gcd(ll x, ll y) {
    return x ? gcd(y % x, x) : y;
}

ll lcm(ll x, ll y) {
    return (x * y) / gcd(x, y);
}

int main() {
    ll n, m, i, j, k;
    cin >> n >> m;
    vector<ll> a(n);
    ll l = 1;
    for(auto &x : a) {
        cin >> x;
        l=lcm(l,x/2);
    }
    ll ret = 0;
    //cout << l << endl;
    for(auto &x:a){
        if(l%x==0){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (m/l+1)/2 << endl;
    return 0;
}


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

int main(){

    ll n;
    cin >> n;

    for(ll i=0;i*i<=1e+10;i++){
        if(i*i>n){
            cout << (i-1)*(i-1) << endl;
            return 0; 
        }
    }

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define MAXN 200005
using namespace std;
int a[MAXN];
int main()
{
	int n;
	long long ans = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		if (i != 1) {
			if (a[i] < a[i - 1]) {
				ans += a[i - 1] - a[i];
				a[i] = a[i - 1];
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4480
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define mod 1000000007
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define R(i,a,b) for (int i=(a);i<(b);i++)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("-1"),0;
#define N 500055
//#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,a[N];
int check(int x){
	int mx=0;
	F(i,1,x) mx=max(mx,a[i]+a[x*2-i+1]);
	F(i,1,n-x){
		int t=a[x*2+i]+a[n*2-i+1]-m;
		if (t<0) return -1;
		mx=max(mx,t);
	}
	return mx;
}
signed main(){
	n=read();m=read();
	F(i,1,n*2) a[i]=read();
	sort(a+1,a+n*2+1);
	int l=0,r=n;
	while (l<r){
		int mid=(l+r)>>1;
		if (check(mid)>=0) r=mid;
		else l=mid+1;
	}
	wrn(check(l));
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int x, y, xx, yy;

int main() {
	cin >> x >> y >> xx >> yy;
	
	rep(i,xx-x) cout << "R";
	rep(i,yy-y) cout << "U";
	rep(i,xx-x) cout << "L";
	rep(i,yy-y+1) cout << "D";
	rep(i,xx-x+1) cout << "R";
	rep(i,yy-y+1) cout << "U";
	cout << "LU";
	rep(i,xx-x+1) cout << "L";
	rep(i,yy-y+1) cout << "D";
	cout << "R" << ln;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define N 25

struct Node{
  int left,right;
  int parent;
  int id;
};
struct Node T[N];
int P[N],I[N],Po[N];
int pre=0,in=0,post=0;
int n;

void presort(int);
void insort(int);
void postsort(int);

int main(void){

  scanf("%d",&n);
 
  int i,j;
  for(i=0;i<n;i++){
    T[i].parent = -1;
  }

  for(i=0;i<n;i++){
    scanf("%d %d %d",&T[i].id,&T[i].left,&T[i].right);
  }

  for(i=0;i<n;i++){
    int R = T[i].right;
    int L = T[i].left;
    if(R != -1)  {
      for(j=0;j<n;j++){
        if(T[j].id == R){
          T[j].parent = T[i].id;
          break;
        }
      }
    }
    if(L != -1) {
      for(j=0;j<n;j++){
        if(T[j].id == L){
          T[j].parent = T[i].id;
          break;
        }
      }
    }
  }
  
  int p;
  for(i=0;i<n;i++){
    if(T[i].parent == -1) {
      p = T[i].id;
      break;
    }
  }

  presort(p);
  insort(p);
  postsort(p);

  printf("Preorder\n");
  for(i=0;i<n;i++){
    printf(" %d",P[i]);
    if(i == n-1) printf("\n"); 
  }

  printf("Inorder\n");
  for(i=0;i<n;i++){
    printf(" %d",I[i]);
    if(i == n-1) printf("\n");
  }

  printf("Postorder\n");
  for(i=0;i<n;i++){
    printf(" %d",Po[i]);
    if(i == n-1) printf("\n");
  }
}

void presort(int p){
  int i,x;

  for(i=0;i<n;i++){
    if(T[i].id == p){
      x = i;
      break;
    }
  }

  P[pre] = p;
  pre++;
  
  if(T[x].left != -1) presort(T[x].left);
  if(T[x].right != -1) presort(T[x].right);
}

void insort(int p){
  int i,x;

  for(i=0;i<n;i++){
    if(T[i].id == p){
      x = i;
      break;
    }
  }

  if(T[x].left != -1) insort(T[x].left);

  I[in] = p;
  in++;

  if(T[x].right != -1) insort(T[x].right);
}

void postsort(int p){
  int i,x;

  for(i=0;i<n;i++){
    if(T[i].id == p){
      x = i;
      break;
    }
  }

  if(T[x].left != -1) postsort(T[x].left);
  if(T[x].right != -1) postsort(T[x].right);

  Po[post] = p;
  post++;
}


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

int main() {
	int n,k;
	cin >> n >> k;
	vector<int> p(n);
	rep(i,n) {
		cin >> p[i];
		p[i]++;
	}
	int s = 0;
	int mx = 0;
	queue<int> q;
	rep(i,n) {
		s += p[i];
		q.push(p[i]);
		if(q.size() > k) {
			s -= q.front();q.pop();
		}
		if(q.size() == k) {
			mx = max(mx,s);
		}
	}
	double ans = mx;
	ans /= 2;
	printf("%.10f\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

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;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;
int main(){
  int N;cin>>N;vi A(N-1);rep(i,N-1)cin>>A[i];
  vi num(N+1);
  rep(i,N-1){
    num[A[i]]++;
  }
  for(int i=1;i<=N;i++){
   cout<<num[i]<<endl;
  }
}





Measured memory_bytes: 4844
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	int *a, *b, s, t, c;
	int p, q;
	a = &p;
	b = &q;
	while(cin >> p >> q){
		s = *a;
		t = *b;
		c = 1;
		for(int tmp = (*a > *b)? *b : *a, i = 2; i <= tmp; i++){
			while(s%i == 0 && t%i == 0){
				s /= i;
				t /= i;
				tmp /= i;
				c *= i;
			}
		}
		cout << c << endl;
}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        String S = sc.next();
        String T = sc.next();
 
        System.out.println(solve(S, T) ? "Yes" : "No");
 
        sc.close();
    }
 
    static boolean solve(String S, String T) {
        return String.format("%s%s", S, S).contains(T);
    }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()

const ll mod=1000000007;

int countBits(int in){
  int res=0;
  for(int i=0;i<10;i++){
    int msk=1<<i;
    if((in&msk)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n;cin>>n;
  vector<int> a(n+1);
  for(int i=1;i<n+1;i++){
    cin>>a[i];
  }
  ll ans=0;
  map<int,vector<int>> mp;
  for(int i=1;i<n+1;i++){
    mp[i-a[i]].push_back(i);
  }
  for(int i=1;i<n+1;i++){
    int val=i+a[i];
    ans+=mp[val].size();
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 38200
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define NMAX 40000
#define INF 200000000
#define REP 60
struct line {
  int a;
  int b;
  int c;
  int i;
  double g;
};
int compare(const void *a, const void *b);
void add(int *bit, int index, int value, int size);
int sum(int *bit, int index);
int main(void)
{
  int d, i, r, n, m, t, h, bit[NMAX+1];
  double mid, lo, hi;
  struct line l[NMAX];
  scanf("%d", &n);
  m = (n - 1) * n / 2;
  t = (m + 1) / 2;
  for (i = 0; i < n; i++) scanf("%d %d %d", &l[i].a, &l[i].b, &l[i].c);
  for (d = 0; d < 2; d++) {
    for (i = 0; i < n; i++) l[i].g = (double)l[i].a / l[i].b;
    qsort(l, n, sizeof(struct line), compare);
    for (i = 0; i < n; i++) l[i].i = i;
    lo = -INF;
    hi = INF;
    for (r = 0; r < REP; r++) {
      mid = (lo + hi) / 2;
      for (i = 0; i < n; i++) l[i].g = (l[i].c - l[i].a * mid) / l[i].b;
      qsort(l, n, sizeof(struct line), compare);
      memset(bit, 0, sizeof(bit));
      h = m;
      for (i = 0; i < n; i++) {
        h -= sum(bit, l[i].i + 1);
        add(bit, l[i].i + 1, 1, n);
      }
      if (h >= t) hi = mid;
      else lo = mid;
    }
    printf("%.9f%c", mid, (d == 0) ? ' ' : '\n');
    for (i = 0; i < n; i++) {
      int temp = l[i].a;
      l[i].a = l[i].b;
      l[i].b = temp;
    }
  }
}

int compare(const void *a, const void *b)
{
  double ta = ((struct line*)a)->g, tb = ((struct line*)b)->g;
  if (ta > tb) return 1;
  else if (ta < tb) return -1;
  else return 0;
}

void add(int *bit, int index, int value, int size)
{
  while (index <= size) {
    bit[index] += value;
    index += index & (-index);
  }
}

int sum(int *bit, int index)
{
  int sum = 0;
  while (index > 0) {
    sum += bit[index];
    index -= index & (-index);
  }
  return sum;
}

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n, ok = 0;
	cin >> n;
	for(int i = 1; i < 10; ++i){
		for(int j = 1; j < 10; ++j){
			if(n == i * j) ok = 1;
		}
	}
	if(ok) cout << "Yes";
	else cout << "No";

	return 0;
}



Measured memory_bytes: 256
N=int(input())
ans=0
def solve(st):
    if int(st)>N:
        return 0
    if all([st.count(c) for c in '357']):
        global ans
        ans = ans + 1
    solve(st+'3')
    solve(st+'5')
    solve(st+'7')
solve('0')
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <stdio.h>
using namespace std;
long long x,y,z;
int main(void){
int n;
scanf("%d",&n);
    long long a[n],b[n];
    for(int i=0;i<n;i++){
        scanf("%lld%lld",&a[i],&b[i]);
    }
    for(int i=0;i<n;i++){
        if(a[i]==b[i])x++;
    }
    if(x==n)printf("0\n");
    else{x=1000000000;
        for(int i=0;i<n;i++){
        y+=b[i];}
        for(int i=0;i<n;i++){
            if(a[i]>b[i]&&x>b[i]){
                x=b[i];
            }
        }
        z=y-x;
    
    printf("%lld\n",z);}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
using namespace std;

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

Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True


def main():
    N = I()
    A = LI()
    mx = A[0]
    ans = 0

    for i in range(1, N):
        if mx > A[i]:
            ans += abs(A[i] - mx)
        else:
            mx = max(A[i], mx)

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 102272
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<set>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<queue>
#define mem(x) memset(x,0,sizeof(x)) 
#define sca(x) scanf("%d",&x)
#define scaa(x,y) scanf("%d%d",&x,&y)
#define inf 0x7f7f7f7f
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#pragma GCC optimize(2)
using namespace std;
const double pi=acos(-1); 
const double eps=1e-6;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<char,char> pcc;
ll a[200005];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	ll ans=a[n-1];
	int j=n-2;
	for(int i=0;i<n-2;i++)
	{
		ans+=a[j];
		if(i%2==1)
		j--;
	}
	cout<<ans<<endl;
} 

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

int main(){
    while(true){
    ll n,k;
    cin>>n>>k;
    if(n==0&&k==0)return 0;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    set<string> ans;
    if(k==2){
        rep(i,n){
            rep(j,n){
                if(i==j)continue;
                string v;
                v+=to_string(a[i])+to_string(a[j]);
                ans.insert(v);
            }
        }
    }else if(k==3){
        rep(i,n){
            rep(j,n){
                if(i==j)continue;
                rep(l,n){
                    if(i==l || j==l)continue;
                    string v;
                    v+=to_string(a[i])+to_string(a[j])+to_string(a[l]);
                    ans.insert(v);
                }
            }
        }
    }else if(k==4){
        rep(i,n){
            rep(j,n){
                if(i==j)continue;
                rep(l,n){
                    if(i==l || j==l)continue;
                    rep(m,n){
                        if(i==m || j==m || l==m)continue;
                        string v;
                        v+=to_string(a[i])+to_string(a[j])+to_string(a[l])+to_string(a[m]);
                        ans.insert(v);
                    }
                }
            }
        }
    }
    cout<<ans.size()<<endl;
    }
}



Measured memory_bytes: 3432
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
#define Swap(a,b) (a+=b,b=a-b,a-=b)
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
static inline char GET(void)
{
  static char buf[1<<15],*s1=buf,*s2=buf;
  return s1==s2&&(s2=(s1=buf)+fread(buf,1,1<<15,stdin),s1==s2)?EOF:*s1++;
}
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=GET();while(c<48||c>57){f^=c==45,c=GET();}
  while(c>47&&c<58){x=x*10+c-48,c=GET();}return f?-x:x;
}
static inline void OUT(int a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
static inline int Max(int x,int y){return x>y?x:y;}
int work[9999][3],sz=0;
static inline void Add(int x,int y,int v){work[sz][0]=x;work[sz][1]=y;work[sz++][2]=v;}
int main(void)
{
  int N=IN(),A[3*N],dp[N][N],B[N],mx,extra=0;
  rep(i,3*N)A[i]=IN()-1;
  memset(B,-0x3f,sizeof(B));
  memset(dp,-0x3f,sizeof(dp));
  dp[A[0]][A[1]]=dp[A[1]][A[0]]=B[A[0]]=B[A[1]]=mx=0;
  rep(i,N-1)
  {
    int k=3*(i+1);
    if(A[k-1]>A[k])Swap(A[k-1],A[k]);
    if(A[k]>A[k+1])Swap(A[k],A[k+1]);
    if(A[k-1]>A[k])Swap(A[k-1],A[k]);
    int x[3]={A[k-1],A[k],A[k+1]};
    if(x[2]==x[0]){extra++;continue;}
    if(x[0]==x[1])rep(j,N)Add(j,x[2],dp[j][x[0]]+1);
    if(x[1]==x[2])rep(j,N)Add(j,x[0],dp[j][x[1]]+1);
    rep(j,3)Add(x[j==0],x[j==2?1:2],dp[x[j]][x[j]]+1);
    rep(j,3)rep(k,j)Add(x[j],x[k],mx);
    rep(j,N)rep(k,3)Add(j,x[k],B[j]);
    rep(j,sz)if(dp[work[j][0]][work[j][1]]<work[j][2])
      dp[work[j][0]][work[j][1]]=dp[work[j][1]][work[j][0]]=work[j][2],
      B[work[j][0]]=Max(B[work[j][0]],work[j][2]),
      B[work[j][1]]=Max(B[work[j][1]],work[j][2]),mx=Max(mx,work[j][2]);
    sz=0;
  }
  return OUT(Max(mx,dp[A[3*N-1]][A[3*N-1]]+1)+extra),0;
}

Measured memory_bytes: 17236
def solve(D, G):
    p, c = [], []

    for _ in range(D):
        _p, _c = map(int, input().split())
        p.append(_p)
        c.append(_c)

    each_total = []
    ans = float('inf')

    for i in range(D):
        each_total.append((p[i])*(i+1)*100+c[i])

    for j in range(1 << D):
        total_ope, total_score = 0, 0
        for k in range(D):
            if j >> k & 1:
                total_score += each_total[k]
                total_ope += p[k]
            else:
                solve_half = k

        for _ in range(p[solve_half]-1):
            if total_score >= G:
                break
            else:
                total_score += 100*(solve_half+1)
                total_ope += 1
        if total_score < G:
            continue

        ans = min(ans, total_ope)

    return ans


if __name__ == '__main__':
    D, G = map(int, input().split())
    print(solve(D, G))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define LINY "YES\n"
#define Liny "Yes\n"
#define LINN "NO\n"
#define Linn "No\n"
#define umap unordered_map
//std::cout << std::setfill('0') << std::right << std::setw(4) << 12; // "0012"

ll min(ll x,ll y){return (x<y ? x:y);}
ll max(ll x,ll y){return (x>y ? x:y);}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a*b /gcd(a,b);}


int main(){
  string s; cin>>s;
  int N = s.size();
  int count[2] = {0};
  REP(i,N){
    count[ctoi(s[i])]++;
  }
  cout << min(count[0],count[1])*2 << "\n";
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{

  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);

  int n;
  cin >> n;
  rep(i, n)
  {
    int a;
    cin >> a;
    if (a % 2 == 1)
    {
      cout << "first" << endl;
      return 0;
    }
  }
  cout << "second" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i,n) for(int i = 0;  i < n ; ++i)
#define REP(i,a,b) for(int i = a ; i <= b ; ++i)
#define filei freopen("input.txt", "r", stdin);
#define fileo freopen("output.txt", "w", stdout);
#define gooi cout<<"Case #"<<i+1<<" :";
#define s(n) scanf("%d",&n)
#define rev(i,n) for(int i = n ; i >= 0 ; --i)
#define REV(i,a,b) for(int i = a ; i >= b ; --i)
#define miN(a,b) (((a)<(b))?(a):(b))
#define sc(n) scanf("%c",&n)
#define tr(c,i) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define INF 1000000000
#define pii pair<long long int,long long int>
#define pb(a) push_back(a)
#define F first
#define S second
typedef long long ll;
using namespace std;
void pre(){}
void solve(){
    ll a;cin>>a;
    cout<<a*(a*(a+1)+ 1)<<"\n";   
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}





Measured memory_bytes: 3608
#!/usr/bin/env python

from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
A = map(int, raw_input().split())

pos1 = pos2 = 0
flag1 = flag2 = False
for i in range(N):
	if A[i] > 0:
		flag1 = True
		pos1 = i
	elif A[i] < 0:
		flag2 = True
		pos2 = i

if flag1 and flag2:
	print sum(abs(num) for num in A)
	n1 = A[pos1]
	n2 = A[pos2]
	for i in range(N):
		if i == pos1 or i == pos2:
			continue
		if A[i] > 0:
			print n2, A[i]
			n2 -= A[i]
		else:
			print n1, A[i]
			n1 -= A[i]
	print n1, n2
elif flag1:
	pos = 0
	for i in range(N):
		if A[pos] > A[i]:
			pos = i
	S = 0
	if pos == 0:
		S = 1
	n1 = A[pos]
	print sum(A) - n1 * 2
	for i in range(N):
		if i == pos or i == S:
			continue
		print n1, A[i]
		n1 -= A[i]
	print A[S], n1
else:
	pos = 0
	for i in range(N):
		if A[pos] < A[i]:
			pos = i
	n1 = A[pos]
	print -sum(A) + n1 * 2
	for i in range(N):
		if i == pos:
			continue
		print n1, A[i]
		n1 -= A[i]
		

Measured memory_bytes: 11528
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;

struct edge{int to,cost;};

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

	int h,w,n;
	cin >> h >> w >> n;

	P a_i[n];
	int a;
	for(int i=1;i<=n;i++){
		cin >> a;
		a_i[i-1] = P(a,i);
	}
	sort(a_i,a_i+n);
	int cont[h*w];
	int num=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<a_i[i].first;j++){
			cont[num++] = a_i[i].second;
		}
	}

	num=0;
	int ans[h][w];
	for(int i=0;i<h;i++){
		if(i%2==0){
			for(int j=0;j<w;j++){
				ans[i][j] = cont[num++];
			}
		}
		else if(i%2==1){
			for(int j=w-1;j>=0;j--){
				ans[i][j] = cont[num++];
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout << ans[i][j] << (j!=w-1?" ":"\n");
		}
	}

	return 0;
}

Measured memory_bytes: 512
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        StringBuilder sb = new StringBuilder();
        int n = sc.nextInt();
        for(int i = 0; i < n; i++){
            sb.append("ACL");
        }
        pw.println(sb.toString());
        pw.flush();
    }
    
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

#define INF (1<<30)

long C=0;

void    merge(vector<int> &A, const int &left, const int &mid, const int &right) {
    int n1 = mid - left;
    int n2 = right - mid;
    // L[0...n1], R[0...n2] を生成
    vector<int> L;
    vector<int> R;
    for (int i = 0; i<n1; i++)
        L.push_back(A.at(left+i));
    for (int i = 0; i<n2; i++)
        R.push_back(A.at(mid+i));
    L.push_back(INF);
    R.push_back(INF);
    int i=0;
    int j=0;
    for (int k=left; k<right; k++) {
        if (L.at(i)<=R.at(j)) {
            A.at(k)=L.at(i);
            i++;
        } else {
            A.at(k)=R.at(j);
            j++;
        }
        C++;
    }
}

void    mergeSort(vector<int> &A, const int left, const 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;
    vector<int> A(n, 0);
    for (int i=0; i<n; i++)
        cin >>A.at(i);
    mergeSort(A, 0, n);
    for (int i=0; i<n; i++)
        if (i==0)
            cout <<A.at(i);
        else
            cout <<' ' <<A.at(i);
    cout <<endl;
    cout <<C <<endl;
    return 0;
}



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

using namespace std;

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


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <utility>

const int N = 100000;

int main() {
  int n;
  long long l;
  long long a[N];
  std::cin >> n >> l;
  for (int ni = 0; ni < n; ++ni) {
    std::cin >> a[ni];
  }
  for (int ni = 0; ni < n - 1; ++ni) {
    if (a[ni] + a[ni + 1] >= l) {
      std::cout << "Possible" << std::endl;
      for (int nj = 0; nj < ni; ++nj) {
        std::cout << nj + 1 << std::endl;
      }
      for (int nj = n - 2; nj > ni; --nj) {
        std::cout << nj + 1 << std::endl;
      }
      std::cout << ni + 1 << std::endl;
      return 0;
    }
  }
  std::cout << "Impossible" << std::endl;
  return 0;
}


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

int main() {
    int n, x;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++) {
        cin >> x;
        d.at(i) = x;
    }
    int count = 0, a = 0;
    for (;;) {
        if (a == 1) {
            cout << count << endl;
            break;
        }
        if (count >= n) {
            cout << "-1" << endl;
            break;
        }
        count++;
        a = d.at(a);
        a = a - 1;
    }
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
namespace IO
{
    const int __S=(1<<20)+5;char __buf[__S],*__H,*__T;
    inline char getc()
    {
        if(__H==__T) __T=(__H=__buf)+fread(__buf,1,__S,stdin);
        if(__H==__T) return -1;return *__H++;
    }
    template <class __I>inline void read(__I &__x)
    {
        __x=0;int __fg=1;char __c=getc();
        while(!isdigit(__c)&&__c!='-') __c=getc();
        if(__c=='-') __fg=-1,__c=getc();
        while(isdigit(__c)) __x=__x*10+__c-'0',__c=getc();
        __x*=__fg;
    }
    inline void readd(double &__x)
    {
        __x=0;double __fg=1.0;char __c=getc();
        while(!isdigit(__c)&&__c!='-') __c=getc();
        if(__c=='-') __fg=-1.0,__c=getc();
        while(isdigit(__c)) __x=__x*10.0+__c-'0',__c=getc();
        if(__c!='.'){__x=__x*__fg;return;}else __c=getc();
        double __t=1e-1;while(isdigit(__c)) __x=__x+1.0*(__c-'0')*__t,__t=__t*0.1,__c=getc();
        __x=__x*__fg;
    }
    inline void reads(char *__s,int __x)
    {
        char __c=getc();int __tot=__x-1;
        while(__c<'a'||__c>'z') __c=getc();
        while(__c>='a'&&__c<='z') __s[++__tot]=__c,__c=getc();
        __s[++__tot]='\0';
    }
    char __obuf[__S],*__oS=__obuf,*__oT=__oS+__S-1,__c,__qu[55];int __qr;
    inline void flush(){fwrite(__obuf,1,__oS-__obuf,stdout);__oS=__obuf;}
    inline void putc(char __x){*__oS++ =__x;if(__oS==__oT) flush();}
    template <class __I>inline void print(__I __x)
    {
        if(!__x) putc('0');
        if(__x<0) putc('-'),__x=-__x;
        while(__x) __qu[++__qr]=__x%10+'0',__x/=10;
        while(__qr) putc(__qu[__qr--]);
    }
    inline void prints(const char *__s,const int __x)
    {
        int __len=strlen(__s+__x);
        for(int __i=__x;__i<__len+__x;__i++) putc(__s[__i]);
    }
    inline void printd(long double __x,int __d)
    {
        long long __t=(long long)floor(__x);print(__t);putc('.');__x-=(double)__t;
        while(__d--)
        {
            long double __y=__x*10.0;__x*=10.0;
            int __c=(int)floor(__y+1e-9);if(__c==10) __c--;
            putc(__c+'0');__x-=floor(__y);
        }
    }
    inline void el(){putc('\n');}inline void sp(){putc(' ');}
}using namespace IO;
int n,m,x,y,gg,col[100005],vis[100005],d[100005],a,b,c;long long ans;vector<int>e[100005];
void dfs(int x)
{
	vis[x]=1;
	for(int i=0;i<e[x].size();i++)
	{
		if(vis[e[x][i]]&&col[e[x][i]]==col[x]) gg=0;
		if(!vis[e[x][i]]) col[e[x][i]]=col[x]^1,dfs(e[x][i]);
	}
}
int main()
{
	read(n);read(m);for(int i=1;i<=m;i++) read(x),read(y),e[x].push_back(y),e[y].push_back(x),d[x]++,d[y]++;
	for(int i=1;i<=n;i++) if(!vis[i]){if(!d[i]){a++,vis[i]=1;continue;}gg=1;dfs(i);if(gg) b++;else c++;}
	print(2ll*a*n-1ll*a*a+2ll*b*b+2ll*b*c+1ll*c*c);flush();
}

Measured memory_bytes: 12288
#include <cstdio>
#include <iostream>
using namespace std;
int main(){
  int n, m, k;
  while(cin >> n >> m >> k, n){
    long long int prob[n*m+1];
    fill(prob,prob+n*m+1,0LL);
    fill(prob+1,prob+m+1,1LL);
    long long int t = m;
    for(int i = 1; i < n; ++i){
      t *= m;
      int acum[m*(i+1)+1];
      fill(acum,acum+m*(i+1)+1,0);
      for(int j = 0; j <= m*(i+1); ++j){
	acum[j+1] = acum[j]+prob[j];
      }
      for(int j = 0; j < i; ++j) prob[j] = 0;
      for(int j = i; j <= m*(i+1); ++j){
	prob[j] = acum[j] - acum[max(0,j-m)];
      }
    }
    double ans = 0.0;
    for(int i = n; i <= n*m; ++i){
      ans += (double)max(1,i-k)*prob[i]/t;
    }
    printf("%.12f\n",ans);
  }
  return 0;
}

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

using namespace std;

template <typename T>
struct edge {
	int from, to;
	T cost;

	edge(int from, int to, T cost) :from(from), to(to), cost(cost) {}
};

template <typename T>
vector<T> bellman_ford(int s, int V, vector<edge<T> >& G) {
	const T INF = numeric_limits<T>::max();
	vector<T> cost(V, INF);
	cost[s] = 0;
	for (int i = 0; i <= 2 * V; ++i) {
		for (edge<T> e : G) {
			if (cost[e.from] == INF) continue;
			if (cost[e.to] > cost[e.from] + e.cost) {
				cost[e.to] = cost[e.from] + e.cost;
				if (i >= V && e.to == V - 1) return vector<T>();
			}
		}
	}
	return cost;
}

int main() {
	int n,m; cin >> n >> m;
	vector<edge<long long> > G;
	for(int i=0;i<m;++i) {
		int a,b,c; cin >> a >> b >> c;
		--a, --b;
		G.push_back({a,b,-c});
	}
	auto ans=bellman_ford(0,n,G);
	if(ans.empty()) cout << "inf" << endl;
	else cout << -ans[n-1] << endl;
	
	return 0;
}


Measured memory_bytes: 256
A = [int(input()) for _ in range(5)]

time = 0
amari = 10
for a in A:
    am = a % 10
    if am == 0:
        time += (a // 10) * 10
    else:
        time += (a // 10 + 1) * 10
        if am < amari:
            amari = am
k = 0 if amari == 10 else 10 - amari
time -= k
print(time)

Measured memory_bytes: 3064