akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

const ll mod = 1000000007;
const ll maxN = 1000011;

ll n, i, sg, db;
ll fact[maxN], inv_fact[maxN];
ll ans, aux;

ll poww(ll a, ll b) {
    ll ans = 1;
    while (b > 0) {
        if (b & 1) ans = (ans * a) % mod;
        b >>= 1;
        a = (a * a) % mod;
    }
    return ans;
}

ll comb(ll n, ll k) {
    ll ans = (fact[n] * inv_fact[n - k]) % mod;
    return (ans * inv_fact[k]) % mod;
}

int main()
{
   // freopen("test.in","r",stdin);

    scanf("%lld", &n);

    fact[0] = 1;
    for (i = 1; i <= n; i++) fact[i] = (fact[i - 1] * i) % mod;

    inv_fact[n] = poww(fact[n], mod - 2);
    for (i = n - 1; i >= 0; i--) inv_fact[i] = (inv_fact[i + 1] * (i + 1)) % mod;

    for (i = (n + 1) / 2; i < n; i++) {
        db = n - i;
        sg = i - db;

        aux = (comb(sg + db - 1, sg) * fact[sg + db]) % mod;
        aux = (aux * fact[n - 1 - sg - db]) % mod;

        ans = (ans + aux) % mod;
    }

    ans = mod + ((fact[n - 1] * n) % mod) - ans;
    ans %= mod;

    printf("%lld", ans);


    return 0;
}


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

void trace(int A[],int N){
  int i;
  for (i=0;i<N;i++){
    if (i>0) std::cout << " ";
    cout << A[i];
  }
  cout << '\n';
}

void InsertionSort(int A[],int N){
  int v,i,j;
  for (i=1;i<N;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    trace(A,N);
    }
  }


int main(){
  int N;
  cin>>N;
  int A[N],i;
  for (int i=0;i<N;i++) std::cin>>A[i];

  trace(A,N);
  InsertionSort(A,N);

  return 0;
}



Measured memory_bytes: 3096
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<cmath>
#include<queue>
using namespace std;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",strout);
    long long x,y;
    scanf("%lld %lld",&x,&y);
    if(x==y||x%y==0){
    	printf("-1\n");
    	return 0;
    }
    for(long long i=2;i*x<=1000000000000000000;i++){
    	if(i>20000000){printf("-1\n");break;}
    	if(i*x%y!=0){printf("%lld\n",i*x);break;}
    }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

typedef complex<double> C;
typedef pair<C,C> pp;
typedef vector<C> VP;
#define eq(a,b) (fabs(a-b)<eps)
#define veq(a,b) (eq(a.real(),b.real())&&eq(a.imag(),b.imag()))
const C O{0,0};

void In(C& p){
	double x,y;
	cin>>x>>y;
	p=C(x,y);
}

void Out(C p){
	cout<<p.real()<<' '<<p.imag()<<endl;
}

double Dot(C p,C q){
	return p.real()*q.real()+p.imag()*q.imag();
}

double Det(C p,C q){
	return p.real()*q.imag()-q.real()*p.imag();
}

C Normal(C p){
	return C(p.imag(),-p.real());
}

bool Comp(C p,C q){
	if(eq(p.real(),q.real())) return p.imag()<q.imag();
	return p.real()<q.real();
}

int Clock(C a,C b,C c){
	double t=Det(b-a,c-a);
	if(t>eps) return 1;
	if(t<-eps) return -1;
	if(Dot(b-a,c-a)<-eps) return 2;
	if(Dot(a-b,c-b)<-eps) return -2;
	return 0;
}

bool is_Orthgonal(C a,C b,C c,C d){
	return eq(Dot(a-b,c-d),0);
}

bool is_Parallel(C a,C b,C c,C d){
	return eq(Det(a-b,c-d),0);
}

bool is_Cross(C a,C b,C c,C d){
	if(is_Parallel(a,b,c,d)){
		int A=Clock(a,b,c),B=Clock(a,b,d);
		if(A>B) swap(A,B);
		if(A==0||B==0||A==-2&&B==2) return 1;
		return 0;
	}
	return Clock(a,b,c)*Clock(a,b,d)<=0&&Clock(c,d,a)*Clock(c,d,b)<=0;
}

int n;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		C a,b,c,d;
		In(a);In(b);In(c);In(d);
		cout<<is_Cross(a,b,c,d)<<endl;
	}
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
#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 1000000000000000000
using namespace std;
int main(void){
    string s;cin>>s;
    int count=0;
    rep(i,s.size()){if(s[i]=='o')count++;}
    if(count+15-s.size()>=8)cout<<"YES";
    else cout<<"NO";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
Scanner s = new Scanner(System.in);
		while (true) {
			
			int n = s.nextInt();
			int p = s.nextInt();
			if (n == 0 && p == 0) {
				break;
			}
			int pos = 0;
			int wan = p;
			int person[] = new int[n];
			for (int i = 0; i < n; i++) {
				person[i] = 0;
			}
			while (true) {
				if (wan != 0) {
					person[pos]++;
					wan--;
					if (person[pos] == p) {
						break;
					} // if2
				} // if2
				else {
					wan = person[pos];
					person[pos] = 0;
				} // else
				pos++;
				if (pos == n) {
					pos = 0;
				} // if3
			} // while2
			System.out.println(pos);
		} // while1
	}// method
}// class

Measured memory_bytes: 27312
n=int(input())
a=[]
c=0
for _ in range(n):
    w=input()
    a.append(w)

for i in range(1,n):
    if a[i-1][-1]!=a[i][0]:
        print('No')
        exit()
if n != len(set(a)):
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 9184
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize,
        red: [(usize, usize); n],
        mut blue: [(usize, usize); n]
    }
    blue.sort();

    let mut b2r = vec![Vec::new(); n];
    for i in 0..n {
        let (bx, by) = blue[i];
        for j in 0..n {
            let (rx, ry) = red[j];
            if rx < bx && ry < by {
                b2r[i].push(red[j]);
            }
        }
        b2r[i].sort_by_key(|&(_, ry)| Reverse(ry));
    }

    let mut red_set = red.into_iter().collect::<HashSet<_>>();
    let mut ans = 0;
    for red_vec in b2r {
        for red in &red_vec {
            if red_set.contains(red) {
                ans += 1;
                red_set.remove(red);
                break;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2240
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var ans = getAns(s);
        Console.WriteLine(ans * 2 + 3);
    }
    static string getString(string s, int sL, int a)
    {
        var ans = "";
        for (int i = 0; i < sL; i++)
            if (((a >> i) & 1) == 1) ans += s[i];
        return ans;
    }
    static bool checkString (string s1, string s2)
    {
        var s1L = s1.Length;
        if (s1L != s2.Length) return false;
        for (int i = 0; i <s1L; i++)
        {
            var w1 = s1[i];
            var w2 = s2[s1L - 1 - i];
            if (w1 == '(' && w2 == ')') continue;
            if (w1 == ')' && w2 == '(') continue;
            if (w1 == '{' && w2 == '}') continue;
            if (w1 == '}' && w2 == '{') continue;
            if (w1 == '[' && w2 == ']') continue;
            if (w1 == ']' && w2 == '[') continue;
            return false;
        }
        return true;
    }
    static int getAns(string s)
    {
        var s1 = s.Substring(0, s.IndexOf('i'));
        var s1L = s1.Length;
        var s2 = s.Substring(s1L + 3);
        var s2L = s2.Length;
        var imax = 1 << s1L;
        var jmax = 1 << s2L;
        var ans = 0;
        for (int i = 0; i < imax; i++)
        {
            var a1 = getString(s1, s1L, i);
            for (int j = 0; j < jmax; j++)
            {
                var a2 = getString(s2, s2L, j);
                if (checkString(a1,a2)) ans = Max(ans, a1.Length);
            }
        }
        return ans;
    }
}




Measured memory_bytes: 19932
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) 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,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


//ここから編集
int dp[310][310];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n; 
  while(cin >> n, n){
    vector<ll> w(n);
    REP(i,n) cin >> w[i];

    vector<vector<bool>> ok(n+1, vector<bool>(n+1, false)); //開区間 [i~j)消せますよの意
    
    vector<vector<int>> dp(n+1, vector<int>(n+1, 0));


    for(int i=2; i<=n; i++){
      for(int j=0; j<n; j++){
        if(j+i > n) break;
        
        if(dp[j+1][j+i-1] == i-2&& abs(w[j] - w[j+i-1]) <= 1) dp[j][j+i] = i;

        for(int k=j+1; k<i+j; k++){
          dp[j][i+j] = max(dp[j][i+j], dp[j][k] + dp[k][i+j]);
        }
      }
    }
    
    cout << dp[0][n] << endl;
  } 
  return 0;
}



Measured memory_bytes: 3376
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int tp = n;
  int cnt = 0;
  while(tp !=0){
    cnt += tp%10;
    tp /= 10;
  }
  cout<<(n%cnt==0?"Yes":"No")<<endl;
  return 0;
}

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

using namespace std;

long long minimumhy(const long long x[],int size){
	int i;
	long long y[size];
	for(i=0;i<size;i++) y[i] = x[i];
	sort(y,y+size);
	return y[0];
}

int minimumhb(const long long x[],int size){
	long long a = minimumhy(x,size);
	int i;
	for(i=0;i<size;i++){
		if(a==x[i]){
			return i;
			break;
		}
	}
}

int main(){
	long long n,limit[5]{},minute=0,i,minhole;
  	int size = sizeof(limit) / sizeof(limit[0]);
	cin >> n;
	for(i=0;i<5;i++) cin >> limit[i];
	minhole = minimumhb(limit,size);
	minute += minhole;
	minute += (long long)(n/limit[minhole]);
	if(n%limit[minhole]!=0) minute++;
	minute += 5 - 1 - minhole;
	cout << minute << endl;
	return 0;
}

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

int main(){
  int N;
  cin>>N;
  int max=0;
  vector<int> A(N);
  for (int i=0; i<N; i++){
    cin>>A[i];
    if (max<A[i]){
      max=A[i];
    }
  }
  sort(A.begin(),A.end());
  vector<int> B(max+1,0);
  B[0]=2;
  int count=0;
  
  for (int i=0; i<N; i++){
    for (int j=1; j*A[i]<max+1; j++){
      B[A[i]*j]+=1;
    }
  }
  for (int i=0; i<N; i++){
    if (B[A[i]]==1){
      count++;
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 7912
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var a = int.Parse(Console.ReadLine());
			var b = int.Parse(Console.ReadLine());
			var h = int.Parse(Console.ReadLine());

			Console.WriteLine((a + b) * h / 2);
		}
	}
}


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

public class Main
{
	public static void main(String[] args) throws NumberFormatException, IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		ArrayList<Integer> lstInt = new ArrayList<Integer>();
		String line = "";
		String[] strArray;
		int result = 0;
		int cnt = 0;

		while (cnt < 200 && (line = br.readLine()) != null)
		{
			strArray = line.split(" ", 0);
			result = Integer.parseInt(strArray[0]) + Integer.parseInt(strArray[1]);
			lstInt.add(Integer.toString(result).length());
			++cnt;
		}

		for (int digit : lstInt)
		{
			System.out.println(digit);
		}

	}
}

Measured memory_bytes: 24592
#!/usr/bin/env python3
n = int(input())

if n < 10:
  print(n)
elif n >= 10 and n < 100:
  print(9)
elif n >= 100 and n < 1000:
  print(9 + n - 100 + 1)
elif n >= 1000 and n < 10000:
  print(909)
elif n >= 10000 and n < 100000:
  print(909 + n - 10000 + 1)
elif n == 100000:
  print(909 + 99999 - 10000 + 1)


Measured memory_bytes: 2940
import collections

n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)

ans = {}
comb = 0
# 全てのキーに対して処理を実施
for k in c.keys():
  comb += int(c[k]*(c[k]-1)/2)
for k in c.keys():
  ans[k] = comb-(c[k]-1)

for i in range(n):
  print(ans[a[i]])

Measured memory_bytes: 34964
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <atcoder/all>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

using namespace atcoder;

using mint = modint998244353;

const ll INF=1e15;

int main(){
    ios;
    int n,m;
    cin >> n >> m;
    vector<mint> a(n),b(m);
    rep(i,n){
        ll x;
        cin >> x;
        a[i]=x;
    }
    rep(i,m){
        ll x;
        cin >> x;
        b[i]=x;
    }
    vector<mint> c=convolution(a,b);
    rep(i,n+m-1){
        if(i) cout << " ";
        cout << c[i].val();
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 19084
module Main where

main :: IO ()
main = input >>= (output 0) . reverse


input :: IO [Int]
input = getLine >> getLine >>= return . ((map read) . words)

output :: Int -> [Int] -> IO ()
output i [] = print i
output i (x:xs)
    | all (<=x) xs = output (i+1) xs
    | otherwise = output i xs


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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision

    int n ; cin>>n;
    int k ; cin>>k;
    vi h(n+1);
    vi dp(n+1,INT_MAX);
    repA(i,1,n) cin>>h[i];
    dp[0] =  0;
    dp[1] = 0;
    dp[2] = abs(h[2]-h[1]);

    repA(i,3,n){
        repA(j,1,k){
            if(i-j>=1)
                dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout<<dp[n]<<endl;
} 

Measured memory_bytes: 1024
// Aizu Vol-2 0282: Programming Contest
// 2017.8.19 bal4u@uu
// Priority Que
#include <stdio.h>

#define QSIZE 1000000

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

typedef struct { int id, key, c; } QUE;
QUE que[QSIZE + 5]; int qsize;

#define MAX 100000
typedef struct { int x, t, c; } T;
T tbl[MAX + 5];

void max_heapify(int i)
{
	int l, r, largest;
	l = LEFT(i), r = RIGHT(i);
	if (l < qsize &&
		(que[l].key > que[i].key || (que[l].key == que[i].key && que[l].id < que[i].id)))
		largest = l;
	else largest = i;
	if (r < qsize &&
		(que[r].key > que[largest].key ||
			(que[r].key == que[largest].key && que[r].id < que[largest].id)))
		largest = r;
	if (largest != i) {
		QUE t = que[i]; que[i] = que[largest], que[largest] = t;
		max_heapify(largest);
	}
}

void deq(void)
{
	if (qsize == 0) return;
	que[0] = que[--qsize];
	max_heapify(0);
}

void enq(void)
{
	int i, max;
	i = qsize++;
	while (i > 0 && (que[max = PARENT(i)].key < que[i].key
		|| (que[max].key == que[i].key && que[max].id > que[i].id))) {
		QUE t = que[i]; que[i] = que[max], que[max] = t;
		i = max;
	}
}

int main()
{
	int N, R, L, d, t, x;
	int lt, ld, i, ans;

	scanf("%d%d%d", &N, &R, &L);
	qsize = 0; lt = 0, ld = 1;
	que[0].id = 1, que[0].key = 0, que[0].c = 1, enq();
	tbl[1].x = 0, tbl[1].c = 1;
	while (R--) {
		scanf("%d%d%d", &d, &t, &x);
		tbl[d].x += x, tbl[d].c++;
		que[qsize].id = d, que[qsize].key = tbl[d].x, que[qsize].c = tbl[d].c;
		enq();

		while (1) {
			d = que[0].id;
			if (tbl[d].c == que[0].c) {
				tbl[ld].t += t - lt;
				lt = t, ld = d;
				break;
			}
			deq();
		}
	}
	tbl[ld].t += L - lt;
	for (t = 0, i = 1; i <= N; i++)
		if (tbl[i].t > t) t = tbl[i].t, ans = i;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 9660
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

vector<vector<ll>> MAP;
ll W, H;

int main() {
	cin >> H >> W;
	MAP.resize(W + 2, vector<ll>(H + 2, 0));
	for (ll y = 0; y < H; y++) {
		string S;
		cin >> S;
		for (ll x = 0; x < W; x++) {
			if (S[x] == '#')MAP[x+1][y+1] = 1;
		}
	}
	ll vect[4][2] = {
		{1,0},{0,-1},{-1,0},{0,1}
	};
	for (ll x = 1; x <= W; x++) {
		for (ll y = 1; y <= H; y++) {
			if (MAP[x][y] == 0)continue;
			ll flag = false;
			for (ll v = 0; v < 4 && !flag; v++) {
				if (MAP[x + vect[v][0]][y + vect[v][1]] == 1)flag = true;
			}
			if (!flag) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

unsigned gcd(unsigned a, unsigned b) {
  if (a == 0) {
    return b;
  } else if (b == 0) {
    return a;
  }
  if (a < b) gcd(b, a);
  unsigned r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}

void disp(vector<int> v) {
  rep(i, v.size()) { cout << v[i] << " "; }
  cout << endl;
}

int search_unused(vector<int> A) {
  int left = 0;
  int right = A.size() - 1;
  int left_gcd = A[left];
  int right_gcd = A[(right - left) / 2 + 1];

  while (left != right) {
    int mid = (right - left) / 2;
    for (int i = left; i <= mid; i++) {
      // cout << "temp1" << left_gcd << endl;
      left_gcd = gcd(left_gcd, A[i]);
      // cout << "temp2" << left_gcd << endl;
    }

    for (int i = mid + 1; i <= right; i++) {
      right_gcd = gcd(right_gcd, A[i]);
    }

    // cout << "left_g:" << left_gcd << ", right_g:" << right_gcd << endl;

    if (left_gcd > right_gcd) {
      left = mid + 1;
      right_gcd = left_gcd;
    } else {
      right = mid;
      left_gcd = right_gcd;
    }

    // cout << "left:" << left << ", right:" << right << endl;
  }

  return left;
}

int main() {
  int N;
  cin >> N;
  vector<int> A;
  rep(i, N) {
    int a;
    cin >> a;
    A.push_back(a);
  }

  vector<int> L(N);
  vector<int> R(N);

  rep(i, N) {
    if (i == 0) {
      L[i] = A[0];
    } else {
      L[i] = gcd(L[i - 1], A[i]);
    }
  }

  for (int i = N - 1; i >= 0; i--) {
    if (i == N - 1) {
      R[i] = A[N - 1];
    } else {
      R[i] = gcd(R[i + 1], A[i]);
    }
  }

  // disp(L);
  // disp(R);

  int result = 0;
  rep(i, N) {
    int l = i == 0 ? 0 : L[i - 1];
    int r = i == N - 1 ? 0 : R[i + 1];
    int tmp = gcd(l, r);
    result = max(result, tmp);
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 1528
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

int main() {
    long long n, a, b, c, d, e;
    scanf("%lld%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d, &e);
    long long m = std::min({a, b, c, d, e});
    printf("%lld", (n+m-1)/m+4);
}


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

using namespace std;

const int N = 2e5 + 5;

string s;
unordered_map<string, int> dp[N];

int fun(int i, string tmp = "") {
  if (i == s.size()) {
    return 0;
  }
  if (dp[i][tmp] != 0) {
    return dp[i][tmp];
  }
  int ans = 0;
  string now = "";
  now += s[i];
  if (tmp == now) {
    if (i + 1 < s.size()) {
      now += s[i + 1];
      if (tmp == now) return 0;
      ans = max(ans, 1 + fun(i + 2, now));
    } else {
      return dp[i][tmp] = -1;
    }
  } else {
    ans = max(ans, 1 + fun(i + 1, now));
    if (i + 1 < s.size()) {
      now += s[i + 1];
      ans = max(ans, 1 + fun(i + 2, now));
    }
  }
  return dp[i][tmp] = ans;
}

int main() {
  cin >> s;
  cout << fun(0);
  return 0;
}


Measured memory_bytes: 94340
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin >> N;
    int A[N],B[N];
    pair<int,int> m[N];
    rep(i,N) {
        cin >> A[i] >> B[i];
        m[i]={B[i],A[i]};
    }
    sort(m,m+N);
    bool z=true;
    int sum=0;
    rep(i,N){
        sum+=m[i].second;
        if(sum>m[i].first) {
            z=false;
            break;
        }
    }
    if(z) cout << "Yes" << endl;
    else cout << "No"<< endl;



}


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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

const int SIZE = 1e5+100;
ll n;
ll h[SIZE];

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> h[i];
        h[i]--;
    }
    for(int i = 1; i < n; i++){
        if(h[i-1]-h[i] == 1){
            h[i]++;
        }
        else{
            if(h[i-1] - h[i] > 1){
            cout << "No\n";
            return 0;
            }
        }
    }
    cout << "Yes\n";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int a[500005];
int main()//cviuaciuqevb'
{
    int n;
    cin>>n;
    while(n--)
    {
        int x;
        cin>>x;
        a[x]++;//核心部分，把上下能修改到的地方都数量加1
        a[x-1]++;
        a[x+1]++;
    }
    int maxv=0;
    for(int i=0;i<=500000;i++)//比大小
        if(a[i]>maxv)
            maxv=a[i];
    cout<<maxv;
    return 0;
 } 

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;
const int INF = 1 << 30;

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

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

    int cost[n];
    fill(cost, cost+n, INF);
    cost[0] = 0;
    for (int i = 0; i < n-1; i++) {
        for (int j = 1; j <= k; j++) {
            if (i+j < n) {
                cost[i+j] = min(cost[i+j], cost[i] + abs(h[i] - h[i+j]));
            }
        }
    }

    cout << cost[n-1] << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define pii(p)			pair<int,int> p
#define mii(m)			map<int, int> m
#define msi(m)			map<string, int, less<>> m
#define mmsi(m)			multimap<string, int, less<>> m
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
#define PI 3.141592
#define MOD 1e9+7
using namespace std;

void solve() {
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); ++i)
		s[i] = 'x';
	cout << s << endl;
}

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

Measured memory_bytes: 256
n, k = map(int, input().split())
v = list(map(int, input().split()))
lim = min(n, k)
ans = [0]

for a in range(lim+1):
    for b in range(lim-a+1):
        hand = sorted(v[:a]+v[n-b:])
        hs = sum(hand)
        for i in range(min(k-a-b, a+b)):
            test = hand[i]
            if test < 0:
                hs -= test
        ans.append(hs)
print(max(ans))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld =long double;
const ld eps = 1e-9;

bool check(const vector<vector<pair<int, int>>>&humans, int x, int y) {
	for (int i = 0; i < 4; ++i) {
		auto it=find(humans[i].begin(),humans[i].end(),make_pair(x,y));
		if(it!=humans[i].end())return false;
	}
	return true;
}
int dx[] = { -1,0,1,0,0 };
int dy[] = { 0,1,0,-1,0 };

template<typename T> struct Compress {
	map<T, int>mp;
	map<int, T>revmp;

	Compress(vector<T>vs) {
		setmp(vs);
	}

	Compress() :mp(), revmp() {

	}
	void setmp(vector<T>vs) {
		sort(vs.begin(), vs.end());
		vs.erase(unique(vs.begin(), vs.end()), vs.end());
		for (int i = 0; i < static_cast<int>(vs.size()); ++i) {
			mp[vs[i]] = i;
			revmp[i] = vs[i];
		}
	}

};
struct sale {
	int id;
	int d;
	int s;
	int e;
};

struct aa {
	int flag;
	int x;
	int y;
	int cost;
};

bool operator <(const vector<int>&l, const vector<int>&r) {
	for (int i = 0; i < l.size(); ++i) {
		if(l[i]<r[i])return true;
		else if(l[i]>r[i])return false;
	}
	return false;
}
int solve(vector<int>haves, vector<int>nums) {
	map<pair<vector<int>,int>,int>mp;
	mp[make_pair(nums,0)]=1;

	int ans=1;
	queue<pair<vector<int>,int>>que;
	que.push(make_pair(nums,0));
	while (!que.empty()) {
		auto atop(que.front());
		que.pop();

		int x=atop.second;
		vector<int>v(atop.first);

		int cost=mp[make_pair(atop.first,atop.second)];
		ans=max(ans,cost);
		for (int i = 0; i < haves.size(); ++i) {
			if (v[i]){
				if (x+haves[i] >= 11) {

				}
				else if (x + haves[i] == 10) {
					v[i]--;
					auto np=make_pair(v,0);
					if (mp[np] < cost + 1) {
						mp[np]=cost+1;
						que.push(np);
					}
					v[i]++;
				}
				else {
					v[i]--;
					auto np=make_pair(v,x+haves[i]);
					if (mp[np] < cost) {
						mp[np]=cost;
						que.push(np);
					}
					v[i]++;
				}
			}
		}
	}
	return ans-1;
}

int main()
{
	while (true) {
		int N;cin>>N;
		if(N==0)break;
		vector<int>vs(10);
		for (int i = 0; i < N; ++i) {
			int a;cin>>a;
			vs[a]++;

		}
		int ans=0;
		for (int i = 6; i <= 9; ++i) {
			int x=min(vs[i],vs[10-i]);
			vs[i]-=x;
			vs[10-i]-=x;
			ans+=x;
		}
		{
			int x=vs[5]/2;
			vs[5]-=2*x;
			ans+=x;
		}
		vector<int>haves;
		vector<int>nums;
		for (int i = 1; i <= 9; ++i) {
			if (vs[i]) {
				haves.push_back(i);
				nums.push_back(vs[i]);
			}
		}
		ans+=solve(haves,nums);
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 60276
def binary_search(lst, t, i):
    left = -1
    right = len(lst)

    while abs(right - left) > 1:
        mid = (left + right) // 2
        if i == 0:
            if lst[mid] < t:
                left = mid
            else:
                right = mid
        elif i == 1:
            if lst[mid] > t:
                right = mid
            else:
                left = mid

    return left


def main():
    n = int(input())
    A = sorted(list(map(int, input().split())))
    B = sorted(list(map(int, input().split())))
    C = sorted(list(map(int, input().split())))
    ans = 0

    for b in B:
        a = binary_search(A, b, 0)
        c = binary_search(C, b, 1)
        ans += (a + 1) * (n - c - 1)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 28880
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    A=input()
    ac=list(Counter(A).values())
    len_a=len(A)
    ans=len_a*(len_a-1)//2
    for acc in ac:
        ans-=acc*(acc-1)//2
    print(ans+1)

if __name__=='__main__':
    main()

Measured memory_bytes: 40176
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int a[2005];
int n;
ll ans;
int main(){
	cin>>n; rep(i,n)cin>>a[i]; sort(a,a+n);
	
	rep(i,n) rep(j,n){
		if(i >= j) continue;
		int x = lower_bound(a,a+n,a[i]+a[j])-a;
		//(j,x)
		if(j < x) ans += x-j-1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
A = []
g  =[[] for _ in range(n+1)]
ans = {}
for _ in range(n-1):
    a,b = map(int,input().split())
    g[a].append(b)
    A.append([a,b])


from collections import deque

q = deque()
q.append(1)

color = [-1]*(n+1)
color[1] = 0
cnt = 0

while q:
    v = q.popleft()
    p = 1
    for u in g[v]:
        if p==color[v]:
            p += 1
        color[u] = p
        ans[v,u] = p
        q.append(u)
        cnt = max(cnt,p)
        p += 1
print(cnt)

for i in range(n-1):
    tmp = (A[i][0],A[i][1])
    print(ans[tmp])


Measured memory_bytes: 122348
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String x = in.nextLine();
		String y = in.nextLine();
		String z = in.nextLine();
		String m = "A";
		int flag = 1;
		while (1==1) {
			
			if (flag == 1) {
				int l = x.length();
				if (l == 0) {
					m = "A";
					break;
				}
				char c = x.charAt(0);

				x = x.substring(1, l);
				flag = getFlag(c);
			} else if (flag == 2) {
				int l = y.length();
				if (l == 0) {
					m = "B";
					break;
				}
				char c = y.charAt(0);

				y = y.substring(1, y.length());
				flag = getFlag(c);
			} else {
				int l = z.length();
				if (l == 0) {
					m = "C";
					break;
				}
				char c = z.charAt(0);

				z = z.substring(1, z.length());
				flag = getFlag(c);
			}
		}
		System.out.println(m);
	}

	public static int getFlag(char c) {
		if (c == 'a') {
			return 1;
		} else if (c == 'b') {
			return 2;
		} else {
			return 3;
		}
	}
}


Measured memory_bytes: 9684
#include<stdio.h>
#include<string.h>
int main(void){
  int i,n,m;
  int c=0;
  char s[100];
  scanf("%s",&s);
  n=strlen(s);
  for(i=0;i<(n-1)/2;i++){
    if(s[i]!=s[i+(n+1)/2]){
      c=c+1;  
    }
  }
  if(c==0){
    printf("Yes");
  }
  else{
    printf("No");
  }  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>

using ll = long long;
typedef std::pair<int, int>p;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = true;
bool used[210];
bool graph[100][100];
bool visited[8];


int main() {
	std::string s;
	int g = 0, p = 0, ans = 0;
	std::cin >> s;
	for (int i = 0;i < s.size();i++) {
		if (g > p) {
			if (s[i] == 'g')ans++;
			p++;
		}
		else if (g == p) {
			if (s[i] == 'p')ans--;
			g++;
		}
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    
    if(a<b){
        cout<<"a < b"<<endl;
    }
    else if(a>b){
        cout<<"a > b"<<endl;
    }
    else if(a==b){
        cout<<"a == b"<<endl;
    }
    
}


Measured memory_bytes: 3076
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	int n;
	unordered_set<string> s[5];
	cin >> n;
	rep(i,n) {
		string name;
		cin >> name;
		if (name[0] == 'M')s[0].insert(name);
		else if (name[0] == 'A')s[1].insert(name);
		else if (name[0] == 'R')s[2].insert(name);
		else if (name[0] == 'C')s[3].insert(name);
		else if (name[0] == 'H')s[4].insert(name);
	}

	long long ans = 0;
	rep(k,5)rep(j,k)rep(i,j) {
		ans += (long long)s[i].size()*s[j].size()*s[k].size();
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 9344
#include<bits/stdc++.h>
#define lf double
#define ll long long
#define ii pair<int,int>
#define li pair<ll,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define pll pair<ll,ll>
#define ld long int
#define heap priority_queue
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define pp pop_back
#define all(x) x.begin(),x.end()
#define len(x) strlen(x)
#define sz(x) (int) x.size()
#define orta ((bas+son)/2)
#define min3(x,y,z) min(min(x,y),z)
#define max3(x,y,z) max(max(x,y),z)
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define MOD 1000000007
#define inf 1000000000
#define N 100005
#define LOG 17
#define M 2000000
#define EPS 0.000001
using namespace std;

int main() {

	int x,y;
	scanf("%d %d",&x,&y);
	int num=1;
	while(x--) {
		if(num+num<num+y) {
			num+=num;
		}
		else {
			num+=y;
		}
	}
	printf("%d",num);

}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    long long int A[200010];

    cin >> N;
    
    long long int s = 0;
    for (int i = 1; i <= N; i++)
    {
        cin >> A[i];
        A[i] = A[i] - i;

        s = s + A[i];
    }

    sort(A+1, A+N+1);

    long long int b;

    if (N % 2)
        b = A[(N+1)/2];
    else
        b = (A[N/2] + A[(N/2)+1]) / 2;

    long long int ans = 0;

    for (int i = 1; i <= N; i++)
    {
        ans = ans + abs(A[i]-b);
    }

    // cout << b << " ";

    cout << ans << endl;

    return 0;
}


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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(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() {
	ll x, y, z, sum, count = 0;
  cin >> x >> y >> z;
  sum = z;
  while (x >= sum + z + y) {
    sum += y + z;
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<math.h>
#include<vector> 
using namespace std;
int main()
{int n,m,k;
 cin>>n>>m>>k;
 int s=m-n+1;
 if(s>k*2)
 {for(int i=0;i<k;i++)
  cout<<n+i<<endl;
  for(int i=k-1;i>=0;i--)
  cout<<n+m-n-i<<endl;
 }
 else
 {for(int i=n;i<=m;i++)
  cout<<i<<endl;
  } 
 system("pause");
 return 0;
}

Measured memory_bytes: 504
#include <stdio.h>

int main(void) {
  int a, b, i;

  scanf("%d %d", &a, &b);
  if(a >= b) {
    for(i = 0; i < a; i++) {
      printf("%d", b);
    }
  } else {
    for(i = 0; i < b; i++) {
      printf("%d", a);
    }
  }
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 128
enum class DIR {
    left, right, up, down
}
fun main(arg: Array<String>) {
    val S = next()
    val (X, Y) = listOfInt()
    val A = mutableListOf<Int>()
    var c = 0
    S.forEach { s ->
        when (s) {
            'F' -> c += 1
            'T' -> { A.add(c); c = 0 }
        }
    }
    if (c > 0) A.add(c)
    val OFFSET = 10000; val OFFSET2 = 2 * OFFSET
    val matrix = Array(2) { BooleanArray(OFFSET2) }
    matrix[0][OFFSET] = true; matrix[1][OFFSET] = true
    A.forEachIndexed { index, dis ->
        val p = mutableListOf<Int>()
        if (index % 2 == 0) { //x
            if (index == 0) p.add(OFFSET + dis)
            else
                for (x in 0 until OFFSET2) {
                    if (matrix[0][x]) {
                        p.add(x + dis)
                        p.add(x - dis)
                        matrix[0][x] = false
                    }
                }
            p.forEach { x -> matrix[0][x] = true }
        } else { //y
            for (y in 0 until OFFSET2) {
                if (matrix[1][y]) {
                    p.add(y + dis)
                    p.add(y - dis)
                    matrix[1][y] = false
                }
            }
            p.forEach { y -> matrix[1][y] = true }
        }
    }
    val ans = if (matrix[0][OFFSET + X] && matrix[1][OFFSET + Y]) "Yes" else "No"
    println(ans)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }


Measured memory_bytes: 118264
#include <iostream>

int main(int argc, const char * argv[]) {
    int a, b;
    std::cin >> a >> b;
    if (a < b) {
        std::cout << "a < b" << std::endl;
    } else if (a > b) {
        std::cout << "a > b" << std::endl;
    } else {
        std::cout << "a == b" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <unordered_set>
#include <cstdio>
using namespace std;
const int maxn = 1e6 + 5;
int N, A[maxn], f[maxn];
vector<int> primes;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
void seive() {
    vector<bool> vis(maxn, false);
    for(int i = 2; i < maxn; ++i) {
        if(vis[i]) {
            continue;
        }
        for(int j = i; j < maxn / i; ++j) {
            vis[i * j] = true, f[i * j] = i;
        }
    }
    for(int i = 2; i < maxn; ++i)
        if(!vis[i]) primes.push_back(i);
}
int main() {
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    cin >> N;
    for(int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    // Check pairwise coprime.
    seive();
    bool pairPirme = true;
    unordered_set<int> visFac;
    for(int i = 0; i < N; ++i) {
        int t = A[i];
        while(f[t]) {
            int p = f[t];
            while(t % p == 0) t /= p;
            if(visFac.count(p)) pairPirme = false;
            visFac.insert(p);
        }
        if(t > 1) {
            if(visFac.count(t)) pairPirme = false;
            visFac.insert(t);
        }
    }

    // Check setwise coprime.
    int t = A[0];
    for(int i = 1; i < N; ++i) {
        t = gcd(t, A[i]);
    }
    bool setPrime = (t == 1);

    if(pairPirme) cout << "pairwise coprime" << endl;
    else if(setPrime) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
    return 0;
}

Measured memory_bytes: 14684
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

cnt = 0
L = []
for i in range(2,55555):
    if i%5==1:
        Ms = make_divisors(i)
        if len(Ms)==2:
            cnt+=1
            L.append(str(i))
    if cnt==55:
        break
print(" ".join(L[0:N]))

Measured memory_bytes: 38768
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define hell 1000000007
#define hell1 1000000006
#define pb push_back
#define x first
#define y second
#define MAXL 100005
#define pll pair<ll,ll>
#define L 1000000000
using namespace std;
//vector<ll>prime(15000002,0);
ll mM(ll a,ll b,ll mod){ll res = 0;a %= mod;while(b){if (b & 1)res = (res + a) % mod;a = (2 * a) % mod;b >>= 1;}return res;}
ll fpow(ll x,ll y,ll p){x=x%p;ll res=1;while(y){if(y&1)res=(res*x)%p;res%=p;if(res<0)res=(res+p)%p;y=y>>1;x=(x*x)%p;if(x<0)x=(x+p)%p;x%=p;}return res;}
ll inv(ll n,ll p){return fpow(n,p-2,p);}
ll modmul(ll x,ll y){return (x*y)%hell;}
ll modadd(ll x,ll y){if(x>=hell)x-=hell;if(y>=hell)y-=hell;ll temp=x+y;if(temp>=hell)temp-=hell;if(temp<0)temp = temp+hell;return temp;}
/*void sieve(){
	prime[1] = 1;
	for(ll i=2;i<=15000000;i++)
		if(!prime[i])
			for(ll j=i;j<=15000000;j+=i)
				if(!prime[j])
					prime[j] = i;
}*/
int main(){
	ios
	ll t = 1;
	//cin >> t;
	//sieve();
	while(t--)
	{
		ll n,k;
		cin >> n >> k;
		vector<ll>a(n),dp(n);
		for(int i=0;i<n;i++)
			cin >> a[i];
		dp[0] = 0;
		for(int i=1;i<k && i<n;i++)
		{
			dp[i] = INT_MAX;
			for(int j=i-1;j>=0;j--)
				dp[i] = min(dp[i],dp[j]+abs(a[j]-a[i]));
		}
		for(int i=k;i<n;i++)
		{
			dp[i] = INT_MAX;
			for(int j=i-1,cnt = 0;j>=0 && cnt<k;j--,cnt++)
				dp[i] = min(dp[i],dp[j]+abs(a[j]-a[i]));
		}
		cout << dp[n-1] << "\n";
	}
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

void Koch(double,int);

double x;
double y;

int main(void){
  int num;
  scanf("%d",&num);
  x = 0.0;
  y = 0.0;

  printf("%.8lf %.8lf\n",0.0,0.0);
  Koch(100.0,num);
  return 0;
}

void draw_polar_line(double r,double theta){
  double radians;

  radians = theta / 180 * M_PI;
  x = x + r * cos(radians);
  y = y + r * sin(radians);

  printf("%.8lf %.8lf\n",fabs(x),fabs(y));
  if(fabs(x - 100) < 0.00001){
    exit(0);
  }
}

void draw_fractal_line(double length,double theta,int order){
  if(order == 0){
    draw_polar_line(length,theta);
  }
  else{
    draw_fractal_line(length / 3,theta,order - 1);
    draw_fractal_line(length / 3,theta + 60,order - 1);
    draw_fractal_line(length / 3,theta - 60,order - 1);
    draw_fractal_line(length / 3,theta,order - 1);
  }
}

void Koch(double size,int order){
  draw_fractal_line(size,0,order);
  draw_fractal_line(size,120,order);
  draw_fractal_line(size,240,order);
}



Measured memory_bytes: 2096
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

int main() {
	int n; qr(n);
	while(n) {
		if(n%10==7) {puts("Yes");return 0;}
		n/=10;
	}puts("No");
	return 0;
}



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

typedef long long ll;
int main()
{
	ll n,k;
	cin>>n>>k;
	
	ll A[n+1];
	for(int i=1;i<=n;i++)
	cin>>A[i];
	if(k==0){
	cout<<"1";return 0;}
	A[0]=0;
	sort(A,A+n+1);
	ll ans[k+1][n+1];
	//cout<<"^";
	ans[0][0]=1;
	//cout<<"@";
	for(int i=1;i<=k;i++)
	{
		ans[i][0]=1;
	}
	//cout<<"#";
	for(int i=1;i<=n;i++)
	ans[0][i]=1;
	ll mod=1e9+7;
//	cout<<"*";
	for(int j=1;j<=n;j++)
	{
		for(int i=1;i<=A[j];i++)
		{
			ans[i][j]=(ans[i][j-1]+ans[i-1][j])%mod;
	//		cout<<"&";
		}
		for(int i=A[j]+1;i<=k;i++)
		ans[i][j]=(ans[i][j-1]-ans[i-A[j]-1][j-1] + ans[i-1][j] + mod)%mod;
	//	cout<<"%";
	}
/*	for(int i=0;i<=k;i++)
	{
		for(int j=0;j<=n;j++)
		cout<<ans[i][j]<<" ";
		cout<<endl;
	}
*/	
	ll h=(ans[k][n]-ans[k-1][n] + mod)%mod;
	cout<<h;
	return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

const int MAX_H = 10004;
int dp[MAX_H];

int main() {
	int h, n;
	cin >> h >> n;
	vector<int> a(n), b(n);
	rep(i,n) cin >> a[i] >> b[i];
	fill(dp, dp+h+1, INF);
	dp[0] = 0;
	rep(i,n)rep(j,h+1) {
		dp[min(j+a[i], h)] = min(dp[min(j+a[i],h)], dp[j]+b[i]);
	}
	cout << dp[h] << endl; 
}

Measured memory_bytes: 256