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

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    ArrayList<Integer> list = new ArrayList<Integer>();
    for(int i=0; i<N; i++){
      list.add(sc.nextInt());
    }
    int total = 0;
    while(N > 0){
      if(total > 0){
        total -= list.get(list.size()-1);
        list.remove(list.size()-1);
      }else{
        total += list.get(0);
        list.remove(0);
      }
      N--;
    }
    if(total < 0){
      total = Math.abs(total);
    }
    System.out.println(total);
  }
}


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



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

    int N;
    cin>>N;

    int X[N];
    rep(i,N){
        cin>>X[i];
    }
    int ans=INF;
    rep(i,101){
        int sum=0;
        rep(j,N){
            sum+=((i-X[j])*(i-X[j]));
        }
        ans=min(ans,sum);
    }
    cout<<ans<<endl;

    



}




Measured memory_bytes: 3668
def test():
    a,b = map(int,input().split())
    count = 0
    for i in range(a,b+1):
        if str(i)[0] == str(i)[4] and str(i)[1] == str(i)[3]:
            count += 1
    print(count)


if __name__ == "__main__":
    test()


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

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


Measured memory_bytes: 256
#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 <climits>
#include <cstring>
#include <cassert>


using namespace std;
//using namespace atcoder;

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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;


// edit

void solve() {
    int N;
    cin >> N;
    vector<int> A(2 * N);
    REP(i, 2 * N) cin >> A[i];
    vector<bool> z(N);
    for (int i = 0; i < N; ++i) {
        if (A[2 * i] == A[2 * i + 1]) {
            z[i] = true;
        } else {
            z[i] = false;
        }
    }

    for (int i = 1; i + 1 < N; ++i) {
        if (z[i] && z[i + 1] && z[i - 1]) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;

}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

int main(){
    int N; cin>>N;
    vector<ll> A(N);
    rep(i,N){
        cin>>A.at(i);
        if(A.at(i)==0){
            cout<<0<<endl;
            return 0;
        }

    }

    ll multiplied = 1;
    double multiplied_d = 1;

    ll large = 1000000000000000000;

    rep(i,N){
        ll original = multiplied;
        multiplied_d = (double)original*(double)A.at(i);
        multiplied = multiplied*A.at(i);

/*
        if(multiplied/A.at(i)!=original){
            cout<<-1<<endl;
            return 0;
        }
        */
       if(multiplied_d>large){
//           cout<<multiplied_d<<endl;
            cout<<-1<<endl;
            return 0;
       }
        if (multiplied>large){
 //           cout<<"case2"<<multiplied<<endl;
            cout<<-1<<endl;
            return 0;
        }

    }

cout <<multiplied<<endl;


    

    return 0;
}

Measured memory_bytes: 4052
#include <stdio.h>
#define MAX_N (10010)
#define MAX_Q (510)

int S[MAX_N];

bool linearSearch( int A[], int n, int key );


int main()
{
    int n, q;
    int ans = 0;

    scanf("%d", &n);
    for ( int i = 0; i < n; i++ ) {
	scanf("%d", &S[i]);
    }

    scanf("%d", &q);
    for ( int i = 0; i < q; i++ ) {
	int t;
	scanf("%d", &t);
	if ( linearSearch( S, n, t ) ) {
	    ans++;
	}
    }

    printf("%d\n", ans);
    
    return 0;
}


bool linearSearch( int A[], int n, int key )
{
    int i = 0;
    A[n] = key;
    while ( A[i] != key ) {
	i++;
    } 
    return (i != n);
}

Measured memory_bytes: 1064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<long long int>a(n);
  long long int total = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    total ^=a[i];
  }
  for(int i = 0; i < n; i++){
    a[i]&=~total;
  }
  sort(a.begin(),a.end(),greater<long long int>() );
  vector<long long int>b;
  for(int i = 0; i < n; i++){
    for(auto j:b){
      a[i] = min(a[i],a[i]^j);
    }
    if(a[i])b.emplace_back(a[i]);
  }
  long long int temp = 0;
  for(int i =0;i< b.size(); i++){
    temp = max(temp,temp^ b[i]);
  }
  cout << temp*2+total << endl;
}


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

int main(){
  int N;
  cin >> N;
  bool a=false;
  while(N>0){
    if(N%10==7){
      a=true;
      break;
    }
    N/=10;
  }
  if(a){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

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

typedef long long ll;

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

ll dp[100010][5];
vector<vector<int>> tos;
int law = 1000000000 + 7;

ll rec(int v, int w_b, int from)
{
	if (dp[v][w_b] != -1) return dp[v][w_b];
	ll res = 1;
	for (int cv : tos[v]) {
		if (cv == from) continue;
		if (!w_b) {
			res = res * ((rec(cv, 0, v) + rec(cv, 1, v)) % law) % law;
		} else {
			res = res * rec(cv, 0, v) % law;
		}
	}
	return dp[v][w_b] = res;
}

void Main()
{
	int N; cin >> N;
	rep(i,N) {
		vector<int> v;
		tos.push_back(v);
	}
	rep(i,N-1) {
		int x, y; cin >> x >> y;
		--x, --y;
		tos[x].push_back(y);
		tos[y].push_back(x);
	}
	memset(dp, -1, sizeof(dp));
	cout << ((rec(0, 0, -1) + rec(0, 1, -1)) % law) << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	Main();
}


Measured memory_bytes: 18416
import bisect


def main(ls):
    total = 0

    for i in range(len(ls) - 2):
        for j in range(i + 1, len(ls) - 1):
            a = ls[i]
            b = ls[j]
            left = j + 1
            num = bisect.bisect_left(ls, a + b) - left
            total += num

    print(total)


_n = input()
ls = list(sorted(map(int, input().strip().split())))

main(ls)


Measured memory_bytes: 3188
S=input()
flag1=True
flag2=True
if int(S[:2]) > 12 or int(S[:2])==0:
    flag1=False
if int(S[2:]) > 12 or int(S[2:])==0:
    flag2=False
if flag1:
    if flag2:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if flag2:
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<vc> vcc;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define in insert
#define sz(v) v.size()
#define mina(a,b) (a)=min((a),(b));
#define maxa(a,b) (a)=max((a),(b));
const int INF = 1e9 + 7;
vvi v;
ll ans;
int n,k;
void rec(int ind,int cur,int parent){
    for(auto i : v[ind]){
        if(i==parent) continue;
        ans=(ans*(ll)(k-cur))%INF;
        cur++;
        rec(i,2,ind);
    }
}

void solve(){
    cin>>n>>k;
    ans=k;
    v.resize(n+1,vi());
    for(int i = 1; i < n; i++){
        int a,b; cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    rec(1,1,-1);
    cout<<ans;
}
int main(){
    int T=1;
    //cin>>T;
    for(int i = 0; i < T; i++) solve(); 
}

Measured memory_bytes: 10368
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

vector<vector<pair<int, int>>>dat;

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

	string S;
	cin >> S;
	int N = S.size();
	int ans = 0;
	for (int i = 0; i < N;i++) {
		if (i > N - 1 - i)break;
		ans += (S[i] != S[N-1-i]);
	}
	puts(ans);

	return 0;
}

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

int main(){
    int N, D;

    cin >> N;
    cin >> D;

    vector<vector<double>> X;

    
    for(int i = 0; i < N; i++){
        vector<double> tmpVec;
        for(int j = 0; j < D; j++){
            double tmpX;
            cin >> tmpX;
            tmpVec.push_back(tmpX);
        }
        X.push_back(tmpVec);
    }

    
    int answer = 0;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            double distance = 0;
            for(int k = 0; k < D; k++){
                distance += (X[j][k] - X[i][k])*(X[j][k] - X[i][k]);
            }
            if(sqrt(distance) == (int)(sqrt(distance))){
                answer++;
            }
        }
    }
    
    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <bitset>
#include <string>
#include <vector>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#define fuck(x) cout<<"["<<x<<"]";
#define FIN freopen("input.txt","r",stdin);
#define FOUT freopen("output.txt","w+",stdout);
#pragma comment(linker,"/STACK:102400000,102400000")
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;

const int MX = 3e3 + 5;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;

struct Edge {
    int v, nxt;
} E[MX * 2];
int Head[MX], erear;
void edge_init() {
    erear = 0;
    memset(Head, -1, sizeof(Head));
}
void edge_add(int u, int v) {
    E[erear].v = v;
    E[erear].nxt = Head[u];
    Head[u] = erear++;
}

int n, A[MX];


bool DFS(int u, int f) {
    int ret = 0;
    for(int i = Head[u]; ~i; i = E[i].nxt) {
        int v = E[i].v;
        if(v == f || A[u] <= A[v]) continue;
        if(!DFS(v, u)) ret = 1;
    }
    return ret;
}

int main() {
    // FIN;
    scanf("%d", &n);
    edge_init();
    for(int i = 1; i <= n; i++) {
        scanf("%d", &A[i]);
    }
    for(int i = 1; i <= n - 1; i++) {
        int u, v;
        scanf("%d%d", &u, &v);
        edge_add(u, v);
        edge_add(v, u);
    }

    bool first = true;
    for(int i = 1; i <= n; i++) {
        if(DFS(i, -1)) {
            if(first) first = false;
            else printf(" ");
            printf("%d", i);
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 384
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
MOD = 998244353

fact = [1] * 300001
ifact = [1] * 300001
for i in range(1, 300001):
    fact[i] = (fact[i-1] * i) % MOD
    ifact[i] = pow(fact[i], MOD-2, MOD)


def nCk(n, k):
    if k < 0 or k > n: return 0
    return (fact[n] * ifact[n-k] * ifact[k]) % MOD

def solve(f):
    n, a, b, k = f.read_int_list()
    ans = 0

    for ai in xrange(n+1):
        res = k - a*ai
        if res < 0 or res%b != 0: continue
        bi = res/b
        ans = (ans + nCk(n, ai)*nCk(n, bi))%MOD

    return ans


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


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

int main(){
  string s;
  char a[2];
  cin >> s;
  for(int i = 0;i<3;i++){
    if(s[i] == '1')a[i]='9';
    if(s[i] == '9')a[i]='1';
  }
  cout << a[0]<< a[1]<< a[2];
  return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int N;
	char[] s;
	int[] a;

	public boolean check(){
		for(int i = 2;i < N;i++){
			int l = (i-1+N)%N;
			int r = (i+1)%N;

			if(s[i] == 'o'){
				if(a[i] == 0)a[r] = a[l];
				else a[r] = (a[l] == 0 ? 1 : 0);
			}else{
				if(a[i] == 0)a[r] = (a[l] == 0 ? 1 : 0);
				else a[r] = a[l];
			}
		}

		for(int i = 0;i < N;i++){
			int l = (i-1+N)%N;
			int r = (i+1)%N;

			if(s[i] == 'o'){
				if(a[i] == 0 && a[l] != a[r])return false;
				if(a[i] == 1 && a[l] == a[r])return false;
			}else{
				if(a[i] == 0 && a[l] == a[r])return false;
				if(a[i] == 1 && a[l] != a[r])return false;
			}
		}
		return true;
	}

	public void solve() {
		N = nextInt();
		s = next().toCharArray();

		for(int i = 0;i < 1 << 3;i++){
			a = new int[N];
			for(int j = 0;j < 3;j++){
				a[j] = (i>>j&1);
			}

			if(check()){
				for(int j = 0;j < N;j++){
					if(a[j] == 0){
						out.print("S");
					}else{
						out.print("W");
					}
				}
				out.println();
				return;
			}
		}

		out.println(-1);
	}
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 24532
#include<stdio.h>
int main(){
  char s[1010],t[1010];
  int i,j,n,m;
  scanf("%s %s",s,t);
  for(n=0;s[n];n++);
  for(m=0;t[m];m++);
  for(i=n-m+1;i--;){
    for(j=0;j<m;j++){
      if(s[i+j]=='?')continue;
      if(s[i+j]-t[j])goto NEXT;
    }
    for(j=0;j<m;j++)s[i+j]=t[j];
    for(j=0;j<n;j++){
      if(s[j]=='?')s[j]='a';
    }
    printf("%s\n",s);
    return 0;
  NEXT:;
  }
  printf("UNRESTORABLE\n");
  return 0;
}


Measured memory_bytes: 128
#include<iostream>

using namespace std;

int dp[100010][3];
int a[100010][3];

int main(){
  int n;
  cin >> n;
  for(int i=0;i < n;i++)for(int j=0;j < 3;j++) cin >> a[i][j];
  
  for(int i=0;i < n;i++){
    for(int j=0;j < 3;j++){
      for(int k=0;k < 3;k++){
        if(j == k) continue;
        dp[i+1][k] = max(dp[i+1][k],dp[i][j]+a[i][k]);
      }
    }
  }
  int ans = 0;
  for(int i=0;i < 3;i++) ans = max(ans,dp[n][i]);
  cout << ans << endl;
  return 0;
}

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

int main(){
  int N; cin >> N;
  int maxmove=0;
  int movetmp=0;
  int H=0;
  for(int i=0; i<N; i++){
    int tmp; cin >> tmp;
    if(i){
      if(H>=tmp){
        movetmp++;
      }else{
        maxmove=(maxmove<movetmp?movetmp:maxmove);
        movetmp=0;
      }
    }
    H=tmp;
  }
  cout << (maxmove<movetmp?movetmp:maxmove) << endl;
}

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;

  vector<double> r(N);  
  for ( int i = 0; i < N; i++ ) {
    cin >> r[i];    
  }

  vector<double> p(N);
  double ans = r[0]*2;  
  p[0] = r[0];
  for ( int i = 1; i < N; i++ ) {
    p[i] = r[i];    
    for ( int j = 0; j < i; j++ ) {
      double a = abs(r[i]-r[j]);
      double b = r[i]+r[j];      
      double d = sqrt(b*b-a*a);      
      p[i] = max(p[i], p[j]+d);      
    }
    ans = max(ans, p[i]+r[i]);    
  }

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



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

int main(){
	long int W, H, x, y;
  	cin >> W >> H >> x >> y;
  	long int result = (long int)(W * H)/2;
  	cout << result;
  	if(W % 2 == 1 && H % 2 ==1){
    	cout << ".500000";
    }else{
    	cout << ".000000";

    }
  
  	if(W % 2 == 0 && H % 2 == 0 && W / 2 == x && H / 2 == y){
    	cout << " " << 1 << endl;
    }else{
    	cout << " " << 0 << endl;
    }
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

# 最小公倍数
def gcd(a, b):
  if a < b:
      a, b = b, a
  while a % b != 0:
      a, b = b, a % b
  return b
 
# 最大公約数 
def lcm(a, b):
  y = a*b / gcd(a, b)
  return int(y)

s, t = S_MAP()

print(t+s)




Measured memory_bytes: 5144
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int MOD = 998244353;

int solveMini(const string& s)
{
    int n = s.size();
    set<string> history;
    queue<string> q;
    history.insert(s);
    q.push(s);

    while(!q.empty()){
        string t = q.front();
        q.pop();

        for(int i=0; i<n-1; ++i){
            char a = t[i];
            char b = t[i+1];
            if(a != b){
                char c = 'a' + 'b' + 'c' - a - b;
                t[i] = t[i+1] = c;
                if(history.find(t) == history.end()){
                    history.insert(t);
                    q.push(t);
                }
                t[i] = a;
                t[i+1] = b;
            }
        }
    }

    return history.size();
}

int solve(const string& s)
{
    vector<vector<int> > dp(4, vector<int>(3, 0));
    for(int i=0; i<3; ++i)
        dp[i][i] = 1;

    int n = s.size();
    for(int i=1; i<n; ++i){
        vector<vector<int> > nextDp(4, vector<int>(3, 0));
        for(int a=0; a<4; ++a){
            for(int b=0; b<3; ++b){
                for(int x=0; x<3; ++x){
                    int a2 = x;
                    if(a == 3 || a == x)
                        a2 = 3;
                    int b2 = (b + x) % 3;
                    nextDp[a2][b2] += dp[a][b];
                    nextDp[a2][b2] %= MOD;
                }
            }
        }
        dp.swap(nextDp);
    }

    int x = 0;
    bool isSame = false;
    for(int i=0; i<n; ++i){
        x += s[i] - 'a';
        x %= 3;
        if(i < n - 1 && s[i] == s[i+1])
            isSame = true;
    }
    int ans = dp[3][x];
    if(!isSame){
        ++ ans;
        ans %= MOD;
    }
    return ans;
}

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    if(s == string(n, s[0])){
        cout << 1 << endl;
        return 0;
    }

    if(n < 4)
        cout << solveMini(s) << endl;
    else
        cout << solve(s) << endl;

    return 0;
}


Measured memory_bytes: 772
A, B, C = map(int, input().split())
ans = 0

if not (A % 2 == B % 2 == C % 2):
    G = [[], []]
    for n in (A, B, C):
        G[n % 2].append(n)
    G.sort(key=lambda a: len(a))

    G[1][0] += 1
    G[1][1] += 1

    A, B, C = G[0][0], G[1][0], G[1][1]
    ans += 1

mx = max(A, B, C)
ans += (mx - A) // 2 + (mx - B) // 2 + (mx - C) // 2
print(ans)


Measured memory_bytes: 3064
using System.Linq;
using static System.Console;

class Program
{
    
    static void Main(string[] args)
    {
        var n = int.Parse(ReadLine());
        var input = ReadLine().Split(' ');
        var s = input.Select(a => int.Parse(a)).ToArray();
        var q = int.Parse(ReadLine());
        input = ReadLine().Split(' ');
        var t = input.Select(a => int.Parse(a)).ToArray();
        var cnt = 0;

        foreach (var x in t)
        {
            foreach(var y in s)
            {
                if(y == x)
                {
                    cnt++;
                    break;
                }
            }
        }
        WriteLine(cnt);
    }
    
}


Measured memory_bytes: 18252
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <map>
using namespace std;
#define ms(a, x) memset(a, x, sizeof(a))
#define fore(i, a, n) for (long long i = a; i < n; i++)
#define ford(i, a, n) for (long long i = n - 1; i >= a; i--)
#define si(a) scanf("%d", &a)
#define sl(a) scanf("%lld", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define debug(a) cout << a << endl
#define pr(a) printf("%d ", a)
#define endl '\n'
#define pi acos(-1.0)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define ull unsigned long long
#define py puts("Yes")
#define pn puts("No")
#define pY puts("YES")
#define pN puts("NO")
#define re(i, a, b) for (int i = a; i <= b; ++i)
#define de(i, a, b) for (int i = a; i >= b; --i)
const double eps = 1e-8;
inline int sgn(const double &x) { return x < -eps ? -1 : x > eps; }
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;
template <class T>
inline void cmin(T &a, T b) { ((a > b) && (a = b)); }
template <class T>
inline void cmax(T &a, T b) { ((a < b) && (a = b)); }
string s;
ll a[MAXN];
int main()
{
  ll x;
  sl(x);
  re(i,-1000,1000)
    re(j,-1000,i)
    if((ll)pow(i,5)-(ll)pow(j,5)==x)
    {
      cout<<i<<" "<<j<<endl;return 0;
    }
}


Measured memory_bytes: 4124
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int N, K, R, S, P;
    cin >> N >> K >> R >> S >> P;
    string T;
    cin >> T;
    map<char, int> mp;
    mp['r'] = P;
    mp['s'] = R;
    mp['p'] = S;
    string dp = "";
    ll ans = 0;
    rep(i, N) {
        if (i >= K && T[i] == dp[i - K]) {
            dp += "#";
            continue;
        }
        if(T[i] == 'r') {
            ans += P;
            dp += "r";
        }
        if(T[i] == 's') {
            ans += R;
            dp += "s";
        }
        if(T[i] == 'p') {
            ans += S;
            dp += "p";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    cout << (n + m + 1)/ 2;
    return 0;
}

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

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

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

void solve() {
	int n; cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int r = n - i;
		if (i >= r)break;
		ans++;
	}
	cout << ans << endl;
}


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



Measured memory_bytes: 256
while true
	h,w = gets.chomp.split(" ").map(&:to_i)
	break if h == 0 && w == 0
	h.times do |i|
		w.times do |j|
			if (i + 1) % 2 == 0
				if (j + 1) % 2 == 0
					print "#"
				else
					print "."
				end
			elsif
				if (j + 1) % 2 == 0
					print "."
				else
					print "#"
				end
			end
		end
		print "\n"
	end
	print "\n"
end

Measured memory_bytes: 8716
// ref. https://atcoder.jp/contests/jsc2019-qual/submissions/7110919

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  rep(i, n-1) {
    for (int j = i + 1; j < n; ++j) {
      // Here, we calculate the level between i and j
      int x = i^j; // xor. assert(x > 0)
      int cnt = 0; // lowest significant bit.
      while (x > 0) {
        x >>= 1;
        ++cnt;
      }
      cout << cnt;
      if (j < n-1) {
        cout << " ";
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define l long long
int main()
{
    l n;
    cin>>n;
    set<string >s;

    while(n--)
    {
        string s1;
        cin>>s1;
        s.insert(s1);

    }
    cout<<s.size()<<endl;
}


Measured memory_bytes: 19176
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#pragma comment(linker, "/STACK:400000000")

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(it=X.begin();it!=X.end();it++)
#define iss istringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sst stringstream
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

string ch[13]={ "ld", "mb", "mp", "nc", "nd", "ng", "nt", "nw", "ps", "qu", "cw", "ts" },s,t,u;
int c[40][40],n;

int main(){
	cin>>n;
    getline(cin,s);
    rep(i,n){
        getline(cin,s);
        t+=s+" ";
    }
    rep(i,t.sz-1){
        rep(j,13){
            if(t[i]==ch[j][0] && t[i+1]==ch[j][1]){
                u+='A'+j;
                i++;
                goto next;
            }
        }
        u+=t[i];
    next:;
    }
    rep(i,u.sz-1)if(u[i]!=' ' && u[i+1]!=' '){
        c[islower(u[i]) ? u[i]-'a' : u[i]-'A'+26]
        [islower(u[i+1]) ? u[i+1]-'a': u[i+1]-'A'+26]++;
    }
    rep(i,38){
        int most=-1,cha=-1;
        rep(j,38){
            if(c[i][j]>most){
                most=c[i][j];
                cha=j;
            }
        }
        if(i<26)cout<<(char)('a'+i)<<" ";
        else cout<<ch[i-26]<<" ";
        if(cha<26)cout<<(char)('a'+cha)<<" ";
        else cout<<ch[cha-26]<<" ";
        cout<<most<<endl;
    }
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
  int n,k; cin >> n >> k;
  int a,ans;
  for(int i=0;i<n;i++){
    cin>>a;
    ans+=min(a*2,abs(k-a)*2);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    s = input()
    if len(s) == 2:
        if s[0] == s[1]:
            print(1, 2)
        else:
            print(-1,-1)
        exit()
    for i in range(len(s) - 2):
        if len(set(list(s[i:i + 3]))) < 3:
            print(i + 1, i + 3)
            exit()
    print(-1, -1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9164
#include <iostream>
using namespace std;
int main() {

    int n,Y;

    cin >> n >> Y;

    int x,y,z;

    x = y = z = -1;

    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            int k = n - i - j;
            if(k<0){
                break;
            }
            if(i*10000 + j*5000 + k*1000 == Y){
                x = i;
                y = j;
                z = k;
                i = n;
                break;
            }
        }
    }

    cout << x << ' ' << y << ' ' << z << endl;

    return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
ac=[0]*N
wa=[0]*N

for i in range(M):
  p,s=input().split()
  if s=="WA" and ac[int(p)-1]==0:
    wa[int(p)-1]+=1
  elif s=="AC" and ac[int(p)-1]==0:
    ac[int(p)-1]+=1

penalty=[wa[k] for k in [i for i,j in enumerate(ac) if j!=0]]    
print("%d %d" % (sum(ac),sum(penalty)))


Measured memory_bytes: 9368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAX=3010;
ll n,m,b2[MAX],s[MAX][MAX],c[MAX][MAX],dig[MAX],co[MAX],fin,p2[MAX*MAX];
ll mk_s(ll x,ll y){
    if(x==y) return 1;
    if(y==0) return 1;
    if(s[x][y]==-1){
        s[x][y]=(mk_s(x-1,y-1)+(y+1)*mk_s(x-1,y))%m;
    }
    return s[x][y];
}
ll comb(ll x,ll y){
    if(x==y) return 1;
    if(y==0) return 1;
    if(c[x][y]==-1){
        c[x][y]=(comb(x-1,y-1)+comb(x-1,y))%m;
    }
    return c[x][y];
}
int main(){
    scanf("%lld%lld",&n,&m);
    b2[0]=2,p2[0]=1;
    for(ll i=0;i<=n;i++) for(ll j=0;j<=n;j++) c[i][j]=-1,s[i][j]=-1;
    for(ll i=1;i<=n*n;i++) p2[i]=p2[i-1]*2,p2[i]%=m;
    for(ll i=1;i<=n;i++) b2[i]=b2[i-1]*b2[i-1],b2[i]%=m;
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=n-i;j++) dig[i]+=mk_s(n-i,j)*p2[i*j]%m,dig[i]%=m;
        co[i]=comb(n,i);
    }
    for(ll i=0;i<=n;i++){
        if((n-i)%2) fin-=b2[i]*dig[i]%m*co[i]%m,fin+=m;
        else fin+=b2[i]*dig[i]%m*co[i]%m;
        fin%=m;
    }
    printf("%lld\n",fin);
}


Measured memory_bytes: 212608
import sys
r=sys.stdin.readline
for e in iter(r,'0\n'):
 R=[[]for _ in[0]*-~int(e)]
 for _ in[0]*int(r()):
  a,b=map(int,r().split())
  R[a]+=[b];R[b]+=[a]
 for m in R[1][:]:R[1]+=R[m]
 print(len({*R[1]}-{1}))


Measured memory_bytes: 6296
#include <atcoder/all>
#include <iostream>
using namespace std;
int main() {
    int t; cin >> t;
    while (t--) {
        int n, m, a, b; cin >> n >> m >> a >> b;
        cout << atcoder::floor_sum(n, m, a, b) << endl;
    }
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));
#define pb push_back

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    string S,T;
    cin>>S>>T;
    ll a=S.size();
    rep(i,a){
        if(S[i]!=T[i]){
            cN;
            return 0;
        }
    }
    if(a+1==T.size()){
        cY;
    }else{
        cN;
    }
}


Measured memory_bytes: 3632
H,W,K=map(int,input().split())
dp=[[0]*(W+1) for _ in range(H+1)]
dp[0][0]=1
mod=10**9+7

for h in range(H):
  for b in range(1<<(W-1)):
    if "11" in bin(b):continue
    b<<=1
    for w in range(W):
      if b&(1<<w):
        dp[h+1][w]+=dp[h][w-1]
      elif b&(1<<(w+1)):
        dp[h+1][w]+=dp[h][w+1]
      else:
        dp[h+1][w]+=dp[h][w]
      dp[h+1][w]%=mod
    
print(dp[H][K-1]%mod)

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

int main(){
  int N;
  cin >> N;
  bool can=false;
  for(int i=0;i<26;i++){
    for(int j=0;j<15;j++){
      if(4*i + 7*j == N){
        can=true;
        break;
      }
    }
    if(can) break;
  }
  
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}
      


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
const int Max_N(100050);

namespace io
{
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush (){fwrite (obuf, 1, oS - obuf, stdout);oS = obuf;}
	inline void putc (char x){*oS ++ = x;if (oS == oT) flush ();}
	template <class I>
	inline void gi (I &x) {for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;}
	template <class I>
	inline void print (I x){
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;while(x) qu[++ qr] = x % 10 + '0',  x /= 10;while (qr) putc (qu[qr--]);}
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io::gi;
using io::putc;
using io::print;

namespace G
{
	const int Max_V(Max_N * 2);
	const int Max_E(Max_N * 10);
	const int INF(0X3F3F3F3F);
	int V, S, T, Head[Max_V], Total, To[Max_E], Next[Max_E], Cap[Max_E];
	inline void Add_Edge(int tot, int s, int t, int c)
	{
		To[tot] = t, Next[tot] = Head[s], Head[s] = tot, Cap[tot] = c;
	}
	inline void Add_Link(int s, int t, int c1, int c2 = 0)
	{
		Total += 2, Add_Edge(Total, s, t, c1), Add_Edge(Total ^ 1, t, s, c2);
	}
	int Cur[Max_V], Dist[Max_V], Q[Max_V];
	bool BFS()
	{
		for (int i = 1;i <= V;++i)
			Dist[i] = 0;
		int l, r;
		Dist[Q[l = r = 1] = S] = 1;
		for (int u;l <= r;)
		{
			u = Q[l++];
			if (u == T)
				return true;
			for (int i = Head[u], v;i;i = Next[i])
				if (!Dist[v = To[i]] && Cap[i])
					Dist[Q[++r] = v] = Dist[u] + 1;
		}
		return false;
	}
	int DFS(int u, int a)
	{
		if (u == T || a == 0)
			return a;
		int Ans(0);
		for (int &i = Cur[u], v, f;i;i = Next[i])
			if (Dist[v = To[i]] == Dist[u] + 1 && (f = DFS(v, min(a, Cap[i]))) > 0)
			{
				Ans += f, Cap[i] -= f, Cap[i ^ 1] += f;
				if ((a -= f) == 0)
					break;
			}
		return Ans;
	}
	int Dinic()
	{
		int Ans(0);
		while (BFS())
		{
			for (int i = 1;i <= V;++i)
				Cur[i] = Head[i];
			Ans += DFS(S, INF);
		}
		return Ans;
	}
}

int N, P[Max_N], Q[Max_N], FP[Max_N], FQ[Max_N], CS[Max_N], CT[Max_N], Ans;

int main()
{
	gi(N);
	for (int i = 1;i <= N;++i)
		gi(P[i]), ++P[i];
	for (int i = 1;i <= N;++i)
		gi(Q[i]), ++Q[i];
	for (int i = 1;i <= N;++i)
	{
		for (int u = i;!FP[u];u = P[u])
			FP[u] = i;
		for (int u = i;!FQ[u];u = Q[u])
			FQ[u] = i;
	}
	G::V = N + N + 2, G::S = N + N + 1, G::T = N + N + 2;
	for (int i = 1;i <= N;++i)
	{
		if (P[i] == i && Q[i] == i)
		{
			++Ans;
			continue;
		}
		if (P[i] == i)
		{
			++CT[FQ[i]];
			continue;
		}
		if (Q[i] == i)
		{
			++CS[FP[i]];
			continue;
		}
		if (P[i] != Q[i])
		{
			G::Add_Link(N + FQ[i], FP[i], 1);
			continue;
		}
		G::Add_Link(FP[i], N + FQ[i], 1, 1);
	}
	for (int i = 1;i <= N;++i)
	{
		if (FP[i] == i)
			G::Add_Link(G::S, i, CS[i] + 1), G::Add_Link(i, G::T, 1), --Ans;
		if (FQ[i] == i)
			G::Add_Link(G::S, N + i, 1), G::Add_Link(N + i, G::T, CT[i] + 1), --Ans;
	}
	print(N - Ans - G::Dinic());
	return 0;
}

Measured memory_bytes: 22016
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int n, a;
	cin >> n >> a;
	int m = n/500;
	if(a < n - 500*m){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    var (N, K) = readLine()!!.split(" "). map { it.toInt() }
    var p = readLine()!!.split(" "). map { it.toInt() }
    var kitai = DoubleArray(2000)
    for (i in 1 .. 1000) {
        var k = 0.0
        for (l in 1..i) {
            k += l / i.toDouble()
        }
        kitai[i] = k
    }
    var c = 0
    var max = 0
    var maxIndex = -1
    for (i in 0 until N) {
        c += p[i]
        if (i >= K) {
            c -= p[i-K]
        }
        if (max < c) {
            max = c
            maxIndex = i
        }
    }
    var ans = 0.0
    for (i in (maxIndex - (K-1)) ..  maxIndex) {
        ans += kitai[p[i]]
    }
    println(ans)
}

Measured memory_bytes: 62072
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s;
    cin >> s;
    cout << s.at(0) + to_string(s.size()-2) + s.at(s.size()-1) << endl;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    int k;
    cin >> k;
    vector<ll> lun, f;
    for(int i = 1; i <= 9; i++){
        lun.emplace_back(i); // f.emplace_back(i);
    }
    int i = 0;
    while(lun.size() <= 100010){
//        ll first = lun[i] % (ll)pow(10, (ll)log10(lun[i]));
//        if(log10(lun[i]) < 1) first = lun[i];
        string s = to_string(lun[i]);
        ll first = s[s.length()-1] - 48;
        if(first == 0){ //1ケタ目が0
            lun.emplace_back(lun[i]*10);
            lun.emplace_back(lun[i]*10+1);
//            f.emplace_back(first);f.emplace_back(first);
        }else if(first == 9){ //1ケタ目が9
            lun.emplace_back(lun[i]*10+8);
            lun.emplace_back(lun[i]*10+9);
//            f.emplace_back(first);f.emplace_back(first);
        }
        else{
            lun.emplace_back(lun[i]*10+first-1);
            lun.emplace_back(lun[i]*10+first);
            lun.emplace_back(lun[i]*10+first+1);
//            f.emplace_back(first);f.emplace_back(first);f.emplace_back(first);
        }
        //if(i < 10) cout << first << endl;
        i++;
    }
    //rep(i, 10000) cout << lun[i] << ", " << f[i] << endl;
    cout << lun[k-1] << endl;
}




Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll n, m, R;
  cin >> n >> m >> R;
  
  vector<ll> r(R);
  for (int i = 0; i < R; i++){
    cin >> r[i];
    r[i]--;
  }

  vector<vector<ll>> dist(n, vector<ll>(n, INF));
  for (int i = 0; i < n; i++){
    dist[i][i] = 0;
  }
  for (int i = 0; i < m; i++){
    ll a, b, c;
    cin >> a >> b >> c;
    
    a--; b--;
    dist[a][b] = c;
    dist[b][a] = c;
  }
  
  for (int k = 0; k < n; k++){
    for (int i = 0; i < n; i++){
      for (int j = 0; j < n; j++){
        dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j]);
      }
    }
  }

  ll res = INF;
  sort(r.begin(), r.end());
  
  
  do {

    ll t = 0;
    for (int i = 0; i < R - 1; i++){
      t += dist[r[i]][r[i + 1]];
    }

    res = min(res, t);

  } while(next_permutation(r.begin(), r.end()));


  cout << res << endl;

  return 0;
}


Measured memory_bytes: 512