akhauriyash/Code-Regression huggingface dataset:
/**********************************/
/*******菴懆??壽ア、譬第棊**************/
/*******譌カ髣エ??013蟷エ8譛?5譌・14轤ケ***/
/*******髦溷暑:蟠皮サァ霑?&阡。豌ク蛛・*******/
/**********************************/
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <queue>
#include <cstdio>
#include <cmath>
#include <string>
#include <stack>
#include <cctype>
using namespace std;

#define INF 0x7fffffff
#define eps 1e-12
#define MOD 10000007
#define M 1000005

int num=0;
int head[M],ans[M];
int mark[M];
long long dist[M];
int u[M],v[M], d[M], c[M];

struct node
{
    int v;
    int w;
    int next;
    int cost;
} e[M];

void add(int aa,int bb,int t, int cc)
{
    e[num].v=bb;
    e[num].w=t;
    e[num].cost=cc;
    e[num].next=head[aa];
    head[aa]=num;
    num++;
}

void SPFA(int x)
{
    queue<int> q;
    q.push(x);
    mark[x]=true;
    dist[x]=0;
    while(!q.empty())
    {
        int tmp=q.front();
        q.pop();
        mark[tmp]=false;
        for(int i=head[tmp]; i!=-1; i=e[i].next)
        {
            if(dist[e[i].v]==dist[tmp]+e[i].w && e[i].cost < ans[e[i].v])
                ans[e[i].v]=e[i].cost;
            if(dist[e[i].v]>dist[tmp]+e[i].w)
            {
                dist[e[i].v]=dist[tmp]+e[i].w;
                ans[e[i].v]=e[i].cost;
                if(!mark[e[i].v])
                {
                    q.push(e[i].v);
                    mark[e[i].v]=true;
                }
            }
        }
    }
}

int main()
{
    int n,m,x;
    while(~scanf("%d%d",&n,&m))
    {
        if(n==0&&m==0)
            break;
        int sum=0;

        memset(head,-1,sizeof(head));
        memset(mark,false,sizeof(mark));
        memset(ans,1,sizeof(ans));
        memset(dist,1,sizeof(dist));
        num=0;

        for(int i=0; i<m; i++)
        {
            scanf("%d%d%d%d",&u[i],&v[i],&d[i], &c[i]);
            add(u[i],v[i],d[i],c[i]);
            add(v[i],u[i],d[i],c[i]);
        }
        SPFA(1);
        for(int i=2; i<=n; i++)
            sum+=ans[i];
        printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 30124
import java.util.*;
 
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
    String[] str_list = {"a","i","u","e","o"};
		if (Arrays.asList(str_list).contains(a)) {
			System.out.println("vowel");
		} else {
			System.out.println("consonant");
		}
  }
}

Measured memory_bytes: 35460
#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<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>

using namespace std;

const int MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;
#define rep(i, m, n) for(int i=m;i<n;i++)
#define rrep(i, n, m) for(int i=n;i>=m;i--)

ll dp[25000010] = {};
ll dp2[25000010] = {};

int main() {
    int n;
    cin >> n;
    int a[3];
    int b[3];
    for (int & i : a) {
        cin >> i;
    }
    for (int & i : b) {
        cin >> i;
    }

    for (int i = 1; i <= n; ++i) {
        dp[i] = dp[i - 1] + 1;
        for (int j = 0; j < 3; ++j) {
            int ga = a[j];
            int gb = b[j];
            if (i - ga >= 0) {
                dp[i] = max(dp[i], dp[i - ga] + gb);
            }
        }
    }
    ll res = dp[n];

    for (int i = 1; i <= res; ++i) {
        dp2[i] = dp2[i - 1] + 1;
        for (int j = 0; j < 3; ++j) {
            int ga = a[j];
            int gb = b[j];
            if (i - gb >= 0) {
                dp2[i] = max(dp2[i], dp2[i - gb] + ga);
            }
        }
    }
    cout << dp2[res] << endl;
}


Measured memory_bytes: 196864
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int N;
    cin >> N;
    int H[20];
    for(int i=0;i<N;i++){
        cin >> H[i];
    }
    int ans = 0;
    int MAX = 0;
    for(int i=0;i<N;i++){
        MAX = max(MAX,H[i]);
        if(MAX == H[i]){
            ans++;
        }
    }
    cout << ans << endl;
return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n,m;
    cin>>n>>m;
    string str(n,'-');

    for (ll i = 0; i < m; i++)
    {
        ll s,c;
        cin >> s >> c;
        if(str[s - 1] == '-'){
            str[s - 1] = c + '0';
        }
        else{
            if(str[s - 1] != c + '0'){
                cout << -1 << endl;
                exit(0);
            }
        }
    }

    if(n != 1 && str[0] == '0')
    {
        cout << -1 << endl;
        exit(0);
    }
    
    for (ll i = 0; i < n; i++)
    {
        if(str[i]=='-'){
            if(i==0 && n != 1){
                str[i] = '1';
            }
            else{
                str[i] = '0';
            }
        }
    }

    cout<<str<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
using namespace std;
int main()
{
	int w,h,n,*x,*y,count=0;
	cin >> w >> h >> n;
	x = new int [n];
	y = new int [n];
	for(int i=0;i<n;i++){
		cin >> x[i] >> y[i];
	}
	for(int i=0;i<n-1;i++){
		if(x[i]<=x[i+1] && y[i]<=y[i+1] || x[i]>=x[i+1] && y[i]>=y[i+1]){
			if(abs(x[i+1]-x[i])<=abs(y[i+1]-y[i])){
				count += abs(y[i+1]-y[i]);
			}
			else {
				count += abs(x[i+1]-x[i]);
			}
		}
		else if(x[i]>=x[i+1] && y[i]<=y[i+1] || x[i]<=x[i+1] && y[i]>=y[i+1]){
			count += abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
		}
	}
	cout << count << endl;
	return 0;
}

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

int main(){
  int n, h, w;
  cin >> n >> h >> w;
  int a[n], b[n];
  for (int i =0; i<n; i++) cin >> a[i] >> b[i];
  int count = 0;
  for (int i =0; i<n; i++){
    if(a[i]>=h && b[i]>=w) count++;
  }
  cout << count;
}


Measured memory_bytes: 256
let () = Scanf.scanf "%d %d %d %d\n" @@ fun x y z k ->
  let as_ = Array.init x @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  let bs = Array.init y @@ fun _ -> Scanf.scanf "%d " @@ fun b -> b in
  let cs = Array.init z @@ fun _ -> Scanf.scanf "%d " @@ fun c -> c in
  Array.sort (fun a a' -> compare a' a) as_;
  Array.sort (fun b b' -> compare b' b) bs;
  Array.sort (fun c c' -> compare c' c) cs;
  let abcs =
    Array.of_list @@
    List.concat @@ Array.to_list @@ Array.init (min x k) @@ fun i ->
      List.concat @@ Array.to_list @@ Array.init (min y (k / (i + 1))) @@ fun j ->
        Array.to_list @@ Array.init (min z (k / (i + 1) / (j + 1))) @@ fun k ->
          as_.(i) + bs.(j) + cs.(k) in
  Array.sort (fun abc abc' -> compare abc' abc) abcs;
  for i = 0 to k - 1 do
    Printf.printf "%d\n" abcs.(i)
  done


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    int ans = 0;
    for(auto c : s){
        if(c=='2') ans++;
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(int i=n;i<=N;++i)
#define rap(i,n,N) for(int i=n;i>=N;--i)
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cout << ">>>>>> " << #x << " -> " << x << endl
#define all(x) x.begin(),x.end()
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define pllll pair<pll,pll>
#define piii pair<int,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
#define endl '\n'
const int MAX = 6e5+5;
const ll MAX2 = 11;
const ll MOD = 1000000007;
const ll MOD2 = 1000000006;
const ll INF = 2e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 316;
 
int n,x,ans,cnt;

int main(){
//	cout<<fixed<<setprecision(10);
//    freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n;
    rep(i,1,n){
    	cin>>x;
    	if(x==i)++cnt;
    	else ans+=(cnt+1)/2, cnt = 0;
	}
	cout<<ans+(cnt+1)/2<<endl;
    return 0;
}

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

int h;
int w;

char buf[13][13];

vector<string> v;


vector<pair<int, bitset<10397> > > ava[13];

bitset<10397> dp[1 << 12];

vector<vector<pair<int, int> > > way;

set<int> us;
vector<pair<int, int> > C;
inline void dfs(int cur,bool pass=false) {
	if (cur == v[0].size()) {
		way.push_back(C);
		return;
	}
	if (us.count(cur)) {
		dfs(cur + 1,pass);
		return;
	}
	else {
		if(pass==false)dfs(cur + 1, true);
	}
	us.insert(cur);
	for (int i = cur + 1; i < v[0].size(); i++) {
		if (us.count(i))continue;
		C.push_back(make_pair(cur, i));
		us.insert(i);
		dfs(cur+1,pass);
		C.pop_back();
		us.erase(i);
	}
	us.erase(cur);
}
char tmp[13][13];
map<char, int> mp;
int main() {
	cin >> h >> w;
	if (h == 1 && w == 1) {
		puts("YES");
		return 0;
	}
	for (int i = 0; i < h; i++) {
		scanf("%s", buf[i]);
	}
	if (w == 1) {
		for (int i = 0; i < h; i++) {
			buf[0][i] = buf[i][0];
		}
		swap(h, w);
	}
	for (int i = 0; i < h; i++) {
		string emp = "";
		v.push_back(emp);
		for (int j= 0; j < w; j++) {
			v.back().push_back(buf[i][j]);
		}
	}
	dfs(0);
	if (h == 1) {
		for (int i = 0; i < w; i++) {
			mp[buf[0][i]]++;
			mp[buf[0][i]] %= 2;
		}
		int cc = 0;
		for (auto el : mp) {
			if (el.second) {
				cc++;
			}
		}
		if (cc > 1) {
			puts("NO");
		}
		else {
			puts("YES");
		}
		return 0;
	}
	for (int i = 0; i < v.size(); i++) {
		for (int j = i + 1; j < v.size(); j++) {
			bitset<10397> can;
			int len = v[i].size();
			for (int k = 0; k <way.size(); k++) {
				bool ok = false;
				for (auto it:way[k]) {
					int a = it.first;
					int b = it.second;
					if (v[i][a] != v[j][b] || v[i][b] != v[j][a]) {
						ok = true;
						break;
					}
				}
				if (ok)continue;
					can.set(k, true);
			}
			if(can.any())ava[i].push_back(make_pair(j, can));
		}
	}
	for (int i = 0; i <way.size(); i++) {
		dp[0].set(i, true);
	}
	for (int i = 0; i < v.size(); i++) {
		for (int j = (1<<12)-1; j>=0; j--) {
			if ((j >> i) & 1)continue;
			if (dp[j].any()) {
				for (int k = 0; k < ava[i].size(); k++) {
					int go = ava[i][k].first;
					if ((j >> go) & 1)continue;
					dp[j | (1 << i) | (1 << go)] |= (dp[j] & ava[i][k].second);
				}
			}
		}
	}
	int need = v.size() / 2;
	need *= 2;
	for (int i = 0; i < (1 << v.size()); i++) {
		int z = 0;
		for (int j = 0; j <v.size(); j++) {
			if ((i >> j) & 1) {
				z++;
			}
		}
		if (z == need) {
			if (dp[i].any()) {
				puts("YES");
				return 0;
			}
		}
	}
	puts("NO");
	return 0;
}

Measured memory_bytes: 6460
#include<iostream>
#include<vector>
#include<map>

using namespace std;

typedef long long ll;

bool check(int n, vector<int> a, int x) {
    map<int, int> mp;
    mp[a[1]-1] = 0;

    // cerr << "x: " << x << endl;
    for(int i=1;i<=n;++i) {
        // cerr << i << endl;
        vector<int> to_erase;
        if(a[i-1] < a[i]) {
            for(auto itr=mp.begin();itr!=mp.end();++itr) {
                if(itr->first >= a[i]) {
                    to_erase.push_back(itr->first);
                }
            }
        } else if(a[i-1] == a[i]) {
            bool added = false;
            for(int j=a[i]-1;j>=0;--j) {
                if(mp.find(j) == mp.end()) {
                    if(x == 1) return false;
                    mp[j] = 1;
                    added = true;
                    break;
                } else if(mp[j] != x-1) {
                    ++mp[j];
                    added = true;
                    break;
                } else {
                    to_erase.push_back(j);
                }
            }
            if(!added) return false;
        } else {
            bool added = false;
            for(int j=a[i]-1;j>=0;--j) {
                if(mp.find(j) == mp.end()) {
                    if(x == 1) return false;
                    mp[j] = 1;
                    added = true;
                    break;
                } else if(mp[j] != x-1) {
                    ++mp[j];
                    added = true;
                    break;
                } else {
                    to_erase.push_back(j);
                }
            }
            if(!added) return false;

            for(auto itr=mp.begin();itr!=mp.end();++itr) {
                if(itr->first >= a[i]) {
                    to_erase.push_back(itr->first);
                }
            }
        }

        for(int e: to_erase) mp.erase(e);

        // for(auto itr=mp.begin();itr!=mp.end();++itr) {
        //     cerr << itr->first << " " << itr->second << endl;
        // }
    }

    return true;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n+1, 0);
    for(int i=1;i<=n;++i) cin >> a[i];
    
    int ng = 0, ok = 300000;
    while(ok-ng > 1) {
        // cerr << endl << ng << " " << ok << endl;
        int mid = (ok + ng) / 2;
        if(check(n, a, mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << ok << endl;
}


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

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}

int main(void){
	int n=in(),t=in(),i,f[200000]={},ans=t;
	for(i=0;i<n;i++){
		f[i]=in();
	}
	for(i=1;i<n;i++){
		ans+=min(f[i]-f[i-1],t);
	}
	print(ans);
	return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define PB push_back

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVi;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;

int main(){
	ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    VI x(m),y(m),red(n+1,0),ball(n+1,1);
    rep(i,m){
        cin>>x[i]>>y[i];
    }
    red[1]=1;
    rep(i,m){
        if(red[x[i]]==1 && ball[x[i]]>1){
            red[y[i]]=1;
        }
        else if(red[x[i]]==1 && ball[x[i]] == 1){
            red[x[i]]=0;
            red[y[i]]=1;
        }
        ball[x[i]]--;
        ball[y[i]]++;
    }
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(red[i]==1)
            cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


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

int main() {
    int N; cin >> N;
    int a, b, c;
    a = N / 100;
    b = N - a * 100;
    b = b / 10;
    c = N - (a * 100 + b * 10);
    string ans = "No";
    if(a == 7) ans = "Yes";
    if(b == 7) ans = "Yes";
    if(c == 7) ans = "Yes";
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define f first
#define sec second
#define pb push_back
#define pf push_front
#define po pop_back
#define fast ios_base::sync_with_stdio(false)
#define vi vector<ll>
#define vii vector< pair<ll,ll> >
#define pi pair<ll,ll>
#define map map<ll,ll>
#define set set<ll>
#define tostr to_string
#define toint stoi
#define gcd __gcd

int main()
{
    fast;
    ll n;cin>>n;
    ll c=0,i,j;
    vi v;
    for(i=1;i<=9;i++)
    {
        for(j=1;j<=9;j++)
         v.pb(i*j);
    }
    for(i=0;i<81;i++)
    {
        if(v[i]==n)
            c=1;
    }
    if(c==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math

a,b,h,m=(int(x) for x in input().split())

h_a=h%12
k_a = (h_a*60+m)*0.5

k_b = m*6
#print(k_a,k_b)

if k_a<=90:
    #print("a")
    a_x = a*math.cos(math.radians(90-k_a))
    a_y = a*math.sin(math.radians(90-k_a))
elif k_a<=180:
    #print("b")
    a_x = a*math.cos(math.radians(k_a-90))
    a_y = -a*math.sin(math.radians(k_a-90))
elif k_a<=270:
    #print("c")
    a_x = -a*math.cos(math.radians(270-k_a))
    a_y = -a*math.sin(math.radians(270-k_a))
else:
    #print("d")
    a_x = -a*math.cos(math.radians(k_a-270))
    a_y = a*math.sin(math.radians(k_a-270))
    
if k_b<=90:
    #print("a")
    b_x = b*math.cos(math.radians(90-k_b))
    b_y = b*math.sin(math.radians(90-k_b))
elif k_b<=180:
    #print("b")
    b_x = b*math.cos(math.radians(k_b-90))
    b_y = -b*math.sin(math.radians(k_b-90))
elif k_b<=270:
   # print("c")
    b_x = -b*math.cos(math.radians(270-k_b))
    b_y = -b*math.sin(math.radians(270-k_b))
else:
    #print("d")
    b_x = -b*math.cos(math.radians(k_b-270))
    b_y = b*math.sin(math.radians(k_b-270))
#print(a_x,a_y,b_x,b_y)

print('{:.10g}'.format(math.sqrt((a_x - b_x) ** 2 + (a_y - b_y) ** 2)))

Measured memory_bytes: 9548
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,a,b,c;
  cin>>A>>B>>C;
  a=max(max(A,B),C);
  b=min(min(A,B),C);
  cout<<a-b<<endl;
 
  
  }
  


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

int main(){
  while(true){
    string s; cin >> s;
    if(s == "0") break;
    int sum_digit = 0;
    for(int i = 0; i < (int)s.size(); i++){
      sum_digit += s[i] - '0';
    }
    cout << sum_digit << endl;
  }
}



Measured memory_bytes: 3224
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();
            int R = in.nextInt();

            int[] r = new int[R];
            for (int i = 0; i < R; i++) {
                r[i] = in.nextInt() - 1;
            }

            int[][] distances = new int[N][N];
            for (int i = 0; i < distances.length; i++) {
                Arrays.fill(distances[i], (int) 1e9);
            }
            for (int i = 0; i < M; i++) {
                int A = in.nextInt() - 1;
                int B = in.nextInt() - 1;
                int C = in.nextInt();
                distances[A][B] = C;
                distances[B][A] = C;
            }

            floyd(N, distances);

            int min = dfs(0, new boolean[R], r, distances, -1);

            System.out.println(min);
        }
    }

    private static int dfs(int index, boolean[] used, int[] r, int[][] distances, int from) {
        if (index >= r.length) {
            return 0;
        }

        int min = (int) 1e9;

        for (int i = 0; i < r.length; i++) {
            if (used[i]) {
                continue;
            }

            used[i] = true;

            int to = r[i];
            int distance = (from == -1 ? 0 : distances[from][to]) + dfs(index + 1, used, r, distances, to);
            if (distance < min) {
                min = distance;
            }

            used[i] = !true;

        }

        return min;
    }

    private static void floyd(int n, int[][] l) {
        for (int b = 0; b < n; b++) {
            for (int a = 0; a < n; a++) {
                for (int c = 0; c < n; c++) {
                    l[a][c] = Math.min(l[a][c], l[a][b] + l[b][c]);
                }
            }
        }
    }

}


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

int a[100000];
signed main(){
int n,k;cin>>n>>k;
for(int i=0;i<n;i++)cin>>a[i];
sort(a,a+n);
int MIN=INT_MAX;
for(int i=k-1;i<n;i++){
MIN=min(MIN,a[i]-a[i-k+1]);
}
  cout<<MIN<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>		// standard input output
#include <iostream>		// input output stream, cin cout( console in console out)
#include <cmath>		// circle math ( sin, con, sinh
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>		// input output manipulation

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep3(i, a, n) for(int i = (int)(a); i < (int)(n); i++)
#define ll long long

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






int main() {
  int N; // 変数の宣言
  cin >> N; // 標準入力

  if(N>=30){
  cout << setprecision(12) << "Yes" << endl; // 標準出力
  }
  else{
     cout << setprecision(12) << "No" << endl;
  }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> sw(m);
    rep(i, m) {
        ll k;
        cin >> k;
        rep(ii, k) {
            ll s;
            cin >> s;
            s--;
            sw[i].push_back(s);
        }
    }
    vector<ll> p(m);
    rep(i, m) cin >> p[i];
    ll ans = 0;
    rep(i, 1 << n) {
        ll ons = 0;
        rep(ii, m) {
            ll sum = 0;
            rep(iii, sz(sw[ii])) {
                if ((i & (1LL << sw[ii][iii])) != 0) sum++;
            }
            if (p[ii] == (sum % 2)) ons++;
        }
        if (ons == m) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> g(n);
    REP(i, m) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<ll> path;
    vector<bool> used;
    auto dfs = [&](auto &&self, ll v, ll p) -> void {
        path.push_back(v);
        used[v] = true;
        for(auto to: g[v]) {
            if(!used[to]) {
                self(self, to, v);
                break;
            }
        }
    };

    vector<ll> ord(n);
    iota(ALL(ord), 0);
    sort(ALL(ord), [&](ll l, ll r){
        return g[l].size() < g[r].size();
    });

    REP(x, n) {
        ll root = ord[x]; 
        ll num = 0;
        vector<ll> ans;
        used.assign(n, false);
        used[root] = true;
        for(auto to: g[root]) {
            dump(to, used);
            if(!used[to]) {
                if(num >= 2) { num = 3; break; }
                path.clear();
                dfs(dfs, to, root);
                dump(path);
                if(num == 0) {
                    reverse(ALL(path));
                    swap(ans, path);
                    ans.push_back(root);
                } else if(num == 1) {
                    for(auto i: path) ans.push_back(i);
                }
                num++;
            }
        }
        if(num <= 2) {
            cout << ans.size() << "\n";
            REP(i, ans.size()) cout << ans[i]+1 << (i+1==ans.size() ? '\n' : ' ');
            return 0;
        }
    }
    assert(false);

    return 0;
}

Measured memory_bytes: 9972
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define a_macro(args...) sum(args)
#define fi first
#define se second
#define pb push_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define forne(i,n) for(int i=1;i<=n;i++)
#define forn(i,n) for(int i=0;i<n;i++)

typedef long long ll;
const ll MOD = 998244353;
typedef tuple<int,int,int> State; // operator< defined

ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
  while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
vector<ll> f;
vector<ll> invf;
ll MAXVAL = 2*(1e5)+100;
void init(){
	f.resize(MAXVAL, 1);
	invf.resize(MAXVAL, 1);
	forne(i, MAXVAL-1) f[i] = (f[i-1]*i)%MOD;
	forne(i, MAXVAL-1) invf[i] = modinv(f[i]);
}
ll ncr(ll n, ll r){
	return invf[n-r] * ( f[n] * invf[r] % MOD ) % MOD;
}

int sum() { return 0; }

template<typename T, typename... Args>
auto sum(T a, Args... args) { return a + sum(args...); }
template<class T> bool uin(T &a,T b) {return a > b ? (a == b, true) : false; }
template<class T> bool uax(T &a,T b) {return a < b ? (a == b, true) : false; }


int main(int argc, const char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
#endif
	init();

	ll n, m, k;
	cin>>n>>m>>k;
	ll answer = 0;
	forn(i, k+1){
		ll factor = (m*modpow(m-1, n-i-1))%MOD;
		answer = answer + (factor*ncr(n-1, i))%MOD;
		answer %= MOD;
	}
	cout<<answer<<endl;

    
#ifndef LOCAL_DEFINE
    cerr << "Time elapsed: "<< 1e1 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif // LOCAL_DEFINE
    return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  rep(k,n){
    string sp = s.substr(k);
    int np = sp.length();
    vector<int> A(np);
    int c = 0;
    for(int i=1; i<np; i++){
      if (i+A[i-c]<A[c]+c) A[i] = A[i-c];
      else{
        int j = max(0, c+A[c]-i);
        while (i+j<np && sp[j]==sp[i+j]) ++j;
        A[i] = j;
        c = i;
      }
    }
    rep(i,np){
      if (A[i]<=i) ans = max(ans, A[i]);
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]
s = set([(x + y) % 2 for x, y in xy])
if len(s) > 1:
    print(-1)
    exit(0)

d = []
w = ["" for _ in xy]
if s.pop() == 0:
    d = [1]
    w = ["L" for _ in xy]
    xy = [(x + 1, y) for x, y in xy]

b = 1 << 30
while b > 0:
    d.append(b)
    for i in range(len(xy)):
        x, y = xy[i]
        if abs(x) > abs(y):
            if x > 0:
                w[i] += 'R'
                xy[i] = (x - b, y)
            else:
                w[i] += 'L'
                xy[i] = (x + b, y)
        else:
            if y > 0:
                w[i] += 'U'
                xy[i] = (x, y - b)
            else:
                w[i] += 'D'
                xy[i] = (x, y + b)
    b //= 2

print(len(d))
print(*d)
for t in w:
    print(t)

Measured memory_bytes: 45040
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
using namespace std;

const double pi = acos(-1);
#define nyan cout << "(=^•ω•^=)" << endl;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop while(true)

int ans;
int n;

signed main(){
    cin>>n;
    if(n==3||n==5||n==7)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
import math, collections, itertools, functools, operator
class PrimeUtils:
    @staticmethod
    def primes_sieve(n):
        sieve = [True] * (n + 1)
        for i in range(2, n + 1):
            if sieve[i]:
                for j in range(i + i, n + 1, i):
                    sieve[j] = False
        return [i for i, x in enumerate(sieve[2:], 2) if x]
    @staticmethod
    # Prime Factor Decomposition
    def pfd(n):
        rn = math.ceil(math.sqrt(n))
        primes = PrimeUtils.primes_sieve(rn)

        factors = []
        cur = n
        for p in primes:
            while True:
                div, rem = divmod(cur, p)
                if rem == 0:
                    factors.append(p)
                    cur = div
                else:
                    break
        if cur != 1 or not factors:
            factors.append(cur)
        return factors
    @staticmethod
    # Returns a list of factors
    def factors(n):
        pf = PrimeUtils.pfd(n)
        pfc = collections.Counter(pf)
        ppv = [[pow(p, i) for i in range(n+1)] for p,n in pfc.items()]
        return [functools.reduce(operator.imul, x) for x in itertools.product(*ppv)]

N, M = map(int, input().split())
for factor in sorted(PrimeUtils.factors(M)):
    if N <= factor:
        print(M // factor)
        break
else:
    print(1)

Measured memory_bytes: 4188
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip> // 文字幅の指定 setw(int), 詰めたい文字の指定 setfill(char)
#include <algorithm> // sort
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define p(x) cout << (x) << endl
#define FOR(i,r,n) for(ll i=(ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n); i>=r; i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) REP(i,0,n)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pb push_back

// 定義する？→左揃えで0埋め
// cout << setfill('0') << left << setw(4) << 12; // "0012"
// http://marycore.jp/prog/cpp/padding-left-right-zero/

const int inf = (int)1e9;
const ll INF = (ll)1e18;

// vectorの中身をcout << vs;で表示
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o << "{";
    for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
    o << "}";
    return o;
}

ll gcd (ll a, ll b) {
	while (b > 0) {
		ll t = a % b;
		a = b, b = t;
	}
	return a;
}

ll lcm (ll a, ll b) {
	return (a / gcd (a, b)) * b;
}

bool is_prime (ll n) {
		if (n < 2) return false;
		else if (n == 2) return true;
		else if (n % 2) return false;
		
		double sqrtn = sqrt(n);
		for (ll i = 3; i < sqrtn; i += 2) {
			if (n % i == 0) return false; 
		}
		return true;
}

ll ctoi(char c) {
	return (ll)(c - 48);
}

ll n, k, cnt=0, ans=0;
string s,t;

// ==================== template ============================

ll euc(ll a, ll b) {
	if(a<b) euc(b, a);
	ll r;
	while((r=a%b)) {
		a = b;
		b = r;
	}
	return b;
}

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

	cin >> n;
	vll vs;
	REP(i, n) {
		ll a; cin >> a;
		vs.pb(a);
	}
	sort(vs.begin(), vs.end());	
//	cout << vs;


	while(true) {
		vll vss;
	//	cout << vs << endl;
		REP(i, vs.size()) {
			ll min = vs[0];
			if (i == 0) {
				vss.pb(min);
			} else {
				ll hoge = vs[i]%min;
			//	cout << hoge;
				if (hoge != 0) {
					vss.pb(hoge);
				}
			}
		}

		sort(vss.begin(), vss.end());
		
	//	cout << vss << endl;
		if (vss.size() == 1) {
			cout << vss.back() << endl;

			// cout << vss << endl;
			break;
		}
		copy(vss.begin(), vss.end(), vs.begin());
	}


}



Measured memory_bytes: 2548
#include <cstdio>
#include <algorithm>
using namespace std;
#define EPS 0.0000001
int main() {
    int t; scanf("%d",&t);
    double max_v=0.0;
    for (int i=0; i<t; i++) {
        double v=0.0, r=1.0;
        int n, m; scanf("%d%d",&n,&m);
        for (int j=0; j<m; j++) {
            int vj;
            double rj;
            scanf("%d%lf",&vj,&rj);
            v+=vj*rj;
            r-=rj;
        }
        double x=1.0, y=0.0;
        for (int j=0; j<100; j++) {
            y+=v*x;
            x*=r;
        }
        max_v=max(max_v,y);
    }
    int p, q; scanf("%d%d",&p,&q);
    double boss=0.0, br=1.0;
    for (int i=0; i<q; i++) {
        int vi;
        double ri;
        scanf("%d%lf",&vi,&ri);
        boss+=vi*ri;
        br-=ri;
    }
    double bx=1.0, by=0.0;
    for (int i=0; i<100; i++) {
        by+=boss*bx;
        bx*=br;
    }
    if (by+EPS<=max_v) puts("YES");
    else puts("NO");
}

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

int sum(vector<int> S, int N){
int countS = 0;
for(int i = 0; i < S.size(); i++){
if(S.at(i) == N){
countS++;}}
return countS;}

int main() {
int N, M;
cin >> N >> M;
vector<int> A(M);
vector<int> B(M);
for(int i = 0; i   < M; i++){
cin >> A.at(i) >> B.at(i);}
sort(A.begin(), A.end());
sort(B.begin(), B.end());
for(int i = 1; i <= N; i++){
cout << sum(A, i) + sum(B, i) << endl;}}


Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
 
    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    ll k;
    ll w,x;
    cin>>a>>b;
    cout<<a*(a-1)/2+b*(b-1)/2<<endl;

    return 0;
}


Measured memory_bytes: 3588
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

ll f(ll n){
    if(n==0)return INF;
    ll ret=0;
    while(n%2==0){
        n/=2;
        ret++;
    }
    return ret;
}

char rf(int n){
    if(n<26)return ('A'+n);
    else return ('a'+(n-26));
}

void check(stack<char>&que){
    if(que.size()<=1)return;
    char u[2];
    u[1]=que.top();
    que.pop();
    u[0]=que.top();
    que.pop();
    // cout<<u[0]<<u[1]<<endl;
    if(!(u[0]=='S' and u[1]=='T')){
        que.push(u[0]);
        que.push(u[1]);
    }else check(que);
}

bool solve(){
    string s;cin>>s;
    stack<char>que;
    rep(i,s.size()){
        que.push(s[i]);
        check(que);
        // cout<<que.size()<<endl;
    }
    cout<<que.size()<<endl;
    return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


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

int vminn(vector<int> v, int n) {
  sort(v.begin(), v.end());
  return v[n-1];
}

int main() {
  int N; cin >> N;
  vector<int> B(N-1);
  rep(i, N-1) cin >> B[i];
  
  int ans=0;
  
  ans += B[0]+B[N-2];
  rep(i, N-2) ans += min(B[i], B[i+1]);
  
  cout << ans << endl;
  
}

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

int w,h,n;
struct td{
    int x,y,i;
    td() {}
    td(int x,int y,int i):x(x),y(y),i(i) {}
    
    bool lower() const {return y==0 || x==w; }
    bool operator<(const td &rhs)const {
        if(lower()) {
            if(rhs.lower()) return x+y<rhs.x+rhs.y;
            else return true;
        } else {
            if(rhs.lower()) return false;
            else return x+y>rhs.x+rhs.y;
        }
    }
};

vector<td> arr;

bool side(int p,int v) {
    return p==0 || p==v;
}
int main() {
    scanf("%d%d%d",&w,&h,&n);
    for(int i=1;i<=n;i++) {
        int a,b,c,d;
        scanf("%d%d%d%d",&a,&b,&c,&d);
        if((side(a,w) || side(b,h)) && (side(c,w) || side(d,h))) {
            td q(a,b,i), w(c,d,i);
            if(w<q) swap(q,w);
            w.i=-w.i;
            arr.push_back(q);
            arr.push_back(w);
        }
    }

    sort(arr.begin(),arr.end());
    
    stack<int> stk;
    for(auto &v:arr) {
        if(v.i>0) stk.push(v.i);
        else {
            if(-v.i!=stk.top()) {
                puts("NO");
                return 0;
            }
            stk.pop();
        }
    }
    puts("YES");
    
    return 0;
}


Measured memory_bytes: 4852
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        s:Chars,
        t:Chars,
    }

    let mut mx = INF;
    for i in 0..s.len() {
        let mut dif = 0;
        for j in 0..t.len() {
            if i + j >= s.len() {
                dif = INF;
                break;
            }
            if s[i + j] != t[j] {
                dif += 1;
            }
        }
        mx = min(mx, dif);
    }
    println!("{}", mx);
}

const INF: i64 = 1 << 60;


Measured memory_bytes: 2148
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX = 21;

int a[MAX],n,res;

int dfs(int num,int x,int y){
  if(num == n){
    if(x < y){
      res = min(res,y-x);
    }
    else{
      res = min(res,x-y);
    }
  }
  else{
    dfs(num+1,x+a[num],y);
    dfs(num+1,x,y+a[num]);
  }
}

int main(){
  while(cin >> n ,n){
    for(int i = 0 ; i < n ; i++){
      cin >> a[i];
    }
    res = 1<<28;
    dfs(0,0,0);
    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 1156
n = int(input())
a = list(map(int, input().split()))
approved = True
for a_one in a:
    if a_one % 2 == 0:
        if not ((a_one % 3 == 0) or (a_one % 5 == 0)):
            approved = False
            break
print('APPROVED' if approved else 'DENIED')

Measured memory_bytes: 3060
N=int(input())
A=[int(x) for x in input().split()]
maxA=max(A)
minA=min(A)
ans=10**9
for i in range(minA,maxA+1):
    kouho=0
    for j in range(N):
        kouho+=(i-A[j])**2
    ans=min(ans,kouho)
print(ans)

Measured memory_bytes: 9148
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using VPII = vector<PII>;
template<typename T, typename C> using PQ = priority_queue<T, vector<T>, C>;
using Complex = complex<double>;


int N;
int mem[110][2][350];
char c[4] = { 'A', 'G', 'C', 'T' };
map<string, int> m;


void makeM(){
    char cp[5] = { ',', 'A', 'G', 'C', 'T' };
    int cnt = 0;
    rep(i, 0, 5) rep(j, 0, 5) rep(k, 0, 5) rep(l, 0, 5){
        string s;
        s.pb(cp[i]);
        s.pb(cp[j]);
        s.pb(cp[k]);
        s.pb(cp[l]);
        string sp;
        for(char x : s)
            if(x != ',') sp.pb(x);
        if(m.find(sp) == m.end()) m[sp] = cnt++;
    }
}


bool judge(string s){
    if(SIZE(s) < 3) return false;
    if(SIZE(s) == 3) return s == "AGC" || s == "GAC" || s == "ACG";
    if(s[0] == 'A' && s[2] == 'G' && s[3] == 'C') return true;
    if(s[0] == 'A' && s[1] == 'G' && s[3] == 'C') return true;
    if(s == "AGTC") return true;
    string subl = s.substr(0, 3);
    string subr = s.substr(1, 3);
    if(subl == "AGC" || subl == "GAC" || subl == "ACG") return true;
    if(subr == "AGC" || subr == "GAC" || subr == "ACG") return true;
    return false;
}


int solve(int k = 0, bool t = false, string s = ""){
    if(k == N) return !t;
    int& ret = mem[k][t][m[s]];
    if(ret != -1) return ret;
    ret = 0;
    string sp;
    if(SIZE(s) < 3) sp = s;
    else sp = s.substr(1, 2);
    rep(i, 0, 4) ret = ADD(ret, solve(k+1, t||judge(s+c[i]), sp+c[i]));
    return ret%MOD;
}


signed main(){
    cin >> N;

    rep(i, 0, N) rep(j, 0, 2) rep(k, 0, 350) mem[i][j][k] = -1;

    makeM();

    cout << solve() << endl;

    return 0;
}

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

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

	if(a >= k) a -= k;
	else if(a+b >= k){
		b -= k-a;
		a = 0;
	}else{
		a = 0;
		b = 0;
	}

	cout << a << " " << b << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int main() {
    int N; cin >> N;
    int a = 0;
    int w = 0;
    int t = 0;
    int r = 0;
    rep(i, N){
        string j; cin >> j;
        if(j == "AC") a++;
        if(j == "WA") w++;
        if(j == "TLE") t++;
        if(j == "RE") r++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << w << endl;
    cout << "TLE x " << t << endl;
    cout << "RE x " << r << endl;
}

Measured memory_bytes: 3632
local h, w, n = io.read("*n", "*n", "*n")
local t = {}

local function add(i_h, i_w)
  local idx = i_h .. ":" .. i_w --(i_h - 1) * 1000000000 + i_w
  local v = t[idx]
  if v then t[idx] = v + 1 else t[idx] = 1 end
end

local function subtask(ah, bw)
  if 3 <= bw then add(ah, bw - 2) end
  if 2 <= bw and bw < w then add(ah, bw - 1) end
  if bw < w - 1 then add(ah, bw) end
end

for i = 1, n do
  local ah, bw = io.read("*n", "*n")
  if 3 <= ah then subtask(ah - 2, bw) end
  if 2 <= ah and ah  < h then subtask(ah - 1, bw) end
  if ah < h - 1 then subtask(ah, bw) end
end

local sum = 0LL
local tbl = {}
for i = 1, 9 do tbl[i] = 0 end
for k, v in pairs(t) do
  tbl[v] = tbl[v] + 1
  sum = sum + 1LL
end
local rem = (h - 2LL) * (w - 2LL) - sum
local str = tostring(rem):gsub("LL", "")
print(str)
for i = 1, 9 do print(tbl[i]) end


Measured memory_bytes: 113036
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int  main(){
int a,b;
cin >> a >> b;

int L=b;
int R = a+b-1;
int eat;
if(R<=0) eat = R;
else if(L>=0) eat =L;
else eat = 0;
int ans = (R+L)*(R-L+1)/2-eat;
cout << ans << endl;
return 0;
}

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

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

    int n, one, two, three;
    cin >> n;
    one = n/100;
    two = (n%100)/10;
    three = (n%100)%10;
    if(one==7 || two==7 || three==7){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3660
N = int(input())
CardList = [0 for i in range(53)]
for i in range(1, N + 1):
    Mark, Rank = map(str, input().split())
    if Mark == 'S':
        CardList[int(Rank) ] = 1
    elif Mark == 'H':
        CardList[int(Rank) + 13] = 1
    elif Mark == 'C':
        CardList[int(Rank) + 26] = 1
    else:
        CardList[int(Rank) + 39] = 1
for j in range(1, 53):
    if CardList[j] == 0:
        if 1 <= j <14:
            print('S', j)
        elif 14 <= j < 27:
            print('H', j - 13)
        elif 27 <= j <40:
            print('C', j - 26)
        else:
            print('D', j - 39)



Measured memory_bytes: 5608
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
// numeric_limits<int>::max()

int main()
{
    ll A, B, T;
    cin >> A >> B >> T;
    ll times = T / A;
    cout << times * B << endl;
    return 0;
}


Measured memory_bytes: 256