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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    map<string, ll> S;

    ll ans = 0;
    REP(i, N){
        string s;
        cin >> s;
        if(S.count(s)){
            S[s]++;
        }
        else{
            S[s]=1;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19180
#include <cstdio>
#include <iostream>
using namespace std;
int main(void)
{
    int a, b;
    scanf("%d%d",&a,&b);
    if(a+b>23){
        printf("%d\n",a+b-24);
    }
    if(a+b<24){
        printf("%d\n",a+b);
    }
    


    
    return 0;
}


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 REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;

#define LINF		((ll)1 << 63 -1)
#define INF 		2000000007
#define MINF		-2000000007
#define MAX 		100005

const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//



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

	cout << (A*N < B ? A*N : B) << endl;



	return 0;
}




Measured memory_bytes: 256
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <locale>

using namespace std;

int main(int argc, char *argv[]) {
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	--a, --b, --c, --d;
	string s;
	cin >> s;
	s += "##";
	if (a > b) {
		swap(a, b);
		swap(c, d);
	}
	bool ok = true;
	for (int i = a; i < c; ++i) {
		if (s[i + 1] == '.') {
			++i;
		} else if (s[i] == '#') {
			ok = false;
		}
	}
	for (int i = b; i < d; ++i) {
		if (s[i + 1] == '.') {
			++i;
		} else if (s[i] == '#') {
			ok = false;
		}
	}
	if (ok && c > d) {
		ok = false;
		for (int i = b - 1; i < d; ++i) {
			if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') {
				ok = true;
				break;
			}
		}
	}
	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);

int N;
vector<pair<int, int>> edge[100001];
ll cost[100001];

void dfs(int n, int p, ll d){
  cost[n] = d;
  REP(i,edge[n].size()){
    if (edge[n][i].first == p)continue;
    dfs(edge[n][i].first, n, d + edge[n][i].second);
  }
}

int main(){
  cin >> N;

  REP(i,N-1){
    int a,b,c;
    cin >> a >> b >> c;
    edge[a].push_back(make_pair(b,c));
    edge[b].push_back(make_pair(a,c));
  }

  REP(i,N+1)cost[i]=-1;

  int Q,K;
  cin >> Q >> K;


  dfs(K,-1,0);

  REP(i,Q){
    int x,y;
    cin >> x >> y;
    cout << cost[x] + cost[y] << endl;
  }


}



Measured memory_bytes: 15232
s=require("fs").readFileSync("/dev/stdin","utf8").split('\n');
[n,k]=s[0].split(' ').map(n=>n|0)
s.shift()
s=s.map(n=>n|0).sort((a,b)=>b-a);
console.log(Math.min(...Array(n-k+1).fill().map((_,i)=>s[i]-s[i+k-1])))


Measured memory_bytes: 29476
import java.io.IOException;
import java.util.NoSuchElementException;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            FastScanner fs = new FastScanner();

            final int a = fs.nextInt();
            final int b = fs.nextInt();
            final int h = fs.nextInt();

            System.out.println((a + b) * h / 2);
        }
    }
}

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: 22356
#include <bits/stdc++.h>

using namespace std;

int main()
{
    char c;
    cin >> c;

    switch (c)
    {
    case 'A':
        cout << 'T' << endl;
        break;
    case 'T':
        cout << 'A' << endl;
        break;
    case 'C':
        cout << 'G' << endl;
        break;
    case 'G':
        cout << 'C' << endl;
        break;
    }

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

n, c = map(int, input().split())
d = [list(map(int, input().split())) for _ in range(c)]

gg = [defaultdict(int) for _ in range(3)]
for i in range(n):
    g = list(map(int, input().split()))
    for j in range(n):
        gg[(i+j)%3][g[j]-1] += 1

ans = max(max(d)) * n**2
for c0 in range(c):
    for c1 in range(c):
        if c1 == c0:
            continue
        for c2 in range(c):
            if c0 == c2 or c1 == c2:
                continue

            tmp_ans = sum([d[i][c0] * gg[0][i] for i in gg[0]]) \
                    + sum([d[i][c1] * gg[1][i]  for i in gg[1]]) \
                    + sum([d[i][c2] * gg[2][i]  for i in gg[2]])
            # print(c0, c1, c2, tmp_ans)
            ans = min(ans, tmp_ans)

print(ans)


Measured memory_bytes: 3440
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from sys import stdin
import math
import copy
# 多分、一定回数うごくと、あとは奇数回動かしたか偶数回動かしたかになる

#for i in range(move_limit):
#    for j in range(length):
#        if rl_list[j] == 'R':
#            now_child_list[j+1] += before_child_list[j]
#            now_child_list[j] -= before_child_list[j]
## 'L'
#        else:
#            now_child_list[j-1] += before_child_list[j]
#            now_child_list[j] -= before_child_list[j]
#    before_child_list = copy.copy(now_child_list)
#
#print(*now_child_list)



rl_list  = stdin.readline().strip()

length = len(rl_list) 

r_child_list = [0] * (length)
l_child_list = [0] * (length)
child_list = [0] * (length)

cnt = 0
for i in range(length):
    if rl_list[i] == 'R':
        cnt +=1
    else :#rl_list == 'L'
        r_child_list[i] += cnt
        cnt = 0
r_child_list[length-1] += cnt
for i in reversed(range(length)):
    if rl_list[i] == 'L':
        cnt += 1
    else :#rl_list == 'R':
        l_child_list[i] += cnt
        cnt = 0
l_child_list[0] += cnt
for i in range(length):
    if r_child_list[i] != 0:
        child_list[i] += math.floor(r_child_list[i] / 2)
        child_list[i-1] += math.ceil(r_child_list[i] / 2)
    if l_child_list[i] != 0:
        child_list[i] += math.floor(l_child_list[i] / 2)
        child_list[i+1] += math.ceil(l_child_list[i] / 2)

print(*child_list)


Measured memory_bytes: 8448
#include <stdio.h>
#include <string.h>
int main(void){
  int i=0,c=0;
  char s[15],a[15];
  scanf("%s",s); 
  scanf("%s",a);
  while(s[i]!='\0'&&a[i]!='\0'){
    if(s[i]==a[i]){
      c++;
    }
    if(c==strlen(s)){
       puts("Yes");
       return 0;
    }
    i++;
  }
  puts("No");
  return 0;
 }

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

class ABSsegtree: # 必要な配列の長さN,単位元ie,関数(2項演算)func,を渡す    
    def __init__(self,N,ie,func):
        self.func=func
        self.getLEN=1 # Length of list
        while self.getLEN<N:
            self.getLEN*=2
        self.getsize=self.getLEN*2 # =len(ST)
        self.getLIN=self.getsize-self.getLEN # internal nodes without ST[0]
        self.ST=[ie]*self.getsize

    def update(self,i,x): # i(0-index)にxをいれる
        i+=self.getLIN
        self.ST[i]=x
        while i>1:
            i//=2
            self.ST[i]=self.func(self.ST[2*i],self.ST[2*i+1])
    
    def get_interval(self,a,b): # [a,b)での最小値を求めたい
        a+=self.getLIN
        b+=self.getLIN
        ret=self.func(self.ST[a],self.ST[b-1])
        while a+1<b: # 階層ごとに見る
            if a%2==1:
                ret=self.func(self.ST[a],ret)
                a+=1
            a//=2
            if b%2==1:
                ret=self.func(self.ST[b-1],ret)
            b//=2
        if a==b:
            pass
        else:
            ret=self.func(ret,self.ST[a])
        return ret

N,Q=map(int,input().split())
ins=ABSsegtree(N,pow(2,31)-1,min)
for _ in range(Q):
    P,X,Y=map(int,input().split())
    if P==0:
        ins.update(X,Y)
    else:
        print(ins.get_interval(X,Y+1))


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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

void f()
{
  ll n,cnt=0;
  cin>>n;
  ll a[n];
  lo(i,0,n)
  cin>>a[i];
  lo(i,1,n)
  {
    if(a[i]<a[i-1])
    {
      cnt+=a[i-1]-a[i];
      a[i]+=a[i-1]-a[i];
    }
  }
    cout<<cnt<<nl;
}

int main()
{
    su;
    ///tt
    f();
    return 0;
}


Measured memory_bytes: 5180
use std::thread;

/// ローカル環境なら _in.txt から入力を受ける
fn read_input() -> String {
    use std::fs::File;
    use std::io::Read;
    let mut s = String::new();
    match option_env!("LOCAL") {
        Some(_) => File::open("src/_in.txt")
            .expect("File not found")
            .read_to_string(&mut s)
            .unwrap(),
        None => std::io::stdin().read_to_string(&mut s).unwrap(),
    };
    s
}

fn main() {
    thread::Builder::new()
        .stack_size(32 * 1024 * 1024) // 32MB
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

fn run() {
    let input = read_input();
    let mut input = input.split_whitespace();
    let x: i32 = input.next().unwrap().parse().unwrap();
    let y: i32 = input.next().unwrap().parse().unwrap();
    if x % y == 0 {
        println!("{:?}", -1);
    } else {
        println!("{:?}", x);
    }
}


Measured memory_bytes: 8572
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, K,L, W, H, P, Q, R, X, Y;
  ll ans;
  string S, T;
  cin >>N;
  ll count = 0;
  while(N>=1){
    ans = 1;
    if (N/10) ans++;
    if (N/100) ans++;
    if (N/1000) ans++;
    if (N/10000) ans++;
    if (N/100000) ans++;
    //cout <<"N: " << N << ", ans: " << ans << endl;
    if (ans%2 != 0) count++;
  	N--;
  }
  
  cout << count << endl;
}


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

int A[10];

int main(){
  
  int N; cin >> N;
  
  vector<int> ord(N,0);
  for(int i = 0; i < N; i++){ A[i] = i+1;}
  for(int i = 0; i < N; i++){ ord[i] = i;}
  
  vector<int> P(N),Q(N);
  
  for(int i = 0; i < N; i++){ 
    cin >> P[i];
  }
  for(int i = 0; i < N; i++){
    cin >> Q[i];
  }
  
  int a,b;
  
  int cnt = 0;
  
  do{
    
    cnt++;
    
    bool p = true,q = true;
    
    for(int i = 0; i < N; i++){ 
      if(A[ord[i]] != P[i] ){ p = false;}
      if(A[ord[i]] != Q[i] ){ q = false;}
      
    }
    
    if(p){ a = cnt;}
    if(q){ b = cnt;}
    
  }while(next_permutation(ord.begin(),ord.end()) );
  
  cout << abs(a-b) << endl;
  
  return 0;
}
  

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int ans = c - (a - b);
    if(ans < 0){
        ans = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long[] arr = new long[5];
        long mi = 1L << 60;
        for(int i = 0; i < 5; i++) {
            arr[i] = sc.nextLong();
            mi = Math.min(mi, arr[i]);
        }
        System.out.println((N+mi-1)/mi + 4);
    }
}

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

void solve()
{
	int n;
	scanf("%d", &n);
	vector<int> v(n);
	map<int,int> m;
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &v[i]);
		m[v[i]]++;
	}
	sort(v.begin(),v.end());
	int cn = 0;
	set<int> s(v.begin(),v.end());
	if(v[0]==1)
	{
		if(m[1]>1)
			printf("0\n");
		else
			printf("1\n");
		return;
	}
	for (int i = 0; i < n; ++i)
	{
		if(m[v[i]]>1)
			continue;
		bool flag = true;
		for(int j = 2; j*j<=v[i]; j++)
		{
			if(v[i]%j==0)
			{
				if(s.find(j)!=s.end())
				{
					flag = false;
					break;
				}
				if(s.find(v[i]/j)!=s.end())
				{
					flag = false ;
					break;
				}
			}
		}
		if(flag)
			cn++;
	}
	printf("%d\n", cn);
}

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

Measured memory_bytes: 22728
#include "bits/stdc++.h"
using namespace std;
int main() {
    long long A, B, C;
    cin >> A >> B >> C;
    long long ans = 0;
    if (A == B && B == C) {
        if (A % 2 == 0) cout << -1 << endl;
        else cout << 0 << endl;
        return 0;
    }
    while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
        long long a = (B + C) / 2, b = (A + C) / 2, c = (A + B) / 2;
        A += a; B += b; C += c;
        ans++;
    }
    cout << ans << endl;
}

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

const int N = 2020, MOD = 1000 * 1000 * 1000 + 7;

int sum(int a, int b) {
	a += b;
	if(a < 0)
		a += MOD;
	else if(a >= MOD)
		a -= MOD;
	return a;
}

void _sum(int &a, int b) {
	a = sum(a, b);
}

int mul(int a, int b) {
	return 1LL * a * b % MOD;
}

int n, m, a[N], b[N], dp[N][N];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= m; i++)
		cin >> b[i];
	for (int i = 0; i < N; i++)
		dp[i][0] = dp[0][i] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++) {
			dp[i][j] = sum(dp[i - 1][j], sum(dp[i][j - 1], -dp[i - 1][j - 1]));
			if(a[i] == b[j])
				_sum(dp[i][j], dp[i - 1][j - 1]);
		}
	cout << dp[n][m];
	return 0;
}

Measured memory_bytes: 16128
def ban():
    from collections import Counter
    n = int(input())
    a = list(map(int, input().split()))
    b = Counter(a)
    total = sum(i*(i - 1)//2 for i in b.values())

    ans = [(total - (b[i] - 1)) for i in a]
    return "\n".join(map(str, ans))

print(ban())

Measured memory_bytes: 39352
'''
研究室PCでの解答
'''
from math import gcd
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7 #998244353
dir = [(-1,0),(1,0),(0,-1),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def Enumeration(x):
    low = []
    high = []
    for i in range(1,x):
        if i**2 >= x:
            if i**2 == x:
                low.append(i)
            break
        if x%i == 0:
            low.append(i)
            high.append(x//i)
    return high+low[::-1]

def main():
    n = int(ipt())
    p = set()
    a = [int(i) for i in ipt().split()]
    if n == 2:
        print(max(a))
        exit()
    ma = 1
    G = gcd(gcd(a[0],a[1]),a[2])
    p.add(gcd(a[0],a[1]))
    p.add(gcd(a[0],a[2]))
    p.add(gcd(a[2],a[1]))

    for i in Enumeration(G):
        nm = 0
        for ai in a[3::]:
            if ai%i != 0:
                nm += 1
                if nm == 2:
                    break
        if nm < 2:
            if ma < i:
                ma = i
            break

    for i in p:
        for j in Enumeration(i):
            f = True
            for ai in a[3::]:
                if ai%j != 0:
                    f = False
                    break
            if f:
                if ma < j:
                    ma = j
                break

    print(ma)




    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 139592
#include <stdio.h>

int main() {
	int a,b,c;
	scanf("%d %d %d", &a, &b, &c);
	if(a == b && b == c) {
		printf("1");
	} else if(a == b || a == c || b == c) {
		printf("2");
	} else {
		printf("3");
	}
	return 0;
}

Measured memory_bytes: 128
# 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 ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    optimize_cin();
    int N, L;
    vector<string> S;
    cin >> N >> L;
    S.resize(N);
    rep (i, N) { cin >> S[i]; }

    std::sort(ALL(S));

    rep (i, N)
    {
        cout << S[i];
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a[4]={0};
  int b[4]={0};
  int i,j;
  while(cin>>a[0]>>a[1]>>a[2]>>a[3]){
    cin>>b[0]>>b[1]>>b[2]>>b[3];
    int h=0,bl=0;
    for(i=0;i<4;i++){
      if(a[i]==b[i]){
	h++;
      }
      for(j=0;j<4;j++){
	if(a[i]==b[j]){
	  bl++;
	}
      }
    }
    bl-=h;
    cout<<h<<" "<<bl<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long
#define MAX 100
using namespace  std;

int g[MAX + 1][MAX + 1];
int n;
int ans = 0;
void calc(int i,int j,int curr)

{
    
    if(i < 0 or j < 0 or i > 1 or j > n-1) return ;
    if(i == 1 && j == n-1)
    {
        ans = max(ans,curr+g[i][j]);
        return ;
    }
    
    
calc(i+1,j,curr+g[i][j]);
calc(i,j+1,curr+g[i][j]);
    

    
    
}

int main() {

cin >> n;

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

calc(0,0,0);
cout << ans;



}

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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(2e6) + 17;

int n;
int a[MAXN];

bool read() {
    if (!(cin >> n))
        return false;

    forn (i, n)
        cin >> a[i];
    
    return true;
}

ll gcd(ll a, ll b) {
    for (; b > 0; a %= b, swap(a, b)) { }
    return a;
}

void solve() {
    sort(a, a + n);
    ll ans = 1;

    forn (i, n)
        ans = ans * gcd(a[i], i) % 998244353;

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif
    
    while (read())
        solve();
    
    return 0;
}



Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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 pla(ll n,ll i)
{
  ll x = pow(3,i + 1),y = pow(3,i);
  return n % x / y;
}

int main() 
{
  ll A,B,C; cin>>A>>B>>C;
  ll K; cin>>K;
  
  if(A<B&&B<C) {cout<<"Yes"<<endl; return 0;}
  
  rep(i,pow(3,K))
  {
    vector<ll> vec={A,B,C};
    rep(j,K)
    {
      vec.at(pla(i,j))*=2;
      if(vec.at(0)<vec.at(1)&&vec.at(1)<vec.at(2)) {cout<<"Yes"<<endl; return 0;}
    }
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 4036
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};

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

/* 
   requirement
   Val : default / copy constructor 
   Upd, Map : Val operator() (Val, Val)
*/
template<class Val, class Upd, class Map>
struct SegTreeLazy {
    int n;
    vector<Val> data, lazy;
    vector<bool> isLazy;
    Upd upd;
    Map mp;
    const Val Id; // 
    explicit SegTreeLazy(int n_, const Val& id_ = Val())
        : upd(Upd()), mp(Map()), Id(id_) { init(n_);}
    void init(int n_) { // 0 init
        for(n = 1; n < n_; n <<= 1);
        data.assign(2 * n - 1, Id);
        lazy.assign(2 * n - 1, Val());
        isLazy.assign(2 * n - 1, false);
    }
    // lazy propagation type 2
    inline void setLazy(int cn, int mul, Val x) {
        isLazy[cn] = true;
        lazy[cn] = upd(lazy[cn], x);
        data[cn] = upd(data[cn], x * mul);
    }
    inline void push(int cn, int cl, int cr) {
        if(isLazy[cn] == false) return;
        int mid = (cl + cr) / 2;
        setLazy(cn * 2 + 1, mid - cl, lazy[cn]);
        setLazy(cn * 2 + 2, cr - mid, lazy[cn]);
        lazy[cn] = Val();
        isLazy[cn] = false;
    }
    // operation : upd [ql, qr) by x
    // current node : cn [cl, cr)
    void updrange(int ql, int qr, const Val& x) {
        updrange(ql, qr, x, 0, 0, n);
        return;
    }
    void updrange(int ql, int qr, const Val& x, int cn, int cl, int cr) {
        if(qr <= cl || cr <= ql) return;
        if(ql <= cl && cr <= qr) {
            setLazy(cn, cr - cl, x);
            return;
        }
        push(cn, cl, cr);
        updrange(ql, qr, x, cn * 2 + 1, cl, (cl + cr) / 2);
        updrange(ql, qr, x, cn * 2 + 2, (cl + cr) / 2, cr);
        data[cn] = mp(data[cn * 2 + 1], data[cn * 2 + 2]);
    }
    Val query(int ql, int qr) {
        return query(ql, qr, 0, 0, n);
    }
    Val query(int ql, int qr, int cn, int cl, int cr) {
        if(qr <= cl || cr <= ql) return Id;
        if(ql <= cl && cr <= qr) return data[cn];
        push(cn, cl, cr);
        Val a = query(ql, qr, cn * 2 + 1, cl, (cl + cr) / 2);
        Val b = query(ql, qr, cn * 2 + 2, (cl + cr) / 2, cr);
        return mp(a, b);
    }
};

template<class T> // requirement : operator +
struct adder {
    T operator ()(const T& a, const T& b) { return a + b;}
};

using i64 = long long;
using SegTree = SegTreeLazy<i64, adder<i64>, adder<i64>>;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    SegTree seg(n);
    for(int _ : in(q)) {
        int p, u, v;
        cin >> p >> u >> v;
        --u;
        if(p) {
            cout << seg.query(u, v) << '\n';
        }
        else {
            i64 x;
            cin >> x;
            seg.updrange(u, v, x);
        }
    }
    return 0;
}

Measured memory_bytes: 7212
ans = []

while true
  args = gets.split(" ").map{|e|e.to_i}
  break if args[0] == -1 && args[1] == -1 && args[2] == -1
  if args[0] == -1 || args[1] == -1
    ans.push "F"
  elsif args[0] + args[1] >= 80
    ans.push "A"
  elsif args[0] + args[1] >= 65
    ans.push "B"
  elsif args[0] + args[1] >=50
    ans.push "C"
  elsif args[0] + args[1] >= 30
    if args[2] >= 50
      ans.push "C"
    else
      ans.push "D"
    end
  elsif args[0] + args[1] < 30
    ans.push "F"
  end
end

ans.each{|e|
  puts e
}

Measured memory_bytes: 8748
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;
typedef long long ll;

int N;
string code[50];
int ans = 0;

void calc(int a, int b) {
	for (int i = 0; i < min(code[a].size(), code[b].size()); i++) {
		if (code[a][i] != code[b][i]) {
			ans = max(ans, i + 1);
			return;
		}
	}
	if (code[a].size() != code[b].size()) {
		int tmp = min(code[a].size(), code[b].size()) + 1;
		ans = max(ans, tmp);
	}else ans = 1000000;
}

int main() {
	while (1) {
		cin >> N;
		if (N == 0)break;
		for (int i = 0; i < N; i++) {
			string name;
			cin >> name;
			code[i] += name[0];
			for (int j = 0; j < name.size() - 1; j++) {
				if (name[j] == 'a' || name[j] == 'i' || name[j] == 'u' || name[j] == 'e' || name[j] == 'o') {
					code[i] += name[j + 1];
				}
			}
		}
		
		//パターンマッチをする
		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				calc(i, j);
			}
		}
		if (ans == 1000000)cout << -1 << endl;
		else cout << ans << endl;
		ans = 0;
		for (int i = 0; i < N; i++)code[i] = "";
	}
	return 0;
}


Measured memory_bytes: 3196
from collections import defaultdict
MOD = 1000000007
N = int(input())
A = list(map(int, input().split()))

ans = 1
d = defaultdict(int)
for a in A:
    if a == 0:
        ans *= 3 - d[a]
        d[a] += 1
        continue
    ans *= d[a - 1] - d[a]
    ans %= MOD
    d[a] += 1
print(ans)

Measured memory_bytes: 62124
#include<stdio.h>
void mincount();
int n,m[100][100],r[100];
main(){
  int c[100],i;
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&r[i],&c[i]);
    if(i == n-1) r[i+1]=c[i];
  }
  mincount();
  printf("%d\n",m[1][n]);
  return 0;
}
void mincount(){
  int q,i,j,k,l;
  for(i = 0 ;  i < n;i++) m[i][i]=0;
  for(l = 2 ; l < n+1 ;l++){
    for(i= 1 ; i < n-l+2 ; i++){
      j = i + l - 1;
      m[i][j]=1000000;
      for(k = i ; k < j ; k++){
    q = m[i][k] + m[k+1][j] + r[i-1] * r[k] * r[j];
    if(m[i][j] > q) m[i][j] = q;
      }
    }
  } 
}



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

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

vector<P> works;
set<int> remains;

ll ans = 0;

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

    int n, m;
    cin >> n >> m;

    for (int i = 0; i <= m; ++i) {
        remains.insert(i);
    }

    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        works.push_back(make_pair(b, a));
    }
    sort(works.begin(), works.end(), greater<P>());

    for (P work : works) {
        set<int>::iterator it = remains.lower_bound(work.second);
        if (it != remains.end()) {
            int d = *it;
            ans += work.first;
            remains.erase(d);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6140
N = int(input())
A = list(map(int,input().split()))
sumA = sum(A)
wa = [0 for _ in range(N)]
wa[0] = A[0]
for i in range(1,N):
    wa[i] = wa[i-1]+A[i]
ans = 10**10
for i in range(N-1):
    x = wa[i]
    y = sumA - wa[i]
    ans = min(ans,abs(x-y))
print(ans)

Measured memory_bytes: 24816
#include<iostream>
#include<string>
#include<cmath>

using namespace std;

int main(){
	
	string in;
	string ls,rs;
	string ans;
	long long li,ri;
	bool f;
	int sdata[8];
	int fdata[4]={5000,2500,1250,625};

	for(int i=0;i<8;i++){
		sdata[i]=pow(2,i);
	}

	while(1){
		cin>>in;
		if(in[0]=='-') break;

		ls="",rs="";
		f=false;
		for(int i=0;i<in.size();i++){
			if(in[i]=='.') f=true;
			else if(f){
				rs+=in[i];
			}
			else{
				ls+=in[i];
			}
		}

		li=0;
		for(int i=0;i<ls.size();i++){
			li+=(ls[ls.size()-1-i]-'0')*pow(10,i);
		}

		ri=0;
		for(int i=0;i<rs.size();i++){
			ri+=(rs[rs.size()-1-i]-'0')*pow(10,i);
		}
		for(int i=0;i<4-rs.size();i++){
			ri*=10;
		}
		ans="";
		for(int i=7;i>=0;i--){
			if(li>=sdata[i]){
				li-=sdata[i];
				ans+="1";
			}
			else ans+="0";
		}
		if(li!=0){
			cout<<"NA"<<endl;
			continue;
		}
		ans+=".";

		for(int i=0;i<4;i++){
			if(ri>=fdata[i]){
				ri-=fdata[i];
				ans+="1";
			}
			else ans+="0";
		}
		if(ri!=0){
			cout<<"NA"<<endl;
			continue;
		}
		cout<<ans<<endl;
	}

}

Measured memory_bytes: 1224
a,b=map(int,input().split())
a1,a2,b1,b2=(a-1)//49,(a-1)%49,(b-1)//49,(b-1)%49
n=6*(max(a1,b1)+1)
print(n,100)
for i in range(n):
  if i%6==0 or i%6==2:
    print("."+"#"*99)
  elif i%6==3 or i%6==5:
    print("."*99+"#")
  elif i%6==1:
    if i//6<a1:
      print(".#"*50)
    elif i//6==a1:
      print(".#"*(a2+1)+"#"*(100-2*(a2+1)))
    else:
      print("."+"#"*99)
  else:
    if i//6<b1:
      print(".#"*50)
    elif i//6==b1:
      print("."*(100-2*(b2+1))+".#"*(b2+1))
    else:
      print("."*99+"#")


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

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;
}

char c;

int main() {
    cin >> c;
    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
int i,j,k,l,n,m;
while(cin>>n){
vector<pair<int,int>> vec;
for(i=0;i<n;i++){
    cin>>j;
vec.push_back(make_pair(j,i));
}
sort(vec.begin(),vec.end());
for(i=0;i<n;i++) {

   cout<<vec[i].second+1<<" ";
}
cout<<endl;
} return 0;
}

Measured memory_bytes: 1780
import scala.io.StdIn.readInt

object Main {
  val r = Array(2,3,5,7)

  def pow(x:Long, y:Long, z:Long):Long = {

    def multi(m:Long, n:Long) = { ( (m%z) * (n%z) ) % z }

    def pow2(m:Long, n:Long, odd:Long, b:Long):Long = {
      n match {
        case 0 => 1
        case 1 => multi(m, odd)
        case _ =>
          pow2(multi(m,m), n/2, (if(n%2==1) multi(odd, b) else odd), multi(b,b))
      }
    }
    pow2(x, y, 1, x)
  }

  def twoPow(d:Int,s:Int):(Int,Int) = {
    if(d%2 == 1) (d,s)
    else twoPow(d>>1,s+1)
  }

  def maybePrime(i:Int,d:Int,s:Int, n:Int):Boolean = {
    if(i>3) true
    else {
      val a = r(i)
      val x = pow(a,d,n)

      if(x==1 || x==n-1) maybePrime(i+1,d,s,n)
      else repeat(s-1,x*x%n, i, d, s, n)
    }
  }

  def repeat(j:Int, x:Long, i:Int, d:Int, s:Int, n:Int):Boolean = {
    if(j==0) false
    else if(x==1) false
    else if(x==n-1) maybePrime(i+1,d,s,n)
    else repeat(j-1,x*x%n,i,d,s,n)
  }

  def isPrime(n:Int):Boolean = {
    if(n<5000) (2 to Math.sqrt(n).toInt).forall(n%_ != 0)
    else if(n%2==0) false
    else {
      val (d,s) = twoPow(n-1,0)
      maybePrime(0,d,s,n)
    }
  }

  def main(args:Array[String]) = {
    val n = readInt
    println((0 until n).count{ _=> isPrime(readInt) })
  }
}

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

class Main{
	public void run(){
		int N = ni();
		int A = ni();
		int B = ni();
		String s = next();
		int k = 0;
		int fs = 1;
		for(int i=0;i<s.length();i++){
			char c = s.charAt(i);
			if(c == 'a'){
				if(k < (A + B)){
					out.println("Yes");
					k++;
				}else{
					out.println("No");
				}
			}else if(c == 'b'){
				if(k < (A + B) && fs <= B){
					out.println("Yes");
					k++;
					fs++;
				}else{
					out.println("No");
				}
			}else if(c == 'c'){
				out.println("No");
			}
		}
	}

	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().run();
		out.flush();
	}

	public Main(){
	}

	int ni(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;	}

	long nl(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}

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

	String next(){
		int c;
		while(!isAlNum(c = read()));
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	String nextLine(){
		int c;
		while(!isAlNumOrSpace(c = read()));
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNumOrSpace(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
	private static boolean isAlNumOrSpace(int c){
		return isAlNum(c) || c == ' ' || c == '\t';
	}
	void debug(Object... os){
		out.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12068
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/

int main() {
    ll N;
    cin>>N;
    vi a(N);
    REP(i,N)cin>>a[i];
    sort(a.begin(),a.end());
    ll ans=-INF;
    REP(i,N){
        ll index=upper_bound(a.begin(),a.end(),a[i]+2)-a.begin();
        ans=max(ans,index-i);
    }
    cout<<ans<<endl;
    return 0;
}

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

}

Measured memory_bytes: 596
def segfunc(x,y):
    return max(x,y)

ide_ele=0


class SegTree():
    # init_valは配列の初期値、self.numはn以上の最小のべき乗 O(N)
    def __init__(self,init_val,segfunc,ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n-1).bit_length()
        # self.treeは0～2n-2の配列を使う
        self.tree = [ide_ele] * 2 * self.num
        for i in range(n):
            self.tree[self.num + i - 1] = init_val[i]

        for i in range(self.num-2,-1,-1):
            self.tree[i]=self.segfunc(self.tree[2*i+1],self.tree[2*i+2])

    # k番目をxに更新 O(logN)
    def update(self,k,x):
        k += self.num - 1
        self.tree[k]=x
        while k:
            k=(k-1)//2
            self.tree[k]=self.segfunc(self.tree[2*k+1],self.tree[2*k+2])

    # 区間[l,r)でsegfuncした結果を返す O(logN)
    def query(self,l,r):
        res = self.ide_ele

        l += self.num-1
        r += self.num-2
        while r>=l:
            if l & 1 == 0:
                res = self.segfunc(res,self.tree[l])
            if r & 1 == 1:
                res = self.segfunc(res,self.tree[r])
                r -= 1
            l = l // 2
            r = (r-1) // 2
        return res


N,K=map(int,input().split())
li=[int(input()) for i in range(N)]
ma=max(li)
dp=[0 for _ in range(ma+1)]

seg=SegTree(dp,segfunc,ide_ele)

for i in li:
    l=max(0,i-K)
    r=min(ma+1,i+K+1)
    x=seg.query(l,r)+1
    seg.update(i,x)

print(seg.query(0,ma+1))


Measured memory_bytes: 137612
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  vector<int> v;
  v.push_back(a);
  v.push_back(b);
  v.push_back(c);
  sort(v.begin(), v.end());
  if(v[1] == c) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val n  = in.nextInt
  val r  = List.fill(n)(in.next -> in.nextInt)

  r.zipWithIndex
    .sortWith(
      (x, y) =>
        if (x._1._1 == y._1._1) {
          x._1._2 >= y._1._2
        } else if (x._1._1 <= y._1._1) {
          true
        } else {
          false
        }
    )
    .map(_._2 + 1)
    .foreach(println)
}


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

using namespace std;

typedef long long ll;

const int N = 55,M = 55;

struct stu{
	int a,b;
}ss[N];

struct cp{
	int c,d;
}cps[M];

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
	int n,m;
	cin >> n >> m;
	for(int i=0;i<n;i++) cin >> ss[i].a >> ss[i].b;
	for(int i=0;i<m;i++) cin >> cps[i].c >> cps[i].d;
	
	for(int i=0;i<n;i++){
		ll dis = INT_MAX,token = INT_MAX,now;
		for(int j=0;j<m;j++){
			now = abs(ss[i].a-cps[j].c) + abs(ss[i].b-cps[j].d);
			if(now<dis) {
				dis = now;
				token = j+1;
			}
		}
		cout << token << "\n";
	}
    
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)

using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

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

    int ans = 0;
    for (int i = 1; i < n-1; i++) {
        if ((v[i] > v[i-1] && v[i] < v[i+1]) || (v[i] < v[i-1] && v[i] > v[i+1])) {
            ans++;
        }
    }

    cout << ans <<endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
using namespace std;
int a[15][15];
int main()
{
    int n, d;
    cin >> n >> d;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            cin >> a[i][j];
        }
    }
    double tmp = 0;
    int cnt = 0;
    for(int i = 0; i < n-1; i++){
        for(int j = i+1; j < n; j++){
            tmp = 0;
            for(int k = 0; k < d; k++){
                tmp += pow(abs(a[i][k] - a[j][k]), 2);
            }
            tmp = sqrt(tmp);
            if(tmp == (int)tmp){
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

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

#define MOD 100000

int poww(int n, int p){
int r = 1;
while(p){
if(p%2==1)
    r=(1LL*r*n)%MOD;
    n=(1LL*n*n)%MOD;
    p/=2;
    }
return r;
}

#define pow poww

main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
/*char s[5];
cin>>s;
if ((s[0]==s[2] && s[1]==s[3]) || (s[0]==s[1] && s[2]==s[3]) || (s[0]==s[3] && s[1]==s[2])) cout<<"Yes";
   else cout<<"No";
int n,a[21];
cin>>n;
for (int i=1;i<=n;i++)
    cin>>a[i];
int ans=0;
for (int i=2;i<n;i++)

    if ((a[i]>a[i-1] && a[i]<a[i+1]) || (a[i]<a[i-1] && a[i]>a[i+1])) ans++;
cout<<ans;*/
int n;
cin>>n;
int a[100001];
for (int i=1;i<=n;i++){
    cin>>a[i];
    }
sort(a+1,a+n+1);
cout<<a[n/2+1]-a[n/2];
}


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

int main(){
	long long N,W=0,R=0;
	cin>>N;
	string c;
	cin>>c;
	string p;

	for(int i=0;i<N;i++){
		if(c[i]=='R'){
			R++;
		}else{W++;}
	}
	for(int i=0;i<R;i++){
		p.push_back('R');
	}for(int i=R;i<R+W;i++){
		p.push_back('W');
	}
	long long counter=0,M=c.size();
	long datap[c.size()],datac[c.size()];
	for(int i=0;i<M;i++){
		datac[i]=c[i];
		datap[i]=p[i];
		if(datac[i]!=datap[i]){counter++;}
	}
	cout<<counter/2<<endl;
	return 0;
}

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

int main() {
    int a, b; cin >> a >> b;

    if(a>=13) cout << b << endl;
    else if(a>=6) cout << b/2 << endl;
    else cout << 0 << endl;
}


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

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

#define ISIN(x, y) ((x) >= 0 && (x) < (w) && (y) >= 0 && (y) < (h))

int main(void)
{
	char s[100][100];
	char f[100][100];
	int w, h;
	int px, py;
	int count, ago;
	
	while (1){
		scanf("%d%d", &w, &h);
		if (w == 0){
			break;
		}
		for (int y = 0; y < h; y++){
			scanf("%s", s[y]);
			for (int x = 0; x < w; x++){
				if (s[y][x] == '@'){
					px = x;
					py = y;
				}
			}
		}
		
		ago = count = 1;
		memset(f, 0, sizeof(f));
		f[py][px] = 1;
		do {
			ago = count;
			for (int y = 0; y < h; y++){
				for (int x = 0; x < w; x++){
					if (f[y][x] == 1){
						for (int i = 0; i < 4; i++){
							if (s[y + dy[i]][x + dx[i]] != '#' && f[y + dy[i]][x + dx[i]] == 0 && ISIN(x + dx[i], y + dy[i])){
								f[y + dy[i]][x + dx[i]] = 1;
								count++;
							}
						}
					}
				}
			}
		} while (ago != count);
		
		printf("%d\n", count);
	}
	
	return (0);
}

Measured memory_bytes: 1052