akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 400010;
const int mod = 998244353,g = 3;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int x,y,k;

char sa[maxn],sb[maxn];

int fac[maxn];

int f[maxn],Ans[maxn];

int A[maxn],B[maxn];

void NTT(int *a,int f,int k){
	for(int i=0,j=0;i<k;i++){
		if(i>j)swap(a[i],a[j]);
		for(int l=k>>1;(j^=l)<l;l>>=1);
	}
	
	for(int i=1;i<k;i<<=1){int w=fexp(g,(f*(mod-1)/(i<<1)+mod-1)%(mod-1));
		for(int j=0;j<k;j+=i<<1){int e=1;
			for(int k=0;k<i;k++,e=1LL*e*w%mod){int x,y;
				x=a[j+k];y=1LL*a[j+k+i]*e%mod;
				a[j+k]=(x+y)%mod;a[j+k+i]=(x-y+mod)%mod;
			}
		}
	}
	
	if(f==-1){
		int _inv=fexp(k,mod-2);
		for(int i=0;i<k;i++)a[i]=1LL*a[i]*_inv%mod;
	}
}


void Conv(int *a,int *b,int *c){
	for(int i=0;i<k;i++)A[i]=B[i]=0;
	REP(i,0,x)A[i]=a[i],B[i]=b[i];
	NTT(A,1,k);NTT(B,1,k);
	REP(i,0,k-1)A[i]=1ll*A[i]*B[i]%mod;
	NTT(A,-1,k);
	REP(i,0,x)c[i]=A[i];
}

void Work(){
//	cout<<x<<' '<<y<<endl;
	REP(i,0,x)f[i]=fexp(fac[i+1],mod-2);
//	REP(i,0,x)cout<<f[i]<<' ';cout<<endl;
	Ans[0]=1;
	for(k=1;k<=x+x;k<<=1);
	int t=y;
	while(y){
		if(y&1)Conv(Ans,f,Ans);
		Conv(f,f,f);y>>=1;
	}
//	REP(i,0,x)cout<<Ans[i]<<' ';cout<<endl;
	int ans=0;
	REP(i,0,x)ans=(ans+Ans[i])%mod;
//	cout<<ans<<endl;
//	dbg(fac[2]);
	ans=1ll*ans*fac[x]%mod*fac[t]%mod*fac[x+t]%mod;
	iout(ans);
}

void Init(){
	scanf("%s%s",sa+1,sb+1);
	int l=strlen(sa+1);
	REP(i,1,l){
		if(sa[i]=='1'&&sb[i]=='1')x++;
		else if(sa[i]=='1')y++;
	}
	fac[0]=1;REP(i,1,l+2)fac[i]=1ll*fac[i-1]*i%mod;
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 6784
program atcoder
    implicit none
    integer(8) :: n,k,i,j
    character(len=7) :: a,b
    character(len=100) :: s
    a = "keyence"
    read*,s
    n = len_trim(s)
    do i = 0,7
        j = 7 - i
        if(i/=0)then
            b(1:i) = s(1:i)
        endif
        if(j/=0)then
            b(7-j+1:7) = s(n-j+1:n)
        endif
        if(b==a)then
            print"(a)","YES"
            stop
        endif
    enddo
    print"(a)","NO"
    stop 
contains


end program atcoder

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

int main(void)
{
  while (true)
  {
    int medal = 100;
    int seven, bar, grape, cherry, star, total;
    cin >> seven>> bar>> grape>> cherry>> star>> total;
    if ( total == 0 ) break;
    int nomal_game;
    int bonus_game;
    bonus_game = seven * 5 + bar * 3;
    nomal_game = total - bonus_game;
    //  Normal Game
    medal += seven * 15;
    medal += bar * 15;
    medal += grape * 7;
    medal += cherry * 2;
    //  Bonus Game
    medal += bonus_game * 15;
    //  Pay
    medal -= bonus_game * 2;
    medal -= (nomal_game - star) * 3;
    cout << medal << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <set>
#include <string>
#include <iostream>

int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::set<std::string> dic;
    int n;
    std::cin >> n;
    for(int i = 0; i < n; ++i){
        std::string command, str;
        std::cin >> command >> str;
        if(command == "insert"){
            dic.insert(str);
        }else
        if(command == "find"){
            std::cout << (dic.find(str) != dic.end() ? "yes" : "no") << std::endl;
        }
    }
    return 0;
}

Measured memory_bytes: 27056
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define inf 1e18
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	t=1;
//	cin>>t;
	while(t--)
	{
       ll n;
       cin>>n;
       ll x,y;
       vector< pair<int,int> > v;
       for(int i=0;i<n;i++)
       {
       	 cin>>x>>y;
       	 v.push_back(make_pair(x,y));
	   }
	   ll f=0;
	   for(int i=0;i<n-2;i++)
	   {
	   	  if(v[i].first==v[i].second && v[i+1].first==v[i+1].second && v[i+2].first==v[i+2].second)
	   	  {
	   	  	f=1;
	   	  	break;
		  }
	   }
	   if(f==0)
	   cout<<"No";
	   else
	   cout<<"Yes";
	   cout<<endl;
	}
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

signed main(){
    string s;
    int k;
    cin >> s >> k;
    int n = s.size();
    vector<int> a(n);
    rep(i, 0, n){
        a[i] = (int)('z' - s[i]) + 1;
        if(s[i] == 'a') a[i] = 0;
    }
    rep(i, 0, n){
        if(a[i] <= k){
            s[i] = 'a';
            k -= a[i];
        }
        if(k == 0) break;
    }
    if(k != 0){
        k %= 26;
        int c = s[n - 1] - 'a';
        c = (c + k) % 26;
        s[n - 1] = 'a' + c;
    }
    cout << s << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define maxn 85
#define maxs 6400
bitset<maxs*2> f[maxn][maxn];
int a[maxn][maxn];
int main(){
	int n,m,x;scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)scanf("%d",a[i]+j);
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)scanf("%d",&x),a[i][j]=abs(a[i][j]-x);
	f[0][1][maxs]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			f[i][j]|=(f[i][j-1]>>a[i][j])|(f[i][j-1]<<a[i][j]);
			f[i][j]|=(f[i-1][j]>>a[i][j])|(f[i-1][j]<<a[i][j]);
		}
	}
	int ans=80;
	for(int i=maxs;;i++)if(f[n][m][i]){ans=i-maxs;break;}
	printf("%d",ans);
	return 0;
} 

Measured memory_bytes: 10880
import numpy as np
a, b, h, m = list(map(int, input().split()))

theta_h = h / 12 * 2 * np.pi + m / 60 * 2 * np.pi /12
theta_m = m / 60 * 2 * np.pi

a_d = a ** 2
b_d = b ** 2

if theta_h < theta_m:
    deg = theta_m - theta_h
else:
    deg = theta_h - theta_m

res = (a_d + b_d - 2 * a * b * np.cos(deg)) ** 0.5

print(res)

Measured memory_bytes: 27196
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans;
  if (b < 0 && c > 0) {
    ans = b * c;
  } else if (a > 0 && d < 0) {
    ans = a * d;
  } else {
    ans = max(a * c, b * d);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define hackcyborg shresth_walia
#define ll  long long
#define ld  long double
#define pb push_back
#define mod 1000000007
#define M_PI 3.141592653589
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
ll binpow(ll a,ll b,ll m=mod) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
main()
{
     IO
     ll n,m,k;
     cin>>n>>m>>k;
     ll a[n];
     ll b[m];
     stack<ll> aw;
     for(int x=0;x<n;x++)
        cin>>a[x];
     for(int x=0;x<m;x++)
        cin>>b[x];
    ll e=0;
    ll r=0;
    ll ans=0;
    for(int x=0;x<n;x++)
        {if(e+a[x]<=k)
        {aw.push(a[x]);
        e+=a[x];
        ++r;
        }
        else
            break;
        }
    ans=max(ans,r);
    for(int x=0;x<m;x++)
    {    while(!aw.empty() && e+b[x]>k)
          {
              e-=aw.top();
              --r;
              aw.pop();
          }
        if(e+b[x]<=k)
        {
            e+=b[x];
            ++r;
            ans=max(ans,r);
        }
        else
            break;
    }
    cout<<ans;
}


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

#define FOR(i,a,b)   for(int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)  for(int i=(b)-1;i>=(a);i--)
#define rep(i,n)     for(int i=0    ;i<(n) ;i++)
#define rrep(i,n)    for(int i=(n)-1;i>=0  ;i--)
#define each(i,a,b)  for(int i=(a)  ;i<=(b);i++)
#define reach(i,a,b) for(int i=(b)  ;i>=(a);i--)
#define all(a)       (a).begin(), (a).end()
#define rall(a)      (a).rbegin(), (a).rend()

int main() {
  int i;
  cin >> i;
  cout << int(i != 1) << endl;

  return 0;
}


Measured memory_bytes: 3628
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M = [int(i) for i in input().split()]
ABS = [[int(i) for i in input().split()] for _ in range(M)]

uf = UnionFind(N+1)
for a, b in ABS:
  uf.union(a, b)

print(uf.group_count() - 2)


Measured memory_bytes: 26968
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define PB push_back
#define PPB pop_back
#define MP make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define test(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define loop(i,start,end) for(ll i=start; i<end; i++)
#define rloop(j,start,end) for(ll j=start-1; j>=end; j--)

int main()
{   
    IOS;

    ll n,W;
    cin>>n>>W;

    ll v[n+1],w[n+1],sumV=0,ans;

    loop(i,1,n+1)
    {  
        cin>>w[i]>>v[i];
        sumV+=v[i];
    }

    ll dp[sumV+1];
    loop(i,0,sumV+1)
        dp[i]=INT_MAX;

    dp[0]=0;
    // minimum weight with the items for value
    loop(i,1,n+1)
        rloop(j,sumV+1,v[i])
            dp[j]=min(dp[j],w[i]+dp[j-v[i]]);
    
    loop(i,1,sumV+1)
        if(dp[i]<=W)
            ans=i;

    d1(ans);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long int m=1000000000000;
long long int dp[100][100001];
int main()
{
	int n,maxw;
	cin >> n >> maxw;
	int w[n],val[n],i,j,k;
	for(i=0;i<n;i++)
	cin >> w[i] >> val[i];
	for(i=0;i<n;i++)
	{
		for(j=0;j<100001;j++)
		dp[i][j]=m;
	}
	for(i=0;i<n;i++)
	dp[i][val[i]]=w[i];
	for(i=1;i<n;i++)
	{
		for(j=0;j<=100000;j++)
		{
			dp[i][j]=min(dp[i-1][j],dp[i][j]);
			if(j>=val[i])
			dp[i][j]=min(dp[i][j],dp[i-1][j-val[i]]+w[i]);	
		}
	}
//	for(i=0;i<n;i++)
//	{
//		for(j=0;j<=100000;j++)
//		cout << dp[i][j] << " ";
//		cout << "\n";
//	}
	for(i=100000;i>=0;i--)
	{
		if(dp[n-1][i]<=maxw)
		{
			cout << i;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 78336
#include <iostream>

using namespace std;

int main(){
	int a;
	int b;
	int an[5000];
	int br[5000];
	cin>>a>>b;
	for(int i=0;i<a;i++){
		cin>>an[i];
	}
	for(int i=0;i<b;i++){
		cin>>br[i];
	}
	int st=0;
	for(int i=0;i<b&&st<b-i;i++){
		int bs=i;
		int pp=0;
		for(int n=0;n<a&&bs<b;n++){
			if(an[n]==br[bs]){
				pp++;
				bs++;
			}
		}
		if(st<pp)
			st=pp;
	}
	cout<<st<<endl;
}

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

int main(void){
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    
    int cnt = 0;
    int i, j, k;
    for(i = 0; i <= a; i++){
        for(j = 0; j <= b; j++){
            for(k = 0; k <= c; k++){
                if(i * 500 + j * 100 + k * 50 == x){
                    cnt++;
                }
            }
        }
    }
    
    cout << cnt << endl;
    
    return 0;
}


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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

ll powermod(ll a,ll b,ll m){
	if(b==0){
		return 1LL;
	}
	if(b%2){
		return (a*powermod(a,b-1LL,m))%m;
	}
	return powermod((a*a)%m,b/2LL,m);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in(),P=in();
	string S=in<string>();
	vector<int> M(N+1,0);
	reverse(ALL(S));
	if(P==2 || P==5){
		ll A=0;
		REP(i,N){
			if(((S[i]-'0')%P)==0){
				A += N-i;
			};
		}
		out(A);
	}
	else{
		REP(i,N){
			int V=M[i];
			int X=(S[i]-'0')*powermod(10,i,P);
			M[i+1] = (X+V)%P;
		}
		map<int,ll> C;
		REP(i,N+1){
			C[M[i]]++;
		}
		ll A=0;
		for(auto& x:C){
			A += x.second*(x.second-1LL)/2LL;
		}
		out(A);
	}
	return 0;
}


Measured memory_bytes: 1812
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    
    System.out.println(N * A >= B ? B : N * A);
  }
}

Measured memory_bytes: 20948
# when initialize get stdin
class StdinGetter
    
    # initialize
    #
    # @param [Boolean] has_header
    def initialize(has_header=false)
        @stdin = initialized_stdin(readlines)
        @header = initialized_header(has_header)
        @body = initialized_body(has_header)
    end
    
    # getter for header
    #
    # @return [String] header
    def header()
        @header
    end
    
    # getter for body
    #
    # @return [Array] body
    def body()
        @body
    end
    
    # get splited body
    #
    # @params [String] splitter
    # @return [Array] body's array
    def splited_body(splitter)
        @body.map { |line| line.split(splitter) }
    end
    
    private
    # initializer for stdin
    #
    # @param [Array] lines
    # @return [Array] 
    def initialized_stdin(lines)
        lines.nil? ? [] : lines.map{ |line| line.chomp }
    end
    
    # initializer for stdin header
    #
    # @param [Boolean] has_header
    # @return [String]
    def initialized_header(has_header)
        has_header ? @stdin[0] : []
    end
    
    # initializer for stdin header
    #
    # @param [Boolean] has_header?
    # @return [Array]    
    def initialized_body(has_header)
        has_header ? @stdin.slice(1..-1) : @stdin
    end
        
end

# HinaArare Class
class HinaArare
    
    @@arare_colors = ["P", "W", "G", "Y"]
    @@count_messages = {
        3 => "Three",
        4 => "Four"
    }
    
    # initialize
    #
    # @params [Array] arares
    def initialize(arares)
        @arares = arares
    end
    
    # get arare valiation as number
    #
    # @return [Integer]
    def arare_valiation()
        @@arare_colors.select { |color| @arares.uniq.include?(color) }.length
    end
    
    # print how many valiation arare includes
    def print_arere_counts()
        if @@count_messages.has_key?(arare_valiation)
            puts @@count_messages[arare_valiation]
        else
            puts "Invalid Arare Select"
        end
    end
    
end

# execute
stdin_getter = StdinGetter.new(true)
arares = stdin_getter.splited_body(" ")[0]

hina_arare = HinaArare.new(arares)
hina_arare.print_arere_counts

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

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;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	deque<int> a(n);
	rep(i,n){
		cin>>a[i];
	}
	vector<vector<ll>> dp(n,vector<ll>(n+1,inf));
	function<ll(int,int)> dfs=[&](int l,int r){
		if(dp[l][r]!=inf) return dp[l][r];
		if(n%2==(r-l)%2){
			if(r-l==1) return dp[l][r]=a[l];
			else return dp[l][r]=max(dfs(l+1,r)+a[l],dfs(l,r-1)+a[r-1]);
		}else{
			if(r-l==1) return dp[l][r]=-a[l];
			else return dp[l][r]=min(dfs(l+1,r)-a[l],dfs(l,r-1)-a[r-1]);
		}
	};
	cout<<dfs(0,n)<<endl;
}

Measured memory_bytes: 71040
a = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

for i in range(3):
  if a[0][i] in b and a[1][i] in b and a[2][i] in b:
    print('Yes')
    exit()
  if a[i][0] in b and a[i][1] in b and a[i][2] in b:
    print('Yes')
    exit()
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
    print('Yes')
    exit()
if a[2][0] in b and a[1][1] in b and a[0][2] in b:
    print('Yes')
    exit()
print('No')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define mod 1000000007
#define inf 9999999999999999ll
void prllknapSack(ll W, vi &wt, vi & val, ll n) 
{ 
    ll i, w; 
    ll K[n + 1][W + 1]; 
  
    // Build table K[][] in bottom up manner 
    for (i = 0; i <= n; i++) { 
        for (w = 0; w <= W; w++) { 
            if (i == 0 || w == 0) 
                K[i][w] = 0; 
            else if (wt[i - 1] <= w) 
                K[i][w] = max(val[i - 1] +  
                    K[i - 1][w - wt[i - 1]], K[i - 1][w]); 
            else
                K[i][w] = K[i - 1][w]; 
        } 
    } 
  
    // stores the result of Knapsack 
    ll res = K[n][W];     
    //printf("%lld\n", res); 
    ll result=res;
      
    w = W; 
    vi present(n,false);
    for (i = n; i > 0 && res > 0; i--) { 
          
        // either the result comes from the top 
        // (K[i-1][w]) or from (val[i-1] + K[i-1] 
        // [w-wt[i-1]]) as in Knapsack table. If 
        // it comes from the latter one/ it means  
        // the item is included. 
        if (res == K[i - 1][w])  
            continue;         
        else { 
  
            // This item is included. 
            present[i-1]=true;
           //printf("%lld ", wt[i - 1]); 
              
            // Since this weight is included its  
            // value is deducted 
            res = res - val[i - 1]; 
            w = w - wt[i - 1]; 
        } 
    } 
    ll weih=0;
    for(ll i=0;i<n;i++)
    {
    	if(present[i])
    	{
    		weih+=wt[i];
    	}
    }
    if(weih<=W)
    {
    	ll max_val=0;
    	for(ll i=0;i<n;i++)
    	{
    		if(present[i]==false)
    		{
    			if(val[i]>max_val)
    			{
    				max_val=val[i];
    			}
    		}
    	}
//        tr2(result,max_val);
    	cout<<result+max_val<<endl;
    }
    else
    {
    	cout<<res<<endl;
    }
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,t;
    cin>>n>>t;
    vi a(n);//weight
    vi b(n,0);//value
    for(ll i=0;i<n;i++)
        cin>>a[i]>>b[i];
    //knapSack(t-1,a,b,n)<<endl;
    prllknapSack(t-1,a,b,n);

}


Measured memory_bytes: 70656
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <math.h>
#include <cstdio>
using namespace std;
typedef long long int ll;
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}

int n,q;
vector<int>abc[200001];
int ans[200001]={0};
bool tf[200001];
void dfs(int p)
{
    tf[p]=1;
    if(abc[p].size())
    for(int i=0;i<abc[p].size();i++)
    {
        if(tf[abc[p][i]]==0)
        {ans[abc[p][i]]+=ans[p];
            dfs(abc[p][i]);}
    }
}
int main()
{
    
    cin>>n>>q;
    for(int i=1;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        a--;b--;
        abc[a].push_back(b);
        abc[b].push_back(a);
        tf[i]=0;
    }
    tf[0]=0;
    for(int i=0;i<q;i++)
    {
        int p,x;
        cin>>p>>x;
        p--;
        ans[p]+=x;
    }
    dfs(0);
    for(int i=0;i<n;i++)
        cout<<ans[i]<<" ";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 23680
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define scn(n) scanf("%d",&n)
using namespace std;

int main() {
	
	int k;
	cin>>k;
	
	int total=0;
	int ans=0;
	bool flag=0;
	for(int i=0;i<1e7;i++)
	{
	    total = (total*10+7)%k;
	    ans++;
	    
	    if(total==0)
	    {
	        flag=1;
	        break;
	    }
	}
	
	if(flag)
	cout<<ans;
	else
	cout<<-1;
	return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;

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

  std::cin >> N;

  int res = 0;

  for(int i=1;i<=N;++i){
      if(std::to_string(i).size() % 2 == 1){
          res += 1;
      }
  }
  
  std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

template<typename Type>
struct SegmentTree {
        vector<Type> data;
        int n;
        SegmentTree(int x) {
                n = pow(2, ceil(log2(x)));
                data.resize(2 * n - 1);
                for (int i = 0; i < 2 * n - 1; i ++) {
                        data[i] = make_pair(0, -1);
                }
        }
        Type merge(Type x, Type y) { //更新関数 (val, idx) maximum value and minimum idx
                if (x.first > y.first) {
                        return x;
                } else if (x.first < y.first) {
                        return y;
                } else {
                        return make_pair(x.first, min(x.second, y.second));
                }
        }
        void update(int k, Type p) { //k番目をpに更新する
                k += n - 1;
                data[k] = p;
                while (k > 0) {
                        k = (k - 1) / 2;
                        data[k] = merge(data[k * 2 + 1], data[k * 2 + 2]);
                }
        }
        // [l, r)
        Type query(int a, int b) { return query(a, b, 0, 0, n); }
        Type query(int a, int b, int k, int l, int r) {
                if (r <= a || b <= l) return make_pair(0, -1); //初期値
                if (a <= l && r <= b) return data[k];
                int m = (l + r) / 2;
                return merge(query(a, b, k * 2 + 1, l, m), query(a, b, k * 2 + 2, m, r));
        }
};

int main() {
        int n;
        scanf("%d", &n);
        vector<int> a(n);
        for (int i = 0; i < n; i ++) {
                scanf("%d", &a[i]);
        }
        SegmentTree<pair<int, int>> seg(n);
        for (int i = 0; i < n; i ++) {
                seg.update(i, make_pair(a[i], i));
        }
        for (int i = 0; i < a.size(); i ++) cerr << a[i] << ' '; cerr << endl;
        //for  (int i = 0; i < 2 * n - 1; i ++) {
        //        cerr << seg.data[i].first << ' ' << seg.data[i].second << endl;
        //}
        map<int, int> cnt;
        for (int i = 0; i < n; i ++) {
                cnt[a[i]] ++;
        }
        sort(a.rbegin(), a.rend());
        a.erase(unique(a.begin(), a.end()), a.end());
        //cerr << seg.query(0, 3).first << ' ' << seg.query(0, 3).second << endl;
        vector<long long> ans(n);
        int idx = n;
        int cur = 0;
        long long total = 0;
        for (;;) {
                pair<int, int> ma = seg.query(0, idx);
                total += cnt[a[cur]];
                if (cur + 1 < a.size()) ans[ma.second] += (long long) (a[cur] - a[cur + 1]) * total;
                else ans[ma.second] += (long long) a[cur] * total;
                cur ++;
                if (cur == a.size()) break;
                if (seg.query(0, ma.second).first == a[cur]) {
                        idx = ma.second;
                }
        }
        for (int i = 0; i < n; i ++) {
                printf("%lld\n", ans[i]);
        }
        return 0;
}



Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
typedef pair< int, int > Pi;

struct edge {
  int to, cost;
};

int Dijkstra(vector< vector< edge > >& info, int s, int g) { //sからgへの最短路
  typedef pair< int, int > Pi;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  vector< int > min_cost;
  min_cost.resize(info.size(), -1);
  que.push( Pi( 0, s));
  min_cost[s] = 0;
  while(!que.empty()){
    Pi p = que.top(); que.pop();
    if(p.second == g) return p.first;
    if(p.first > min_cost[p.second]) continue;
    for(int i = 0; i < info[p.second].size(); i++){
      edge& e = info[p.second][i];
      if(min_cost[e.to] == -1 || p.first + e.cost < min_cost[e.to]){
        min_cost[e.to] = p.first + e.cost;
        que.push( Pi( min_cost[e.to], e.to));
      }
    }
  }
  return -1;
}

int main()
{
  int n;
  while(cin >> n, n) {
    vector< int > a(n), b(n);
    vector< vector< edge > > graph(2 * n + 2);
    for(int i = 0; i < n; i++) {
      cin >> a[i];
    }
    for(int i = 0; i < n; i++) {
      cin >> b[i];
    }

    int Start = 2 * n;
    int Goal  = 2 * n + 1;
    graph[Start].push_back((edge){0, 0});
    graph[Start].push_back((edge){1, 0});
    if(a[n - 1] != 2) graph[n * 2 - 2].push_back((edge){Goal, 0});
    if(b[n - 1] != 2) graph[n * 2 - 1].push_back((edge){Goal, 0});

    for(int i = 0; i < n; i++) {
      if(a[i] == 2) {
        graph[i * 2].push_back((edge){i * 2 - 2, 0});
      } else if(a[i] == 0 || (a[i] == 1 && a[i + 1] != 1)) {
        for(int j = i; j < min(n, i + 3); j++) {
          graph[i * 2].push_back((edge){j * 2 + 1, 1});
        }
      } else {
        graph[i * 2].push_back((edge){i * 2 + 2, 0});
      }

      if(b[i] == 2) {
        graph[i * 2 + 1].push_back((edge){i * 2 - 1, 0});
      } else if(b[i] == 0 || (b[i] == 1 && b[i + 1] != 1)) {
        for(int j = i; j < min(n, i + 3); j++) {
          graph[i * 2 + 1].push_back((edge){j * 2, 1});
        }
      } else {
        graph[i * 2 + 1].push_back((edge){i * 2 + 3, 0});
      }
    }
    int ret = Dijkstra(graph, Start, Goal);
    if(~ret) cout << ret << endl;
    else cout << "NA" << endl;
  }
}

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

int main()
{
	int n, m, l, i, j, k;
	cin >> n >> m >> l;

	int Anm[100][100];
	int Bml[100][100];
	long Cnl[100][100] = {};
	for (i = 0; i<n; i++)
	{
		for (k = 0; k<m; k++)
		{
			cin >> Anm[i][k];
		}
	}
	for (k = 0; k<m; k++)
	{
		for (j = 0; j<l; j++)
		{
			cin >> Bml[k][j];
		}
	}

	for (i = 0; i<n; i++)
	{
		for (j = 0; j<l; j++)
		{
			for (k = 0; k<m; k++)
			{
				Cnl[i][j] += Anm[i][k] * Bml[k][j];
			}
		}
	}

	for (i = 0; i<n; i++)
	{
		for (j = 0, k = 0; j<l; j++, k++)
		{
			if (k != 0){
				cout << " ";
			}
			cout << Cnl[i][j];
		}
		cout << endl;
	}


	return 0;
}

Measured memory_bytes: 1320
n,x,y=map(int,input().split())
ans=[int(0)]*n

for i in range(1,n):
  for j in range(i+1,n+1):
    a=j-i
    if i<=x:
      if j>=y:
        a=a-(y-x-1)
      else:
        b=y-j+1+x-i
        a=min(a,b)
    else:
      if j>=y:
        b=i-x+1+j-y
        a=min(a,b)
      else:
        b=i-x+1+y-j
        a=min(a,b)
    ans[a-1]=ans[a-1]+1

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

Measured memory_bytes: 3444
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    int n, m;
    cin >> n >> m;
    vvi G(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    queue<int> q;
    q.push(0);
    vector<P> check(n, P(-1, -1)); // 親、距離
    check[0] = P(-2, 0);
    while(!q.empty()) {
        int now = q.front();
        q.pop();
        for(int ne:G[now]) {
            if(check[ne].first != -1) {
                continue;
            } 
            check[ne] = P(now, check[now].second+1);
            q.push(ne);
        }
    }

    cout << "Yes" << endl;
    rep(i, n-1) {
        cout << 1+check[i+1].first << endl;
    }
}

Measured memory_bytes: 10724
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
  long double x1, x2, y1, y2;

  cin >> x1 >> y1 >> x2 >> y2;
  printf("%Lf\n", sqrt(pow(x1-x2, 2)+pow(y1-y2, 2)));

  return 0;
}



Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;
int main(){
  double x;
  cin>>x;
  double y=floor(x/200);
  cout<<10-y;
return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int main(){
  int l[5];
  string res="Yay!";
  for(int i=0;i<5;i++){
    cin>>l[i];
  }
  int k;cin>>k;
  for(int i=0;i<5;i++){
    for(int j=0;j<5;j++){
      if(abs(l[i]-l[j])>k){
        res=":(";
        break;
      }
    }
  }
  cout<<res<<endl;
}

Measured memory_bytes: 256
/**
** 
** Last Updated: 2019/09/26 18:17:57 JST
** (c) was
**/
#include <bits/stdc++.h>
using namespace std;

int main() {
  //input
  int w,h,x,y;
  cin >> w >> h >> x >> y;

  //output
  if(w == x*2 && h == y*2)
    printf("%.11f %d\n",double(w)*double(h)/2,1);
  else
    printf("%.11f %d\n",double(w)*double(h)/2,0);
    
  return 0;
	
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int check(int);

int main() {
  int i,x[10000],n,count=0; /*x???10000?????????*/

  scanf("%d",&n);
  for(i = 0; i < n; i++) {
    scanf("%d",&x[i]);
  }
  for(i = 0; i < n; i++) {
    if(0 != check(x[i])) count++; /*?´???°?????????0??\???????????????*/
   }
  printf("%d\n",count);
  return 0;
}

int check(int x) {
  int i;
  if(x == 2) return 1;
  else if(x < 2 || x % 2 == 0) return 0;
  for(i = 3; i <= sqrt(x); i+=2) {
    if(x % i == 0) return 0;
  }
  return 1;
}

Measured memory_bytes: 628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

		while ((line = br.readLine()) != null) {

			double a = Double.parseDouble(line);
			double[] prog = new double[10];
			double sum = 0;

			prog[0] = a;
			for (int i = 1; i < 10; i++) {
				if ((i % 2) == 1) {
					prog[i] = prog[i - 1] * 2;
				} else {
					prog[i] = prog[i - 1] / 3;
				}
			}
			for (int i = 0; i < 10; i++) {
				sum += prog[i];
			}
			System.out.println(sum);
		}
	}
}

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

typedef unsigned int uint;
typedef unsigned long long ull;
const uint MOD = 998244353;
const ull LMOD = (ull(7e18) / MOD) * MOD;

const int M = 310;
string s;
int n;
int pref[M][M];
bool ok[3][M][M];

uint dp[M][M];

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> s;
	n = int(s.size());
	{
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= n; j++) {
				pref[i][j] = M;
			}
		}
		pref[0][0] = 0;
		int c0 = 0, c1 = 1, c2 = 2;
		ok[c0][0][0] = true;
		for (int k = 0; k < n; k++) {
			for (int i = 0; i <= k; i++) {
				for (int j = 0; i+j <= k; j++) {
					if (!ok[c0][i][j]) continue;
					// 直接扔掉
					ok[c1][i][j] = true;
					if (i && s[k] == '1') {
						ok[c1][i-1][j+1] = true;
					}
					if (j && s[k] == '0') {
						ok[c1][i+1][j-1] = true;
					}
					if (k+1 < n) {
						for (int zz = 0; zz < 2; zz++) {
							if (zz == s[k]-'0' || zz == s[k+1]-'0') {
								ok[c2][i + (zz==0)][j + (zz==1)] = true;
							}
						}
					}
				}
			}
			c0 = (c0+1) % 3;
			c1 = (c1+1) % 3;
			c2 = (c2+1) % 3;
			for (int i = 0; i <= k+1; i++) {
				for (int j = 0; i+j <= k+1; j++) {
					if (ok[c0][i][j] && pref[i][j] == M) {
						pref[i][j] = k+1;
					}
				}
			}
		}
	}

	ull total = 0;
	reverse(s.begin(), s.end());
	dp[0][0] = 1;
	for (int k = 0; k < n; k++) {
		for (int i = k; i >= 0; i--) {
			for (int j = k-i; j >= 0; j--) {
				if (!dp[i][j]) continue;
				int z = s[k-i-j] - '0';
				if (z == 0) {
					dp[i][j+1] += dp[i][j];
					if (dp[i][j+1] >= MOD) dp[i][j+1] -= MOD;
				} else {
					dp[i+1][j] += dp[i][j];
					if (dp[i+1][j] >= MOD) dp[i+1][j] -= MOD;
				}
			}
		}
		for (int i = 0; i <= k+1; i++) {
			for (int j = 0; i+j <= k+1; j++) {
				int rest = (k+1) - (i+j);
				if (pref[i][j] <= n-rest) {
					total += dp[i][j];
				}
			}
		}
	}
	total %= MOD;
	cout << uint(total) << '\n';
}


Measured memory_bytes: 4532
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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 (a > b) {
    a = b;
    return true;
  }
  return false;
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)

int main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll a;
  ll c;
  string b;
  cin >> a;
  cin >> b;
  b.erase(b.begin()+1);
  c = stoi(b);
  debug(c);
  // c = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0');
  ll res = a * c / 100LL;
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3632
include Math

loop do
    d, e = gets.split.map(&:to_i)
    break if d == 0

    x = nil
    if 2 * e * e <= d * d
        x = d / 2.0
    elsif d <= e
        x = d
    else
        x = (d + sqrt(2 * e * e - d * d)) / 2
    end

    x1 = x.floor
    x2 = x.ceil

    p [x1, x2].map {|x| (sqrt(x**2 + (d-x)**2) - e).abs}.min
end

Measured memory_bytes: 8716
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String num = sc.next();
        if(num.charAt(0) == '9' | num.charAt(1) == '9'){
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 21972
using System;

class Program
{
    static void Main(string[] args)
    {
        var ab = Console.ReadLine().Split(' ');
        var a = int.Parse(ab[0]);
        var b = int.Parse(ab[1]);

        if (a + b < 10)
        {
            Console.WriteLine(a + b);
        }
        else
        {
            Console.WriteLine("error");
        }
    }
}


Measured memory_bytes: 13140
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			int n = int.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int t = vs[0];
			int a = vs[1];
			int[] h = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int ans = 1;
			double min = Math.Abs(t - h[0] * 0.006 - a);
			//System.Diagnostics.Debug.WriteLine($"1:{min} = {t} - {h[0] * 0.006}");
			for (int i = 1; i < n; i++) {
				double c = Math.Abs(t - h[i] * 0.006 - a);
				//System.Diagnostics.Debug.WriteLine($"{i + 1}:{c} = {t} - {h[i] * 0.006}");
				if (min > c) {
					ans = i + 1;
					min = c;
				}
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13396
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {

	//vector<string> p;
	for (int i = 0; i < 3; i++) {
		string a;
		cin >> a;
		//p.push_back(a);
		cout << a[i];
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
from collections import deque
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    d=deque()

    alp=["a","b","c","d","e","f","g","h","i","j"]
    for i in range(1,N+1):
        if i==1:
            d.append(["a",1])
        else:
            while True:
                s=d.popleft()
                if len(s[0])!=i-1:
                    d.appendleft(s)
                    break
                else:
                    for j in range(s[1]+1):
                        if j!=s[1]:
                            d.append([s[0]+alp[j],s[1]])
                        else:
                            d.append([s[0]+alp[j],s[1]+1])

    res=[]
    l=len(d)
    for i in range(l):
        res.append(d.pop()[0])

    res.sort()
    for i in range(l):
        print(res[i])
if __name__=="__main__":
    main()

Measured memory_bytes: 23924
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		int[] x = fs.nextIntArr(n);
		
		
		int ans = 1_000_000_000;
		for(int i = 0; i <= 100; i++) {
			int total = 0;
			for(int j = 0; j < n; j++) {
				int diff = Math.abs(x[j] - i);
				total += diff * diff;
			}
			ans = Math.min(ans, total);
		}
		
		System.out.println(ans);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 21332
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        var h = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        int GetCost(int a, int b) => Math.Abs(a - b);

        var dp = new int[N];
        dp[0] = 0;
        dp[1] = GetCost(h[1], h[0]);

        for (int i = 2; i < N; i++)
            dp[i] = Math.Min(dp[i - 2] + GetCost(h[i - 2], h[i]), dp[i - 1] + GetCost(h[i - 1], h[i]));

        WriteLine(dp[N - 1]);
    }
}


Measured memory_bytes: 35812
// {{{ by shik
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REP1(i, a, b) for (int i = (a); i <= int(b); i++)
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

namespace { namespace shik {

template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" SCNd64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }

template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }

#ifdef SHIK
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) { sort(begin(v), end(v), f); v.resize(unique(begin(v), end(v)) - begin(v)); }
template<class T> inline T bit(T x, int i) { return (x >> i) & 1; }
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

// }}}

const int N=55;
int n,a[N],b[N];

bool dp[N][N][N];

void main() {
    R(n);
    REP(i,n) R(a[i]);
    REP(i,n) R(b[i]);
    vector<VI> vv;
    REP(i,n) vv.PB({a[i]});
    REP1(i,0,50) REP1(j,0,50) REP1(k,0,50) {
        if ( i==j ) dp[i][j][k]=1;
        else if ( k>0 ) dp[i][j][k]=dp[i][j][k-1]||dp[i%k][j][k-1];
    }
    REP(i,n) if ( !dp[a[i]][b[i]][50] ) {
        W(-1);
        return;
    }
    LL ans=0;
    for ( int k=50; k>=1; k-- ) {
        bool take=0;
        REP(i,n) {
            bool any=0;
            for ( int j:vv[i] ) {
                any|=dp[j][b[i]][k-1];
            }
            take|=!any;
        }
        if ( !take ) continue;
        dump(k);
        ans+=1LL<<k;
        REP(i,n) {
            int l=SZ(vv[i]);
            REP(j,l) vv[i].PB(vv[i][j]%k);
            sort_uniq(vv[i]);
        }
    }
    W(ans);
}

// {{{ main
}}
int main() { shik::main(); return 0; }
// }}}


Measured memory_bytes: 384