akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

long long dp[100111];
long long h[100111];

int main()
{
	int n, k;
	
	k = 2;
	
	cin >> n;
	
	for(int i = 1; i <= n; i++)
	{
		cin >> h[i];
		dp[i] = 1e10;
	}
	
	dp[1] = 0;
	
	for(int i = 2; i <= n; i++)
	{
		for(int j = max(1, i - k); j <= i - 1; j++)
		{
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
		}
	}
	
	cout << dp[n];
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define N 200050
inline int Pow(int x,int zs){
	int ret=1;
	for(;zs;zs>>=1,x=x*1ll*x%mod)
		if(zs&1)ret=ret*1ll*x%mod;
	return ret;
}
int f[5050][5050],n,ans,A[N],B[N],a[N],b[N];
inline int C(int n,int m){
	if(m>n||m<0)return 0;
	if(m==n||m==0)return 1;
	return A[n]*1ll*B[m]%mod*B[n-m]%mod;
}
int main(){
	for(int i=A[0]=1;i<=8000;i++)A[i]=A[i-1]*1ll*i%mod;
	B[8000]=Pow(A[8000],mod-2);
	for(int i=7999;~i;i--)B[i]=B[i+1]*(i+1ll)%mod;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i],&b[i]),f[2001-a[i]][2001-b[i]]++;
	for(int i=1;i<=4001;i++)
		for(int j=1;j<=4001;j++)
			f[i][j]=(f[i][j]+f[i-1][j]+f[i][j-1])%mod;
	for(int i=1;i<=n;i++){
		ans=(ans-C(a[i]+b[i]+a[i]+b[i],a[i]+a[i])+mod)%mod;
		ans=(ans+f[a[i]+2001][b[i]+2001])%mod;
	}
	printf("%lld\n",ans*1ll*Pow(2,mod-2)%mod);
	return 0;
}


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

vector<int> Zalgorithm(const string &s){
    int n=s.size();
    vector<int> z(n);
    z[0]=n;
    int i=1,j=0;
    while(i<n){
        while(i+j<n&&s[j]==s[i+j]) ++j;
        z[i]=j;
        if (j==0){++i; continue;}
        int k=1;
        while(i+k<n&&k+z[k]<j) z[i+k]=z[k],++k;
        i+=k,j-=k;
    }
    return z;
}

vector<int> LCP(const string &s,const string &t){
    vector<int> Z=Zalgorithm(t+s);
    for (int &i:Z) i=min(i,(int)t.size());
    return vector<int>(Z.begin()+t.size(),Z.end());
}

struct CycleDetection{
    vector<vector<int>> G;
    vector<int> seen,finished;
    stack<int> hist;
    int pos;
    CycleDetection(int n):G(n),seen(n,0),finished(n,0),pos(-1){}
    void add_edge(int u,int v){
        G[u].emplace_back(v);
    }
    void dfs(int v){
        seen[v]=1; hist.push(v);
        for (int u:G[v]){
            if (finished[u]) continue;
            if (seen[u]&&!finished[u]){pos=u; return;}
            dfs(u);
            if (pos!=-1) return;
        }
        finished[v]=1; hist.pop();
    }
    vector<int> build(int &cycle){
        for (int v=0;v<G.size();++v){
            if (!seen[v]) dfs(v);
        }
        cycle=(pos!=-1);
        vector<int> res;
        while(!hist.empty()){
            int t=hist.top(); hist.pop();
            res.emplace_back(t);
            if (t==pos) break;
        }
        return res;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S,T; cin >> S >> T;
    int s=S.size(),t=T.size(),u=s;
    string U=S;
    while(u<s+t) U+=S,u+=s;
    vector<int> lcp=LCP(U,T);
    CycleDetection CD(s);
    vector<int> deg(s,0);
    for (int i=0;i<s;++i) if (lcp[i]==t){
        CD.add_edge(i,(i+t)%s);
        deg[(i+t)%s]=1;
    }
    int cycle;
    CD.build(cycle);
    if (cycle){cout << -1 << '\n'; return 0;}
    int ans=0;
    for (int i=0;i<s;++i) if (!deg[i]){
        int now=i,cnt=0;
        while(lcp[now]==t){
            deg[now]=1;
            (now+=t)%=s; ++cnt;
        }
        ans=max(ans,cnt);
    }
    cout << ans << '\n';
}

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

ll N, M;
vector<bool> visited(50, false);
vector<vector<ll>> m(50, vector<ll>(50, 0));
vector<ll> A;
vector<ll> B;

void dfs(ll num)
{
//      cout << "DFS = " << num << endl;
        visited[num] = true;

        for (int i = 0; i < N; ++i) {

                if (m[num][i] == 1) {
                        if (visited[i] == true) continue;
                        else dfs(i);
                }
        }
}

int main()
{
        cin >> N >> M;
        for (int i = 0; i < M; ++i) {
                ll a, b; cin >> a >> b;
                A.push_back(a-1);
                B.push_back(b-1);
                m[a-1][b-1] = 1;
                m[b-1][a-1] = 1;
        }
        ll ans = 0;
        for (int i = 0; i < M; ++i) {

                for (int j = 0; j < N; ++j) visited[j] = false;

                m[A[i]][B[i]] = 0;
                m[B[i]][A[i]] = 0;

                dfs(0);

                m[A[i]][B[i]] = 1;
                m[B[i]][A[i]] = 1;

                for (int i = 0; i < N; ++i) {
                        if (visited[i] == false) {
                                ans++;
                                break;
                        }
                }

        }
        cout << ans << endl;


}


Measured memory_bytes: 256
#スイッチ、電球
n,m=list(map(int,input().split()))
con=[]
for i in range(m):
    tmp=list(map(int,input().split()))
    con.append(tmp[1:])
p=list(map(int,input().split()))

#2進に変換
def convert(x):
    li=[]
    for i in range(1,n+1):
        li.append(x%2)
        x=x//2
    return li
ans=0
for i in range(2**n):
    sw=convert(i)
    flg=True
    for j in range(m):
        lit=p[j]
        for k in con[j]:
            if sw[k-1]==1:
                if lit==1:
                    lit=0
                else:
                    lit=1
        if lit==1:
            flg=False
            break
    if flg:
        ans+=1
print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    long X = sc.nextLong();
    long t = sc.nextLong();

    if(X<=t){
	System.out.println("0");
    }else{
	System.out.println(X-t);    
    }
}
}

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using mii = std::map<int, int>;
using mll = std::map<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = 2*(int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
//const int dc[4] = {1, -1, 0,  0};
//const int dr[4] = {0,  0, 1, -1};
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T, typename U, typename V> inline
ostream& operator<<(ostream &o, tuple<T,U,V> &p)
{
    return o << "{" << get<0>(p) << "," << get<1>(p) << "," << get<2>(p) << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }

template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    string s;
    cin >> s;
    int k;
    cin >> k;

    string abc = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";

    int n = s.size();

    irep(i, n) {
        int x = 26-(s[i]-'a');
        if(s[i] != 'a' && k >= x) {
            k-=x;
            s[i] = 'a';
        }
    }

    if(k) {
        int i = 0;
        while(abc[i] != s[n-1]) {
            i++;
        }
        s[n-1] = abc[i+((k-1)%26)+1];
    }
    cout  << s << endl;
    return 0;
}

/*atcoder*/


Measured memory_bytes: 3660
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef pair<int,int> P;
#define fr first
#define sc second
#define INFTY ( 1 << 28 )
int W,H,mas[10][10],f,m,o,ret;
int min_cost[10][10][50];
void solve(int y,int x,int bit,int air,int cost){
  if(air <= 0) return;
  if(!(bit >> x & 1)){
    if(mas[y][x] > 0) air = min(m,air + mas[y][x]);
    else cost -= mas[y][x];
    bit |= 1 << x;
  }
  if(cost > f || min_cost[y][x][air] <= cost) return;
  min_cost[y][x][air] = cost;
  if(y == H - 1){
    ret = min(ret,cost);
    return;
  }
  solve(y+1,x,0,air-1,cost);
  if(x + 1 < W) solve(y,x+1,bit,air-1,cost);
  if(x - 1 >= 0) solve(y,x-1,bit,air-1,cost);
}
int main(){
  while(cin >> W >> H , W){
    fill_n(min_cost[0][0],5000,INFTY);
    cin >> f >> m >> o;
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
        cin >> mas[i][j];
      }
    }
    ret = INFTY;
    for(int i = 0 ; i < W ; i++) solve(0,i,0,o-1,0);
    if(ret == INFTY) cout << "NA" << endl;
    else cout << ret << endl;
  }
}

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

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 D = 0;
	SINT32 ANS = 0;


	cin >> D;
	cin >> N;
	
	if (N==100) {
		N = 101;
	}

	ANS = N * pow(100,D);

	cout << ANS << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	a := nextLine()
	arr := strings.Split(a, " ")
	x, _ := strconv.Atoi(arr[0])
	y, _ := strconv.Atoi(arr[1])

	num := 4*x - y
	if num < 0 || num%2 != 0 || num/2 > x {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}


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

ll gcd(ll a,ll b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

ll kaizyou(ll N){
  ll num=1;
  for(ll i=1;i<=N;i++){
  num*=i;
  }
  return num;
}

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

int main(){
  int N;
  cin >> N ;
  vector<int>d(N+1);
  rep(i,N){
    cin>> d[i+1];
  }
  sort(d.begin(),d.end());
  cout << d.at(N/2+1)-d.at(N/2) << endl;
}
      
  
  
  

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> C(N - 1), S(N - 1), F(N - 1);
  for (int i = 0; i < N - 1; ++i) cin >> C[i] >> S[i] >> F[i];
  for (int i = 0; i < N; ++i) {
    int now = 0;
    for (int j = i; j < N - 1; ++j)
      now = max(S[j], (now + F[j] - 1) / F[j] * F[j]) + C[j];
    cout << now << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

int intceil(int a, int b) {
    return (a + (b - 1)) / b;
}

signed main() {
    cin >> H >> A;
    cout << intceil(H, A) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef     long long               ll;
typedef     vector<ll>              vll;
#define     meme(s)                 memset(s,0,sizeof(s))
#define     rall(s)                 s.rbegin(),s.rend()
#define     i(x)                    scanf("%lld",&(x))
typedef     unordered_map<ll,ll>    mll;
#define     pb                      push_back
#define     in2(x,y)                i(x),i(y)
#define     EL                      cout<<'\n'
#define     fio                     ios_base::sync_with_stdio(false),cin.tie(NULL)
#define     all(s)                  s.begin(),s.end()
typedef     unordered_map<ll,vll>   circuit;
typedef     unordered_map<ll,bool>  is;
const ll    MOD=                    1e9+7;
#define     no                      cout<<"NO\n"
#define     yes                     cout<<"YES\n"
#define     fr(n,x)                 for(int n=0;n<x;n++)
#define     pf(x)                   printf("%lld\n",(x))
const ll    mx=                     2e7;
#define     segtree                 ll L=2*node,R=L+1,mid=(l+r)/2
#define     cs(n)                   printf("Case %lld: ",(n))
typedef     pair<ll,ll>             pll;
typedef     set<ll>                 sll;
#define     X                       first
#define     Y                       second
vector<bool>                        pr(mx,1);
void sv()                           {pr[1]=0;for(ll n=2;n*n<=mx;n++){if(pr[n]){for(ll k=2*n;k<mx;k+=n)pr[k]=0;}}}
ll bit[mx];
void up( ll ind,ll vl)            {while (ind<mx){bit[ind]+=vl;ind+=ind&(-ind);}} //BIT update
ll qr( ll ind)              {ll res=0;while(ind){res+=bit[ind];ind-=ind&(-ind);}return res;} //BIT query
#define T(j) ll t;i(t);for(ll j=1;j<=t;j++)

ll f(ll x)
{
    ll p=sqrt(1+8*x)-1;
    return p/2;
}

void solve()
{
    ll x;
    i(x);
    mll pw;
    sll p;
    while (x%2==0)
    {
        pw[2]++;
        p.insert(2);
        x/=2;
    }
    for(ll n=3;n*n<=x;n+=2)
    {
        if(x%n==0)
        {
            p.insert(n);
            while (x%n==0)
            {
                pw[n]++;
                x/=n;
            }
        }
    }
    if(x>1)
    {
    	p.insert(x);
    	pw[x]++;
    }
    ll res=0;
    for(auto j:p)
    {
    	//cout<<j<<' '<<pw[j]<<'\n';
        res+=f(pw[j]);
    }
    pf(res);
}

int main() {
    //T(n)
    //cs(n),
    solve();

}


Measured memory_bytes: 5456
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n)  for(int i=0;i<n;i++)
#define per(i,n)  for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    bool flag1 = false, flag2 = false;
    rep(i,3){
        if (s[i] == 'A') flag1 = true;
        if (s[i] == 'B') flag2 = true;
    }
    if (flag1 && flag2) cout << "Yes";
    else cout << "No";
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}

vector< int > divisor(int n) {
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret),greater<int>());
  return (ret);
}

signed main(){
  int n;cin>>n;double a[100];rep(i,n)cin>>a[i];
  double ans = 0;
  rep(i,n){
    ans += 1/a[i];
  }
  cout << std::setprecision(9) << 1/ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<cmath>

#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e12

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; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    string s;
    cin >> s;
    ll o[2];
    ll e[2];
    o[0] = 0;
    o[1] = 0;
    e[0] = 0;
    e[1] = 0;
    rep(i, s.size()){
        if(i % 2==0){
            if(s[i]=='0') e[0]++;
            else e[1]++;
        }else{
            if(s[i]=='0') o[0]++;
            else o[1]++;
        }
    }
    
    ll ans1, ans2;
    ll ans;
    ans1 = e[1] + o[0];
    ans2 = e[0] + o[1];
    ans = min(ans1, ans2);
    cout << ans;

}

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

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

void solve(){
	//code
	int n,f=0;
	cin>>n;
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			if(i*j==n) {
				f=1;
				break;
			}
		}
	}
	if(f==1) cout<<"Yes";
	else cout<<"No";
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	solve();
 	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

vi v[10][6];

pair<pii, int> chk(int n) {
	vi v1;
	while(n > 0) {
		v1.pb(n % 10);
		n /= 10;
	}
	reverse(all(v1));
	for(int i = 1; i < v1.size(); i++) {
		if(abs(v1[i] - v1[i - 1]) > 1) {
			return {{0, -1}, 0};
		}
	}
	return {{1, v1[0]}, v1.size()};
}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int k;
	cin >> k;
	int cnt = 0;
	vi res;
	for(int i = 1; i < 100000; i++) {
		pair<pii, int> x = chk(i);
		if(x.fi.fi) {
			if(x.se == 5) {
				res.pb(i);
			}
			cnt++;
			v[x.fi.se][x.se].pb(i);
			if(cnt == k) {
				cout << i;
				return 0;
			}
		}
	}
	for(int i = 1; i <= 5; i++) {
		for(int j = 1; j <= i - 1; j++) {
			for(auto it : v[1][j]) {
				v[0][i].pb(it);
			}
		}
	}
	for(int j = 1; j <= 5; j++) {
		for(auto it : res) {
			int cur = it % 10;
			for(int i : {cur - 1, cur, cur + 1}) {
				if(i <= 9 && i >= 0) {
					cnt += (int)v[i][j].size() + (i == 0);
					if(cnt >= k) {
						cnt -= ((int)v[i][j].size() + (i == 0));
						int left = k - cnt;
						cout << it;
						if(i == 0 && left == 1) {
							cout << string(j, '0');
						}
						else if(i == 0) {
							cout << v[i][j][left - 2];
						}
						else {
							cout << v[i][j][left - 1];
						}
						return 0;
					}
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,st,en,h) for(int i=st; i<=en; i+=h)
#define eb emplace_back
#define pri1(a) cout<<a<<'\n'
#define pri2(a,n) rep(i,n)cout<<a[i]<<'\n'
#define pri3(a,n) rep(i,n)cout<<a[i]<<(i!=n-1?' ':'\n')
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T>
vector< T > divisor(T n) {
  vector< T > ret;
  for(T i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int n,m,_,x,y,q;
string s;

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

	cin>>n; V(int)a(n,0),i1,i2; rep(i,n)cin>>a[i]; map<int,int> p;
  i1=divisor(a[0]); i2=divisor(a[1]);
  for(auto e:i1)p[e]++; for(auto e:i2)p[e]++;
  rep(i,n-2){
    for(P e:p){
      if(!e.second)continue;
      if(a[i+2]%e.first)p[e.first]--;
    }
  }
  int ans=1;
  for(P e:p){if(e.second)cmax(ans,e.first);}
  END
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int a[3];
	for(int i=0;i<3;i++) scanf("%d",a+i);
	sort(a,a+3);
	if(a[0]==5&&a[1]==5&&a[2]==7) printf("YES\n");
	else printf("NO\n");
}


Measured memory_bytes: 128
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        int x = sc.nextInt(), y = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
        PriorityQueue<Node> q = new PriorityQueue<>();
        int xy = x + y;

        for (int i = 0; i < a; i++) {
            q.add(new Node(sc.nextInt(), 0));
        }
        for (int i = 0; i < b; i++) {
            q.add(new Node(sc.nextInt(), 1));
        }
        for (int i = 0; i < c; i++) {
            q.add(new Node(sc.nextInt(), 2));
        }

        long ans = 0;
        while (xy > 0) {
            Node cur = q.remove();
            switch (cur.type) {
                case 0:
                    if (x > 0) {
                        ans += cur.v;
                        x--;
                        xy--;
                    }
                    break;
                case 1:
                    if (y > 0) {
                        ans += cur.v;
                        y--;
                        xy--;
                    }
                    break;
                case 2:
                    ans += cur.v;
                    xy--;
            }
        }

        out.println(ans);
        out.flush();
    }

    class Node implements Comparable<Node> {

        long v;
        int type;
        Node(long v, int type) {
            this.v = v;
            this.type = type;
        }

        @Override
        public int compareTo(Node o) {
            if (v == o.v) {
                return type - o.type;
            }
            return Long.compare(o.v, v);
        }
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 105028
/** @Date    : 2017-05-06 19:55:37
  * @FileName: A.cpp
  * @Platform: Windows
  * @Author  : Lweleth (SoundEarlf@gmail.com)
  * @Link    : https://github.com/Lweleth
  * @Version : $Id$
  */
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int ,int>
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std;

const int INF = 0x3f3f3f3f;
const int N = 1e5+20;
const double eps = 1e-8;

LL rep(LL a, LL b, LL c, LL k)
{
	if((a % 2) || (b % 2) || (c % 2))
		return k;
	else if((b+c)/2 == a && (a+c)/2 == b && (a+b)/2 == c)
		return k;
	return rep((b+c)/2, (a+c)/2, (a+b)/2, k + 1);
}

int main()
{
	LL a, b, c;
	scanf("%lld%lld%lld", &a, &b, &c);
		/*if(a % 2 || b % 2 || c % 2)
			printf("-1\n");
		else if((b+c)/2 == a && (a+c)/2 == b && (a+b)/2 == c)
			printf("-1\n");
		else 
			printf("%lld\n", rep(a, b, c, 0));*/
		LL x , y, z;
		LL cnt = 0;
		while(!(a % 2 || b % 2 || c % 2))
		{
			x = (b + c) / 2;
			y = (a + c) / 2;
			z = (a + b) / 2;
			cnt++;
			if(a == x && b == y && c == z)
			{
				cnt = -1;
				break;
			}
			a = x, b = y, c = z;
		}
		printf("%lld\n", cnt);
    return 0;
}

Measured memory_bytes: 256
#! env python
# -*- coding: utf-8 -*-

import os
import sys


# atcoder.main
# Date: 2020/06/18
# Filename: main 
# Author: acto_mini

def main():
    x1, x2, x3, x4, x5 = map(int, input().split())
    list = []
    list.append(x1)
    list.append(x2)
    list.append(x3)
    list.append(x4)
    list.append(x5)
    for i, x in enumerate(list):
        if x == 0: print(i+1)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 61952
s = input()
x,y = map(int,input().split())
k = 0
data = [[],[]]
f = 0
p = 1
for s_ in s:
    if p==1 and s_=='F':
        x -= 1
        continue
    p = 0
    if s_ == 'T':
        if f:
            data[k].append(f)
        k = (k+1)%2
        f = 0
    else:
        f += 1
if f:
    data[k].append(f)

nx = sum(data[0])
ny = sum(data[1])

if nx<x or ny<y:
    print('No')
    exit()

dpx = [set() for _ in range(len(data[0])+1)]
dpy = [set() for _ in range(len(data[1])+1)]
dpx[0] |= {0}
dpy[0] |= {0}

for i in range(len(data[0])):
    k = data[0][i]
    for m in dpx[i]:
        dpx[i+1] |= {m+k,m-k}

for i in range(len(data[1])):
    k = data[1][i]
    for m in dpy[i]:
        dpy[i+1] |= {m+k,m-k}

if x in dpx[-1] and y in dpy[-1]:
    print('Yes')
else:
    print('No')

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

using ll = long long;
ll modinv(ll a, ll m) {
	assert(m > 0);
	if (m == 1) return 0;
	a %= m;
	if (a < 0) a += m;
	assert(a != 0);
	if (a == 1) return 1;
	return m - modinv(m, a) * m / a;
}

template <int MOD_> struct modnum {
private:
	int v;
public:
	static const int MOD = MOD_;

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int () const { return v; }
	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum operator ~ () const {
		modnum res;
		res.v = modinv(v, MOD);
		return res;
	}

	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= (~o);
	}

	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};

using num = modnum<int(1e9)+7>;


int main(){
	int n, m;
	cin >> n >> m;
	string s;
	cin >> s;
	vector<int> q;
	for(int i = 0; i < m; i++){
		q.push_back((s[i] == 'R') ^ (s[0] == 'R'));
	}
	int nonzero = 0;
	for(int x : q){
		if(x > 0) nonzero = 1;
	}
	if(!nonzero){
		vector<num> fib = {0, 1};
		while(fib.size() <= n+1){
			fib.push_back(fib[fib.size()-1] + fib[fib.size()-2]);
		}
		cout << int(fib[n+1] + fib[n-1]) << '\n';
		exit(0);
	}
	int constraint = 1e8;
	int cur = 0;
	int st = 1;
	for(int x : q){
		if(x == 1){
			if(st){
				if(cur % 2 == 1){
					constraint = min(constraint, cur);
				} else {
					constraint = min(constraint, cur + 1);					
				}
			} else {
				if(cur % 2 == 1){
					constraint = min(constraint, cur);
				}
			}
			cur = 0;
			st = 0;
		} else {
			cur += 1;
		}
	}
	if(n & 1){
		cout << 0 << '\n';
		exit(0);
	}
	n /= 2;
	constraint = (constraint + 1) / 2;
	vector<num> dp(n+1, 0);
	vector<num> dpsum(n+1, 0);
	dp[0] = 1;
	dpsum[0] = 1;
	for(int i = 1; i <= n; i++){
		dp[i] = dpsum[i-1];
		if(i-1-constraint >= 0) dp[i] -= dpsum[i-1-constraint];
		dpsum[i] = dpsum[i-1] + dp[i];
	}
	num ans = 0;
	for(int i = 1; i <= constraint; i++){
		if(i <= n){
			ans += dp[n - i] * (2 * i);
		}
	}
	cout << int(ans) << '\n';
}

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

int k,s;

int main(){
  int cnt = 0;
  cin>>k>>s;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
        if (0<=s-i-j && s-i-j<=k) cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
s = input()
t = input()
dic1 = {}
dic2 = {}

for i in range(len(s)):
    if s[i] in dic1.keys():
        if dic1[s[i]]!=t[i]:
            print("No")
            exit()
    else:
        dic1[s[i]] = t[i]

for i in range(len(t)):
    if t[i] in dic2.keys():
        if dic2[t[i]]!=s[i]:
            print("No")
            exit()
    else:
        dic2[t[i]] = s[i]

print("Yes")


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

int main() {
  string S;
  cin >> S;
  string s1 = "";
  string s2 = "";
  int cs1 = 0, cs2 = 0;
  for (int i = 0; i < 4; i++) {
    if (S[i] != s1[0] && s1.empty()) {
      s1 = S[i];
    } else if (S[i] == s1[0]) {
      cs1++;
    } else if (S[i] != s2[0] && s2.empty()) {
      s2 = S[i];
    } else if (S[i] == s2[0]) {
      cs2++;
    }
  }
  if (cs1 == 1 && cs2 == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;

}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	cout.tie(NULL);
	int N, K;	cin >> N >> K;
	vector<int> a(N);
	for (int i = 0; i < N; ++i)
		cin >> a[i];
	sort(a.begin(), a.end());
	int sum = 0;
	for (int i = 0; i < K; i += 1) {
		sum += a[i];
	}
	cout << sum << '\n';
	return 0;
}

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

int main(){
    ll a,b,x;
    cin >> a >> b >> x;
    
    ll sita;
    if(a == 0){
        sita = -1;
    }else{
        sita = (a-1)/x;
    }
    
    ll ue = b/x;
    
    
    //cout << sita << endl;
    
    cout << ue - sita << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    public class Prog
    {
        public static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Prog().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            var r = cin.ReadInt;
            var g = cin.ReadInt;
            var b = cin.ReadInt;
            var n = cin.ReadInt;

            var ans = 0L;

            for (int ri = 0; ri * r <= n; ri++)
            {
                for (int gi = 0; ri * r + gi * g <= n; gi++)
                {
                    if ((n - ri * r - gi * g) % b == 0)
                    {
                        ans++;
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; } }
    }
}


Measured memory_bytes: 11220
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        int sum = 0;
        for (int i = 1; i <= n; i++) {
            int sumOfDigits = findSumOfDigits(i);
            if (a <= sumOfDigits && sumOfDigits <= b) {
                sum += i;
            }
        }
        System.out.println(sum);
    }

    public static int findSumOfDigits(int num) {
        int sum = 0;
        while(num > 0) {
            sum += num % 10;
            num /= 10;
        }
        return sum;
    }
}

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

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

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

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

int main() {
  char a;
  cin >> a;

  for (char i = 'a'; i <= 'z'; ++i) {
    if (a == i) {
      cout << "a" << endl;
      return 0;
    }
  }
  cout << "A" << endl;
  return 0;
}


Measured memory_bytes: 3536
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iomanip>

using namespace std;

typedef long long ll;

ll calc(ll a, ll b)
{
	return b == 0 ? 0 : calc(b, a % b) + b * (a / b);
}

int main()
{
	ll n, x;
	cin >> n >> x;

	cout << 3 * calc(n - x, x) << endl;
}

Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
int main() {
	int n, a, min = 0, max = 0, color[9] = {0};
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		for (int j = 0; j < 9; j++) {
			if (400 * j <= a && (a < 400 * (j + 1) || j == 8)) {
				color[j]++;
			}
		}
	}
	for (int i = 0; i < 8; i++) {
		if (color[i] != 0) {
			min++;
			max++;
		}
	}
	if (min == 0) {
		min = 1;
	}
	max += color[8];
	printf("%d %d\n", min, max);
	return 0;
}

Measured memory_bytes: 128
//AOJ-GRL-2-A
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

#define MAX_E 100000

struct UnionFind{
    vector<int> par;
    vector<int> siz;

    UnionFind(int n){
        init(n);
    }

    //n要素で初期化
    void init(int n){
        par.resize(n);
        siz.resize(n);
        for(int i = 0; i < n; i++){
            par[i] = i;
            siz[i] = 1;
        }
    }

    //木の根を求める
    int root(int x){
        if(par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    //xとyの属する集合を併合
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
    }

    bool same(int x, int y){
        return root(x) == root(y);
    }

    int size(int x){
        return siz[root(x)];
    }
};

struct edge { int u, v, cost; };//辺の張り型 : es[i] = edge{u, v, cost}

bool comp(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;//不等号を逆にすると、最大全域木を求められる,
}

edge es[MAX_E];
int V, E;

int kruskal(){
    sort(es, es + E, comp);
    UnionFind uf(V);
    int res = 0;
    for(int i = 0; i < E; i++){
        edge e = es[i];
        if(!uf.same(e.u, e.v)){
            uf.unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

signed main(){
    cin >> V >> E;
    int s,t,w;
    REP(i,E){
        cin >> s >> t >> w;
        es[i] = edge{s, t, w};
    }
    cout << kruskal() << endl;
    return 0;
}


Measured memory_bytes: 4300
from itertools import accumulate

n, k = list(map(int, input().split()))
s = input()

s_num = []

prev = s[0]
cnt = 0
for c in s:
    if prev == c:
        cnt += 1
    else:
        s_num.append(cnt)
        cnt = 1
    prev = c
s_num.append(cnt)

if prev == '0':
    s_num.append(0)

if s[0] == '0':
    s_num = [0] + s_num
if s[-1] == '0':
    s_num = s_num + [0]

w = 2 * k + 1

if len(s_num) <= w:
    print(n)
else:

    acc = [0] + list(accumulate(s_num))
    res = [acc[i+w] - acc[i] for i in range(0, len(acc) - w, 2)]

    # print(s)
    # print(s_num)
    # print(acc)
    print(max(res))


Measured memory_bytes: 10608
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double w = sc.nextDouble();
        double h = sc.nextDouble();
        double x = sc.nextDouble();
        double y = sc.nextDouble();
        double ans = w * h / 2;
        int ans2 = 0;
        if(x * 2 == w && y * 2 == h) ans2 = 1;
        System.out.println(ans + " " + ans2);
    }
}

Measured memory_bytes: 39428
#include <stdio.h>

int main() {
    
    int n,i,j ,minj, a[100], t, c;
    c = 0;
    scanf("%d", &n);
    
    
    for (i = 0; i < n; ++i){
        scanf("%d", &a[i]);
    }
    
    for (i = 0; i < n; ++i){
        minj = i;
        for (j = i; j < n; ++j){
            if (a[j] < a[minj]) minj = j;
        }
        if (minj != i){
            t = a[i];
            a[i] = a[minj];
            a[minj] = t;
            c=c+1;
        }
    }
    
    for (i = 0; i < n; ++i){
        printf("%d",a[i]);
        if(i != n-1)putchar(' ');
    }
    
    putchar('\n');
    printf("%d\n", c);
    
    return 0;
    

}

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

const int maxn = 1e5 + 10;

int n;
int a[maxn];

int solve() {
	int ans = 0;

	map<int, int> M;

	for(int i = 1; i <= n; ++i)
		++M[a[i]];

	for(auto i: M) {
		int val = i.first;
		int cnt = i.second;

		if(cnt < val)
			ans += cnt;
		else
			ans += (cnt - val);
	}

	return ans;
}

int main() {
	cin >> n;

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

	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 5120
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<complex>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
#define EPS (long double) 1e-8
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

int main(void) {
	string s;
	cin>>s;
	int res = INF;
	bool d = true;
	char a = s[0];
	REP(i, s.size()) {
		if(s[i] != a) d = false;
	}
	if(d) res = 0;
	REP(roop, 26) {
		string s_c = s;
		REP(i, s.size()) {
			REP(j, s_c.size()) {
				if(s_c[j] == (char)('a' + roop)) s_c[j] = (char)('a' + roop);
				else if(j != s_c.size() - 1 && s_c[j + 1] == (char)('a' + roop)) s_c[j] = (char)('a' + roop);
			}
			s_c.pop_back();
			char b = s_c[0];
			bool f = true;
			REP(i, s_c.size()) {
				if(s_c[i] != b) f = false;
			}
			if(f) res = min(res, (int)i + 1);
		}
	}
	cout<<res<<endl;
}


Measured memory_bytes: 256
//
// Created by kuroneko on 2019-09-07.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>

using namespace std;

typedef long long ll;

#define INF 1000000000000009LL
#define MOD 1000000007LL

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight):src(src), dst(dst), weight(weight) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

int main() {
    int N; cin >> N;
    vector<ll> b(N-1);
    for (int i = 0; i < N-1; i++) cin >> b[i];

    ll res = b[0];
    for (int i = 0; i < N - 2; i++) {
        if (b[i] <= b[i+1]) res += b[i];
        else res += b[i+1];
    }
    res += b[N-2];
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pll pair<ll,ll>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define bp __builtin_popcountll
#define MOD  1000000007
#define MOD1 1000000006
const int N = 1000005;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
ll fact[N],inv[N];
ll modularExponentiation(ll x,ll n)
{
    int result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%MOD;
        x=(x*x)%MOD;
        n=n/2;
    }
    return result;
}
ll ncr(ll n,ll k)
{
    if(k>n)   return 0;
    ll ans = fact[n];
    ans = (ans * inv[n-k])%MOD;
    ans = (ans * inv[k])%MOD;
    return ans;
}
ll p(ll n,ll k)
{
    ll ans = (fact[n]*inv[n-k])%MOD;
    return ans;
}
void solve()
{
    fact[0] = inv[0] = 1;
    for(ll i=1;i<N;i++)  
    {
        fact[i] = (fact[i-1] * i)%MOD;
        inv[i] = modularExponentiation(fact[i],MOD-2);
    } 
    ll n,m;
    cin >> n >> m;
    ll ans = p(m,n);
    ll temp = 0;
    for(ll i=0;i<=n;i++)
    {
        ll d = ncr(n,i);
        d = (d * p(m-i,n-i))%MOD;
        if(i%2)    temp = (temp - d + MOD)%MOD;
        else       temp = (temp + d + MOD)%MOD;
    }
    ans = (ans * temp)%MOD;
    cout<<ans;
}

int main()
{
    FAST;
    ll t = 1;
  //  cin >> t;
    while(t--)
    {
        solve();
    }
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

const int MAX = 510000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(void){
    int N, K; cin >> N >> K;
    ll A[N]; rep(i, N) cin >> A[i];
    COMinit();
    ll ans = 0;

    sort(A, A+N);
    for(int i = 0; i < N; i++){
        ans = (ans - A[i]*COM(N-1-i, K-1)) % mod;
        while(ans < 0) ans += mod;
    }

    reverse(A, A+N);
    for(int i = 0; i < N; i++){
        ans = (ans + A[i]*COM(N-1-i,K-1)) % mod;    
        while(ans < 0) ans += mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12928