akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
    int i,x;

    for ( i = 1; i <= 10000; i++ )
    {
        scanf("%d",&x);
        if (x == 0)
        {
            break;
        }
        printf("Case %d: %d\n",i,x);
        
    }
    return 0;
}




Measured memory_bytes: 2044
#include<iostream>
#include<stdio.h>

using namespace std;

int l, s;
int n=0;

int main(){
    cin >> l >> s;
    int i , j, k;
    for (i=0; i<l+1; ++i){
        for (j=0; j<l+1; ++j){
            k=s-i-j;
            if (k>=0 && k<=l){
                ++n;
            }

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


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

int main(void)
{
    int n;
    int t[100001] = {0};
    int x[100001] = {0};
    int y[100001] = {0};

    int flag = 1;
    int i, sx, sy, s, e;

    scanf("%d", &n);
    for (i=1; i<=n; i++) {
        scanf("%d%d%d", &t[i], &x[i], &y[i]);
    }


    for (i=1; i<=n; i++) {
        sx = abs(x[i] - x[i-1]);
        sy = abs(y[i] - y[i-1]);
        s = sx + sy;
        e = t[i] - t[i-1];

        if (!(s<=e && (e-s)%2==0)) {
            flag = 0;
            break;
        }
    }

    if (flag)   printf("Yes\n");
    else        printf("No\n");

    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" \
                              << "\n";

int main()
{
  bool f = true;
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m), ans(n, -1);
  REP(i, m)
  {
    cin >> s.at(i) >> c.at(i);
  }

  REP(i, m)
  {
    if (ans.at(s.at(i) - 1) == -1)
      ans.at(s.at(i) - 1) = c.at(i);
    else if (ans.at(s.at(i) - 1) != c.at(i))
      f = false;
    if (s.at(i) == 1 && c.at(i) == 0 && n >= 2)
      f = false;
  }

  if (ans.at(0) == -1)
  {
    if (n >= 2)
      ans.at(0) = 1;
    else
      ans.at(0) = 0;
  }

  REP(i, n)
  {
    if (ans.at(i) == -1)
      ans.at(i) = 0;
  }

  if (f)
  {
    REP(i, n)
    {
      cout << ans.at(i);
    }
    cout << "\n";
  }
  else
  {
    cout << -1 << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
	int N, x;
  	cin >> N >> x;
  	vector<int> a(N);
  	rep(i,N) cin >> a[i];
  
  	ll ans = 0;
  	ll temp;
  	rep(i,N-1){
      	if(i==0 && a[i] > x){
          	ans += a[i] - x + a[i+1];        
          	a[i+1] = 0;
        }
      	else{
     		temp = a[i] + a[i+1] - x;
		  	if(temp>0){
        		a[i+1] -= temp;
	          	ans += temp;
        	}
        }
    }
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  ll n, m;
  cin >> n >> m;
  vl a(n);
  REP(i, n) { cin >> a[i]; }
  sort(ALL(a));

  ll ng = 200001LL;
  ll ok = 0LL;
  while (abs(ok - ng) > 1LL) {
    ll x = (ng + ok) / 2LL;

    ll cnt = 0LL;
    REP(i, n) { cnt += (ll)(a.end() - lower_bound(ALL(a), x - a[i])); }
    if (cnt >= m) {
      ok = x;
    } else {
      ng = x;
    }
  }

  vl cum(n + 1);
  cum[0] = 0LL;
  REP(i, n) { cum[i + 1] = cum[i] + a[i]; }

  ll ans = 0LL;
  ll cnt = 0LL;
  REP(i, n) {
    ll c = (ll)(a.end() - lower_bound(ALL(a), ok - a[i]));
    ans += c * a[i] + cum[n] - cum[n - c];
    cnt += c;
  }

  cout << ans - ok * (cnt - m) << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
template <typename T = int>
T in() {
    T temp; cin >> temp; return temp;
}

template <typename VType = int>
list<VType> const LR(VType start, VType end) {
    list<VType> ret; for (VType i = start; i < end; i++) ret.push_back(i); return move(ret);
}

int main() {
    int const R(in()), G(in()), B(in()), N(in());
    int ret = 0;

    for (size_t i = 0; i <= N/R; i++) {
        int remain = N - i*R; 
        for (int j = 0; j <= remain / G; j++) {
            int remain2 = remain - j * G;
            if (0 == (remain2 % B)) ret++;
        }
    }

    cout << ret << endl; 
    return 0;
}




Measured memory_bytes: 256
import java.util.*;
class Main {
	
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		Dice dice1 = new Dice(stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt());
		Dice dice2 = new Dice(stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt());
		boolean a = solv(dice1, dice2, 0);
		System.out.println((a)?"Yes":"No");
	}
	public static boolean solv(Dice f, Dice dice,int count) {
		if(dice.Top == f.Top && dice.S == f.S && dice.Bottom == f.Bottom && dice.E == f.E && dice.N == f.N && dice.W == f.W) return true;
		if(count == 6) return false;
		Dice tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
		tmp.TurnN();
		if(solv(f,tmp,count+1)) {
			return true;
		}
		tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
		if(solv(f,tmp,count+1)) {
			return true;
		}
		tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
		tmp.TurnE();
		tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
		tmp.TurnW();
		if(solv(f,tmp,count+1)) {
			return true;
		}
		
		return false;
	}
	
	
	
}

class Dice {
	int Top; //1
	int Bottom; //6
	int N; //   5
	int S; //   2
	int W; //左 4
	int E; //右 3
	Dice(int a, int b, int c, int d, int e, int f) {
		Top = a;
		S = b;
		E = c;
		W = d;
		N = e;
		Bottom = f;
	}
	public void TurnN() {
		int tmp = Top;
		Top = S;
		S = Bottom;
		Bottom = N;
		N = tmp;
	}
	public void TurnW() {
		int tmp = Top;
		Top = E;
		E = Bottom;
		Bottom = W;
		W = tmp;
	}
	public void TurnE() {
		int tmp = Top;
		Top = W;
		W = Bottom;
		Bottom = E;
		E = tmp;
	}
	public void TurnS() {
		int tmp = Top;
		Top = N;
		N = Bottom;
		Bottom = S;
		S = tmp;
	}
	
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}


int nextInt() { int x; scanf("%d", &x); return x;}

bool isPalin(string s) {
  int N = (int)s.size();
  REP(i, N/2) {
    if (s[i] != s[N-1-i]) return false;
  }
  return true;
}

int main2() {
  string s;
  cin >> s;

  string v;
  REP(i, s.size()) if (s[i] != 'x') v.push_back(s[i]);

  if (!isPalin(v)) {
    cout << -1 << endl;
  } else {
    int a = 0;
    int b = (int)s.size() - 1;

    int ans = 0;
    while (a < b) {
      int x1 = 0;
      int x2 = 0;
      while (a < (int)s.size() && s[a] == 'x') { x1++; a++; }
      while (b >= 0 && s[b] == 'x') { x2++; b--; }
      a++;
      b--;
      ans += abs(x1 - x2);
    }
    cout << ans << endl;
  }
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



Measured memory_bytes: 640
use std::io;
use std::collections::VecDeque;

fn main() {
    let mut input = Input::new();
    let n: usize = input.next();
    let mut a: Vec<(usize, usize)> = (0..n).map(|_| input.next::<usize>()).enumerate().collect();
    a.sort_by(|a, b| a.1.cmp(&b.1));
    for i in 0..n {
        a[i].1 = i;
    }
    println!("{}",
             a.iter().filter(|&&(i, v)| i % 2 == 0 && v % 2 == 1).count());
}

struct Input {
    queue: VecDeque<String>,
}

impl Input {
    fn new() -> Input {
        Input { queue: VecDeque::new() }
    }

    fn next<T>(&mut self) -> T
        where T: std::str::FromStr,
              T::Err: std::fmt::Debug
    {
        if self.queue.is_empty() {
            let mut line = String::new();
            let _ = io::stdin().read_line(&mut line);
            for x in line.split_whitespace() {
                self.queue.push_back(String::from(x));
            }
        }
        return self.queue.pop_front().unwrap().parse::<T>().unwrap();
    }
}



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

 #define REP(i, a, n) for(int i=a; i<n; i++)

int main() {
	int a;
	cin >> a;
  	if(105%a==0 and a!=1){
    cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
fn main() {
    let (n, m) = {
        let nm = read_vec::<usize>();
        (nm[0], nm[1])
    };
    let mut lights: Vec<Vec<usize>> = Vec::new();
    for i in 0..m {
        let ks = read_vec::<usize>();
        let k = ks[0];
        let mut v = vec![0; k];
        for j in 0..k {
            v[j] = ks[j+1] - 1;
        }
        lights.push(v);
    }
    let p = read_vec::<usize>();

    // switchをbit全探索
    let mut ret = 0;
    for i in 0..(1 << n) {
        let mut switches = vec![0; n];
        for j in 0..n {
            let bit = 1 << j;
            if (i & bit) == 0 { continue; }
            switches[j] = 1; // switch on
        }

        let mut on_lights = 0;
        for (i_light, light) in lights.iter().enumerate() {
            let mut cnt = 0;
            for j in light {
                if switches[*j] == 1 { cnt += 1; }
            }
            if cnt % 2 == p[i_light] { on_lights += 1; }
        }

        if on_lights == m { ret += 1; }
    }

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


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

int main() {
	string s; cin >> s;
	int fx = 0;
	for (int i = 0; i < s.size(); i++) {
		fx += s[i] - '0';
	}
	int x = stoi(s);

	if (x % fx == 0) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
x = gets.split.map(&:to_i).sort
min_sum = 10 ** 9
for p in x[0]..x[-1] do
  sum = 0
  for i in 0...n do
    sum += (x[i] - p) ** 2
  end
  min_sum = sum if min_sum > sum
end
puts min_sum


Measured memory_bytes: 1788
N = int(input())
A = list(map(int,input().split()))
mod = 1000000007
ans = 0
res = [A[0]]
for i in range(N-1):
    res.append(res[i]+A[i+1])
for i in range(1,N):
    ans = ans + (A[i]*res[i-1])%mod
ans = ans%mod
print(ans)

Measured memory_bytes: 31560
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	int n, k;
	cin >> n >> k;
	vector<int>m;
	for (int i = 0; i < n; i++) {
		int r;
		cin >> r;
		m.push_back(r);

	}
	sort(m.begin(), m.end());
	int ans = 0;
	for (int i = 0; i < k; i++) {
		ans += m[n - 1 - i];
	}
	cout << ans << endl;
	return 0;

}




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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  for(int i = 0; i < N; i++) cin >> l[i];

  sort(l.begin(), l.end(), greater<int>());

  int ans = 0;
  for(int i = 0; i < K; i++){
    ans += l[i];
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
    int n;cin>>n;
    int m=n;
    int keta=0;
    while(n>0){
        n/=10;
        keta++;
    }
    if(keta==1) cout<<m<<endl;
    if(keta>1){
        int ans=0;
        for(int i=2;i<=keta;i++){
            if(i%2==0) ans+=9*pow(10,i-2);
        }

        if(keta%2==1) ans+=m-pow(10,keta-1)+1;

        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
while 1:
    s = input()
    if s == '#':
        break
    M = []
    for l in s.split('/'):
        num = 0
        tmp = []
        for c in l:
            if c == 'b':
                if num > 0:
                    tmp.extend([0]*num)
                tmp.append(1)
                num = 0
            else:
                num = 10*num + int(c)
        if num > 0:
            tmp.extend([0]*num)
        M.append(tmp)
    a, b, c, d = map(int, input().split())
    assert M[a-1][b-1] == 1
    M[a-1][b-1] = 0
    assert M[c-1][d-1] == 0
    M[c-1][d-1] = 1
    ans = []
    for l in M:
        tmp = ""
        cnt = 0
        for c in l:
            if c:
                if cnt > 0:
                    tmp += str(cnt)
                cnt = 0
                tmp += 'b'
            else:
                cnt += 1
        if cnt > 0:
            tmp += str(cnt)
        ans.append(tmp)
    print("/".join(ans))

Measured memory_bytes: 7680
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    for (int & x : a)
        cin >> x;
    int mx = a[0] + k - a[n - 1];
    for (int i = 1; i < n; ++i)
        mx = max(mx, a[i] - a[i - 1]);
    cout << k - mx << endl;
}


Measured memory_bytes: 1024
def vec(s,t):
    return [t[0]-s[0],t[1]-s[1]]

def dot(a,b):
    return a[0]*b[0]+a[1]*b[1]

def scalsquared(a):
    return (a[0]**2+a[1]**2)

def project(p,a,b):
    k = dot(vec(a,p),vec(a,b)) / scalsquared(vec(a,b))
    return [a[0]+k*(b[0]-a[0]), a[1]+k*(b[1]-a[1])]

def symmetrical_point(p,q):
    return [p[0]+2*(q[0]-p[0]), p[1]+2*(q[1]-p[1])]

while True:
    try:
        tmp = [float(x) for x in input().split(',')]
        p1 = [tmp[0],tmp[1]]
        p2 = [tmp[2],tmp[3]]
        q = [tmp[4],tmp[5]]
        r = symmetrical_point(q,project(q,p1,p2))
        print(r[0], r[1])
    except:
        break


Measured memory_bytes: 5612
#include<stdio.h>

int main()
{
    long long int a,b,res;
    scanf("%lld%lld",&a,&b);
    while(b!=0)
    {
               res = a%b;
               a = b;
               b = res;
    }
    printf("%lld\n",a);
    return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;
import java.lang.Math;


public class Main {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n;
        double[] ans = new double[1000];
        int k=0;
        while(true){
            n = scan.nextInt();
            if(n==0)break;
            int[] a = new int[n];
            int sum=0;
            for(int i=0;i<n;i++){
                a[i]=scan.nextInt();
                sum+=a[i];
            }
            double ave = (double)sum/n;
            double var=0;
            for(int i=0;i<n;i++){
                var =var+((a[i]-ave)*(a[i]-ave)/n);
            }
            ans[k] = Math.sqrt(var);
            k++;
        }
        for(int i=0;i<k;i++){
            System.out.printf("%.5f\n",ans[i]);
        }
    }
}


Measured memory_bytes: 33644
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#define lld long long int
#define DBG1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define DBG2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define DBG3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// freopen("input.txt", "r", stdin);  
	string s;
	cin >> s;
	int n=s.size();
	int a;
	int z;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='A')
		{
			a=i;
			break;
		}
	}
	for(int i=0;i<n;i++)
	{
		if(s[i]=='Z')
			z=i;
	}
	cout << z-a+1; 
}

Measured memory_bytes: 720
A,B,K = map(int,input().split())
count = 0
for i in range(100):
  if count ==K:
    break
  else:
    if A%2 == 1:
      A = A-1
    B = B + A/2
    A = A/2
    count += 1
  if count == K:
    break
  else:
    if B%2 == 1:
      B = B-1
    A = A+ B/2
    B = B/2
    count += 1
print(int(A),int(B))

Measured memory_bytes: 3064
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tlll tuple<ll, ll, ll>

int main() {
    int n, ans = 0;
    cin >> n;
    string s;
    cin >> s;

    for (int i = 0; i < n - 2; i++) {
        if (s.substr(i, 3) == "ABC") ans++;
    }

    cout << ans << endl;

}



Measured memory_bytes: 256
#include<stdio.h>
#define N 200
void find(int samx,int samy,int x[],int y[],int a[]);
int main(void){
  int n,m,data_n[N],data_m[N],i,sum_n=0,sum_m=0,a[3];
  while(1){
    sum_m=0;
    sum_n=0;
    scanf("%d %d",&n,&m);
    if(n==m && n==0)
      break;
    for(i=0;i<n;i++){
      scanf("%d",&data_n[i]);
      sum_n=sum_n+data_n[i];
    }
    for(i=0;i<m;i++){
      scanf("%d",&data_m[i]);
      sum_m=sum_m+data_m[i];
    }
    if(sum_m<sum_n){
      a[0]=n;
      a[1]=m;
      a[2]=0;
      find(sum_m,sum_n,data_m,data_n,a);
    }
    else{
      a[0]=m;
      a[1]=n;
      a[2]=1;
      find(sum_n,sum_m,data_n,data_m,a);
    }
    if(a[0]!=-1){
      if(a[2]==0){
	printf("%d %d\n",a[0],a[1]);
      }
      else{
	printf("%d %d\n",a[1],a[0]);
      }
    }
    else{
      printf("%d\n",a[0]);
    }
  }
  return 0;
}
void find(int samx,int samy,int x[],int y[],int a[]){
  int i,flag=0,cpx=N,cpy=N,sumdata=N+N,sumcp;
  int n=a[0],m=a[1],j;
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      if((samy-samx)%2!=0){
	flag=2;
	break;
      }
      if(y[i]-x[j]==(samy-samx)/2){
	cpx=y[i];
	cpy=x[j];
	sumcp=y[i]+x[j];
	flag=1;
      }
      if(flag==1 && sumdata>sumcp){
	a[0]=cpx;
	a[1]=cpy;
	sumdata=sumcp;
	flag=0;
      }	
    }
    if(flag==2){
      break;
    }
  }
  if(sumdata==N+N || a[0]==0 || flag==2)
    a[0]=-1;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main{
	static Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
    	
    	int a = in.nextInt();
    	int[] ints = new int[a];
    	
    	for (int i=0; i<a; i++) {
            ints[i] = in.nextInt();
        }
    	int MyArray;
    	for (int i=0; i<a; i++) {
    		MyArray = ints[i];
            
            int j = i - 1;
            while (j>=0 && ints[j]>MyArray) {
                ints[j+1] = ints[j];
                j--;
            }
            ints[j+1] = MyArray;
            
            for (int t=0; t<ints.length; t++) {
                System.out.print(ints[t]);
                if (t!=ints.length-1) {System.out.print(" ");}
            }
            System.out.println();
            
            
    	} 
            
    	       
            }
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	int ans=0;
	for(int i=0;i<n;++i){
		int A; cin>>A;
		if(A%2==0)while(A%2==0)A/=2,++ans;
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  int u=n/100;
  int d=n-(u*100);

  if((d<13&&u<13)&&0<d&&0<u){
    printf("AMBIGUOUS");
  }else if((d==0&&12<u)||(u==0&&12<d)||(12<d&&12<u)||(d==0&&u==0)){
    printf("NA");
  }else if((12<u||u==0)&&d<13&&0<d){
    printf("YYMM");
  }else if((12<d||d==0)&&u<13&&0<u){
    printf("MMYY");
  }

  return 0;
}


Measured memory_bytes: 128
n, k = map(int, input().split())
graph = []
Y = []
X = []
for _ in range(n):
    x, y = map(int, input().split())
    graph.append([x, y])
    Y.append(y)
    X.append(x)

Y.sort()
X.sort()
ans = []
for sx in range(n):
    for ex in range(n-1, sx, -1):
        for sy in range(n):
            for ey in range(n-1, sy, -1):
                x1, x2, y1, y2 = X[sx], X[ex], Y[sy], Y[ey]
                count = len([True for x, y in graph if x1 <= x <= x2 and y1 <= y <= y2])
                if count >= k:
                    ans.append((x2-x1)*(y2-y1))
                else:
                    break

print(min(ans))

Measured memory_bytes: 114652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		solver.readA(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
	}

	public void readA(String str) {
		String[] strArr = str.split("\\s+");
		ArrayList<Integer> A = new ArrayList<Integer>();
		for (int i = 0; i < N; i++)
			A.add(Integer.parseInt(strArr[i]));
		A.sort((a1, a2) -> a1 - a2);
		double ans = (double) A.get(0);
		for (int i = 1; i < N; i++) {
			ans = (ans + (double) A.get(i)) / 2;
		}
		System.out.println(ans);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  string s;
  cin >> s;

  set<char> v(s.begin(), s.end());

  if (s.length() == v.size()) {
    p("yes");
  } else {
    p("no");
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#define NUL -1
const int N_MAX = 45;
int root;
struct Node{
    int parent, left, right;
};
Node tree[N_MAX];
int pre[N_MAX], in[N_MAX];

void reConstruct(int parent, int * preP, int * inP, int n, bool isLeft){
    if(n==0) return;
    int nowRoot = preP[0];
    tree[nowRoot].parent = parent;
    //getchar();
    //cout<<"-- nowRoot: "<<nowRoot<<endl;
    if(parent==NUL){
        root=nowRoot;
    }else if(isLeft){
        tree[parent].left=nowRoot;
    }else{
        tree[parent].right=nowRoot;
    }
    if(n==1)return;
    int flag = 0;
    for(;flag<n;flag++){
        if(inP[flag]==nowRoot) break;
    }
    //cout<<"nowRoot: "<<nowRoot<<" flag: "<<flag<<endl;
    reConstruct(nowRoot, preP+1, inP, flag, true);
    reConstruct(nowRoot, preP+1+flag, inP+1+flag, n-flag-1, false);
}

void post(int id){
    if(id==NUL) return;
    if(tree[id].left==NUL&&tree[id].right==NUL&&id!=root){
        printf("%d ", id);
        //cout<<id<<" ";
        return;
    }
    post(tree[id].left);
    post(tree[id].right);
    if(id==root){
        printf("%d", id);
        //cout<<id<<endl;
    }else{
        printf("%d ", id);
        //cout<<id<<" ";
    }
}

int main(){
    int n;
    scanf("%d", &n);
    //cin>>n;
    for(int i=0;i<n;i++){
        scanf("%d", &pre[i]);
        //cin>>pre[i];
        tree[i].parent=tree[i].left=tree[i].right=NUL;
    }
    tree[n].parent=tree[n].left=tree[n].right=NUL;
    for(int i=0;i<n;i++){
        scanf("%d", &in[i]);
        //cin>>in[i];
    }
    reConstruct(NUL, pre, in, n, true);
    /*//Debugging/
    for(int i=1;i<=n;i++){
        cout<<"node"<<i<<": p: "<<tree[i].parent<<"  l: "<<tree[i].left<<"  r: "<<tree[i].right<<endl;
    }
    ///Debugging*/
    post(root);
    printf("\n");
    //cout<<"root: "<<root<<endl;
    return 0;
}



Measured memory_bytes: 2752
#include <stdio.h>
int main(void)
{
  int h1,h2,a1,a2;
  int flag=0;
  scanf("%d",&h1);
  scanf("%d",&a1);
  scanf("%d",&h2);
  scanf("%d",&a2);
  
  do
  {
    h2-=a1;
    
    if(h2<=0)
    {  
      flag=1;
      break;
    }
    h1-=a2;
  }while(h1>0);
  
  
  if(flag){
    printf("Yes");
  }
  else{ 
    printf("No");
  }
  return 0;
}
    


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

int main(void)
{
    int x, ans = 1;
    cin >> x;
    while (1)
    {
        if (x * ans % 360 == 0)
            break;
        else
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int n,A[50];

int solve(int i, int m){

  if( m == 0 )
    return 1;
  if( i >= n )
    return 0;

  int res = solve(i+1,m) || solve(i+1,m-A[i]);
  return res;

}



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

  int i;
  int q,M;

  scanf("%d",&n);

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

  scanf("%d",&q);

  for( i = 0 ; i < q ; i++ ){
    scanf("%d",&M);


    if( solve(0,M) )
      printf("yes\n");
    else
      printf("no\n");

  }

  return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  string s;
  cin>>s;
  for(ll i=0;i<s.size();i++){
    if(s[i]==',') cout<<" ";
    else cout<<s[i];
  }
  cout<<"\n";
  return 0;
}
	


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
        long long N;
        long long count[5]={};
        string S;
        cin >> N;
        for(int i=0; i<N; i++){
                cin >> S;
                if(S[0]=='M')
                        count[0]++;
                else if(S[0]=='A')
                        count[1]++;
                else if(S[0]=='R')
                        count[2]++;
                else if(S[0]=='C')
                        count[3]++;
                else if(S[0]=='H')
                        count[4]++;
        }
        cout << count[0]*count[1]*count[2]+count[0]*count[1]*count[3]+count[0]*count[1]*count[4]+count[0]*count[2]*count[3]+count[0]*count[2]*count[4]+count[0]*count[3]*count[4]+count[1]*count[2]*count[3]+count[1]*count[2]*count[4]+count[1]*count[3]*count[4]+count[2]*count[3]*count[4] << endl;
        return 0;
}

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



Measured memory_bytes: 2040
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n := nextLine()
	r := map[string]string{}
	nn := strings.Split(n, "")

	for _, item := range nn {
		r[item] = item
	}

	if len(r) == 2 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll x,y,T,i,a[10010],A,res_one,n;
double res,miin=1000000007;
int main()
{
//	freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    cin>>n;
    cin>>T>>A;
    for(i=1;i<=n;i++) cin>>a[i];
    for(i=1;i<=n;i++)
       {
       	  res=T-a[i]*0.006;
       	  if (abs(res-A)<miin) 
       	     {
       	     	res_one=i;
       	     	miin=abs(res-A);
				}
	   }
	   cout<<res_one;
	return 0;
}


Measured memory_bytes: 256
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N,K=map(int,readline().split())

    if K%2!=0:
        print((N//K)**3)
    else:
        count=0
        L=K//2
        count+=(N//L-N//K)**3
        count+=(N//K)**3
        print(count)
        
if __name__=="__main__":
    main()

Measured memory_bytes: 3060
ALPA = 'abcdefghijklmnopqrstuvwxyz'
sets = dict(zip(list(ALPA), range(26)))
A_LIST = [n for n in range(1, 26) if n%2 != 0 and n%13 != 0]

def encode(word, a, b):
    return [(a*y+b)% 26 for y in [sets[c] for c in list(word)]]

def find(words):
    for a in A_LIST:
        for b in range(26):
            for word in words:
                if word == encode("this", a, b) or word == encode("that", a, b):
                    return (a, b)
                
for i in range(int(raw_input())):
    data = raw_input()
    a, b = find([[sets[c] for c in list(word)] for word in data.split(' ') if len(word) == 4])
    ans = dict(zip(encode(ALPA, a, b), list(ALPA)))
    print ' '.join([''.join([ans[n] for n in [sets[c] for c in list(word)]]) for word in data.split(' ')])

Measured memory_bytes: 6560
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}

vector<pair<ll,ll>> factor_arr;

void myfactor(ll num){ 
    ll count = 0;   
    while (!(num % 2)) { 
        num >>= 1; count++; 
    }  
    if (count) factor_arr.push_back({2,count}); 
    for (auto i = 3; i <= sqrt(num); i += 2) { 
        count = 0; 
        while (num % i == 0) { 
            count++; 
            num /= i; 
        } 
        if (count) factor_arr.push_back({i,count}); 
    } 
    if (num > 2) factor_arr.push_back({num,1});
}

void virus(){
        vector<string> arr = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
        string tod;
        cin>>tod;
        cout<<7 - (find(arr.begin(),arr.end(),tod) - arr.begin());
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t=1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define rep(i,n) for (int i=0;i<(n);++i)
#define REP(i,n) for (int i=0;i<=(n);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int INF = 10000000;

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

int main() {
    ll a; cin >> a;
    double b; cin >> b;
    ll bb = (ll)(b * 100 + 0.001);
    cout << a * bb / 100 << endl;
}

Measured memory_bytes: 3744
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
        checked {
#if DEBUG
            //TestCaseMaker.MakeTestCase1("../TextFile2.txt");
            MyDebugger.Test(process, "../TextFile1.txt");
            //MyDebugger.Test(process, "../TextFile2.txt");
#else
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            Console.WriteLine(ret);
#endif
        }
    }

    static object process(TextReader input) {
        var ary = input.ReadLine().Split(' '); //ToIntArray(input.ReadLine(), 5);

        for(int i=0; i<5; i++) {
            if(ary[i] == "0") return i+1;
        }

        return 0;
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}


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

int main() {
	int height, width;
  	int whiteCellsNum;
  
  	cin >> height >> whiteCellsNum;
  
  	width = height;
  
  	int totalCellsNum = height * width;
  	int blackCellsNum = totalCellsNum - whiteCellsNum;
  	cout << blackCellsNum << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
string str,cp="CODEFESTIVAL2016";
int dif;
int main(){
	cin>>str;
	for(int i=0;i<16;i++){
		cp[i]==str[i]?dif++:dif+=0;
	}
	cout<<16-dif<<endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
li = [0] * n
li = list(map(int, input().split()))
result = sum(li)

m = int(input())
r1 = [0] * m
r2 = [0] * m

for i in range(m) :
  a,b = map(int, input().split())
  print(result - li[a-1] + b)

Measured memory_bytes: 3316
#include <iostream>

using namespace std;

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

  int ans = 1;
  int max_count = 0;
  for (int n = 2; n <= N; n += 2) {
    int two = 2;
    int count = 0;
    while (!(n % two)) {
      ++count;
      two *= 2;
    }

    if (count > max_count) {
      max_count = count;
      ans = n;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <cstdlib>
#include <cmath>

int main() {
	std::array<char, 1000000> is_prime_table = { 0, 0, 1 };
	for( int i=3; i<=is_prime_table.size(); i+=2 ) {
		if ( [&i]() -> bool
		{
			for( int j=3; j<=std::sqrt(i); j+=2 )
				if ( i % j == 0 )
					return false;
			return true;
		}() )
			is_prime_table[i] = 1;
	}
	
	std::string line;
	while( std::getline( std::cin, line ) ) {
		int const num = std::atoi( line.c_str() );
		int result = num > 1 ? 1 : 0;	// 2
		
		for( int i=3; i<=num; i+=2 )
			if ( is_prime_table[i] == 1 )
				++result;

		std::cout << result << std::endl;
	}
}

Measured memory_bytes: 2164
#include <bits/stdc++.h>
#define int long long
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define MOD 1000000007
/* DEFINE cout */
#define pln cout << "===============================\n"
#define on cout<<"\n"
#define os cout<<" "
#define o2(a,b) cout<<a<<" "<<b
#define o(a) cout << a
#define bitcount __builtin_popcount
/* DEFINE cout */
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//fastio
using namespace std;
struct hash_pair { // use pair as key in unordered_map<pair<int,int>,int,hash_pair>;
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
bool prime[10000001];
int P=MOD-2;
int factorial[10000001]={0};
int powerFunction(int x,int y){
    int res = 1;
    int p = MOD;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}
void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
        factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int n;
int arr[3001];
int dp[3001][3001];
int fun(int i, int j, bool turn){
    if(i > j){
        return 0;
    }
    if(dp[i][j] != -1){
        return dp[i][j];
    }
    int a = fun(i+1, j, !turn);
    int b = fun(i, j-1, !turn);
    if(turn){
        dp[i][j] = max(a + arr[i], b + arr[j]);
    }else{
        dp[i][j] = min(a - arr[i], b - arr[j]);
    }
    return dp[i][j];
}
signed main(){
    memset(dp, -1, sizeof(dp));
    cin >> n;
    for(int i=0;n>i;i++){
        cin >> arr[i];
    }
    cout << fun(0, n-1, true) << endl;
}


Measured memory_bytes: 72064
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

template<class T> inline bool chmin(T& a, T b) {if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if(a<b){a=b;return true;}return false;}

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vi Left(n+1);
  Vi Right(n+1);
  Vi A(n);
  VIN(A)
  REP(i,n){
    Left[i+1] = gcd(A[i],Left[i]);
  }
  for(int i = n-1; i >= 0; i--){
    Right[i] = gcd(A[i],Right[i+1]);
  }
  z = -INF;
  REP(i,n){
    z = max(z, gcd(Left[i],Right[i+1]));
  }
  OUT(z);
}

Measured memory_bytes: 2560
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
    }
    let mut result = n;
    for i in 1..n {
        if i * i > n {
            break;
        }
        if n % i == 0 {
            let d = n / i + i - 2;
            if d < result {
                result = d;
            }
        }
    }
    println!("{}", result);
}


Measured memory_bytes: 4352
a = input()
if a=="SUN":
    b=7
elif a=="MON":
    b=6
elif a=="TUE":
    b=5
elif a=="WED":
    b=4
elif a=="THU":
    b=3
elif a=="FRI":
    b=2
elif a=="SAT":
    b=1
print(b)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int n;
vector<int> arr;
struct edge {
    int to;
    edge(int to) : to(to) {}
};
vector<edge> G[200009];
ll ans[200009], dist[200009];
int pv[200009];
bool seen[200009];
int seen2[200009];
int cg[2][200009];

void bfs(int s) {
    queue<int> qu;
    qu.push(s);
    seen[s] = true;
    pv[s] = -1;
    while (!qu.empty()) {
        int u = qu.front();
        qu.pop();
        for (auto e : G[u]) {
            if (!seen[e.to]) {
                seen[e.to] = true;
                pv[e.to] = u;
                dist[e.to] = dist[u] + 1;
                qu.push(e.to);
            }
        }
    }
}

vector<ll> lis;
bool dfs(int s) {
    bool flag = false;
    for (auto e : G[s]) {
        if (pv[e.to] == s && !seen2[e.to]) {
            flag = true;
            seen2[e.to] = true;
            ll _pvv;
            int _pvp;
            auto lb = lower_bound(all(lis), arr[e.to]);
            _pvp = lb - lis.begin();

            if (lb == lis.end()) {
                _pvv = -1;
                lis.push_back(arr[e.to]);
            } else {
                _pvv = lis[_pvp];
                lis[_pvp] = arr[e.to];
            }
            ans[e.to] = lis.size();

            dfs(e.to);
            if (_pvv == -1) {
                lis.pop_back();
            } else {
                lis[_pvp] = _pvv;
            }
        }
    }
    return flag;
}

int main() {
    cin >> n;
    arr.resize(n);
    rep(i, n) { scanf("%d", &arr[i]); }
    rep(i, n - 1) {
        int u, v;
        scanf("%d%d", &u, &v);
        u--, v--;
        G[u].push_back(edge(v));
        G[v].push_back(edge(u));
    }
    bfs(0);
    seen2[0] = true;
    lis.push_back(arr[0]);
    dfs(0);
    ans[0] = 1;
    rep(i, n) { printf("%lld\n", ans[i]); }
    return 0;
}

Measured memory_bytes: 40024
using System.Collections.Generic;
using System.Linq;
using System;
class Program
{
    static void Main()
    {
        int width = int.Parse(Console.ReadLine());
        string[] cells = new string[2];
        cells[0] = Console.ReadLine();
        cells[1] = Console.ReadLine();

        List<bool> verticalList = new List<bool>();
        for (int i = 0; i < width; i++)
        {
            if(cells[0][i] == cells[1][i])
            {
                verticalList.Add(true);
            }
            else
            {
                verticalList.Add(false);
                i++;
            }
        }

        int count = verticalList.Count();
        bool isLastVertical = verticalList[0];
        ulong result = 6;
        if (isLastVertical)
            result = 3;
        
        for (int i = 1; i < count; i++)
        {
            if(isLastVertical)
            {
                if(verticalList[i])//v, v
                {
                    result *= 2;
                }
                else//v, h
                {
                    result *= 2;
                }
            }
            else
            {
                if (verticalList[i])//h, v
                {
                    //Do nothing
                }
                else//h, h
                {
                    result *= 3;
                }
            }
            isLastVertical = verticalList[i];
            result %= 1000000007;
        }

        Console.WriteLine(result.ToString());
    }
}

Measured memory_bytes: 11476
#include<bits/stdc++.h>
using namespace std;
#define debug 1

int main(int argc,char **argv) {
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<10;i++) {
		if(n>=i) ans++;
		else {
			cout<<ans<<endl;
			return 0;
		}
	}
	for(int i=100;i<1000;i++) {
		if(n>=i) ans++;
		else {
			cout<<ans<<endl;
			return 0;
		}
	}
	for(int i=10000;i<100000;i++) {
		if(n>=i) ans++;
		else {
			cout<<ans<<endl;
			return 0;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import numpy as np
n, q = map(int, input().split())
s = input()
w = np.zeros(n, dtype=int)

a = 0
for i in range(n):
    if s[i] == "A":
        if a == 0:
            a += 1
    elif s[i] == "C":
        if a:
            w[i-1] = 1
            a -= 1
    else:
        if a:
            a -= 1

ans = np.append(np.zeros(1, dtype=int), np.cumsum(w))
for _ in range(q):
    l, r = map(int, input().split())
    print(ans[r-1] - ans[l-1])


Measured memory_bytes: 16664