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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

    ll N;
    cin >> N;

    vector<ll> b(N);
    rep (i, N) {
        cin >> b[i];
    }

    vector<ll> a;
    rep (i, N) {
        rrep (j, b.size()) {
            if (b[j] == j+1) {
                a.push_back(j+1);
                b.erase(b.begin()+j);
                break;
            }
        }
    }

    if (a.size() == N) {
        rrep (i, N) {
            cout << a[i] << endl;
        }
    } else {
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h,w;
  string s;
  cin>>h>>w;
  for(int i=0;i<w+2;i++){cout<<'#';}
  cout<<endl;
  for(int i=0;i<h;i++){
    cin>>s;
  cout<<'#';
    cout<<s;
  cout<<'#'<<endl;
  }
  for(int i=0;i<w+2;i++){cout<<'#';}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var A = ReadInt();
            var B = ReadInt();
            var C = ReadInt();
            var D = ReadInt();
            Println(Min(A, B) + Min(C, D));
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


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

long long int ans;
void solve(){
	int input;
	int N, x;
	cin >> N >> x;
	int old = 0;
	while(cin >> input){
		if(input > x){
			ans += input - x;
			input = x;
		}
		if(input + old > x){
			ans += input + old - x;
			input = x - old;
		}
		old = input;
	}
	cout << ans << endl;
}

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


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

using namespace std;

int A, B, C, D, E, F;

struct SugarWater {
    SugarWater() : sugar(0), water(0) {}
    int sugar;
    int water;
};

const SugarWater ZERO = SugarWater();
double MAX_DENSITY;

double density(SugarWater sw) {
    if (sw.sugar + sw.water == 0) {
        return -1.0;
    }
    else {
        return (double)sw.sugar / (double)(sw.sugar + sw.water);
    }
}

SugarWater dp(SugarWater sw, vector<vector<SugarWater>>& memo) {
    if (sw.sugar + sw.water > F || density(sw) > MAX_DENSITY) {
        return ZERO;
    }
    if (memo[sw.sugar][sw.water].sugar >= 0 && memo[sw.sugar][sw.water].water >= 0) {
        return memo[sw.sugar][sw.water];
    }

    SugarWater op1 = sw;
    SugarWater op2 = sw;
    SugarWater op3 = sw;
    SugarWater op4 = sw;
    op1.water += 100 * A;
    op2.water += 100 * B;
    op3.sugar += C;
    op4.sugar += D;
    op1 = dp(op1, memo);
    op2 = dp(op2, memo);
    op3 = dp(op3, memo);
    op4 = dp(op4, memo);

    SugarWater ret;
    if (density(op1) >= density(op2)
        && density(op1) >= density(op3)
        && density(op1) >= density(op4)
        && density(op1) >= density(sw)) {
        ret = op1;
    }
    else if (density(op2) >= density(op1)
        && density(op2) >= density(op3)
        && density(op2) >= density(op4)
        && density(op2) >= density(sw)) {
        ret = op2;
    }
    else if (density(op3) >= density(op1)
        && density(op3) >= density(op2)
        && density(op3) >= density(op4)
        && density(op3) >= density(sw)) {
        ret = op3;
    }
    else if (density(op4) >= density(op1)
        && density(op4) >= density(op2)
        && density(op4) >= density(op3)
        && density(op4) >= density(sw)) {
        ret = op4;
    }
    else {
        ret = sw;
    }
    memo[sw.sugar][sw.water] = ret;
    return ret;
}

void Main() {
    cin >> A >> B >> C >> D >> E >> F;
    MAX_DENSITY = (double)E / (100.0 + E);
    SugarWater neg;
    neg.sugar = -1;
    neg.water = -1;
    vector<vector<SugarWater>> memo(3000 + 10, vector<SugarWater>(3000 + 10, neg));
    SugarWater ans = dp(SugarWater(), memo);
    cout << (ans.sugar + ans.water) << " " << ans.sugar << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 74288
#include <cstdio>
#include <cstring>

int main(void)
{
  int a,b;
  char op[128];
  char p[]="+",d[]="-",m[]="*",f[]="/",q[]="?";

  for(;;){
    scanf("%d %s %d", &a, op, &b);
    if(strcmp(op,p) == 0){
      printf("%d\n", a + b);
    } else if(strcmp(op,d) == 0){
      printf("%d\n", a - b);
    } else if(strcmp(op,m) == 0){
      printf("%d\n", a * b);
    } else if(strcmp(op,f) == 0){
      printf("%d\n", a / b);
    } else if(strcmp(op,q) == 0){
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 1036
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int N,K;
	cin>>N>>K;
	ce(N-K+1)
	
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

const long long MIN = -10e9 - 6;

void solve(long long N, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c)
{
    vector<vector<long long>> h(N, vector<long long>(3));
    vector<vector<long long>> dp(N, vector<long long>(3, MIN));
    for (int i = 0; i < N; i++)
    {
        h[i][0] = a[i];
        h[i][1] = b[i];
        h[i][2] = c[i];
    }
    for (int i = 0; i < 3; ++i)
    {
        dp[0][i] = h[0][i];
    }
    for (int i = 1; i < N; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            for (int k = 0; k < 3; k++)
            {
                if (k != j)
                {
                    dp[i][j] = max(dp[i][j], dp[i - 1][k] + h[i][j]);
                }
            }
        }
    }
    cout<< *std::max_element(dp[N - 1].begin(), dp[N-1].end()) << "\n";
}

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


Measured memory_bytes: 13568
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

//Degree <-> Radian
double toRad(double d){ double rad; rad=d*PI/180; return rad; }
double toDegree(double rad){ double d; d=rad*180/PI; return d; }
//The least common multiple : lcm
ll lcm(int a,int b){ return a*b/__gcd(a,b); }
//素数判定
bool isPrime(int n){
    int i; 
    if(n<2) return 0;
    else if(n==2) return 1;
    if(n%2==0) return 0;
    for(i=3;i*i<=n;i+=2) if(n%i==0) return 0;
    return 1;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h,a;
    int count=0;
    cin >> h >> a;
    while(h>0){
        h-=a;
        count++;
    }
    cout << count ENDL;
    
    return 0;
}

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

int main(){
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  int ans=0;
  
  for(int i=0;i<=a;i++){
    for(int q=0;q<=b;q++){
      for(int p=0;p<=c;p++){
        if(500*i+100*q+50*p == x){ans++;}
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int N, D, X;
    cin >> N >> D >> X;

    int choco = 0;
    for(int i = 0; i < N; ++i)
    {
        int Ai;
        cin >> Ai;
        choco += D / Ai;
        if(D % Ai)
            choco++;
    }

    cout << X + choco << endl;

    return 0;
}

Measured memory_bytes: 380
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
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 ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

R,G,B,N=MAP()

cnt=0
for x in range(3001):
    for y in range(3001):
        z=(N-R*x-G*y)/B
        # zが0以上の整数になっていればOK
        if z>=0 and z.is_integer():
            cnt+=1
print(cnt)


Measured memory_bytes: 42460
#include "iostream"
#include <algorithm>

using namespace std;

long long int N;
long long int a[300001];
long long int ans=0;
long long int box;

int main(){
	cin >> N;
	for (int i = 1; i <= 3 * N; i++) {
		cin >> a[i];
	}
	sort(a, a + 3 * N + 1);
	for (int i = N + 1; i <= 3 * N; i++) {
		if ((i - N) % 2 == 1)ans += a[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        boolean ok = true;
        for (int i = 0; i < n; i++) {
            if (a[i] % 2 == 1) {
                ok = false;
                break;
            }
        }
        if (ok) {
            System.out.println("second");
            return;
        }
        System.out.println("first");
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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


Measured memory_bytes: 24008
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'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'};
vector<char>AL(26);
AL = {'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'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N, K;
	cin >> N >> K;
	vector<int>H(N);
	rep(i, N) {
		cin >> H[i];
	}
	int cnt = 0;
	rep(i, N){
		if (H[i] >= K) {
			cnt++;
		}
}
	cout << cnt << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <memory>

//#define int long long

using namespace std;

void Main()
{
	int n;
	cin >> n;
	vector<int> w(n, 0);
	vector<int> s1(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> w[i];
		if (i == 0) {
			s1[i] = w[i];
		}
		else {
			s1[i] = s1[i - 1] + w[i];
		}
	}
	int sum = s1[n - 1];
	int diffmin = 0;
	for (int i = 0; i < n; i++) {
		int diff = abs(s1[i] - (sum - s1[i]));
		if (i == 0) {
			diffmin = diff;
		}
		else {
			diffmin = min(diffmin, diff);
		}
	}

	cout << diffmin << endl;
}

int32_t main()
{
	Main();
	return 0;
}



Measured memory_bytes: 256
N, K = map(int,input(). split())
x = list(map(int,input().split()))
ans = float("inf")
for i in range(N - K + 1):
    if ans > abs(x[i]) + (x[i + K - 1] - x[i]):
        ans = abs(x[i]) + (x[i + K - 1] - x[i])
    if ans > abs(x[i + K - 1]) + (x[i + K - 1] - x[i]):
        ans = abs(x[i + K - 1]) + (x[i + K - 1] - x[i])
print(ans)

Measured memory_bytes: 62576
import bisect
import sys
input = sys.stdin.buffer.readline

def main():
    A,B,Q = map(int,input().split())
    s = [int(input()) for _ in range(A)]
    t = [int(input()) for _ in range(B)]
    x = [int(input()) for _ in range(Q)]
    INF = float('inf')
    s = [-INF] + s + [INF]
    t = [-INF] + t + [INF]
    
    
    for i in range(Q):
        S,T = bisect.bisect_right(s,x[i]),bisect.bisect_right(t,x[i])
        ans = INF
        for j in [s[S],s[S-1]]:
            for k in [t[T],t[T-1]]:
                l,_l = abs(j-x[i])+abs(k-j),abs(k-x[i])+abs(j-k)
                ans = min(ans,l,_l)
        print(ans)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 16872
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,ans=0;
	cin>>n;
	if (n>=10000 && n<=99999)
	{
		ans=n-9090;
	}
	if (n>999 && n<=9999)
	{
		ans=909;
	}
	if (n>99 && n<=999)
	{
		ans=n-90;
	}
	if (n>9 && n<=99)
	{
		ans=9;
	}
	if (n<=9)
	{
		ans=n;
	}
	if (n==100000)
	{
		ans=90909;
	}
	cout<<ans<<endl;
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
using namespace std;
int main()
{
	int n,c=0,i;
	cin>>n;
	string s;
	cin>>s;
	for(i=0;i+2<n;i++)
		if(s.substr(i,3)=="ABC")
			c++;
	cout<<c<<endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main()
{
	fast;
	ll n,index,ans=1,cnt0=0;
	cin>>n;
	ll arr[n],pos[n],diff[n]{};
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i],pos[i]=1;
		if(arr[i]==0)
			cnt0++;
		diff[arr[i]]++;
	}
	if(cnt0>1)
	{
		cout<<0;
		return 0;
	}
	for(ll i=0;i<n;i++)
		if(diff[i]>2)
		{
			cout<<0;
			return 0;
		}
	for(ll i=0;i<n;i++)
	{
		index=(n-arr[i])/2;
		// cout<<index<<endl;
		if(arr[i]!=0)
			pos[index]=2;
		else
			pos[index]=1;
	}
	if(n%2)
	{
		for(ll i=0;i<=n/2;i++)
			ans=(ans*pos[i])%MOD;
	}
	else
	{
		for(ll i=0;i<n/2;i++)
			ans=(ans*pos[i])%MOD;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 5888
#include <cstdio>
#include <algorithm>

using namespace std;

int N;
int A[100];

void printA() {
  for (int i=0; i<N; i++) {
    if (i > 0) putchar(' ');
    printf("%d", A[i]);
  }
  putchar('\n');
}

int main() {
  scanf("%d", &N);
  for (int i=0; i<N; i++) scanf("%d", &A[i]);
  int sc = 0;
  for (int i=0; i<N; i++) {
    bool loop = false;
    for (int j=N-1; j>i; j--) {
      if (A[j] < A[j-1]) {
        swap(A[j], A[j-1]);
        sc++;
        loop = true;
      }
    }
    if (!loop) break;
  }
  printA();
  printf("%d\n", sc);
  return 0;
}

Measured memory_bytes: 2652
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(), (a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(), (a).end())
int main(){
    string s;
    cin>>s;
    int n = s.length();
    map<char,int> q;
    rep(i,n){
        q[s[i]]++;
    }
    if(q.size()==1){
        cout<<0<<endl;
        return 0;
    }
    char ans;
    int a=10000;
    for(char c = 'a';c<='z';c++){
        //cout<<c<<endl;
        string t = s;
        string N;
        int j = 1;
        //char c ='v';
        while(1){
            int size;
            map<char,int> p;
            for(int i =0;i<n-j;i++){
                
                if(t[i]==c||t[i+1]==c){
                    //N[i] = c;
                    N += c;
                }
                else{
                    //N[i] = t[i];
                    N += t[i];
                }
                //p[N[i]]++;
                
            }
            rep(i,N.length()){
                p[N[i]]++;
            }
            //cout<<N<<endl;
            t = N;
            N = "";
            if(p.size()==1){
                if(a>j){
                ans = c;
                a = j;
                }
                break;
            }
            j++;
        }
    }
    //cout<<ans<<" "<<a<<endl;
    cout<<a<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i = n;i >= 0;--i)
#define FOR(i,m,n) for(int i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
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 gcd(int a,int b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

int main(void)
{
    int N;
    cin >> N;
    if(N == (int)((int)(N/1.08)*1.08)){
        cout << (int)(N/1.08) << endl;
    }
    else if( N == (int)((ceil(N/1.08))*1.08)){
        cout << (int)ceil(N/1.08) << endl;
    }
    else{
        cout << ":(" << endl;
    }

    return 0;
}

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll K; cin >> K ;
  auto digsum = [&](ll a){
    ll s = 0;
    while(a!=0LL){
      s += a%10;
      a /= 10;
    }
    return double(s);
  } ;
  vl aa,ans;
  ll pp = 1;
  int lim = 16;
  rep(i,lim){
    ll t = pp - 1;
    for(ll k = 0;k < 1000;k++) aa.pb(k*pp+t);
    pp *= 10;
  }
  sort(ALL(aa));
  aa.erase(unique(aa.begin(), aa.end()), aa.end());
  double mi = 1e20;
  rrep(i,aa.size()-1){
    auto ss = digsum(aa[i]);
    double temp = double(aa[i])/ss;
    if(temp<=mi){
      mi = temp;
      ans.pb(aa[i]);
    }
  }
  reverse(ALL(ans));
  dump(ans);
  rep(i,K) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 512
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension [String] {
//    func joined() -> String {
//        return self.joinWithSeparator("")
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let input = readIntSplit(by: " ")
let (a, b) = (input[0], input[1])
print((1..<b-a).reduce(0){$0+$1}-a)


Measured memory_bytes: 4468
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;



int main() {
    int n, r;
    cin >> n >> r;
    r = min(r, n-r);
    vector<int> p(n);
    for (auto &&i : p) scanf("%d", &i), i--;
    vector<int> visited(n);
    int k = 0;
    vector<int> sz;
    for (int i = 0; i < n; ++i) {
        if(visited[i]) continue;
        if(p[i] == i) {
            k++;
            continue;
        }
        int cnt = 0;
        while(!visited[i]){
            cnt++;
            visited[i] = 1;
            i = p[i];
        }
        sz.emplace_back(cnt);
    }
    bitset<150001> v;
    v.set(0);
    for (int i : sz) v |= (v << i);
    for (int i = max(0, r-k); i <= r; ++i) {
        if(v[i]){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}


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

using namespace std;

int main(){
	int n,cnt = 0;
	string name;

	cin >> n;
	cin >> name;

	vector<string> str;
	str.resize(n);

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

	int name_len = name.length();

	for(int i=0;i<n;i++){
		int len = str[i].length();
		if(str[i] == name){
			cnt++;
			goto ok;
		}
		for(int j=0;j<len;j++){
			if(str[i][j] == name[0]){
				for(int k=j,sp=0;k<len;k++,sp++){
					if(str[i][k] == name[1]){
						bool flag = true;
						for(int l=2,c=1;l<name_len;c++,l++){
							if(str[i][k+sp*c] != name[l]){
								flag = false;
							}
						}
						if(flag){
							cnt++;
							goto ok;
						}
					}
				}
			}
		}
		ok:;
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    set<int> s;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        s.insert(a[i]);
    }
    if(s.size()==n)
        cout << "YES" << endl;
    else
        cout <<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define sync ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,n) for(int i=0; i<int(n); ++i)
#define repp(i,a,n) for(int i=a; i<int(n); ++i)
#define sz(x) int((x).size())
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define mp make_pair

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T> &input){for (auto const& i: input) {os << i << " ";}return os;}
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T> &input){for (auto const& i: input) {os << i << " ";}return os;}
template<class T, size_t n> std::ostream& operator<<(std::ostream& os, const std::array<T, n> &input){for (size_t i=0; i<n; ++i) {os << input[i] << " ";}return os;}
template<class T1, class T2> std::ostream& operator<<(std::ostream& os, const std::pair<T1,T2> &input){os << "(" << input.first << ", " << input.second << ')';return os;}
template<class T1, class T2> std::ostream& operator<<(std::ostream& os, const std::unordered_map<T1,T2> &input){for (auto const& i: input) {os << i << " ";}return os;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << H;debug_out(T...);}
#ifdef LOCAL
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

double startTime;
double getCurrentTime(){return ((double)clock() - startTime) / CLOCKS_PER_SEC;}

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<pi> vp;
typedef vector<ll> vl;
typedef vector<vi> vvi;

// === temeplate ===

const int maxn = 50;

void solve(){
	string s; cin >> s;
	int ans=0;
	rep(i,sz(s)){
		ans += s[i] - '0';
		ans %= 9;
	}
	cout << (ans? "No":"Yes") << endl;
}

int main(){
    sync;
    int cas = 1;
    // cin >> cas;
    rep(ca, cas) solve();
    return 0;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    LL X,K,D;cin >> X >> K >> D;
    X = abs(X);
    LL num = X/D;   //0付近までに使う回数
    if(num > K)cout << X - K*D << endl;
    else{
        LL tmp = K - num;
        if(tmp % 2 == 0){
            cout << X - num*D << endl;
        }
        else{
            cout << abs(X - (num+1)*D) << endl;
        }
    }

}

Measured memory_bytes: 3620
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int n, k, q;
  scan(n, k, q);
  vi a(q);
  scan(a);
  vi point(n, 0);
  rep (i, q) {
    point[a[i] - 1] += 1;
  }
  int max_index = 0;
  int max_point = 0;
  rep (i, n) {
    if (max_point < point[i]) {
      max_index = i;
      max_point = point[i];
    }
  }
  int offset = k - (q - max_point) - point[max_index];
  rep (i, n) {
    if (point[i] + offset <= 0) {
      print("No");
    } else {
      print("Yes");
    }
  }

  return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    double r1, r2;
    cin >> r1 >> r2;
    double r3 = r1 * r2 / (r1 + r2);
    cout << OF64 << r3 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int n = sc.nextInt();
        if (n == 100) {
            if (d == 0) {
                System.out.println(101);
            } else if (d == 1) {
                System.out.println(10100);
            } else {
                System.out.println(1010000);
            }
        } else {
            System.out.print(n);
            for (int i = 0; i < d; i++) {
                System.out.print("00");
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 23636
#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

int main(void){
    string S;
    cin >> S;
    const int N = S.length();

    int tmp_0 = 0;
    int tmp_1 = 0;

    for(int i=0;i<N;i++){
        if(i&1){
            if(S[i] == '0') tmp_0++;
            if(S[i] == '1') tmp_1++;
        }else{
            if(S[i] == '1') tmp_0++;
            if(S[i] == '0') tmp_1++;
        }
    }
    cout << min(tmp_0, tmp_1) << endl;
    return 0;

}


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

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int num = Integer.valueOf(scan.nextLine());
        int[] numList = new int[num];

        for(int i=0; i<num; i++) {
            numList[i] = scan.nextInt();
        }

        int[] resultnum = new int[num+1];
        Arrays.fill(resultnum, 0);
        for(int i=0; i<num; i++) {
            resultnum[numList[i]-1] = i+1;
        }

        for(int i=0; i<num; i++) {
            System.out.print(resultnum[i] + " ");
        }
    }
}


Measured memory_bytes: 59280
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

N,M = map(int, input().split())
ab_s = [list(map(int, input().split())) for _ in range(M)]
answer = 0
for i in range(M):
    uf = UnionFind(N)
    for j in range(M):
        if i == j:
            continue
        a,b = map(int, ab_s[j])
        uf.Unite(a,b)
    a,b = map(int, ab_s[i])
    if not uf.isSameGroup(a,b):
        answer += 1
print(answer)

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

using namespace std;
#define         MAX         2*10000
#define         ll          long long
#define         input       freopen("input.txt","r",stdin)
#define         output      freopen("output.txt","w",stdout)
#define         inf         10000000


int main() {

    //input;
    //output;


    int n,cnt = 0;
    cin>>n;
    map<string, int>m;
    string s;
    while(n--){
        s = "";
        cin>>s;
        if(m[s]==0) {
          cnt++;
          m[s] = 1;
        }

    }

    cout<<cnt<<endl;

    //map<string, int>::iterator it;

    //for(it=m.begin(); it!= m.end(); it++){

    //}




    return 0;
}


Measured memory_bytes: 19228
import sys
from collections import deque  # 双方向キュー
from collections import defaultdict  # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー
from bisect import bisect_left, bisect_right  # 二分探索
#import numpy as np  # 1.8.2
#import scipy  # 0.13.3
#sys.setrecursionlimit(int(1e+6))
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
MOD = int(1e+9) + 7

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def main():
    N = i2n()
    A = i2nn()
    # n = -1
    # for i in range(N):
    #   Aからi番目を取り除く
    #   t = gcd(A[0:i], A[i+1:N])
    #   if n < t:
    #     n = t
    L = [0] * N
    R = [0] * N
    L[0] = A[0]
    R[-1] = A[-1]
    for i in range(1, N):
        L[i] = gcd(L[i-1], A[i])
    for i in range(N-2, -1, -1):
        R[i] = gcd(R[i+1], A[i])
    n = -1
    if n < R[1]:
        n = R[1]
    if n < L[-2]:
        n = L[-2]
    for i in range(1, N-1):
        t = gcd(L[i-1], R[i+1])
        if n < t:
            n = t
    print(n)

main()


Measured memory_bytes: 60064
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

int dy[5] = {-1, 0, 1, 0, 0};
int dx[5] = {0, -1, 0, 1, 0};

long long int gcd(long long int a, long long int b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

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

    cin>>a>>b;

    cout<<lcm(a,b)<<endl;
}


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

int main(){
    double L;
    cin >> L;
    printf("%.12f",(double)L*L*L/27);
    return 0;
}





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

int main(void) {
	int r, g, b, n;
	int ret = 0;
	int t1, t2;
	cin >> r >> g >> b >> n;
	for (int i = 0; i * r <= n; i++) {
		t1 = i * r;
		for (int j = 0; j * g <= n - t1; j++) {
			t2 = j * g;
			int k = (n - t1 - t2) / b;
			if (t1 + t2 + k * b == n)
				ret++;
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
/*
Submitted With (^^) by -> Hossam ^_^
 _____________________
|     ___     ___     |
|    (^_^)   (^_^)    |
|   /( | )\_/( | )\   |
|_____|_|_____|_|_____|
*/

#include <bits/stdc++.h>

using namespace std;

inline void prep()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
}

#define X first
#define Y second
#define ll long long
#define inf (0x7fffffffffffffff)
#define all(x) x.begin(), x.end()

const int mod = (int)1e9 + 7;
const int MX = (int)2e5 + 1;

int main()
{
    prep();

    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    ll res = 1e10;
    for(int i = 0; i <= 2 * max(x, y); i += 2){
        int xx = max(0, x - (i / 2));
        int yy = max(0, y - (i / 2));

        ll cur = i * c + xx * 1ll * a + yy * 1ll * b;
        res = min(res, cur);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
for i in range(1,n):
	A[i] += A[i-1]
for i in range(n-2,-1,-1):
	B[i] += B[i+1]
print(max([A[i]+B[i] for i in range(n)]))

Measured memory_bytes: 61716
#include <bits/stdc++.h>
#define ll long long
#define arena ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main() 
{
    char c;
    cin>>c;
    
    ll x=c;
    x++;
    
    if(x==123)
    x=x-26;
    
    char a=x;
    cout<<a;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main () {
  int n, s;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> s;
    a[s-1] = i + 1;
  }
  for (int i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
}

Measured memory_bytes: 1152
n, a, b = map(int, input().split())
s = input()
counterSelected = 0
counterB = 0
for i in s:
    if i == "a":
        if counterSelected < a + b:
            counterSelected += 1
            print('Yes')
        else:
            print('No')
    elif i == "b":
        if counterSelected < a + b and counterB <= b - 1:
            counterSelected += 1
            counterB += 1
            print('Yes')
        else:
            print('No')
    else:
        print('No')

Measured memory_bytes: 53464
n = int(input())
A = list(map(int, input().split()))
numchange = 0

for i in range(n):
    minj = i
    for j in range(i, n):
        if A[j] < A[minj]:
            minj = j
    if A[i] != A[minj]:
        tmp = A[i]
        A[i] = A[minj]
        A[minj] = tmp
        numchange += 1
        
print(str(A).replace(',', '')[1:-1])
print(numchange)
    


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  string s; cin >> s;
  vector<bool> in(n);
  REP(i, n) in[i] = (s[i] == 'o') ? 1 : 0;

  vector<vector<bool>> v(4);
  vector<bool> now(4);
  REP(i, 4) v[i].resize(n+2);
  v[0][0] = 0; v[0][1] = 0; now[0] = 0;
  v[1][0] = 0; v[1][1] = 1; now[1] = 1;
  v[2][0] = 1; v[2][1] = 0; now[2] = 1;
  v[3][0] = 1; v[3][1] = 1; now[3] = 0;
  
  REP(i, 4) {
    REP(j, n) {
      v[i][j+2] = now[i] ^ in[j];
      now[i] = v[i][j+1] ^ v[i][j+2];
    }

  }

  int ans = -1;
  REP(i, 4) {
    if(v[i][0] == v[i][n] && v[i][1] == v[i][n+1]) ans = i;
  }

  if(ans == -1) cout << -1;
  else REP(i, n) cout << ((v[ans][(i+1)%n]) ? 'S' : 'W');
  cout << endl;
}


Measured memory_bytes: 512