akhauriyash/Code-Regression huggingface dataset:
use std::cmp;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        s: chars
    }

    let one = s[0] as usize - 48;
    let two = s[1] as usize - 48;
    let three = s[2] as usize - 48;
    let four = s[3] as usize - 48;

    let head = one * 10 + two;
    let tail = three * 10 + four;

    let mut head_yy = false;
    let mut tail_yy = false;

    if head == 0 || head > 12 {
        head_yy = true;
    }

    if tail == 0 || tail > 12 {
        tail_yy = true;
    }

    if head_yy && !tail_yy {
        println!("YYMM");
    } else if !head_yy && tail_yy {
        println!("MMYY");
    } else if !head_yy && !tail_yy {
        println!("AMBIGUOUS");
    } else {
        println!("NA");
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 8572
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int M;
    cin >> M;
    int N = M % 10;
    if (N == 2 || N == 4 || N ==  5 || N == 7 || N == 9)
    {
        cout << "hon" << endl;
    }else if (N == 0 || N == 1 || N ==  6 || N == 8)
    {
        cout << "pon" << endl;
    }else if (N == 3)
    {
        cout << "bon" << endl;
    }
    
    return 0;
    
}

Measured memory_bytes: 3056
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map { it.toLong() }
    val mod = 1000000007

    var res = 0L
    var twoFactor = 1L
    for(d in 0 until 60){
        var even = 0L
        var odd = 0L
        for(i in 0 until N){
            if((A[i] shr d) and 1L == 1L){
                odd++
            }else{
                even++
            }
        }
        val add = (((odd * even) % mod) * twoFactor) % mod
        res = (res + add) % mod
        twoFactor = (twoFactor * 2) % mod
    }
    println(res)
}

Measured memory_bytes: 103736
// Shift-JIS（シフトジス）

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

int gcd(int a, int b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

int main()
{
    string S;
    cin >> S;
    int ans = 0;
    for (char s : S)
    {
        if (s == '+')
        {
            ans++;
        }
        else
        {
            ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define vcin(V) for (int i = 0; i < (V).size(); i++) { cin >> (V).at(i); }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define nn int n=0
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool; 
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　（A＋B）÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
//BEGIN OF CODE.
int c = 0;
int main(void){
	string s;
	cin >> s;
	cncn;
	if (s[0] == s[1] && s[2] == s[3])cnt++;
	if (s[0] == s[2] && s[1] == s[3])cnt++;
	if (s[0] == s[3] && s[2] == s[1])cnt++;
	Yes(cnt == 1);
	please AC;
}
//THE END.

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
string a,b;
int main() {
    cin>>a>>b;
    sort(b.begin(),b.end(),greater<char>());
    sort(a.begin(),a.end());
    if(a<b)cout<<"Yes"; else cout<<"No";
    return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    ll N;
    ll a[10005];
    ll b[10005];
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >>a[i];
    }
    for(int i = 1; i <= N; i++) {
        cin >> b[i];
    }
    ll A = 0;
    ll B = 0;
    for(int i = 1; i <= N; i++) {
        if(a[i] > b[i]) {
            B += a[i] - b[i];
        }
        if(a[i] < b[i]) {
            A += (b[i] - a[i]) / 2;
        }
    }
    //cout << A << " " << B << endl;
    if(A >= B) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 384
import math
Q = int(input())
AB = [sorted(list(map(int,input().split()))) for i in range(Q)]

for A,B in AB:
    x = math.sqrt(A*B)
    y = int(x)
    if x!=y:
        if y*(y+1)<A*B:
            print(y*2-1)
        else:
            print(y*2-2)
    else:
        if A==B:
            print(y*2-2)
        else:
            print(y*2-3)

Measured memory_bytes: 38256
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int N,i;
	cin>>N;
	int L;
	int MaxL=0;
	int SumL=0;
	for (i=0;i<N;i++){
		cin>>L;
		if (MaxL<L){
			MaxL=L;
		}
		SumL+=L;
	}
	SumL-=MaxL;
	if (MaxL<SumL){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    long n;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextLong();
        solve();
    }

    void solve() {
        int sqrtN = (int)Math.sqrt(n) + 1;
        int minDigit = Integer.MAX_VALUE;
        for (long i = 1; i <= sqrtN; i++) {
            if (n % i > 0) {
                continue;
            }
            long j = n / i;
            int digit = f(i, j);
            if (digit < minDigit) {
                minDigit = digit;
            }
        }
        System.out.println(minDigit);
    }

    int f(long a, long b) {
        int digitA = digit(a);
        int digitB = digit(b);
        if (digitA < digitB) {
            return digitB;
        }
        return digitA;
    }

    int digit(long a) {
        int ret = 0;
        for (; a > 0; ++ret) {
            a /= 10;
        }
        return ret;
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

typedef complex<double> P;
#define X real()
#define Y imag()

#define PI 3.14159265358979

double exterior_product(P p1, P p2, P p3){
        double vx2 = p2.X - p1.X;
        double vy2 = p2.Y - p1.Y;
        double vx3 = p3.X - p1.X;
        double vy3 = p3.Y - p1.Y;
        return vx2*vy3 - vx3*vy2;
}

int main(){
    double x1, x2, x3;
    double y1, y2, y3;
    double xp, yp;

    while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp){
        P a(x1, y1);
        P b(x2, y2);
        P c(x3, y3);
        P p(xp, yp);

        double ex_1 = exterior_product(a, b, p);
        double ex_2 = exterior_product(c, a, p);
        double ex_3 = exterior_product(b, c, p);

        if(ex_1 > 0 && ex_2 > 0 && ex_3 > 0){
            cout << "YES" << endl;
        }
        else if(ex_1 < 0 && ex_2 < 0 && ex_3 < 0){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

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

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

    vector<int> city(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        city[a - 1]++;
        city[b - 1]++;
    }

    for (int i = 0; i < n; i++) {
        cout << city[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

int min(int a,int b){
    int result;
    if(a<b)result = a;
    else result = b;
    return result;
}

int main(){
    int N,A,B;
    cin >> N >> A >> B;

    int P[N];
    for(int i=0;i<N;i++){
        cin >> P[i];
    }

    int n1=0,n2=0,n3=0;
    for(int i=0;i<N;i++){
        if(P[i] <= A)n1++;
        else if(P[i] > B)n3++;
        else n2++;
    }

    cout << min(min(n1,n2),n3) << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=[0]*(n+2)
for i in range(n):
    if a[i]>n:
        b[n+1]+=1
    else:
        b[a[i]]+=1
sm=0
for i in range(1,n+1):
    if b[i]>i:
        sm+=b[i]-i
    elif b[i]<i:
        sm+=b[i]

sm+=b[n+1]
print(sm)


Measured memory_bytes: 20496
#include<bits/stdc++.h>
using namespace std;
template <class I>
inline void read(I &x){
    int f=1;
    char c;
    for(c=getchar();c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
    for(x=0;c>='0'&&c<='9';x=(x<<3)+(x<<1)+(c&15),c=getchar());
    x*=f;
}
const int N=270000,LOG=20;
int x[N],v[N],L[LOG][N],R[LOG][N],val[N],Lf[N],Rf[N],n,k,tot;
int main(){
    read(n);
    read(v[0]);
    while(v[k]) v[k+1]=v[k]>>1,k++;
    tot=(1<<k)-1;
    for(int i=1;i<=n;i++)
        read(x[i]);
    for(int i=0;i<=k;i++){
        L[i][1]=1;
        for(int j=2;j<=n;j++) 
            if(x[j]-x[j-1]<=v[i]) 
                L[i][j]=L[i][j-1];
            else L[i][j]=j;
        R[i][n]=n;
        for(int j=n-1;j>=0;j--) 
            if(x[j+1]-x[j]<=v[i]) 
                R[i][j]=R[i][j+1];
            else R[i][j]=j;
    }
    for(int i=1;i<=tot;i++) 
        Lf[i]=1,Rf[i]=n;
    Lf[0]=0,Rf[0]=n+1;
    for(int i=0;i<=tot;i++)
        for(int j=1;j<=k;j++) 
            if(!((i>>(j-1))&1)) {
                Lf[i|(1<<(j-1))]=max(Lf[i|(1<<(j-1))],R[j][Lf[i]+1]);
                Rf[i|(1<<(j-1))]=min(Rf[i|(1<<(j-1))],L[j][Rf[i]-1]);
            }
    for(int i=0;i<=n+1;i++) 
        val[i]=2*n;
    for(int i=0;i<=tot;i++) 
        val[Lf[i]]=min(val[Lf[i]],Rf[tot^i]);
    for(int i=n;i>=0;i--) 
        val[i]=min(val[i],val[i+1]);
    for(int i=1;i<=n;i++) 
        printf(val[L[0][i]-1]<=R[0][i]+1?"Possible\n":"Impossible\n");
    return 0;
}

Measured memory_bytes: 49536
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var t=sc.S;
		int n=t.Length;
		int ans=0;
		string p="",q="";
		for(int i = 0;i<n;i++) {
			if(q+t[i].ToString()!=p){
				ans++;
				p=q+t[i].ToString();
				q="";
			}
			else{
				q=t[i].ToString();
			}
		}
		Console.WriteLine("{0}",ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


Measured memory_bytes: 17876
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

const long long MOD = 1e9 + 7;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    vector<ll> stair(N + 1, 0);
    rep(i, M)
    {
        ll tmp;
        cin >> tmp;
        stair[tmp] = 1;
    }
    vector<ll> dp(N + 1, 0);
    dp[0] = 1;
    for (ll i = 0; i < N; ++i)
    {
        if (stair[i + 1] != 1)
            if (i == 0)
                dp[i + 1] = dp[i];
            else
                dp[i + 1] = dp[i] + dp[i - 1];
        dp[i + 1] %= MOD;
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	int ans=0;
	cin>>s>>t;
	for(int i=0;i<s.length();i++){
		if(s[i]!=t[i])ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

ll X[500][500], Y[500], b[500], dp[2][1LL << 23];

ll solveN(ll N, ll M) {
  REP(i, 0, N) {
    char s[500];
    scanf("%s", s);
    REP(j, 0, M) X[i][j] = s[j] - '0';
  }

  ll ans = 0;
  REP(s, 0, 1LL << N) {
    REP(i, 0, M) b[i] = 0;
    REP(i, 0, N) if (s & (1LL << i)) {
      REP(j, 0, M) b[j] ^= X[i][j];
    }
    bool ok = true;
    REP(i, 0, M) ok = ok && !b[i];
    if (ok) ans = max(ans, (ll) __builtin_popcount(s));
  }

  return ans;
}

ll solveM(ll N, ll M) {
  REP(i, 0, N) {
    char s[500];
    scanf("%s", s);
    Y[i] = 0;
    REP(j, 0, M) Y[i] = Y[i] * 2 + (s[j] - '0');
  }

  REP(i, 0, 1LL << M) dp[0][i] = -(1LL << 60);
  dp[0][0] = 0;
  REP(i, 0, N) {
    REP(j, 0, 1LL << M) dp[(i + 1) & 1][j] = -(1LL << 60);
    REP(s, 0, 1LL << M) {
      dp[(i + 1) & 1][s ^ Y[i]] = max(dp[(i + 1) & 1][s ^ Y[i]], dp[i & 1][s] + 1);
      dp[(i + 1) & 1][s] = max(dp[(i + 1) & 1][s], dp[i & 1][s]);
    }
  }

  return dp[N & 1][0];
}

int main(void) {
  while (1) {
    ll N, M;
    scanf("%lld %lld", &N, &M);
    if (N == 0 && M == 0) break;
    printf("%lld\n", !(M <= 23) ? solveN(N, M) : solveM(N, M));
  }
}


Measured memory_bytes: 134304
rec = 0
loz = 0

while True:
    try:
        a,b,c = map(int,input().split(','))
    except EOFError:
        break
    if a == b:
        loz += 1
    if a * a + b * b == c * c:
        rec += 1

print(rec)
print(loz)

Measured memory_bytes: 7544
using System;

namespace ITP_2_B
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string[] temp = Console.ReadLine().Split(' ');
            int a = int.Parse(temp[0]);
            int b = int.Parse(temp[1]);
            int c = int.Parse(temp[2]);
            
            if (a<b && b<c)
            {
                Console.WriteLine("Yes");
            }else{
                Console.WriteLine("No");
            }
        }
    }
}

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// #include <cstdio>
// int a; ll B;
// scanf("%d %lld", &a, &B);
// printf("%d\n", a);
//
// for (int i=0; i<n; ++i)
// 	scanf("%d", &a[i]);
//
// char c;
// scanf(" %c", &c);
//
// cout << "\n";

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

/*
ll	myPow(ll x, ll n) {
	if (0==n)
		return 1;
	if (0==n%2)
		return myPow(x*x%MOD, n/2);
	else
		return x*myPow(x, n-1)%MOD;
}
*/
ll	myPow(ll x, ll n) {
	ll r=1;
	while(n>0)
		if (0==n%2) {
			x *=x;
			x %=MOD;
			n /=2;
		} else {
			r *=x;
			r %=MOD;
			n--;
		}
	return r;
}

int	main() {
	double N;
	cin >>N;
	cout <<fixed <<setprecision(10) <<N*M_PI*2 <<endl;
	return 0;
}



Measured memory_bytes: 3788
#include<iostream>
#include<cassert>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;
	int tmp = X;
	X = Y;
	Y = tmp;
	tmp = X;
	X = Z;
	Z = tmp;
	cout << X << " " << Y << " " << Z;
}

Measured memory_bytes: 768
// --https://kenkoooo.com/atcoder/#/table/soma62jp

#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>

using namespace std;

int main(int argc, char* argv[]) {


	int S;
	int yy,mm;

	cin >> S;

	yy = S/100;
	mm = S%100;

	if((yy>=0 && mm>0 && mm<=12) && (mm>=0 && yy>0 && yy<=12)){
		cout << "AMBIGUOUS" << endl;
	}
	else if(yy>=0 && mm>0 && mm<=12){
		cout << "YYMM" << endl;
	}else if(mm>=0 && yy>0 && yy<=12){
		cout << "MMYY" << endl;
	}else{
		cout << "NA" << endl;
	}

	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a[10];
	int v[2];
	int sum;
	float t;
	int i;
	float len;

	while (scanf("%d,", &a[0]) != EOF){
		sum = a[0];
		for (i = 1; i < 10; i++){
			scanf("%d,", &a[i]);
			sum += a[i];
		}
		scanf("%d,%d", &v[0], &v[1]);

		t = (float)sum / (v[0] + v[1]);
		len = v[0] * t;

		i = 0;
		while (len > 0){
			len -= a[i];
			i++;
		}

		printf("%d\n", i);
	}

	return (0);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define translow transform(s.begin(),s.end(),s.begin(),::tolower);
#define transup transform(s.begin(),s.end(),s.begin(),::toupper);
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;
 
 
int main() {
                fast
                // #ifndef ONLINE_JUDGE
                // freopen("input.txt","r",stdin);
                // freopen("output.txt","w",stdout);
                // #endif
                    ll k,n;
                    cin>>k>>n;
                    ll mx=LLONG_MIN;
                    ll arr[n];
                    for(ll i=0;i<n;i++)
                    {
                        cin>>arr[i];
                    }
                    for(ll i=0;i<n-1;i++)
                    {
                        mx=max(mx,abs(arr[i]-arr[(i+1)]));
                    }
                     // cout<<mx<<endl;
                    mx=max(mx,abs(abs(arr[0]-0)+abs(arr[n-1]-k)));
                    cout<<k-mx<<endl;

                return 0;
            }

Measured memory_bytes: 1792
n = int(input())
la = list(map(int, input().split()))

a = min(la)
z = max(la)

ld = list()
for i in range(a, z+1):
    d = 0
    for j in range(n):
        d += (la[j] - i)**2
    ld.append(d)

print(min(ld))

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

void print(int A[],int N)
{
    for(int i=0;i<N;i++)
    {
        if(i>0)
            cout<<" ";
        cout<<A[i];
    }
    cout<<endl;
}

int selectSort(int A[],int N)
{
    int i,minj,sum=0;
    for(i=0;i<N;i++)
    {
        minj=i;
        for(int j=i;j<N;j++)
        {
            if(A[j]<A[minj])
                minj=j;
        }

       
        if(A[minj]!=A[i])
        {
           int temp;
           temp=A[minj];
           A[minj]=A[i];
           A[i]=temp;
           sum++;
        }


    }
     print(A,N);
     return sum;

}
int main()
{
    int N,A[100],sum;
    cin>>N;
    for(int i=0;i<N;i++)
    {
        cin>>A[i];
    }
   sum= selectSort(A,N);
   cout<<sum<<endl;
   return 0;

}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
using Graph = vector<vector<int>>;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

int main(){
    fastcin();
    int n,k;
    cin >> n >> k;
    vector<int> cnt(n, 0);
    rep(i, k){
        int d;
        cin >> d;
        rep(j, d){
            int x;
            cin >> x;
            x--;
            cnt[x]++;
        }
    }
    int ans = 0;
    rep(i, n)if(cnt[i] == 0) ans++;
    cout << ans<< endl;
}

Measured memory_bytes: 3656
// clang++ -std=c++14 -stdlib=libc++ -O2 ./*.cpp

#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
// #include <bits/stdc++.h>
using namespace std;

#define size_t int
typedef long long ll;
// #define int long long
typedef vector<int> VI;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define debug(x) cerr << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug1(i, x) cerr << "(" << (i) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug2(i, j, x) cerr << "(" << (i) << ", " << (j) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
template <typename T> class vec2d : public vector<vector<T>> {
public:
    vec2d(int H, int W): vector<vector<T>> (H, vector<T>(W)) {
    }
};
template <typename T> istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template <typename T> ostream& operator << (ostream& os, vector<T>& vec){
  REP(i, vec.size()) {
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0);
        // cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

signed main(signed argc, char **argv) {
  int H, W, N;
  cin >> H >> W >> N;
  int hs, ws;
  cin >> hs >> ws;
  hs--; ws--;
  char S[N + 1];
  char T[N + 1];
  cin >> S;
  cin >> T;
  // cout << S << T;
  int h = hs;
  int w = ws;
  for (size_t i = 0; i < N; i++) {
    if (S[i] == 'D') {
      h++;
      if (h >= H) {
        cout << "NO" << endl;
        return 0;
      }
    }
    if (T[i] == 'U' && h > 0) {
      h--;
    }
  }
  h = hs;
  w = ws;
  for (size_t i = 0; i < N; i++) {
    if (S[i] == 'U') {
      h--;
      if (h < 0) {
        cout << "NO" << endl;
        return 0;
      }
    }
    if (T[i] == 'D' && h < H - 1) {
      h++;
    }
  }
  h = hs;
  w = ws;
  for (size_t i = 0; i < N; i++) {
    if (S[i] == 'L') {
      w--;
      if (w < 0) {
        cout << "NO" << endl;
        return 0;
      }
    }
    if (T[i] == 'R' && w < W - 1) {
      w++;
    }
  }
  h = hs;
  w = ws;
  for (size_t i = 0; i < N; i++) {
    // debug(h);
    // debug(w);
    if (S[i] == 'R') {
      w++;
      if (w >= W) {
        cout << "NO" << endl;
        return 0;
      }
    }
    if (T[i] == 'L' && w > 0) {
      w--;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <cassert>
#include <cstdio>
#include <algorithm>
#define N int(1e3)
#define M int(1e9+7)
using namespace std;
char a[N][N];
int dp[N][N];
int main(int argc,char ** argv)
{
    int r,c;
    cin>>r>>c;
    for(int i=0;i<r;++i)cin>>a[i];
    dp[0][0]=1;
    for(int i=0;i<r;++i){
        for(int j=0;j<c;++j){
            if(i==0&&j==0)continue;
            dp[i][j]=((i==0||a[i-1][j]=='#'?0:dp[i-1][j])+(j==0||a[i][j-1]=='#'?0:dp[i][j-1]))%M;
        }
    }
    cout<<dp[r-1][c-1]<<endl;
    return 0;
}

Measured memory_bytes: 8404
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
#define pii pair<int, int>
#define MP make_pair
using namespace std;
typedef long long LL;
const int MAXN = 500005;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int n, q, d[MAXN], dis[MAXN], dp[MAXN];

void init() {
	read(n); read(dis[0]);
	for (int i=1;i<=n;++i) {
		read(d[i]);
		dis[i] = min(dis[i-1], abs(dis[i-1] - d[i]));
	}	
}

void solve() {
	dp[n+1] = 1;
	for (int i=n;i>=1;--i) {
		dp[i] = dp[i+1];
		if (d[i] < dp[i+1] * 2) {
			dp[i] += d[i];
		}
	}
	read(q);
	while (q--) {
		int x; read(x);
		puts((dis[x-1] >= dp[x+1])? "YES" : "NO");
	}
}

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


Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    string S;
    cin >> S;
    for(int i = 0; i < S.size(); i++){
        if(i % 2 == 0){
            if(S[i] == 'L'){
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(S[i] == 'R'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

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

ans = []
while len(ans) < N:
    j = -1
    for i,b in enumerate(B):
        if b==i+1:
            j = i
    if j==-1:
        print(-1)
        exit()
    ans.append(j+1)
    del B[j]
print(*ans[::-1], sep='\n')

Measured memory_bytes: 9180
#include<iostream>
#include<map>
using namespace std;
map<string,int> M;
int main() {
    string s;
    int n;
    cin >> n;
    while(n--) {
        cin >> s;
        ++M[s];
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",M["AC"],M["WA"],M["TLE"],M["RE"]);
return 0;
}

Measured memory_bytes: 3656
def move(move_count, add, flag):
    for i in range(move_count):
        n_lis.append(num_lis[add+i])
        if flag == n:
            calculate()
            del n_lis[-1]
        else:
            move(move_count-i-1, add+i+1, flag+1)
            del n_lis[-1]
    
def calculate():
    global count
    if sum(n_lis) == s:
        count += 1

while True:
    n, s = map(int, raw_input().split())
    if n == 0 and s == 0:
        break
    num_lis = [0,1,2,3,4,5,6,7,8,9]
    n_lis = []
    count = 0
    move(10,0,1)
    print count

Measured memory_bytes: 4240
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define f first
#define int long long
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<ll, ll> pii;
typedef vector<vector<ll>> mat;
const ll mod = 1e9+7;
const int MAXN = 1e5+5;

ll expo(ll a, ll b){
    if(b == 0) 
		return 1;
    ll x = expo(a, b/2);
    return (b & 1 ? ((x*x)*a) : (x*x) );
}

int32_t main() {
	int n;
	cin >> n;
	vector<int> v(n);
	for(int &i : v)
		cin >> i;
	
	map<ll, int> mapa;
	mapa[ v[0] + 1 ] ++;
	
	ll ans = 0;
	
	for(int j = 1; j < n; j++) {
		ans += mapa[ j + 1 - v[j] ];
		mapa[ j + 1 + v[j] ]++;
	}
	
	cout << ans << endl;
	
}


Measured memory_bytes: 27544
#include<stdio.h>
#include<iostream>
#include<cmath>
#define EPS 0.00001
 
using namespace std;
 
main(){
  int a, b, c, d, e, f;
  double x, y;
  while ( cin >> a >> b >> c >> d >> e >> f ){
    x = 1.0 * ( c*e - b*f ) / ( a*e - b*d ) + EPS;
    y = 1.0 * ( c*d - a*f ) / ( b*d - a*e ) + EPS;
    printf("%.3lf %.3lf\n", x, y);
  }
}

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

int main() {
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;
  if (x - r < 0 or W < x + r or y - r < 0 or H < y + r) cout << "No" << endl;
  else cout << "Yes" << endl;
}


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

stack<int> st;

int main(){
	string str;
	cin >> str;
	int n = str.size();
	int sum = 0;
	for(int i = 0; i < n; i++){
		if(str[i] == 'S') st.push(1);
		if(str[i] == 'T' && !st.empty()){
			st.pop();
			sum += 2;
		}
	}
	//n = str.size();
	cout << n - sum;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
#define LL long long int
#define Max(x, y) (x > y ? x : y)
#define Min(x, y) (x < y ? x : y)
#define Abs(x) ( (x) > 0 ? (x) : -(x) )
#define Swap(x,y) do{x = x ^ y; y = x ^ y; x = x ^ y;}while(0)
#define IO_BOOST                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(0)
#define setp(x) fixed << setprecision(x)
#define INF 0x3f3f3f3f
#define Lowbit(x) ((x) & (-x))
#define Pii pair<int, int>
#define x first
#define y second
#define MOD ((int)1e9+7)
using namespace std;

struct Node{
    LL w, v;
};
Node a[(int)2e5+5];
int n, k, w;

void solve(){
    vector<LL> dp((int)2e5, 1e18L);
    LL sumv = 0;
    for(int i = 1 ; i <= n ; i++) sumv += a[i].v;
    dp[0] = 0;
    for(int i = 1 ; i <= n ; i++){
        for(int j = sumv-a[i].v ; j >= 0 ; j-- ){
            dp[ j+a[i].v ] = Min(dp[j+a[i].v], dp[j] + a[i].w  );
        }
    }
    for(LL i = sumv ; i >= 0 ; i--){
        if( dp[i] <= w ){
            cout << i << '\n';
            return;
        }
    }

   
}
int main(){
    IO_BOOST;
    cin >> n >> w;
    for(int i = 1 ; i <= n ; i++)
        cin >> a[i].w >> a[i].v ;
    solve();

}

Measured memory_bytes: 1792
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int max(int A, int B){
    if(A > B){
        return A;
    }else{
        return B;
    }
}

int main(){
    int A, B;
    cin >> A >> B;

    if(A == B) cout << A*2 << endl;
    if(A != B) cout << max(A, B) * 2 - 1 << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input()) 
S = input()


def index(s, N):
    ABC = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 
    s_ind = ABC.find(s)
    an_ind = (s_ind + N) % 26
    return(ABC[an_ind])

rotn = ''
for s in S:
    rotn += index(s, N)
print(rotn)

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(void){

	
	int N, D; cin >> N >> D;
	int F = D * 2 + 1;
	int ans = (N+F-1) / F;
	cout << ans << endl;


	return 0;

}


Measured memory_bytes: 256
import string
charset = string.ascii_lowercase
s = list(input())

unused = set(charset) - set(s)

if unused:
    s.append(min(unused))
    print(''.join(s))
    exit()
else:
    length = len(s)
    
    cand=[s[-1]]
    for i in range(length-1):
        if s[length-i-2] < s[length-i-1]:
            # candからs[length-i-2]より大きく、最小の値を選ぶ
            s[length-i-2] = min([c for c in cand if c>s[length-i-2]])
            print(''.join(s[:length-i-1]))
            exit()
        cand.append(s[length-i-2])
print(-1)

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

int a[200000];
signed main(){
  int n;cin >> n;
  rep(i,n)cin >> a[i];
  sort(a, a+n);
  int ans = 0;
  if(n%2 == 0){
    rep(i,n/2-1)ans -= a[i]*2;
    rep(i,n/2-1)ans += a[n/2+i+1]*2;
    ans -= a[n/2-1];ans += a[n/2];
  }else{
    int ans1 = 0, ans2 = 0;
    rep(i,n/2)ans1 -= a[i]*2;
    rep(i,n/2-1)ans1 += a[n/2+i+2]*2;
    ans1 += a[n/2]+a[n/2+1];
    rep(i,n/2-1)ans2 -= a[i]*2;
    rep(i,n/2)ans2 += a[n/2+i+1]*2;
    ans2 -= a[n/2]+a[n/2-1];
    ans = max(ans1, ans2);
  }
  cout << ans << endl;
  return 0;
}





Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n],b[n];
    for (int i=0; i<n; i++){
        cin >> a[i];
    }
    for (int i=0; i<n; i++){
        cin >>b[i];
    }
    long long ans=0;
    for (int i=0; i<n; i++){
        long long cand=0;
        for (int j=0; j<=i; j++){
            cand+=a[j];
        }
        for (int j=i; j<n; j++){
            cand+=b[j];
        }
        ans=max(ans,cand);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;

  ll res = 1;
  ll val = 1;
  ll limit = 1e18;

  ll arr[n + 5];
  bool zero = false;
  for (ll i = 1; i <= n; i++) {
    cin >> arr[i];
    if (arr[i] == 0)
      zero = true;
  }
  if (zero) {
    cout << 0 << en;
    return 0;
  }
  for (ll i = 1; i <= n; i++) {
    ll x = arr[i];
    if (val > limit) {
      cout << -1 << en;
      return 0;
    }

    if (val == 0) {
      cout << 0 << en;
      return 0;
    }
    ld val1 = (ld)limit / val;

    if (x > (val1 + 1)) {

      cout << -1 << en;
      return 0;
    }
    val *= x;

    if (val > limit) {
      cout << -1 << en;
      return 0;
    }
  }

  cout << val << en;

  return 0;
}


Measured memory_bytes: 4432
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long INF = (long long)1e15;

int main() {
	long long a, b, Q;
	cin >> a >> b >> Q;
	vector<long long> s(a), t(b);
	for (int i = 0; i < a; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < b; i++) {
		cin >> t[i];
	}
	for (int q = 0; q < Q; q++) {
		long long x;
		cin >> x;
		long long s1, s2, t1, t2;
		s1 = t1 = -INF;
		s2 = t2 = INF;
		auto itr_s = lower_bound(s.begin(), s.end(), x);
		auto itr_t = lower_bound(t.begin(), t.end(), x);
		if (itr_s != s.end()) s2 = *itr_s;
		if (itr_t != t.end()) t2 = *itr_t;
		if (itr_s != s.begin()) s1 = *--itr_s;
		if (itr_t != t.begin()) t1 = *--itr_t;
		auto f = [&](long long r1, long long r2) {
			return abs(x-r1) + abs(r1-r2);
		};
		vector<long long> v1{s1, s2}, v2{t1, t2};
		long long ans = INF;
		for (long long es : v1) {
			for (long long et : v2) {
				ans = min({ans, f(es, et), f(et, es)});
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4784
#include<iostream>
#include<algorithm>
using namespace std;
int A, B;
int keta[4];
int main(){
  cin >> A >> B;
  int counter =0;
  for(int i=A; i<B+1; i++){
    keta[4] = i/10000;
    keta[3] = (i- keta[4]*10000)/1000;
    keta[2] = (i -keta[4]*10000 -keta[3]*1000)/100;
    keta[1] = (i -keta[4]*10000 -keta[3]*1000 -keta[2]*100)/10;
	keta[0] = (i -keta[4]*10000 -keta[3]*1000 -keta[2]*100 -keta[1]*10);
    if ((keta[4] == keta[0]) && (keta[3] == keta[1])) counter++;
  }
  cout << counter << endl;
  return 0;
}

Measured memory_bytes: 256
//abc100_c.cpp
//Sat Jun 16 21:09:25 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
using ll=long long;

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

	ll ans = 0;

	ll a[n];
	for (int i=0;i<n;i++){
		cin >> a[i];
		while (a[i]%2 == 0 && a[i] > 0){
			ans++;
			a[i] = a[i]/2;
		}
	}


	cout << ans << endl;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline

n = int(input())
A = list(map(int,input().split()))

# n = 10**6
# A = [i+1 for i in range(n)]

A.sort()
p_ng = 0
l = 10**6 + 5
B = [0] * l

B[0] = 1
B[1] = 1

for i in range(2, l):
    if B[i] == 0:
        j = 2
        ind = j * i
        while ind < l:
            B[ind] = 1
            j += 1
            ind = j * i

# for i in range(100):
#     print(i, B[i])

C = [0] * l
for i in range(n):
    # print(i, A[i])
    if A[B[i]] == 0:
        if C[B[i]] == 1:
            p_ng = 1
            break
        C[i] = 1
    else:
        a = A[i]
        w = 2
        one = []
        while a != 1:
            f = 1

            while a%w == 0:
                a//=w
                if f == 1 and C[w] == 1:
                    p_ng = 1
                    break
                f = 0
                one.append(w)
            w += 1
            if B[a] == 0:
                if C[a] == 1:
                    p_ng = 1
                    break
                one.append(a)
                break
            # print(a,w)
            if p_ng== 1:
                break
        for ii in one:
            C[ii] = 1
        if p_ng == 1:
            break


# ind = 0
# while ind < n and A[ind] == 1:
#     ind += 1

# if ind < n:
#     for j in range(ind, n):
#         # print(B[:10])
#         for i in range(1, (l-1) // A[j] + 1):
#             indj = i * A[j]
#             # print(indj)
#             if i == 1 and B[indj] == 1:
#                 p_ng = 1
#                 break
#             B[indj] = 1
#         if j > 0 and A[j-1] == A[j]:
#             p_ng = 1
#             break
#         if p_ng == 1:
#             break

if p_ng == 0:
    print("pairwise coprime")
    sys.exit()

from math import gcd
g = A[0]
for i in range(1, n):
    g = gcd(g, A[i])

if g == 1:
    print("setwise coprime")
else:
    print("not coprime")
    


Measured memory_bytes: 188856
#include <iostream>
#include <numeric>
#include <algorithm>

using namespace std;

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

    int L[100];
    for(int i = 0; i < N; i++) {
        cin >> L[i];
    }

    int max;
    max = *max_element(L, L+N);
    int sum = accumulate(L, L+N, 0);

    if(sum - max > max) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#include<math.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
  int N;
  cin>>N;
  if(N/100==N%10){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256