akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        
		
        while(true){
            int x = sc.nextInt();
            int y = sc.nextInt();
            
                if(x<y){
                    System.out.println(x+" "+y);
                }else if(x==0 && y==0){
                    break;
                }else{
                    System.out.println(y+" "+x);
                }
            

                
            
        }
		

	}
}


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

int main() {
  // KEYENCE String
  string s; cin >> s;
  string ans = "NO", t="keyence";
  int c = 0, sn = s.size(), tn = t.size();
  int r = 0;
  int l = tn-1;

  rep(i,sn) {
    if (s[i] == t[r]) {
      r++;
      c++;
    }
    else break;
  }

  for (int i = sn-1; i>r; i--) {
    if (s[i] == t[l]) {
      l--;
      c++;
    }
    else break;
  }

  if (c==7) ans = "YES";
  cout << ans << endl;
  return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

ll sum = 0;

int main() {
    int N;
    cin >> N;
    vector<int> a(N+1, 0);
    rep(i, N) cin >> a[i+1];
    a.push_back(0);
    N += 2;
    rep(i, N-1) {
        sum += abs(a[i]-a[i+1]);
    }
    for (int i=1; i<N-1; ++i) {
        cout << sum-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]) << endl;
    }
    return 0;
}


Measured memory_bytes: 1656
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
using namespace std;

int INF = 1e9 + 7;

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

vector<int> a(200010), sum(200010), x(200010);

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sum[i] = sum[i - 1] + a[i];
		x[i] = x[i - 1] ^ a[i];
	}

	ll ans = 0, l = 1, r = 1;
	while (l <= n) {
		while (r <= n && (x[r] ^ x[l - 1]) == sum[r] - sum[l - 1]) r++;
		ans += r - l;
		l++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll h, w, a, b;

const int MAX = 200008;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	cin >> h >> w >> a >> b;
	
	COMinit();
	
	ll ans = 0;
	for(ll j = b+1;  j <= w; j++){
		ans += COM(h-a+j-2, j-1)*COM(a+w-j+1-2, a-1);
		ans %= MOD;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
using System;
using System.Linq;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        Console.ReadLine();
        int[] i = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        //被りの振り分け
        Array.Sort(i);
        List<int> j = new List<int>();
        List<int> k = new List<int>();
        j.Add(0);
        k.Add(0);
        for (int a = 0; a < i.Length; a++)
        {
            if (a % 2 == 0)
            {
                j.Add(i[a]);
            }
            else
            {
                k.Add(i[a]);
            }
        }
        int minvalue = 24 - (j.Last() + k.Last());
        for (int a = 0; a < j.Count - 1; a++)
        {
            minvalue = Math.Min(minvalue,Math.Abs(j[a] - j[a + 1]));
        }
        for (int a = 0; a < k.Count - 1; a++)
        {
            minvalue = Math.Min(minvalue, Math.Abs(k[a] - k[a + 1]));
        }
        Console.WriteLine(minvalue);
    }
}

Measured memory_bytes: 13268
require 'pp'

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

def min(a, b)
  return a < b ? a : b
end

N, K = gets_i_list
h_list = gets_i_list

INF = Float::INFINITY
dp = Array.new(N, INF)
dp[0] = 0

(N - 1).times do |i|
  n_min = INF
  
  k = i + 1 - K
  k = 0 if k < 0
  k.upto(i) do |j|
    n = (h_list[i + 1] - h_list[j]).abs + dp[j]
    n_min = min(n_min, n)
  end
  dp[i + 1] = n_min
end
puts dp.last

Measured memory_bytes: 9724
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include<set>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define DIVCEIL(a,b) ((a+b-1)/b)
//int CHMAX

int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return  a * b / GCD(a, b);
}
//int NUMOFDIV(int n) 素因数分解して+1してかける奴
int NUMOFDIV2(int n) {
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
int CEIL1(int n) {
	return (n + 9) / 10 * 10;
}
int DIGITSUM(int n) {
	int sum = 0, dig;
	while (n) {
		dig = n % 10;
		sum += dig;
		n /= 10;
	}
	return sum;
}
int DIVTIME(int n, int k) {
	int div = 0;
	while (n % k == 0) {
		div++;
		n /= k;
	}
	return div;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR(int x) {
	if (x == 1)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
bool SQRTOR(int n) {
	if (sqrt(n) == (int)sqrt(n))
		return true;
	else
		return false;
}
// 順位付け
using namespace std;
#pragma endregion
signed main() {
	int N, sum = 0;
	cin >> N;
	vector <int> A(N), B(N), C(N - 1);
	rep(i, N)
		cin >> A[i];
	rep(i, N)
		cin >> B[i];
	rep(i, N - 1)
		cin >> C[i];
	sum += B[A[0]-1];
	REP(i, N - 1) {
		sum += B[A[i]-1];
		if (A[i] - A[i-1] == 1)
			sum += C[A[i - 1]-1];
	}
	cout << sum;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

#define ll long long
#define LINF LLONG_MAX

using namespace std;

int main() {
  ll N;
  cin >> N;
  vector<vector<ll>> count(10, vector<ll>(10, 0));
  for (int i = 1; i <= N; i++) {
    string s = to_string(i);
    count[s[0] - '0'][s[s.size() - 1] - '0']++;
    // count[s[s.size() - 1] - '0'][s[0] - '0']++;
  }

  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    string s = to_string(i);
    ans += count[s[s.size() - 1] - '0'][s[0] - '0'];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $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, usize1) => {
        read_value!($next, usize) - 1
    };

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize
    }
    if n % 2 == 1 {
        println!("0");
        return;
    }
    let mut ans = 0;
    let mut m = n;
    while m > 0 {
        m /= 5;
        ans += m / 2;
    }
    println!("{}", ans);
}


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

const string day[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

int main(){
    string s;
    int count = 0;
    cin >> s;
    for(int i = 0; i < 7; i++ ){
        if(s == day[i]){
            count = 0;
        }
        count++;
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	public static void main(String[] args) {
		int N=sc.nextInt()	;
		
		int a[]=new int[N];
		
		int a4=0;
		int a2=0;
		
		for(int i=0;i<N;i++) {
			a[i]=sc.nextInt();
			if(a[i]%4==0)a4++;
			else if(a[i]%2==0)a2++;
		}
		
		if(a4*2+1>=N)p("Yes");
		else if(2*a4+a2>=N)p("Yes");
		else p("No");
		
		
		
		
		
	}
	
	
	
	
	/*static boolean v(int i,long sum1,long sum2) {
		if(i==N) {
			long b=Math.abs(sum1-sum2);
			if(b==0) {
				if(sum1<=K) {
					return true;
				}else return false;
			}else if(b%D==0) {
				if(Math.max(sum1, sum2)<=K)return true;
				else return false;
			}
			else return false;
		}
		
		if(v(i+1,sum1,sum2+v[i]%D))return true;
		
		if(v(i+1,sum1+D-v[i]%D,sum2))return true;
		return false;
		
	}*/
	
	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 49976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int A, P;
    cin >> A >> P;
    cout << (A * 3 + P) / 2 << endl;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n, k;
    cin >> n >> k;
    vector<LL> sum(n + 1);
    sum[0] = 0;
    for(int i = 1; i <= n; ++i) {
        cin >> sum[i];
        sum[i] += sum[i - 1];
        sum[i] %= k;

    }

    map<LL, LL> mp;
    queue<LL> q;
    LL res = 0;
    for(int i = 0; i <= n; ++i) {
        LL t = (sum[i] - i) % k;
        if(t < 0) t += k;

        res += mp[t];
        mp[t]++;
        q.push(t);
        if(q.size() >= k) {
            mp[q.front()]--;
            q.pop();

        }
    }
    cout << res << endl;
    return 0;
}



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

using namespace std;

#define ll long long

ll a[200001], b[200001];

 int main()
{
    ll i, j, n, m, hi, lo, mid, no=0, c;



    scanf("%lld", &n);

    for(i=0; i<n; i++) scanf("%lld", &a[i]);

    scanf("%lld", &m);

    for(i=0; i<m; i++) scanf("%lld", &b[i]);

    sort(a, a+n);

    sort(b, b+m);

    for(i=0; i<m; i++)
    {
        if(binary_search(a, a+n, b[i])==0)
        {
        no=1;
        break;
        }

    }
    if(no==1) printf("0\n");
    else printf("1\n");


    return 0;

}


Measured memory_bytes: 6348
N, K = map(int, input().split())
import numpy as np
A = np.array(input().split(), dtype=int)
I = np.arange(0, N)
for i in range(K):
  X = np.zeros(N + 1, int)
  np.add.at(X, np.maximum(0, I - A), 1)
  np.add.at(X, np.minimum(N, I + A + 1), -1)
  A = X.cumsum()[:-1]
  if np.all(A == N):
    break
print(*A)

Measured memory_bytes: 50136
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	s := ""
	for N > 0 {
		N--
		s = string(byte('a'+N%26)) + s
		N /= 26
	}
	fmt.Println(s)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


Measured memory_bytes: 1844
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

 
void solve()
{
    int n;cin>>n;
    int num1,val1=0,num2,val2;
    REP(i,n)
    {
        int a;cin>>a;
        if(a>val1){val2=val1;num2=num1;val1=a;num1=i;}
        else if(a>val2){val2=a;num2=i;}
        
    }
    REP(i,n)
    {
        if(i==num1&&val2!=0)cout<<val2<<endl;
        else cout<<val1<<endl;
    }
}

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

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a){
    long long ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
int main(){
    ll n,count=0;cin >> n ;
    string s;cin >> s;
    rep(i,n-1){
        if(s[i+1]=='E')count++;
    }
    ll ans=count;
    rep(i,n-1){
        if(s[i]=='W')count++;
        if(s[i+1]=='E')count--;
        ans = min(ans,count);
    }
    cout << ans << endl;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define INF LONG_LONG_MAX
#define MOD 1000000007
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;

string s,t,u;
int a,b;

signed main() {
    cin >> s >> t >> a >> b >> u;
    if (u == s) cout << --a << " " << b << endl;
    else cout << a << " " << --b << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cassert>

using namespace std;

typedef long long Long;

Long N; int K;

bool input() {
    cin >> N >> K;
    return N != 0 || K != 0;
}

template<class T>
string to_s(T x) {
    ostringstream os;
    os << x;
    return os.str();
}

Long C(int x) {
    Long ret = 0;
    int c = int(to_s(x).size());
    for (int i = 1; i < c; i++) {
        ret += i * pow(10, i - 1) * 9;
    }
    ret += c * (x - pow(10, c - 1) + 1);
    return ret;
}

void solve() {
    Long lb = 0, ub = Long(1e9 + 1);
    while (lb + 1 < ub) {
        Long mid = (lb + ub) / 2;
        (C(mid) < N ? lb : ub) = mid;
    }
    Long i = ub;
    string s = "";
    while (Long(s.size()) <= K + 200) {
        s += to_s(i++);
    }
    cout << s.substr(N - 1 - C(ub - 1), K) << endl;
}

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

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

using namespace std;

const int N = 2017;

char s[N][N];
int a[N][N], n, m;

int p[N * N];
int find(int x) {
  return p[x] < 0 ? x : p[x] = find(p[x]);
}

int merge(int x, int y) {
  if ((x = find(x)) == (y = find(y)))
    return -p[x];
  if (-p[x] < -p[y])
    swap(x, y);
  p[x] += p[y];
  p[y] = x;
  return -p[x];
}

int enc(int x, int y) {
  return x * m + y;
}

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++)
    scanf("%s", s[i]);
  for (int i = 0; i < n; i++)
    a[i][0] = i+1;

  vector<pair<int, pair<int, int > > > val;
  for (int j = 1; j < m; j++) {
    int same = -1, change = -1;
    for (int i = 0; i < n; i++) {
      if (s[i][j] == s[i][j-1])
        change = i;
      else
        same = i;
      a[i][j] = i - min(same, change);
      val.push_back({a[i][j], {i, j}});
    }
  }
  sort(val.begin(), val.end());
  int ans = max(n, m);
  int cur = ans;
  memset(p, -1, sizeof p);
  for (int i = val.size() - 1; i >= 0; i--) {
    ans = max(ans, val[i].first * merge(enc(val[i].second.first, val[i].second.second), enc(val[i].second.first, val[i].second.second-1))); 
  }
  printf("%d\n", ans);
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n, a[200001], b[200001];
  cin >> n;
  rep(i, 0, n) cin >> a[i] >> b[i];
  int ans = 0;
  int mn = 1145141919;
  int f = 0;
  rep(i, 0, n) {
    if(a[i] != b[i]) f = 1;
    if(a[i] > b[i]) mn = min(mn, b[i]);
    ans += a[i];
  }
  if(!f) {
    cout << 0 << endl;
    return 0;
  }
  cout << ans - mn << endl;
}


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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N;
  cin >> N;

  map<int,int> odd,even;
  odd[0] = 0;
  even[0] = 0;

  for(int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    if(i %2 == 0){
      if(odd.count(tmp) == 0){
        odd[tmp] = 1;
      } else {
        odd[tmp] += 1;
      }
    } else { 
      if(even.count(tmp) == 0){
        even[tmp] = 1;
      } else {
        even[tmp] += 1;
      }
    }
  }
  // odd と evenの頻度1位と2位を取り出す
  vector<pair<int,int>> v_odd;
  for(auto x: odd){
    v_odd.push_back(make_pair(x.second, x.first));
  }

  sort(v_odd.rbegin(), v_odd.rend());

  vector<pair<int,int>> v_even;
  for(auto x: even){
    v_even.push_back(make_pair(x.second, x.first));
  }
  sort(v_even.rbegin(), v_even.rend());
//  cerr << v_odd[0].first << " " << v_odd[0].second << endl;
//  cerr << v_odd[1].first << " " << v_odd[1].second << endl;
//  cerr << v_even[0].first << " " << v_even[0].second << endl;
//  cerr << v_even[1].first << " " << v_even[1].second << endl;

  int ans = 0;
  if(v_odd[0].second != v_even[0].second){
    ans += (N/2) - v_odd[0].first;
    ans += (N/2) - v_even[0].first;
  } else {
    int tmpans1 = 0;
    if(v_odd[1].first >= v_even[1].first){
      // oddを2番目にする
      ans += (N/2) - v_odd[1].first;
      ans += (N/2) - v_even[0].first;
    } else {
      ans += (N/2) - v_odd[0].first;
      ans += (N/2) - v_even[1].first;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 6136
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  string n; rd(n);
  
  if(n[0]=='9' || n[1]=='9') writeln("Yes");
  else writeln("No");

}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.buffer.readline

h,w = map(int,input().split())
cx,cy = map(int,input().split())
dx,dy = map(int,input().split())
cx -= 1
cy -= 1
dx -= 1
dy -= 1

c = cx*w + cy
d = dx*w + dy


s = []
for i in range(h):
    s.append(list(input()))

a = [10**6]*(h*w)
a[c] = 0

tank = deque([c])
used = [False]*(h*w)

while tank:
    now = tank.popleft()
    if used[now]:
        continue
    used[now] = True

    x,y = divmod(now,w)

    cost = a[now]

    for i in range(-2,3):
        for j in range(-2,3):
            if i == 0 and j == 0:
                continue
            if (0 <= x+i < h) and (0 <= y+j < w) and (not used[(x+i)*w + y+j]) and s[x+i][y+j] == 46:
                if (i == 0 and (j == 1 or j == -1)) or (j == 0 and (i == 1 or i == -1)):
                    tank.appendleft((x+i)*w + y+j)
                    a[(x+i)*w + y+j] = min(a[(x+i)*w + y+j],cost)
                else:
                    tank.append((x+i)*w + y+j)
                    a[(x+i)*w + y+j] = min(a[(x+i)*w + y+j],cost + 1)

if a[d] == 10**6:
    print(-1)
else:
    print(a[d])

Measured memory_bytes: 127648
#include <stdio.h>
int main(){
  int A[100];
  int i,j,len,sw,c=0;

  scanf("%d",&len);
  for(i=0;i<len;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<len;i++){
    for(j=len-1;i<j;j--){
      if(A[j]<A[j-1]){
	sw=A[j];
	A[j]=A[j-1];
	A[j-1]=sw;
	c++;
      }
    }
    
  }
  for(i=0;i<len;i++){
    printf("%d",A[i]);
    if(i==len-1) printf("\n");
    else printf(" ");
  }
  printf("%d\n",c);

  return 0;
}

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

int main(){
  int t;
  cin >> t;
  
  vector<int> vec(4);
  vec.at(3) = t / 1000;
  vec.at(2) = (t - vec.at(3)*1000) / 100;
  vec.at(1) = (t - vec.at(3)*1000 - vec.at(2)*100) / 10;
  vec.at(0) = t - vec.at(3)*1000 - vec.at(2)*100 - vec.at(1)*10;
  
  vector<char> op(3);
  
  for(int i=0; i<(1 << 3); i++){
    int sum = vec.at(3);
    bitset<3> o(i);
    for(int j=2; j>=0; j--){
      if(o.test(j)){
        sum += vec.at(j);
        op.at(j) = '+';
      }else{
        sum -= vec.at(j);
        op.at(j) = '-';
      }
    }
    if(sum == 7){
      cout << vec.at(3);
      for(int k=2; k>=0; k--){
        cout << op.at(k) << vec.at(k);
      }
      cout << '=' << sum << endl;
      break;
    }
  }
}

Measured memory_bytes: 3536
l = int(input())
n = l.bit_length()
edge = list()
for i in range(1,n):
  edge.append((i,i+1,0))
  edge.append((i,i+1,1<<(i-1)))
t = l - (1<<(n-1))
cnt = (n-1)*2
while t:
  m = t.bit_length()
  edge.append((m,n,l-t))
  t -= (1<<m-1)
  cnt += 1
print(n,cnt)
for t in edge:
  print(*t)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long X = sc.nextLong();
        long a = 100;
        
        for(long i = 0; i < X;i++){
            a += a/100;
            if(a >= X){
                System.out.print(i + 1);
                i = X;
            }
        }
    
    }
}

Measured memory_bytes: 27024
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans = 0;
		for(int i = A; i <= B; i++) {
			if(i / 10000 == i % 10 && (i % 10000) / 1000 == (i % 100) / 10) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  for(int i=0;i<k;++i){
    int a,b;
    cin >> a >> b;
    if(a > (n+1)/2) a = n-a+1;
    if(b > (n+1)/2) b = n-b+1;
    int c = min(a,b)-1;
    c %= 3;
    cout << c+1 << endl;
  }
}


Measured memory_bytes: 3088
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, K: int, l: "List[int]"):
    l.sort(reverse=True)
    print(sum(l[:K]))

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    l = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, l)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
from itertools import product
s = input()
l = len(s)
ans = 0
pat = list(product(['+', ''], repeat=l-1))
for i in range(2**(l-1)):
    fom = s[0]
    for j, k in zip(pat[i], s[1:]):
        fom += (j + k)
    ans += eval(fom)
print(ans)

Measured memory_bytes: 3064
*S, = input()

flag_x = False
flag_y = False

if 'S' in S and 'N' in S:
    flag_y = True
if 'S' not in S and 'N' not in S:
    flag_y = True

if 'E' in S and 'W' in S:
    flag_x = True
if 'E' not in S and 'W' not in S:
    flag_x = True

if flag_x and flag_y:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9132
#include<stdio.h>
main(){
int w,h,i,j,z;
for(;scanf("%d%d",&h,&w);){
if (h == 0 && w==0) break;
for(i=0;i<h;i++){
if (i==0|| i==(h-1))
for(j=0;j<w;j++)
printf("#");
else{
printf("#");
for(j=1;j<(w-1);j++)
printf(".");
printf("#");}
printf("\n");}
printf("\n");}
return 0; 
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
int v[510][510];
vector<vi> ans;
void solve() {
	ans.reserve(500010);
	var(int, h, w);
	rep(i, 1, h + 1) {
		rep(j, 1, w + 1) {
			cin >> v[i][j];
		}
	}
	rep(i, 1, h) {
		rep(j, 1, w + 1) {
			if (v[i][j] & 1) {
				ans.eb(vi{i, j, i + 1, j});
				++v[i + 1][j];
			}
		}
	}
	rep(j, 1, w) {
		if (v[h][j] & 1) {
			ans.eb(vi{h, j, h, j + 1});
			++v[h][j + 1];
		}
	}
	print(len(ans));
	each(a, ans) {
		print(a[0], a[1], a[2], a[3]);
	}
}
int main() {
	solve();
	return 0;
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  do {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
  } while (false);
  int n;
  cin >> n;
  int add = n & 1 ? 0 : 1;
  n += add;
  vector<int> pri;
  for (int i = 2; pri.size() <= n * 2; i++) {
    auto is_prime = [&] (int p) {
      for (int x = 2; x * x <= p; x++) {
        if (!(p % x)) {
          return false;
        }
      }
      return true;
    };
    if (is_prime(i)) {
      pri.push_back(i);
    }
  }
  vector<vector<ll> > ans(n, vector<ll>(n, 1));
  for (int i = 0; i <= n * 2; i += 2) {
    for (int j = -n / 2 * 2; j <= n / 2 * 2; j += 2) {
      int x = (i + j) / 2, y = (i - j) / 2;
      if ((i + j & 1) || x < 0 || x >= n || y < 0 || y >= n || (x + y & 1)) {
        continue;
      }
      ans[x][y] = pri[i / 2] * pri[(j + n / 2 * 2) / 2 + n];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i + j & 1) {
        std::vector<int> dx = {1, -1, 0, 0}, dy = {0, 0, 1, -1};
        for (int k = 0; k < 4; k++) {
          int x = i + dx[k], y = j + dy[k];
          if (x < 0 || x >= n || y < 0 || y >= n) {
            continue;
          }
          ans[i][j] = ans[i][j] / __gcd(ans[i][j], ans[x][y]) * ans[x][y];
        }
        ans[i][j]++;
      }
    }
  }
  n -= add;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

typedef string::const_iterator state;

string cipher(state& begin);
string str(state& begin);
string letter(state& begin);

string cipher(state& begin){
    string res;
    while(*begin=='+' or *begin=='-' or ('A'<=*begin and *begin<='Z') or *begin=='?' or *begin=='[') res+=str(begin);
    return res;
}

string str(state& begin){
    string res;
    if(*begin=='['){
        ++begin;
        res=cipher(begin);
        ++begin;
        reverse(res.begin(),res.end());
    }else res=letter(begin);
    return res;
}

string letter(state& begin){
    int x=0;
    string res;
    while(true){
        if(*begin=='+'){
            ++x;
            ++begin;
        }else if(*begin=='-'){
            --x;
            ++begin;
        }else if(*begin=='?'){
            res='A';
            ++begin;
            break;
        }else{
            res='A'+(*begin-'A'+x+26*100)%26;
            ++begin;
            break;
        }
    }
    return res;
}

void solve(){
    while(true){
        string s;
        cin >> s;
        if(s==".") break;
        state begin=s.begin();
        cout << cipher(begin) << endl;
    }
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 3088
a, b, k = map(int,input().split())
if 2*k > b - a + 1:
    for n in range(a, b+1):
        print(n)
    exit()
for n in range(a, a+k):
    print(n)
for n in range(b-k+1, b+1):
    print(n)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int n, k, d;
  cin >> n >> k;
  int a[n] = {};
  REP(i, k) {
    cin >> d;
    REP(j, d) {
      int tmp;
      cin >> tmp;
      a[tmp - 1]++;
    }
  }
  int cnt = 0;

  REP(i, n) {
    if(a[i] == 0) cnt++;
  }

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


Measured memory_bytes: 3624
import java.util.*;
import static java.lang.System.*;

class Guidebook implements Comparable<Guidebook>{
  public String city;
  public int score;
  public int number;
  
  public int compareTo(Guidebook obj){
    if(this.city.equals(obj.city)){
      return obj.score - this.score;
    }else{
      return this.city.compareTo(obj.city);
    }
  }
}

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    Scanner sc = new Scanner(in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int s[] = new int[N];
    for(int i=0; i<M; i++){
      int k = sc.nextInt();
      for(int j=0; j<k; j++){
        int a = sc.nextInt();
        s[a-1] |= 1 << i;
      }
    }
    int p = 0;
    for(int i=0; i<M; i++){
      int x = sc.nextInt();
      p |= x << i;
    }
    int ans = 0;
    for(int i=0; i<(1<<N); i++){
      int t = 0;
      for(int j=0; j<N; j++){
        if((i>>j & 1) == 1) t ^= s[j];
      }
      if(t == p) ans++;
    }
    out.println(ans);
      
  }

  public static int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}



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

int main() {
    string s; cin >> s;
    if(s.at(2) == s.at(3) && s.at(4) == s.at(5))
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int  main(void){
int aa,bb,cc,x,y,z;
string a;
string b;
string c;
cin>>a>>b>>c;
 aa=a.size();
 bb=b.size();
 cc=c.size();

if(a[aa-1]==b[0]&&b[bb-1]==c[0])
cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
list0, list1, list2 = [],[],[]
j = 1

if K % 2 == 1:
  i = K * 1
  while i <= N:
    list0.append(int(i))
    j += 1
    i = K * j
  ans = len(list0) ** 3
else:
  i = K / 2
  while i <= N:
    if j % 2 == 0:
      list1.append(int(i))
    if j % 2 == 1:
      list2.append(int(i))
    j += 1
    i = K * j / 2
  ans = len(list1) ** 3 + len(list2) ** 3
print(ans)

Measured memory_bytes: 11032
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, 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 ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  ll L, R; cin >> L >> R;
  ll ans = INF;
  for (ll i = L; i <= R; ++i){
    for (ll j = i + 1; j <= R; ++j){
      ans = min(ans, (i * j) % 2019);
      if (ans == 0) {cout << ans << endl; return 0;}
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

//container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQUE(a)  (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//debug
#define dump(x)  cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";

// i love camel

/// flow
const int _V = 200; // _N
VI G[_V];
int match[_V];
bool used[_V];

void addEdge(int from, int to){
	G[from].push_back(to);
	G[to].push_back(from); // rev
}

bool dfs(int v){
	used[v] = true;
	REP(i, G[v].size()){
		int u = G[v][i], w = match[u];
		if(w < 0 || !used[w] && dfs(w)){
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

int bipartiteMatching(int V){
	int res=0;
	memset(match, -1, sizeof match);
	REP(v, V){
		if(match[v]<0){
			memset(used, 0, sizeof used);
			if(dfs(v)){
				res++;
			}
		}
	}
	return res;
}

///

bool isPrime(int x){
	if(x==1)return false;
	for(int i=2;i*i<=x;i++){
		if(x%i==0)return false;
	}
	return true;
}

VI diff_odd, diff_even;
int main() {
	int n;
	cin >> n;
	int last=-1;
#define ADD(a) ((a)%2 ? diff_odd : diff_even).push_back(a)
	REP(i, n){
		int x;
		cin >> x;
		if(x!=last+1){ // not 隣接
			if(last>0)ADD(last);
			ADD(x-1);
		}
		last = x;
	}
	ADD(last);
	REP(i, diff_odd.size()){
		REP(j, diff_even.size()){
			int o = diff_odd[i], e = diff_even[j];
			if(isPrime(abs(o-e)))addEdge(i, j + diff_odd.size());
		}
	}
	int ans, k = ans = bipartiteMatching(diff_odd.size() + diff_even.size());
	ans += (diff_odd.size() - k)/2*2;
	ans += (diff_even.size() - k)/2*2;
	ans += (diff_odd.size() - k) % 2 * 3;
	cout << ans << endl;
}


Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        if (a[0] == 1)
        {
            a[0] = 1212;
        }
        if (a[1] == 1)
        {
            a[1] = 1212;
        }
        Console.WriteLine(a[0] == a[1] ? "Draw" : (a[0] < a[1] ?"Bob":"Alice"));
    }
}

Measured memory_bytes: 11348
#include<stdio.h>

int main(void){
  char s[13],str2[13],str3[13];
  int i;
  scanf("%12s",s);

  for(i=0;i<4;i++){
    str2[i]=s[i];
  }
  for(i=4;i<12;i++){
    str2[i+1]=s[i];
    }
  str2[4]=' ';
  printf("%s\n",str2);
 
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<stdint.h>
#define ii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define int long long int
using namespace std;

int32_t main(){
	string a,b;
	cin>>a>>b;
	int x=-1,c=0;
	map<char,set<int> > data;
	for(int i=0;i<a.length();i++){
		data[a[i]].insert(i+1);
	}
	for(int i=0;i<b.length();i++){
		if(!data.count(b[i])){
			cout<<-1;
			return 0;
		}
		set<int>::iterator itr=data[b[i]].upper_bound(x);
		if(itr==data[b[i]].end()){
			c+=a.length();
			x=*data[b[i]].lower_bound(-1);
		}
		else{
			x=*itr;
		}
//		cout<<c+x<<" ";
	}
	cout<<c+x;
		
}


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

const int N = 100010;

typedef long long LL;

LL D[N]; int id[N], sz[N];
map<LL, int> mp;

inline void Fuck() {
	puts("-1"), exit(0);
}

vector<int> G[N];

inline void adde(int from, int to) {
	G[from].push_back(to), G[to].push_back(from);
}

LL dfs(int u, int f) {
	LL res = 0;
	for (auto v : G[u]) if (v != f) 
		res += dfs(v, u) + sz[v];
	return res;
}

int main() {
	int n; scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%lld", &D[i]), mp[D[i]] = i, sz[i] = 1, id[i] = i;
	sort(id + 1, id + n + 1, [](int a, int b){return D[a] > D[b];});
	for (int i = 1; i < n; i++) {
		int v = id[i];
		LL tmp = D[v] - n + sz[v] * 2;
		if (!mp.count(tmp) || tmp >= D[v]) Fuck();
		adde(v, mp[tmp]), sz[mp[tmp]] += sz[v];
	}
	if (dfs(id[n], 0) != D[id[n]]) Fuck();
	for (int i = 1; i <= n; i++)
		for (auto v : G[i]) if (v > i) printf("%d %d\n", i, v);
}


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

int main(){
	int N;
	char last='\0';
	map<string,bool> exists;
	cin >> N;
	for(int i=0;i<N;i++){
		string W;
		cin >> W;
		if( (i==0 || *W.begin()==last) && !exists[W] ){
			exists[W]=true;
			last=*W.rbegin();
		}else{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


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

static const int MAX = 10000;
static const int INF = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int,int>> adj[MAX];

void dijkstra(){
    int color[MAX], d[MAX];

    for(int i = 0; i < n; i++){
        color[i] = WHITE;
        d[i] = INF;
    }

    d[0] = 0;

    // pair<vに到達するまでのスコア、v>
    priority_queue<pair<int,int>> pq;
    pq.push({0,0});
    color[0] = GRAY;

    while(!pq.empty()){
        pair<int,int> p = pq.top(); pq.pop();
        int u = p.second;
        
        color[u] = BLACK;
        if(d[u] < p.first*(-1)) continue;

        for(int j = 0; j < adj[u].size(); j++){
            int v = adj[u][j].first;
            if(color[v] == BLACK)   continue;
            if(d[v] > d[u] + adj[u][j].second){
                d[v] = d[u] + adj[u][j].second;
                pq.push({d[v]*(-1), v});
                color[v] = GRAY;
            }
        }
    }

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

int main(){
   int u, k, v, c;

   cin >> n;
   for(int i = 0; i < n; i++){
       cin >> u >> k;
       for(int j = 0; j < k; j++){
           cin >> v >> c;
           adj[u].push_back({v,c});
       }
   }

   dijkstra();

   return 0;
}


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

int main(){
    int a, b, c;
    scanf("%d%d%d",&a,&b,&c);
    int ans = 0;
    if(a%2 != b%2 && a%2 != c%2){b++;c++;ans++;}
    else if(b%2 != a%2 && b%2 != c%2){a++;c++;ans++;}
    else if(c%2 != a%2 && c%2 != b%2){a++;b++;ans++;}
    printf("%d\n", ans + (max(max(a, b), c) * 3 - (a + b + c)) / 2);
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 1000000
int A[N];

int Partition(int p,int r)
{
  int x,i,j,tmp;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++)
    {
      if(A[j]<=x)
	{
	  i++;
	  tmp=A[i];
	  A[i]=A[j];
	  A[j]=tmp;
	}
    }
  tmp=A[i+1];
  A[i+1]=A[r];
  A[r]=tmp;
  return i+1;
}

main()
{
  int n,i,x;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    {
      scanf("%d",&A[i]);
    }
  x=Partition(1,n);
 for(i=1;i<=n;i++)
   {
     if(i==x)
       {
	 printf("[%d]",A[i]);  
       }
     else
       {
	 printf("%d",A[i]);
       }
     if(i<n)
       {
	 printf(" ");
       }
   }
 printf("\n");
return 0;
}

Measured memory_bytes: 992
package main
 
import (
  "fmt"
)
 
func main() {
  var n, k int
  fmt.Scan(&n, &k)
  ans := 0
  for c := k; c < n + 2; c++ {
    ans += c * (n - c + 1) + 1
    ans %= 10e8 + 7
  }
  fmt.Println(ans)
}

Measured memory_bytes: 1752
N, Q = map(int, input().split())

trees = {}
for _ in range(N - 1):
    id1, id2 = map(int, input().split())
    if id1 not in trees:
        trees[id1] = []
    trees[id1].append(id2)

from collections import defaultdict
values = defaultdict(int)
for _ in range(Q):
    nid, val = map(int, input().split())
    values[nid] += val

counters = defaultdict(int)
stack = [[1, 0]] # id, value from parent
while len(stack) > 0:
    myid, parent_val = stack.pop()
    current_val = parent_val + values[myid]
    counters[myid] = current_val
    if myid in trees:
        for cid in trees[myid]:
            stack.append([cid, current_val])

print(' '.join(map(str, [counters[myid] for myid in range(1, N + 1)])))

Measured memory_bytes: 111888
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	while(cin >> n){
		if(n>81) cout << "No\n";
		else{
			int f=1;
			for(int i=1;i<=9;i++){
				for(int j=i;j<=9;j++){
					if(i*j==n){
						cout << "Yes\n";
						f=0;
						break; 
					}
				}
				if(!f)	break;
			}
			if(f) cout << "No\n";
		}
	}
}

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

X = dict()
ans = 0
for i in range(N):
    L = i + A[i]
    if L not in X:
        X[L] = 1
    else:
        X[L] += 1

for i in range(N):
    R = i - A[i]
    if R in X:
        ans += X[R]
        
print(ans)

Measured memory_bytes: 40264
package main

import "fmt"

func main() {
	var A,B,K int
	fmt.Scan(&A,&B,&K)

	var a,b int
	if K <= A {
		a = A-K
		b = B
	} else {
		a = 0
		if K-A >= B {
			b = 0
		} else {
			b = B-(K-A)
		}
	}
	fmt.Printf("%d %d",a,b)
}

Measured memory_bytes: 512
void main(){
	string[] st = _scanln!string();
	writeln(st[1], st[0]);
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


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

ll n,a,ans=0;

int main() {
  cin >> n;
  if(n%2==1)
  cout << 0 << endl;
  else{ 
  n/=2;
  while(n){
  ans+=n/5; n/=5;
  }
  cout << ans << endl;
  }
}

Measured memory_bytes: 256