akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

struct P{
	int x, y;
};

int W, H, n;
int memo[16], res[10][10];
P pos[16];

//i番目を置くよー
int rec(int map[10][10], int used, int x, int y){
	if(y == H){//できたよー
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				res[i][j] = map[i][j];
			}
		}
		return 1;
	}

	int res = 0;
	if(map[y][x] != 0){//もう埋まっている
		res += rec(map, used, (x+1)%W, (x+1)%W?y:y+1);
	}

	for(int i=1;i<=n;i++){
		if(used >> i & 1)continue;
		for(int width=1;width<=memo[i];width++){
			if(memo[i] % width != 0)continue;

			int height = memo[i] / width, _map[10][10];
			if(x <= pos[i].x && pos[i].x <= x + width - 1 &&
				 y <= pos[i].y && pos[i].y <= y + height - 1 &&
				 x + width - 1 < W && y + height - 1 < H){
				for(int j=0;j<H;j++){
					for(int k=0;k<W;k++){
						_map[j][k] = map[j][k];
					}
				}

				bool divided = true;
				for(int j=0;j<height&&divided;j++){
					for(int k=0;k<width&&divided;k++){
						if(_map[y+j][x+k] != 0)divided = false;//同じ所に入れない
						_map[y+j][x+k] = i;
					}
				}

				if(!divided)break;

				res += rec(_map, used | (1 << i), (x+width)%W, (x+width)%W?y:y+1);
			}
		}	
	}

	return res;
}

int main(){
	while(std::cin >> W >> H >> n, W){
		for(int i=n;i--;){
			int index;
			std::cin >> index;
			std::cin >> memo[index];
		}

		for(int y=0;y<H;y++){
			for(int x=0;x<W;x++){
				int v;
				std::cin >> v;
				if(v != 0){
					pos[v] = {x, y};
				}
			}
		}

		int map[10][10];
		for(int i=0;i<100;i++){
			map[i/10][i%10] = 0;
		}

		if(rec(map, 0, 0, 0) == 1){
			for(int i=0;i<H;i++){
				std::cout << res[i][0];
				for(int j=1;j<W;j++){
					std::cout << " " << res[i][j];
				}
				std::cout << std::endl;
			}
		}else{
			std::cout << "NA" << std::endl;
		}
	}
}

Measured memory_bytes: 1208
x,y,a,b,c=map(int,input().split())
p=[0]+sorted(list(map(int,input().split())))[a-x:]
q=[0]+sorted(list(map(int,input().split())))[b-y:]
r=[0]+sorted(list(map(int,input().split())))
pi=-1
qi=-1
ri=-1
gs=0
rs=0
ws=0
s=0              
while gs+rs+ws!=x+y:
    if r[ri]>=q[qi]>=p[pi]:
        s += r[ri]
        ws+=1
        ri-=1

    elif r[ri]>=p[pi]>=q[qi]:
        s += r[ri]
        ws += 1
        ri -= 1

    elif q[qi]>=r[ri]>=p[pi]:
        s += q[qi]
        gs += 1
        qi -= 1

    elif q[qi]>=p[pi]>=r[ri]:
        s += q[qi]
        gs += 1
        qi -= 1

    elif p[pi]>=r[ri]>=q[qi]:
        s += p[pi]
        rs += 1
        pi -= 1

    elif p[pi]>=q[qi]>=r[ri]:
        s += p[pi]
        rs += 1
        pi -= 1

print(s)


Measured memory_bytes: 28384
package main

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

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	d := sc.ReadInt()
	dSq := d * d

	counter := 0
	for i := 0; i < n; i++ {
		x := sc.ReadInt()
		y := sc.ReadInt()
		distanceSq := x*x + y*y
		if distanceSq <= dSq {
			counter++
		}
	}

	fmt.Println(counter)
}

// from [my library](https://github.com/ikngtty/go-contestlib)
// -   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 4896
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================




int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	ll A, B, M;
	cin >> A >> B >> M;


	vll a(A), b(B), X(M), Y(M), C(M);

	for (int i = 0; i < A; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < B; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> X[i] >> Y[i] >> C[i];
	}


	ll ret = LLINF;

	for (int i = 0; i < M; i++) {
		ret = min(ret, a[X[i] - 1] + b[Y[i] - 1] - C[i]);
	}


	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	ret = min(ret, a[0] + b[0]);

	cout << ret;






}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long
				
int32_t main() {
	fast_cin();  
	int n; cin >> n;
	vector<int> a(n);
	for (int &i : a) {
		cin >> i;
	}
	sort(a.rbegin(), a.rend());
	int ans = a[0], cnt = n - 2;
	for (int i = 1; i < n and cnt; ++i) {
		ans += a[i];
		--cnt;
		if (cnt > 0) ans += a[i], --cnt;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4776
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    char a, b;
    cin >> a >> b;
    puts(a > b ? ">" : a < b ? "<" : "=");
}



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int n;
	scanf("%d", &n);
	int pay=0;
	
	for(int i= 0; i<n; i+=1000){
		pay = i + 1000;
	}
	int change=0;
	change= pay-n;
	printf("%d", change);
	
	return 0;
}

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

#define vi vector<int>

int main() {

    int N;
    cin >> N;

    int h;
    int count = 0;
    int max_h = 0;
    for (int i = 0; i<N; i++) {
        cin >> h;
        if (h >= max_h) {
            count++;
            max_h = h;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

//M-SOLUTIONS
signed main(void){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);

    string s; cin>>s;
    int a=0;
    rep(i,s.size())if(s.at(i)=='o')a++;
    if(a+15-s.size()>=8)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

}

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

int main() {
  int K;
  cin >> K;
  
  if (K == 32) cout << 51 << endl;
  else if (K == 24) cout << 15 << endl;
  else if (K == 16) cout << 14 << endl;
  else if (K == 8 || K == 12 || K == 18 || K == 20 || K == 27) cout << 5 << endl;
  else if (K == 28 || K == 30) cout << 4 << endl;
  else if (K == 2) cout << 1 << endl;
  else if (K % 2 == 0) cout << 2 << endl;
  else if (K == 9 || K == 21 || K == 25) cout << 2 << endl;
  else cout << 1 << endl;
}


Measured memory_bytes: 256
Q=input()
S=input()
N,Q_num = int(Q.split(" ")[0]),int(Q.split(" ")[1])
AC=[0]
count = 0
for i in range(N-1):
  if S[i]=="A" and S[i+1]=="C":
    count = 1+count
  AC.append(count)
for q in range(int(Q_num)):
  qu = input().split(" ")
  print(AC[int(qu[1])-1]-AC[int(qu[0])-1])

Measured memory_bytes: 6100
#include <bits/stdc++.h>
using namespace std;
#define lli long long
lli dp[3002][3002];
lli a[3002];
const lli INF = (lli)(3e14);
int n;

lli solve(int i, int j) {
    
    //cout<<"i and j "<<i<<" "<<j<<endl;
    
    if(i>=n || j>=n || i<0 || j<0) return 0;
    
    if(i==j) return dp[i][j] = a[i];
    
    if(i>j) return dp[i][j] = 0;
    
    if(dp[i][j]!=INF) return dp[i][j];
    
    return dp[i][j] = max(a[i] - solve(i+1,j), a[j] - solve(i,j-1));
}

int main() 
{
    cin >> n;
    lli sum = 0;
    
    for(int i=0;i<n;i++) {cin >> a[i]; sum+=a[i];}
    
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++) dp[i][j] = INF;
    }
    
    lli X = solve(0,n-1);
	
	cout<<X<<endl;
	
	return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

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

using namespace std;

int getNext(int, int);
int getNumber(vector<int>);

int main(void){
	int a[20];
	for(int l; cin >> a[0] >> l, l;){
		for(int i = 1; i <= 20; i ++){
			a[i] = getNext(a[i - 1], l);

			int* p = find(a, a + i, a[i]);
			if(p != a + i){
				cout << p - a << " " << *p << " " << i - int(p - a) << endl;
				break;
			}
		}
	}

	return 0;
}

int getNext(int a, int l){
	vector<int> number(l);

	rep(i, l){ number[i] = a % 10; a /= 10; }

	sort(number.begin(), number.end());
	int min = getNumber(number);

	reverse(number.begin(), number.end());
	int max = getNumber(number);

	return max - min;
}

int getNumber(vector<int> in){
	int result = 0;
	rep(i, in.size()) result += in[i] * (int)pow(10, in.size() - i - 1);

	return result;
}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    cin>>k;
    int arr[32]= {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout<<arr[k-1]<<endl;
}

Measured memory_bytes: 256
require 'pp'

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

x_abs = x.abs
y_abs = y.abs

diff = (y_abs - x_abs).abs

num_count = 0

if x_abs == y_abs
  puts 1
elsif x > 0 && y > 0 && x_abs < y_abs
  puts diff
elsif x > 0 && y > 0 && x_abs > y_abs
  puts diff + 2
elsif x < 0 && y < 0 && x_abs < y_abs
  puts diff + 2
elsif x < 0 && y < 0 && x_abs > y_abs
  puts diff
elsif x > 0 && y < 0 && x_abs < y_abs
  puts diff + 1
elsif x > 0 && y < 0 && x_abs > y_abs
  puts diff + 1
elsif x < 0 && y > 0 && x_abs < y_abs
  puts diff + 1
elsif x < 0 && y > 0 && x_abs > y_abs
  puts diff + 1
elsif x < y
  puts diff
elsif x > y
  puts diff + 1
end

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

int main(void){
  int count0 = 0,count1 = 0;
  char string[100001];
  cin >> string;
  for(int i = 0; string[i] != '\0'; i++){
    if(string[i] == '0')count0++;
    else count1++;
  }
  cout << min(count0,count1) * 2 << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int lcm(int x, int y){
	int g = gcd(x,y);
	return x/g*y;
}

int facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum = (sum%MOD*i%MOD)%MOD;
    }
    return sum;
}

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

	vector<ll> v(n);
	ll ans = 0;
	rep(i,n){
		cin >> v[i];
		if (i>0){
			if (v[i]-v[i-1] >=t){
				ans += t;
			}else{
				ans += v[i]-v[i-1];
			}
		}
	}
	ans += t;
	cout << ans << endl;
}

Measured memory_bytes: 1792
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)    
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    string s;
    cin>>s;
    reverse(all(s));
    int co[2019];
    fill(co, 0);
    co[0]++;
    int mul=1,sum=0,ans=0;
    for(char ch:s)
    {
        sum=(sum+((ch-'0')*mul))%2019;
        //cout<<ch<<" "<<mul<<" "<<sum<<"\n";
        ans+=co[sum]++;
        mul=(mul*10)%2019;
    }
    cout<<ans;
}

Measured memory_bytes: 3720
# https: // onlinejudge.u-aizu.ac.jp/problems/GRL_1_C
INF = float('inf')

V, E = list(map(int, input().split()))

D = [[INF for _ in range(V)] for _ in range(V)]
for i in range(V):
    D[i][i] = 0

for _ in range(E):
    s, t, d = list(map(int, input().split()))
    D[s][t] = d

for k in range(V):
    for i in range(V):
        for j in range(V):
            D[i][j] = min(D[i][j], D[i][k] + D[k][j])

has_negative_cycle = False
for i in range(V):
    for j in range(V):
        if i == j and D[i][j] < 0:
            has_negative_cycle = True
        if D[i][j] == INF:
            D[i][j] = 'INF'
        else:
            D[i][j] = str(D[i][j])


if has_negative_cycle:
    print('NEGATIVE CYCLE')
else:
    for row in D:
        print(' '.join(row))



Measured memory_bytes: 6468
#pragma optimize("unroll-loops,no-stack-protector")
#include <bits/stdc++.h>
using namespace std;
// using namespace __gnu_pbds;
// #include <ext/pb_ds/assoc_container.hpp>
// typedef tree<int,null_type,less<int>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define Max(a,b,c) max(a,max(b,c))
#define Min(a,b,c) min(a,min(b,c))
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define pc(x)  __builtin_popcount (x)
#define vl vector< ll >
#define sorts(v) sort(v.begin(),v.end())
#define sortg(v) sort(v.begin(),v.end(),greater<ll>())
#define ss second
#define ff first
#define ll long long
#define ld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1e18)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod 1000000007
#define mem(x,y) memset(x,y,sizeof(x))
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define gcd __gcd
#define primeDEN 727999983
#define nx_pe next_permutation(s.begin(),s.end())
#define cl cout<<"\n"
#define sp(x) setprecision(x)
const ll N=3005;
ll dp[N][N][2];
ll a[N];
ll n;

ll fun(ll i,ll j,ll turn)
{
    if(i==j)
    {
        return a[i];
    }
    if(i>j)
    {
        return 0;
    }
    if(dp[i][j][turn]!=-1)return dp[i][j][turn];
    ll ans=-1e18;
    if(turn==1)
    {
        ans=max(ans,max(a[i]-fun(i+1,j,turn^1),a[j]-fun(i,j-1,turn^1)));
    }
    else
    {
        ans=max(ans,max(a[i]-fun(i+1,j,turn^1),a[j]-fun(i,j-1,turn^1)));
    }
    return dp[i][j][turn]=ans;
    
}

void solve()
{
   cin>>n;
   rep(i,n)cin>>a[i];
   mem(dp,-1);
   ll x=fun(0,n-1,0);
   cout<<x<<"\n";

   
}


    
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("ouput.txt", "w", stdout) ;
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    std::ios::sync_with_stdio(false);
    ll te=1;
    // cin>>te;
    while(te--){
        solve();
    }
    
}


Measured memory_bytes: 144980
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

int n;
string s;

bool check(int len){
  map<string,int> C;//(部分文字列,l1の連想配列)
  for(int l2 = 0; l2 + len <= n; l2++) {
    string t = s.substr(l2,len);
    //cout << t << endl;
    if(!C.count(t)){
      C[t] = l2;
    }
    else{
      int l1 = C[t];
      if(l1+len <= l2) return true;
    }
  }
  return false;
}

int main(){
  cin >> n >> s;
  int ok = 0,ng = n/2+1;
  while(ng-ok>1){
    int mid = (ok+ng)/2;
    (check(mid) ? ok : ng) = mid;
  }

  cout << ok << endl;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;


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

    vector<vector<char>> outer(n, vector<char>(n));
    vector<vector<char>> inner(m, vector<char>(m));

    rep(i, n) rep(j, n) {
            cin >> outer[i][j];
        }

    rep(i, m) rep(j, m) {
            cin >> inner[i][j];
        }

    auto check = [&](int xs, int ys) {
        for (int x = 0; x < m; x++) {
            for (int y = 0; y < m; y++) {
                if (outer[x + xs][y + ys] != inner[x][y]) {
                    return false;
                }
            }
        }
        return true;
    };


    for (int x = 0; x <= n - m; x++) {
        for (int y = 0; y <= n - m; y++) {
            if (check(x, y)) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
}



Measured memory_bytes: 256
n=map(int,input().split())
a=list(map(int,input().split()))

m=1000000
c=[0]*(m+1)

for i in a:c[i]+=1

for i in range(1,m+1):
	if c[i] == 0:continue
	for j in range(i*2,m+1,i):
		c[j]+=1
ans=0
for i in a:
 if c[i]==1:ans+=1
print(ans)


Measured memory_bytes: 116748
// ------------------------------------
// Date:2018/ 2/22
// Problem:ABC 044 BeautifulStrings b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()

using ll = long long;

int main()
{
  string w;
  int cnt[26] = {0};
  cin >> w;
  REP(i,w.size()) {
    ++cnt[w[i]-97];
  }
  REP(i,26) {
    if (cnt[i]%2 == 1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

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

  int a, b;
  string s;
  cin >> a >> b >> s;
  string ans = "Yes";
  if (s[a] != '-') ans = "No";
  else {
    for (int i = 0; i < s.size(); i++) {
      if (i == a) continue;
      int d = s[i] - '0';
      if (d >= 0 && d <= 9) continue;
      ans = "No";
      break;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>

using namespace std;

class QuickSort
{
public:
  int n;
  int a[100000];
  int solve();
  int partition( int p, int r );
};

int QuickSort::partition( int p, int r )
{
  int x = a[r];
  int i = p - 1;

  for ( int j = p; j < r; j++ )
    {
      if ( a[j] <= x )
        {
          ++i;
          swap( a[i], a[j] );
        }
    }
  swap( a[i+1], a[r]);
  
  return i+1;
}

int QuickSort::solve()
{
  cin >> n;

  for ( int i = 0; i < n; i++ )
    cin >> a[i];

  int b = partition(0, n-1);

  for ( int i = 0; i < n; i++ )
    {
      if ( i ) cout << " ";
      if ( i == b ) cout << "[";
      cout << a[i];
      if ( i == b ) cout << "]";
    }
  cout << endl;
  
  return 0;
}

int main()
{

  QuickSort qs;

  qs.solve();

  return 0;
}

Measured memory_bytes: 1548
n = int(input())
s = input()

#w[i]は, s[0]～s[i]に含まれるWの個数
w = [0] * n
bf = 0
#文字列sを順に調べて、Wの累積和を求める
for i in range(n):
    w[i] = bf
    if s[i] == 'W':
        w[i] += 1
    bf = w[i]

ans = n - 1
#リーダーをi番目とする
for i in range(n):
    #i番目より手前のW数とi+1番目以降のE数の和を最小にする
    myE = (n - w[n - 1]) - (i + 1 - w[i])#E数
    if i == 0:
        myW = 0#W数
    else:
        myW = w[i - 1]#W数
    ans = min(ans, myE + myW)

print(ans)

Measured memory_bytes: 15264
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define gcd __gcd
#define lcm(n, m) n * m / gcd(n, m)
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define ea(i, n) for(auto&& i: n)
#define so(n) sort(n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// rtsq ルート, int 2*10^9, __gcd

int main() {
  int a = 10, b = 0;
  ve<int> A(5);
  rep(i, 5){
    ci(A.at(i));
  }
  bool f;
  rep(i, 5){
    if(A.at(i) % 10 != 0 && A.at(i) % 10 < a){
      a = A.at(i) % 10;
      f = 1;
    }
    if(A.at(i) % 10 != 0){
      A.at(i) = (A.at(i) / 10 + 1) * 10;
    }
  }
  int ans = 0;
  rep(i, 5){
    ans += A.at(i); 
  }
  if(f = 1){
    ans -= 10 - a;
  }
  co(ans);
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
vector<LL>v,v1;
int main()
{
    LL n;
    cin>>n;
    for(LL i=0; i<n; i++)
    {
        LL x,y;
        cin>>x>>y;
        v.pb(x+y);
        v1.pb(x-y);
    }
    sort(all(v));
    sort(all(v1));
    LL ans=max(v[n-1]-v[0],v1[n-1]-v1[0]);
    cout<<ans;

}


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

int main() {
  int N;
  string S;
  bool ans = 1;
  cin >> N >> S;
  int x;
  x = S.size();
  
  if (S.size() % 2 == 1) {
    cout << "No" << endl;
  }
  else {
    for (int i = 0; i < x / 2; i++) {
      if (S.at(i) != S.at(i + x / 2)) {
        ans = 0;
        break;
      }
    }
    if (ans == 1) cout << "Yes";
    else cout << "No";
  }
}









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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(random_device{}());
template<typename... Args> void write(Args... args) { ((cout << args << " "), ...); cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    set<string> st;
    forn(i,n){
        string s;
        cin>>s;
        st.insert(s);
    }
    cout<<st.size();
    return 0;
}



Measured memory_bytes: 19296
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;


int N,M;
vi X,Y,Z;

struct UnionFind {
    vector<int> root;
    
    UnionFind(int n) {
        root.assign(n,-1);
    }
    
    int find(int n){
        if(root[n] < 0) return n;
        else return root[n] = find(root[n]);
    }
    
    void connect(int a,int b){
        int ar = find(a);
        int br = find(b);
        if(ar == br) return;
        
        if(-root[ar] < -root[br]){
            root[br] += root[ar];
            root[ar] = br;
        }else{
            root[ar] += root[br];
            root[br] = ar;
        }
    }
    
    
};


int main()
{
    cin >> N >> M;
    X.resize(M);
    Y.resize(M);
    Z.resize(M);
    rep(i,M) cin >> X[i] >> Y[i] >> Z[i];
    
    UnionFind uf(N);
    rep(i,M){
        uf.connect(X[i]-1, Y[i]-1);
    }
    //outve(uf.root);
    
    int ans = 0;
    rep(i,N) if(uf.root[i] < 0) ans++;
    cout << ans << endl;
    
    
    
    
    
    
    

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define LL long long
#define mp make_pair
#define pb push_back
#define INF (1<<29)
using namespace std;
typedef pair<int,int>pii;
vector<int>path,path2;
vector<int>G[100010];
int n,m;
inline int read_int(){
	int t=1,x=0;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')t=-1,ch=getchar();
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+ch-'0';
		ch=getchar();
	}
	return x*t;
}
bool vis[100010];
void dfs(int x){
	vis[x]=1;
	path.pb(x);
	for(int i:G[x]){
		if(!vis[i]){
			dfs(i);
			return;
		}
	}
}
int main(){
	n=read_int(),m=read_int();
	for(int i=1;i<=m;i++){
		int x=read_int(),y=read_int();
		G[x].pb(y),G[y].pb(x);
	}
	dfs(1);
	swap(path,path2);
	dfs(1);
	printf("%d\n",path.size()+path2.size()-1);
	for(int i=path2.size()-1;i>=1;i--){
		printf("%d ",path2[i]);
	}
	for(int i:path)printf("%d ",i);
	puts("");
	return 0;
}


Measured memory_bytes: 9720
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <ctype.h>

char str[200000+1] = "";

bool check_two_block(int st, int ed)
{
	for (int i = st; i <= ed; i++)
	{
		if( str[i-1] == '#' && str[i] == '#' ) return true;
	}
	return false;
}

int main(int argc, void **argv)
{
	long long n, a, b, c, d;

	memset(str, 0, sizeof(0));

	scanf("%lld %lld %lld %lld %lld", &n, &a, &b, &c, &d);
	scanf("%s", str);

	if( check_two_block(a, c) || check_two_block(b, d) )
	{
		puts("No");
		return 0;
	}

	if( c > d )
	{
		for (int i = b-1; i < d; i++)
		{
			if( str[i-1] == '.' && str[i] == '.' && str[i+1] == '.' )
			{
				puts("Yes");
				return 0;
			}
		}
		puts("No");
		return 0;
	}

	puts("Yes");

	return 0;
}


Measured memory_bytes: 384
from collections import deque

def bfs():
    d = [[float("inf")] * w for i in range(h)]

    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    que = deque([])
    que.append((sx, sy))
    d[sx][sy] = 0

    while que:
        p = que.popleft()
        if p[0] == gx and p[1] == gy:
            break

        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]

            if 0 <= nx < h and 0 <= ny < w and maze[nx][ny] != "#" and d[nx][ny] == float("inf"):
                que.append((nx, ny))
                d[nx][ny] = d[p[0]][p[1]] + 1
    
    return d[gx][gy]

h, w = map(int, input().split())
maze = [list(input()) for _ in range(h)]
sx, sy = 0, 0
gx, gy = h-1, w-1

white = 0
for i in range(h):
    for j in range(w):
        if maze[i][j] == ".":
            white += 1

res = bfs()

if 0 < res < float("inf"):
    print(white-res-1)
else:
    print(-1)

Measured memory_bytes: 3444
N = int(input())
HPs = list(map(int, input().split()))

while len(HPs) > 1:
    HPs.sort()
    for i in range(len(HPs)-1):
        HPs[i+1] = HPs[i+1] % HPs[0]
    while 0 in HPs:
        HPs.remove(0)

print(HPs[0])

Measured memory_bytes: 14224
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
//typedef long long unsigned int ll;
typedef long long ll;
typedef pair<ll, ll> edge;
typedef tuple<ll, ll, ll> tp;

int main() {
  ll n;
  cin >> n;
  
  ll b = 0;
  for (int i=0; i<=5; i++){
    
    if (pow(10,i) <= n && n < pow(10,i+1)) b = i;
  }
  //cout << b << endl;
  ll bb = n - pow(10,b) + 1;
  
  if(b==0) cout << bb << endl;
  if(b==1) cout << 9 << endl;
  if(b==2) cout << 9 + bb << endl;
  if(b==3) cout << 909 << endl;
  if(b==4) cout << 909 + bb << endl;
  if(b==5) cout <<  90909 << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            if (3 == ReadLine().Distinct().Count())
                WriteLine("Yes");
            else
                WriteLine("No");
        }

        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll x1, x2, x3, x4, x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;

  if (x1 == 0) cout << 1 << endl;
  else if (x2 == 0) cout << 2 << endl;
  else if (x3 == 0) cout << 3 << endl;
  else if (x4 == 0) cout << 4 << endl;
  else if (x5 == 0) cout << 5 << endl;

  return 0;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/


void Calc() {
  int n = in;
  auto a = in.Array(n);
  auto b = in.Array(n);
  auto c = in.Array(n);
  //a.push_back((int)1e9 + 10);
  //b.push_back((int)1e9 + 9);
  sort(all(a));
  sort(all(b));
  sort(all(c));
  err(a, b, c);
  ll ans = 0;
  ll x = 0, y = 0;
  ll tmp = 0;
  rep(i, n) {
    ans += tmp;
    while (x < n && b[x] < c[i]) {
      x++;
      while (y < n && a[y] < b[x - 1]) {
        y++;
      }
      if (y == 0)continue;
      err(x, y, ans);
      tmp += y;
    }
    err(ans);
  }
  ans += tmp;
  cout << (ans) << endl;


}


Measured memory_bytes: 1408
#include<stdio.h>

int isprime(int n){
  int i;
  for(i = 2; i * i <= n; i++){
    if(n % i == 0){
      return 0;
    }
  }
  return 1;
}

int main(){
  int k, n, ans, dif;
  while(1){
    scanf("%d", &n);
    if(n == 0){
      break;
    }
    for(k = n; k >= 2; k--){
      ans = isprime(k);
      if(ans == 1){
        dif = isprime(k - 2);
        if(dif == 1){
          printf("%d %d\n", k - 2, k);
          break;
        }
      }
    }
  }
  return 0;
}

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

void solve()
{
    long long t,n,m,i,j,k=0,kk=0,x,y,z=0,mn=0,mx,a[10],cnt=0;
    string s;

    cin >> n;

    cout << fixed  << setprecision(7) << (double)((n*n*n)*1.00/27*1.00) << endl;

}

int main()
{
     long long t,n,m,i,j,k=0,kk=0,x,y,z=0,mn,mx;

     ios_base::sync_with_stdio(false);
     cin.tie(NULL);

     //cin >> t;

     //while(t--)
     solve();

}


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

void solve() 
{
    int k,n;cin>>k>>n;
    int a[n];REP(i,n)cin>>a[i];
    int mn=0;
    REP(i,n-1){
        mn=max(mn,a[i+1]-a[i]);
    }
    mn=max(mn,k-a[n-1]+a[0]-0);
    cout<<k-mn<<endl;
}

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

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<int> vec;

void solve(){
	int ans = 3;
	string s, t; cin >> s >> t;
	rep(i, 3)if (s[i] != t[i])ans--;
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(5);
	//init();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 256
n,s=map(int,input().split())
a=[int(j)for j in input().split()]
dp=[0]*(3000+1)
dp[0]=1
import numpy as np
pre=np.array(dp)
mod=998244353
for i in a:
    dp=pre*2
    dp[i:]+=pre[:-i]
    dp%=mod
    pre=dp
print(dp[s])

Measured memory_bytes: 29252
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#define ll long long int

int main()
{
    int A , B;
    scanf("%d %d",&A,&B);

    if (A>=13)printf("%d",B);
    else if (A>=6 && A<=12)printf("%d",B/2);
    else if (A<=5)printf("0"); 
   
    return 0;
}



Measured memory_bytes: 128
#include <stdio.h>
#define MAX 100000

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

int main(){
  int H,i,A[MAX+1];

  scanf("%d",&H);

  for(i = 1; i <= H; i++) scanf("%d",&A[i]);

  for(i = 1; i <= H; i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i) >= 1) printf("parent key = %d, ",A[parent(i)]);
    if(left(i) <= H) printf("left key = %d, ",A[left(i)]);
    if(right(i) <= H) printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2048
#include<stdio.h>
	int main()
{
	int W, H, x, y ,r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if((x - r < 0) || (W < x + r)){
		printf("No\n");
	}else if((y - r < 0) || (H < y + r)){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    ll MOD = 1000000007;
    int N, M;
    cin >> N >> M;
    
    vector<int> a(M);
    for (int i = 0; i < M; i++)
        cin >> a[i];
    
    vector<ll> dp(N+1, 0);
    dp[0] = 1;
    int a_idx = 0;
    if (M != 0)
        if (a[a_idx] != 1)
            dp[1] = 1;
        else
            a_idx++;
    else
        dp[1] = 1;

    for (int i = 2; i < N+1; i++) {
        if (a_idx != M)
            if (a[a_idx] == i) {
                a_idx++;
                dp[i] = 0;
            }
            else
                dp[i] = (dp[i-1] + dp[i-2]) % MOD;
        else
            dp[i] = (dp[i-1] + dp[i-2]) % MOD;
    }
    cout << dp[N] << endl;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef long long ll;

const int MOD = 1000000007;

void solve() {
  int N;
  cin >> N;
  vi A(N + 2, 0);
  for (int i = 1; i < N + 1; i++) {
    cin >> A[i];
  }
  int sum = 0;
  for (int i = 1; i < N + 2; i++) {
    sum += abs(A[i] - A[i - 1]);
  }
  for (int i = 0; i < N; i++) {
    cout << sum - (abs(A[i] - A[i + 1]) + abs(A[i + 1] - A[i + 2])) +
                abs(A[i] - A[i + 2])
         << endl;
  }
}

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

  solve();

  return 0;
}


Measured memory_bytes: 1664
#include<iostream>
using namespace std;
int main() {
	int tomo, time,*fri;
	cin >> tomo >> time;
	fri = new int[tomo + 1]{ 0 };
	int *target;
	target = new int[time+1];
	for (int i = 1; i <= time; ++i) {
		cin >> target[i];
	}
	int OK;
	int dummy;
	for (int i = 1; i <= time; ++i) {
		OK = 0;
		for(int j=1;j<=tomo;++j){
			cin >> dummy;
			if (dummy == target[i]) {
				++fri[j];
				++OK;
			}
		}
		fri[target[i]] += tomo - OK;
	}
	for (int i = 1; i <= tomo; ++i) {
		cout << fri[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3044
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<30)
#define LLINF (1LL<<60)
#define MOD 998244353
#define PI 3.141592653589793238462643383279L
typedef long long ll;
using namespace std;

int main(){
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    long double angle=max(h*30+m*0.5-m*6,m*6-h*30-m*0.5);
    if(angle>=180)angle=360-angle;
    long double rad=angle*PI/180;
    long double ans=(long double)(a*a+b*b)-(long double)(2*a*b*cos(rad));
    printf("%20.20Lf", sqrtl(ans));
    return 0;
}


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

const ll mod = 1e9+7;

ll modexp(ll x,ll n){
    if(n==0){
        return 1;
    }
    ll tmp = modexp(x,n/2);
    if(n%2==0){
        return (tmp*tmp)%mod;
    }
    else{
        return (((tmp*tmp)%mod)*x)%mod;
    }
}

int main()
{
    ll n;
    cin>>n;
    ll ans;
    ans = (modexp(10,n)-(2*modexp(9,n))%mod+modexp(8,n)+mod)%mod;
    cout<<ans;
}

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

int main() {
  string S; cin >> S;
  int count =0; int countMax =0;
  int N = S.size();
  for (int i =0; i<N; i++) {
    if (S.at(i) == 'A' || S.at(i) == 'C' || S.at(i) == 'G' || S.at(i) == 'T') {
      count++;
    } else {
      countMax = max(count,countMax);
      count =0;
    }
    countMax = max(count,countMax);
  }
  cout << countMax << endl; 
}


Measured memory_bytes: 3568