akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll INF = 1e18L+5;
int main(){
    int n;
    cin>>n;
    ll W;
    cin>>W;
    vector<int> val;
    vector<ll> weights;
    int sum_value=0;
    for(int i=0;i<n;i++){
        int a;
        ll b;
        cin>>a>>b;
        weights.push_back(a);
        val.push_back(b);
        sum_value+=b;
    }
    vector<ll> dp(sum_value+1,INF);
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=sum_value-val[i];j>=0;j--){
            dp[j+val[i]]=min(dp[j+val[i]],dp[j]+weights[i]);
        }
    }
    int ans=0;
    for(int i=0;i<sum_value+1;i++){
        if(dp[i]<=W){
            ans = max(ans,i);
        }
    }
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int right = b;
		int left = a;
		if (a > b) {
			right = a;
			left = b;
		}
		int ret = right - (left + W);
		if (ret < 0) {
			System.out.println(0);
			return;
		}
		System.out.println(ret);
	}

}

Measured memory_bytes: 20692
#include <iostream>
#include <string>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;

bool isOK(int index, int key,vector<int> &A)
{
	if(A[index] >= key)return true;
	else return false;
}

int binsrch(vector<int> &a,int key) {
      int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key,a)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main()
{
	int n;cin >> n;
	vector<int> l(n);
	rep(i,n)cin >> l[i];
	sort(l.begin(),l.end());
	int count=0;
	for(int i=0;i<(n-2);i++)
		for(int j=i+1;j<(n-1);j++)
		{
			int find = binsrch(l,l[j]+l[i]);
			//if(find==n)find--;
			count+=find-j-1;
			//cout<<i<<":"<<j<<":"<<find<<endl;
		}
	cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdlib.h>

using namespace std;

int main() {
  string a, b;
  cin >> a >> b;
  int num = atoi((a+b).c_str());

  string result = "No";
  for (int i = 0; i < num; i++) {
    if (num == i*i) {
      result = "Yes";
      break;
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n, i, j, k, l, r, t, g, p;
string s;
int main(){
    cin>>s;
    n=s.size();
    g=1;
    if(s[0]=='p')t--;
    for(i=1;i<n;i++){
        if(s[i]=='p'){
            if(p==g){g++;t--;}
            else p++;
        }
        else{
            if(p<g){p++;t++;}
            else g++;
        }
    }
    cout<<t<<endl;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-
import sys
from operator import itemgetter
from fractions import gcd
from math import ceil, floor, sqrt
from copy import deepcopy
from collections import Counter, deque
import heapq
from functools import reduce
sys.setrecursionlimit(200000)
# local only
# if not __debug__:
#     fin = open('in_1.txt', 'r')
#     sys.stdin = fin
# local only
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template


def main():
    N = ii()
    A = lmi()
    B = []
    for i in range(1, N - 1):
        B.append(min(A[i], A[i - 1]))
    print(sum(B) + A[0] + A[-1])
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 5716
#include <queue>
#include <vector>
#include <iostream>
using namespace std;
struct edge {
	int to, cost;
};
struct state {
	int pos, cost, used;
};
bool operator<(const state& s1, const state& s2) {
	return s1.cost < s2.cost;
}
int n, m, t, a, b, c;
int main() {
	while (cin >> n >> m >> t, n) {
		vector<vector<edge> > G(n);
		for (int i = 0; i < m; i++) {
			cin >> a >> b >> c; a--, b--;
			G[a].push_back(edge{ b, c });
		}
		priority_queue<state> que; que.push(state{ 0, 0, 0 });
		vector<vector<int> > dist(n, vector<int>(n, 999999999)); dist[0][0] = 0;
		while (!que.empty()) {
			state st = que.top(); que.pop();
			for (edge e : G[st.pos]) {
				int cost1 = dist[st.pos][st.used] + e.cost;
				if (dist[e.to][st.used] > cost1) {
					dist[e.to][st.used] = cost1;
					que.push(state{ e.to, -cost1, st.used });
				}
				int cost2 = dist[st.pos][st.used];
				if (st.used != n - 1 && dist[e.to][st.used + 1] > cost2) {
					dist[e.to][st.used + 1] = cost2;
					que.push(state{ e.to, -cost2, st.used + 1 });
				}
			}
		}
		int ret = -1;
		for (int i = 0; i < n; i++) {
			if (dist[n - 1][i] <= t) {
				ret = i; break;
			}
		}
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll a, b, h, m; cin >> a >> b >> h >> m;

    // 度数表記
    double mdeg = 6.0*m;
    double hdeg = (h*60+m)*0.5;
    double theta = abs(mdeg - hdeg);
    theta = theta*M_PI/180.0; // rad
    double ans = sqrt(a*a+b*b-2*a*b*cos(theta));
    cout << ans << endl;
}

Measured memory_bytes: 4180
import sys
input = sys.stdin.readline
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    ans = N
    for i in range(M):
        ans -= A[i]
    if ans < 0:ans = -1
    print(ans)
if __name__ == "__main__":
    main()

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

int main(){
  char X,Y;
  cin >> X >>Y;
  if((int)X > (int)Y){
  cout << ">" << endl;
  }else if((int)X == (int)Y){
  cout << "=" << endl;
  }else{
  cout << "<" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>

using namespace std;
		
int main(void){
	string taro,hanako;
	int tp=0,hp=0;
	int turn;
	cin>>turn;
	for(int i=0;i<turn;i++){
		cin>>taro>>hanako;
		for(int j=0;j<taro.size();j++){
		   if(isupper(taro[j]))
			    taro[j] = tolower(taro[j]);
	    }
		for(int i=0;i<hanako.size();i++){
		   if(isupper(hanako[i]))
			    hanako[i] = tolower(hanako[i]);
		}
		if(taro.compare(hanako)<0)
			hp+=3;
		else if(taro.compare(hanako)>0)
			tp+=3;
		else{
			tp++;
			hp++;
		}
	}
	cout<<tp<<" "<<hp<<endl;

	return 0;
}

Measured memory_bytes: 1208
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int t = sc.nextInt();
    
    if (X > t) {
      System.out.println(X-t);
    } else {
      System.out.println(0);
    }
  }
}

Measured memory_bytes: 21716
#include <queue>
#include <cstdio>
#include <iostream>

using namespace std;

int n, m;

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

int t[1010][1010];
char c[1010][1010];

queue <pair <int, int> > q;

int main () {
	scanf ("%d%d", &n, &m);
	
	for (int i = 1; i <= n; ++i) scanf ("%s", c[i] + 1);
	
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j) if (c[i][j] == '#')
			for (int d = 0; d < 4; ++d) {
				int x = i + dx[d], y = j + dy[d];
				if (c[x][y] == '.' && !t[x][y]) t[x][y] = 1, q.push (make_pair (x, y));
			}
	
	int ans = 0;
	
	while (!q.empty ()) {
		int i = q.front ().first, j = q.front ().second; q.pop ();
		ans = t[i][j];
		for (int d = 0; d < 4; ++d) {
			int x = i + dx[d], y = j + dy[d];
			if (c[x][y] == '.' && !t[x][y]) t[x][y] = t[i][j] + 1, q.push (make_pair (x, y));
		}
	}
	
	printf ("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define int long long

using namespace std;

const int N = 1e5 + 5;



signed main()
{/*
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);*/
    int ans = 0;
    int n, d,x,y;
    cin >> n >> d;
    for (int i = 1; i <= n; i++) {
        cin >> x >> y;
        if (x * x + y * y <= d * d)
            ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;

int n, top, mn = 1000000007;

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d",&n);
	for(int i = 1; i <= n; i++){
		int a;
		scanf("%d",&a);
		if(a % 10)
			mn = min(mn, a);
		top += a;
	}
	if(top % 10)
		printf("%d\n", top);
	else
		printf("%d\n", max(0, top - mn));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 1000000000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}

// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  

//////////
int ma[10]={0,2,5,5,4,5,6,3,7,6};
int a[21];
string dp[100000];
int m;
string f(int n)
{
    if(n==0)
        return "";
    if(n<0)
        return "-1";
    if(dp[n]!="")
        return dp[n];
    vector<string> v;
    for(int i=1;i<=m;++i)
    {
        string s=f(n-ma[a[i]]);
        if(s=="-1")
            continue;
        s+=char_to_str(((char)'0'+a[i]));
        v.push_back(s);
    }
    if(v.size()==0)
    return "-1";
    string maxx=v[0];
    for(int i=0;i<v.size();++i)
    {
        if(maxx.length()<v[i].length())
            maxx=v[i];
        else
            if(maxx.length()==v[i].length()&&maxx<v[i])
                maxx=v[i];
    }
    dp[n]=maxx;
    return maxx;
}
int n;
signed main()
{
    fastio;
    cin>>n>>m;
    for(int i=0;i<=n;++i)
        dp[i]="";
    for(int i=1;i<=m;++i){
        cin>>a[i];
    }
    cout<<f(n);
}

Measured memory_bytes: 49408
#include<iostream>
#include <complex>
#include <vector>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
int main() {

	int A, B, C;
	long long K;
	int result;
	cin >> A >> B >> C >> K;
	if (K % 2 == 0)result = A - B;
	else result = -A + B;

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int solve(int *arr, int n,int *dp) {
    if (n == 0) {
        return 0;
    }
    if (n == 1) {
        return abs(arr[1] - arr[0]);
    }
    int a1;
    int a2;
    if (dp[n] == -1) {
        a1 = abs(arr[n] - arr[n - 1]) + solve(arr, n - 1,dp);
        a2 = abs(arr[n] - arr[n - 2]) + solve(arr, n - 2,dp);
        dp[n] = min(a1, a2);
    }
    return dp[n];
}
int main() {
    int n;
    cin >> n;
    int arr[n];
    int i;
    int dp[n];
    for (i = 0; i < n; i++) {
        cin >> arr[i];
        dp[i] = -1;
    }
    cout << solve(arr, n - 1,dp);
    return 0;
}

Measured memory_bytes: 8832
#include<stdio.h>

int main(void){
    int a,n,i,min=1000000,max=-1000000;
    long int sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        sum+=a;
        if(min>a)
            min=a;
        if(max<a)
            max=a;
    }
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}



Measured memory_bytes: 2100
#include <iostream>
#include <math.h>
#include <vector>
#include <numeric>
#include <set>
#include <stdio.h>
#include <algorithm>
#include <functional>
using namespace std;

int main(){

  int N,res=0;
  scanf("%d",&N);
  vector<int> L(N);
  for (int i = 0;i < N;i++){
    scanf("%d",&L[i]);
  }
  sort(L.begin(),L.end());
  for (int i = 0;i < N-2;i++){
    for (int j = i+1;j < N-1;j++){
      // cout << lower_bound(L.begin()+j+1,L.end(),L[i]+L[j]) - (L.begin()+j+1) << endl;
      // cout << upper_bound(L.begin()+j+1,L.end(),L[i]+L[j]) - (L.begin()+j+1) << endl;
     res += lower_bound(L.begin()+j+1,L.end(),L[i]+L[j]) - (L.begin()+j+1);      
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

using P=pair<long double,long double>;
void solve(){
  int n;
  string s;
  cin>>n>>s;
  string t=s.substr(0,n/2);
  if(s==t+t)cout<<"Yes\n";
  else cout<<"No\n";
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


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

#define ii pair<int,int> 

int p[100], lvl[100], num[100];
int n;
ii co[100], diff[100][100];
int ans = 200;

void reset(){
	for(int i = 0; i < 100; ++i){
		p[i] = i;
		lvl[i] = 0;
		num[i] = 1;
	}
}

int getParent(int x){
	return (p[x] == x) ? x : getParent(p[x]);
}

void conn(int a, int b){
	int pa = getParent(a), pb = getParent(b);
	if(pa != pb){
		if(lvl[pa] > lvl[pb]){
			p[pb] = pa;
			num[pa] += num[pb];
		}else{
			p[pa] = pb;
			num[pb] = num[pa];
			if(lvl[pa] == lvl[pb]){
				lvl[pb]++;
			}
		}
	}
}

int getNum(ii d){
	int tmpAns = 0;
	reset();
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n; ++j){
			if(diff[i][j] == d){
				conn(i, j);
			}
		}
	}
	bool visited[100] = {0};
	for(int i = 0; i < n; ++i){
		int pi = getParent(i);
		if(!visited[pi])
			tmpAns++;
		visited[pi] = true;
	}
	return tmpAns;
}

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; ++i){
		scanf("%d %d", &co[i].first, &co[i].second);
	}
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n; ++j){
			diff[i][j] = ii(co[i].first-co[j].first, co[i].second-co[j].second);
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(diff[i][j].first != 0 || diff[i][j].second != 0){
				ans = min(ans, getNum(diff[i][j]));
			}
		}
	}
	if(n == 1){
		ans = 1;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
s=input()
t=input()
b=len(t)
a=len(s)


dp=[[0 for i in range(a+1)] for j in range(b+1)]
for i in range(b+1):
	for j in range(a+1):
		if(i==0 or j==0):
			continue
		if(t[i-1]==s[j-1]):
			dp[i][j]=1+dp[i-1][j-1]
		else:
			dp[i][j]=max(dp[i-1][j],dp[i][j-1])
i=b
j=a
l=[]
while(i>0 and j>0):
	if(t[i-1]==s[j-1]):
		l.append(t[i-1])
		i=i-1
		j=j-1
	else:
		if(dp[i-1][j]>dp[i][j-1]):
			i=i-1
		else:
			j=j-1
for i in reversed(l):
    print(i,end='')

    




Measured memory_bytes: 154220
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[float('inf')]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
  for j in range(k):
    dp[i]=min(dp[max(0,i-j-1)]+abs(h[i]-h[max(0,i-j-1)]),dp[i])
print(dp[n-1])

Measured memory_bytes: 55520
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	ll n;
	cin >> n;
	vector<ll> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	ll ans = 0;
	for(int i = 0; i < n; i++){
		ans += a[i] -1;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
var
        n,a,b,c,d:integer;
begin
        readln(n);
        a:=n div 1000;
        b:=n mod 1000 div 100;
        c:=n mod 100 div 10;
        d:=n mod 10;
        if (a=b)and(b=c) then writeln('Yes')
        else if (b=c)and(c=d) then writeln('Yes')
             else writeln('No');
end.

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

using namespace std;

int main(){
    int n;
    cin>>n;
    deque<int> deq;
    for(int i=0;i<n;i++){
        int tmp;
        cin>>tmp;
        if(i%2==(n-1)%2)
            deq.push_front(tmp);
        else
            deq.push_back(tmp);
    }
    for(auto i:deq)
        cout<<i<<" ";
}


Measured memory_bytes: 3072
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif

#define ynmes(a) (a) ? mes("Yes") : mes("No")
#define YNmes(a) (a) ? mes("YES") : mes("NO")
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void)
{    
    ll x, y;
    cin >> x >> y;
    ll r = LLINF;
    ll x2 = x, y2 = y;
    rep(i, 4) {
        ll tmp = 0;
        x2 = x *(1-2*(i%2));
        y2 = y *(1-2*(i/2));
        
        tmp += i%2 + i/2;
        
        if(y2-x2 >= 0) {
            tmp += y2-x2;
            r = min(r, tmp);
        }
        
    }
    
    
    
    mes(r);
    


    
	
    
    
    
    
    
    
    
}



Measured memory_bytes: 3636
import java.util.Scanner;

/**
 * @author yoshizaki
 * EDCP A
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        // 足場の数
        int node = scanner.nextInt();
        // 足場の高さの配列
        long[] height = new long[node];
        // DP用配列
        long[] dp = new long[node];
        // 足場の高さを取得
        for (int i = 0 ; i < node ; i++) height[i] = scanner.nextInt();
        // DP用配列の初期化
        for (int i = 0; i < node; i++) dp[i] = 100000000000000l;
        // 初期条件 初めのコストはゼロ
        dp[0] = 0;
        
        for (int i = 1; i < node; i++) {
            long cost = dp[i-1] + Math.abs(height[i] - height[i-1]);
            if (dp[i] > cost) dp[i] = cost; 
            if (i > 1) {
                long cost2 = dp[i-2] + Math.abs(height[i] - height[i-2]);
                if (dp[i] > cost2) dp[i] = cost2;
            }
        }
        System.out.println(dp[node -1]);
    }
}

Measured memory_bytes: 60896
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
	int X;
	cin >> X;
	
	unsigned int score = 0;
	
	int x500 = (X / 500);
	X -= 500 * x500;
	int x5 = (X / 5);
	
	score += 1000 * x500;
	score += 5 * x5;
	
	cout << score << endl;
	
	return 0;
}

Measured memory_bytes: 256
def main():
	a,b,c,d = map(int,input().split())
	i = 0
	while a >= 0 and c >= 0:
		a = a - d
		c = c - b
		if a == c == 0:
			print("Yes")
			break
		elif c <= 0:
			print("Yes")
			break
		elif a <= 0:
			print("No")
			break

	

if __name__ == '__main__':
	main()

Measured memory_bytes: 61792
n = int(input())
ps = list(map(int, input().split()))

p_min = min(ps)
p_max = max(ps)

a = 999999999999999999999

for i in range(p_min, p_max+1):
    b = sum([abs(p-i)**2 for p in ps])
    a = min(a, b)

print(a)

Measured memory_bytes: 9192
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int d = sc.nextInt();  
      	int[] c = new int[26];
      	int[][] s = new int[d][26];
      	for(int i=0;i<26;i++){
          c[i] = sc.nextInt();
        }
      	for(int i=0;i<d;i++){
          for(int j=0;j<26;j++){
            s[i][j] = sc.nextInt();
          }
        }
      	for(int i=0;i<d;i++){
          int n = s[i][0];
          int pos = 0;
          for(int j=1;j<26;j++){
            if( s[i][j] > n ){
              n = s[i][j];
              pos = j;
            }
          }
          System.out.println(pos+1);
        }
    }
}

Measured memory_bytes: 38120
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
const int INF = 1 << 28;

// Rolling Hash
// Verified: AOJ 2444 (Substring)

struct RollingHash {
public:
    long long base_1, base_2, mod_1, mod_2;
    vector<long long> hash1, hash2, pow1, pow2;

    // init (constructor)
    RollingHash(string s) : base_1(1013), base_2(1007),
        mod_1(1000000007), mod_2(1000000009),
        hash1(s.length()+1,0), hash2(s.length()+1,0),
        pow1(s.length()+1,1), pow2(s.length()+1,1) {
            for(int i=0; i<s.length(); i++) {
                hash1[i+1] = (hash1[i]+s[i]) * base_1 % mod_1;
                hash2[i+1] = (hash2[i]+s[i]) * base_2 % mod_2;
                pow1[i+1] = pow1[i] * base_1 % mod_1;
                pow2[i+1] = pow2[i] * base_2 % mod_2;
            }
        }

    // calc str[l,r) hash (0-indexed)
    // if get(i1,j1) == get(i2,j2) -> identical string
    pair<long long, long long> get(int l, int r) {
        long long t1 = ((hash1[r] - hash1[l] * pow1[r-l]) % mod_1 + mod_1) % mod_1;
        long long t2 = ((hash2[r] - hash2[l] * pow2[r-l]) % mod_2 + mod_2) % mod_2;
        return make_pair(t1, t2);
    }
};

int dp[510], cnt[26], b[10];
int main() {
    int N; cin >> N;
    string s; cin >> s;
    int len = 0;
    for(int i=0; i<N; i++) {
        if(s[i] != '+') {
            len++;
            cnt[ s[i] - 'a' ]++;
        }
    }
    for(int i=0; i<26; i++) {
        b[ cnt[i] ]++;
    }

    int ans = 0;
    int rem = 26 - b[0];
    for(int i=1; i<=9; i++) {
        rem -= b[i];
        if(i == 1) {
            ans += max(0, 2 * b[i] - 1);
            if(b[i] > 0 and rem > 0) ans++;
        }
        else {
            if(b[i] >= 2) ans += 4;
            else if(b[i] == 1) ans += 2;
            
            ans += max(2 * b[i] - 1, 0);
            if(b[i] > 0 and rem > 0) ans++;
        }
        // fprintf(stderr, "i = %d, b = %d, rem = %d, ans = %d\n", i, b[i], rem, ans);
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;

int main() {

	int a,b,c;
	cin >> a >> b >> c ;

	if (max(a, max(b, c)) == a) {
		cout << b * c / (double)2 << endl;
	}
	if (max(a, max(b, c)) == b) {
		cout << a * c / (double)2 << endl;
	}
	if (max(a, max(b, c)) == c) {
		cout << a * b / (double)2 << endl;
	}

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long k = sc.nextLong();
        int n = 50;
        long[] result = new long[n];
        for (int i = 0; i < n; i++) {
            result[i] = k/n + i;
        }

        int currentCandidateIdx = 0;
        for (int i = 0; i < (k%n); i++) {
            for (int idx = 0; idx < n; idx++) {
                if (idx == currentCandidateIdx) {
                    result[idx] = result[idx] + n;
                }
                else {
                    result[idx] = result[idx] - 1;
                }
            }
            currentCandidateIdx = (currentCandidateIdx + 1) % n;
        }

        System.out.println(n);
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < n; i++) {
            sb.append(result[i]).append(" ");
        }
        System.out.println(sb.toString());
    }

}


Measured memory_bytes: 21844
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  vi p(n);
  rep(i, n) cin >> p[i];
  int ans = 0;
  for(int i = 1; i < n - 1; i++){
    if(max({p[i - 1], p[i], p[i + 1]}) != p[i] && min({p[i - 1], p[i], p[i + 1]}) != p[i]) ans++;
  }
  cout << ans << endl;
}

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

int main() {
	int N, L;
	cin >> N >> L;

	vector<string> S( N );
	for( int i = 0; i < N; ++i ) {
		cin >> S.at( i );
	}

	sort( S.begin(), S.end() );

	for( int i = 0; i < N; ++i ) {
		cout << S.at( i );
	}

	cout << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
const int MOD = 1000000007;
int main() {
    int A, B;
    cin >> A >> B;
    int res = 0;
    int kuchi = 1;

    rep(i, 0, 20) {
        if(kuchi >= B) {
            break;
        }
        kuchi += A - 1;
        res++;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String c =sc.next();
		if(c.equals("a")||c.equals("i")||c.equals("u")||c.equals("e")||c.equals("o")){
			System.out.println("vowel");
		}
		else{
		System.out.println("consonant");
	}
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll H;cin>>H;
	ll temp = H;
	ll cnt = 0;
	while(temp>1)
	{
		temp/=2;
		cnt++;
	}
	ll ans = (ll)pow(2,cnt);
	ans += ans-1;
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
import sys
import re
S = input()
array_S = list(S)

if not ( 4 <= len(S) <= 10 ):
    print('WA')
    sys.exit()
if len(re.findall('[A-Z]',S)) != 2:
    print('WA')
    sys.exit()

result = 0
if array_S[0] != 'A': result += 1
if array_S[2:-1].count('C') != 1: result += 1 
array_S.pop(0)
array_S.pop(array_S.index('C'))
if not "".join(array_S).islower(): result += 1 
print('WA') if result != 0 else print('AC')

Measured memory_bytes: 9760
/*input
20 3
0 5 15
*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e6;

int n, k;
int a[N];
int main() {
  scanf("%d%d", &k, &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  for (int i = n; i < 2 * n; ++i) {
    a[i] = a[i - n] + k;
  }
  int path = INT_MAX;
  for (int i = 0; i < n; ++i) {
    path = min(path, a[i + n - 1] - a[i]);
  }
  printf("%d\n", path);
  return 0;
}

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

int main(){
    int n,x;
    cin >> n >> x;
    int  L[n];
    int  D[n];

    for(int i = 1;i <= n;i++){
        cin >> L[i];
    }

    D[1] = 0;
    int count = 0;

    for(int i = 2;i <= n+1;i++){
        D[i]=D[i-1]+L[i-1];
    }

    for(int i = 1;i <= n+1;i++){
        if(D[i] <= x) count++;
    }

    cout << count << endl;

    return 0;
}



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

#define ll long long
#define ull unsigned ll

#define vi vector <int>
#define ii pair <int, int>
#define vii vector <ii>
#define INFLL 9e18
#define INF 2e9
#define EPS 1e-9
#define pb push_back
#define emp emplace_back
#define PI acos(-1.0)
#define endl "\n"
#define mp make_pair
#define DEBUG 0

const int mod = 1e9+7;

int main ()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout.tie(NULL);

    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    
    int h, w;
	cin >> h >> w;

	char grid[h+1][w+1];

	for (int i=1; i<=h; i++){
		for (int j=1; j<=w; j++){
			cin >> grid[i][j];
		}
	}

	int dp[h+1][w+1];
	memset(dp, 0, sizeof(dp));
	dp[1][1] = 1;
	for (int i=1; i<=h; i++){
		for (int j=1; j<=w; j++){
			if (i+1 <= h && grid[i+1][j] == '.'){
				dp[i+1][j] += dp[i][j];
				dp[i+1][j] %= mod;
			}
			if (j+1 <= w && grid[i][j+1] == '.'){
				dp[i][j+1] += dp[i][j];
				dp[i][j+1] %= mod;
			}
		}
	}

	cout << dp[h][w] << endl;



    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define lol long long
using namespace std;
int main(){
    int a,b,c,ans,co=0;
    string s,t;
    cin>>a>>b>>c;
    ans=c;
    b+=c;
    while(ans<a){
        if(ans+b>a) break;
        else{
            ans+=b;
            co++;
        }
    }
    cout<<co<<"\n";
    return(0);
}

Measured memory_bytes: 3624
def main():
    N = int(input())
    S1 = input()
    S2 = input()
    ans = 3
    i = 0
    while N - 1 > i:
        if S1[i] == S2[i]:
            if S1[i + 1] == S2[i + 1]:
                ans *= 2
            i += 1
        else:
            if N > i + 2 and S1[i + 2] != S2[i + 2]:
                ans *= 3
            else:
                ans *= 2
            i += 2
    print(ans % 1000000007)


main()


Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
	  public static void main(String[] args) {
	        Scanner scan = new Scanner(System.in);
	        int a;
	        int b;
	        int c;
	        a=scan.nextInt();
	        b=scan.nextInt();
	        c=scan.nextInt();
	        if(a<b&&b<c){
	        	System.out.println("Yes");
	        }
	       
	        else{
	        	System.out.println("No");
	        }
	    }
	}


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

const int N = (int)3e5 + 50;

struct seg {
    int l, r;
};
int n, m;

vector<seg> sgs[N];

struct BIT {
    int n;
    int bit[N];

    void add(int x, int val) {
        for(int i = x; i < n; i |= i + 1) bit[i] += val;
    }

    int get(int x) {
        int res = 0;
        for(int i = x; i >= 0; i = (i & (i + 1)) - 1)  res += bit[i];
        return res;
    }

    void add(int l, int r, int val) {
        add(l, val);
        add(r + 1, -val);
    }

    int get(int l, int r) {
        return get(r) - get(l - 1);
    }

}bit;

int res[N];

int main() {
    cin >> n >> m;
    m++;
    for(int i = 0; i < n; i++) {
        int l, r; cin >> l >> r;
        sgs[r-l+1].push_back({l, r});
    }
    bit.n = m;
    int sumbig = n;
    for(int d = 1; d < m; d++) {
        for(const auto &s : sgs[d]) {
            bit.add(s.l, s.r, 1);
        }
        sumbig -= sgs[d].size();
        for(int j = d; j < m; j += d) {
            res[d] += bit.get(j);
        }
        res[d] += sumbig;
    }
    for(int d = 1; d < m; d++) cout << res[d] << "\n";


}

Measured memory_bytes: 13440
#include <iostream>
using namespace std;
int main() {
  int Q, N, s, t, l, ans;
  cin >> Q;
  for (int i = 0; i < Q; ++i) {
    cin >> N;
    s = N;
    ans = 0;
    while (s > 9) {
      ++ans;
      l = 10;
      t = 0;
      while (l < N) {
	t = max(t, (s%l)*(s/l));
	l *= 10;
      }
      s = t;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3088
import java.io.*;

class Tranp{
    private int[][] card;
    public Tranp(){
	card=new int[4][];
	for(int i=0;i<4;i++) card[i]=new int[13];
	for(int i=0;i<4;i++){
		for(int j=0;j<13;j++){
		    card[i][j]=0;
		}
	}
    }
    public void markcard(String mark,int num){		   	
	if(mark.equals("S")) card[0][num-1]++;
	else if(mark.equals("H")) card[1][num-1]++;
	else if(mark.equals("C")) card[2][num-1]++;	
	else if(mark.equals("D")) card[3][num-1]++;
    }

    public void printcard(){
	for(int i=0;i<4;i++){
	    for(int j=0;j<13;j++){
		if(card[i][j]==0){
		    if(i==0) System.out.println("S " + (j+1));
		    else if(i==1) System.out.println("H " + (j+1));
		    else if(i==2) System.out.println("C " + (j+1));
		    else if(i==3) System.out.println("D " + (j+1));
		}
	    }
	}
    } 
}    
class Main{
    public static void main(String[] args)throws IOException{
	final BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	final Tranp tr=new Tranp();
	
	String str=br.readLine();
	int n=Integer.parseInt(str);
	for(int i=0;i<n;i++){
	    String[] st=br.readLine().split(" ");
	    String mark=st[0];
	    int num=Integer.parseInt(st[1]);
	    tr.markcard(mark,num);
	}
	tr.printcard();
    }
}

Measured memory_bytes: 16940
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

int main(){
    iostream::sync_with_stdio(false);
    
    int N;
    cin >> N;
    int a[100000];
    for(int i=0; i<N; i++) cin >> a[i];
    //最後のを取った方の勝ち
    //自分の番が終わった時点で残り個数をそれぞれ全部偶数にしてしまえばよい
    
    for(int i=0; i<N; i++){
        if(a[i] % 2 == 1){
            cout << "first" << endl;
            return 0;
        }
    }
    cout << "second" << endl;

    return 0;
}

/*

int main(){
    iostream::sync_with_stdio(false);
    
    
    
    return 0;
}
*/

/*

int main(){
    iostream::sync_with_stdio(false);
    
    
    
    return 0;
}
*/

/*

int main(){
    iostream::sync_with_stdio(false);
    
    
    
    return 0;
}
*/

/*

int main(){
    iostream::sync_with_stdio(false);
    
    
    
    return 0;
}
*/

/*

int main(){
    iostream::sync_with_stdio(false);
    
    
    
    return 0;
}
*/

Measured memory_bytes: 640
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll n;
    cin >> n;
    int ans = 0;
    int max_cnt = 0;
    for (int i = 1; i <= n; ++i) {
        int cnt = 0;
        int num = i;
        while(1) {
            if (num % 2 != 0) break;
            num /= 2;
            ++cnt; 
        }
        if (max_cnt <= cnt) {
            ans = i;
            max_cnt = cnt;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int     main() {
        long N, D;
        cin >>N >>D;
        vector<vector<long>> X(N, vector<long>(D));
        for (long i=0; i<N; i++) {
                for (long j=0; j<D; j++) cin >> X.at(i).at(j);
        }
        long S=0;
        vector<long> XX(D);
        for (int i=0; i<N-1; i++) {
                for (long j=i+1; j<N; j++) {
                        long d=0;
                        for (long k=0; k<D; k++) {
                                long XX=X.at(i).at(k)-X.at(j).at(k);
                                d += XX*XX;
                        }
                        double ddd=sqrt(d);
                        long dd=ddd;
                        if (d==dd*dd) S++;
                }
        }
        cout << S << endl;
        return 0;
}


Measured memory_bytes: 256
from math import sqrt

def cal_factors(num):
    factors = {}
    maxmod = int(sqrt(num)) + 1
    for mod in range(2, maxmod):
        i = 0
        while True:
            d, q = divmod(num, mod)
            if q == 0:
                num = d
                i += 1
                factors[mod] = i
            else:
                break

    if num > 1:
        factors[num] = 1

    return factors


def comb(n, r, mod):
    result = 1
    r = min(r, n-r)
    for i in range(n, n-r, -1):
        result *= i
    for i in range(2, r+1):
        result //= i
    result %= mod

    return result


n, m = [int(v) for v in input().split()]

mod = 1000000000 + 7
factors = cal_factors(m)
ans = 1
for v in factors.values():
    ans *= comb(v + n - 1, v, mod)
    ans %= mod

print(ans)

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

int main() {
  string N;
  cin >> N;
  if ((N[0]==N[1] && N[1]==N[2]) || (N[1]==N[2] && N[2]==N[3])) {
              cout << "Yes" << endl;
  }
              else {
                cout << "No" << endl;
              }
              }
              
  

Measured memory_bytes: 256
W,H,x,y,z = [int(i) for i in input().split()]
ans = ""
#x,yが正か負か
if x <= 0 or y <= 0:
    ans = "No"

#x+r or y+rが第１象限内かつW or Hを超えないか かつ　x-r>=0 and y-r>=0か
if x+z <= W and y+z <= H:
    if x-z >= 0 and y-z >= 0:
        ans ="Yes"
else:
    ans = "No"

print(ans)


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

using namespace std;
const int INF=10000000;
typedef pair<int,int> P;

int h,w;
int d[50][51];
int dx[4]={0,0,-1,1},dy[4]={-1,1,0,0};
char field[50][51];

int bfs(){
  	
	queue<P> que;
  	for(int i=0;i<h;i++)
     	for(int j=0;j<w;j++)
          	d[i][j]=INF;
  
  	que.push(P(0,0));
  	d[0][0]=0;
  
  	P p;
  	while(que.size()){
    	p=que.front(); que.pop();
      	if(p.first==h-1 && p.second==w-1) break;
      
        for(int i=0;i<4;i++){
            int nx=p.first+dx[i];
            int ny=p.second+dy[i];
            if(0<=nx && nx<h && 0<=ny && ny<w && field[nx][ny]=='.' && d[nx][ny]==INF){
                que.push(P(nx,ny));
                d[nx][ny]=d[p.first][p.second]+1;
            }
        }
    }
	return d[h-1][w-1];
}

int main(){
 cin>>h>>w;
 for(int i=0;i<h;i++){
 	string tmp; cin>>tmp;
   	for(int j=0;j<w;j++){
    	field[i][j]=tmp[j];
    }
 }
 int ans=bfs();
  
 int black=0;
 for(int i=0;i<h;i++){
 	for(int j=0;j<w;j++){
    	if(field[i][j]=='#'){
         	black++;
        }
    }
 }
 if(ans==INF){
 	printf("-1\n");
  	return 0;
 }
 else{
 	printf("%d\n",h*w-ans-1-black);
 }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
vector<int>vec(3);
  cin>>vec.at(0)>>vec.at(1)>>vec.at(2);
  sort(vec.begin(),vec.end());
  cout<<vec.at(2)*10+vec.at(1)+vec.at(0)<<endl;
}

Measured memory_bytes: 3584
S = str(raw_input())
N = len(S)

rev = S[::-1]
S1 = S[:(N-1)/2]
S2 = S[(N+1)/2:]

if (rev == S and S1[::-1] == S[:(N-1)/2] and S2[::-1] == S[(N+1)/2:]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2568
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE

void solve(void)
{
   int H,W;
  cin>>H>>W;
  int COUNT = 0;
  vector<vector<char> > MAZE(H,vector<char>(W));
  pair<int,int> START,GOAL;
  for (int h = 0; h < H; h++)
  {
    for (int w = 0; w < W; w++)
    {
      cin>>MAZE[h][w];
      if(MAZE[h][w] == 'S')
      {
        START.first = h;START.second=w;
        MAZE[h][w] = '.';
      }

      if(MAZE[h][w] == 'G')
      {
        GOAL.first = h;GOAL.second=w;
        MAZE[h][w] = '.';  
      }      
      if(MAZE[h][w] == '.')COUNT++;
    }
  }
  START.first = 0;
  START.second = 0;
  GOAL.first = H-1;
  GOAL.second = W-1;
  vector<int> dx = {1,0,-1,0};
  vector<int> dy = {0,1,0,-1};
  vector<vector<int> > dist(H,vector<int>(W,INF));

  queue<pair<int,int> > q;
  q.push(START);
  dist[START.first][START.second] = 0;
  while(! q.empty())
  {
    pair<int,int> point = q.front();
    q.pop();
    if(point == GOAL) break;

    for (int i = 0; i < 4; i++)
    {
      int nx = point.second + dx[i];
      int ny = point.first + dy[i];
      if(nx >= 0 && ny >= 0 && nx < W && ny <H && MAZE[ny][nx] != '#' &&dist[ny][nx] == INF)
      {
        q.push(pair<int,int>(ny,nx));
        dist[ny][nx] = dist[point.first][point.second] + 1;
      }
    }
    

  }
  if(dist[GOAL.first][GOAL.second] == INF)
  {
    cout<<-1<<endl;
    return;
  }
  cout<<COUNT -1*dist[GOAL.first][GOAL.second] -1<<endl;
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  bool u[10];
  mem(u);
  rep(i,4) {
    int x;
    R x;
    u[x]++;
  }
  if(u[1]&&u[9]&&u[7]&&u[4]) pr("YES");
  else pr("NO");
}

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


Measured memory_bytes: 256
n,k = map(int, input().split())

win = []

for i in range(1, n+1):
  if i >= k:
    win.append(1/n)
  else:
    t = True
    count = 0
    while t == True:
      if i < k:
        i = 2*i
        count += 1
      else:
        t = False
    win.append((((1/2)**count)*(min(n,k)/n))/min(n,k))

total = int(sum(win)*(10**12))/(10**12)
print(total)

Measured memory_bytes: 12952
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import core.stdc.stdlib;
import std.math;

void main() {
  auto N = readln.chomp.to!ulong;
  ulong answer = N-1;

  for(ulong i = 1; i * i <= N; i++) {
    if (N % i != 0) continue;

    auto j = N/i;
    auto candidate = i-1 + j-1;
    if (candidate < answer) answer = candidate;
  }

  writeln(answer);
}


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

using namespace std;

#define DIM 3009
#define INF ((long long)1e18+9ll)
#define MODULO 1000000007
#define pairll pair<long long,long long>
#define fi first
#define se second
#define ld long double
#define endl '\n'
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define amen exit(0)

long long i,j,k,l,n,m,sz,C;

ld dp[DIM],p[DIM],dp1[DIM],res;

int main()
{
    fast;

    cin>>n;
    dp[0]=1;

    for(i=1;i<=n;i++){
        cin>>p[i];
       // cout<<"A"<<' ';
        for(j=0;j<=i;j++){
            dp1[j]=dp[j]*((ld)1-p[i]);
            if(j!=0)dp1[j]+=dp[j-1]*p[i];
           // cout<<dp1[j]<<' ';
        }
       // cout<<endl;
      //  cout<<"B"<<' ';
        for(j=0;j<=i;j++)dp[j]=dp1[j];
      //  cout<<endl;
    }

    for(i=(n+1)/2;i<=n;i++)res+=dp[i];
    cout<<fixed<<setprecision(10)<<res<<endl;

    amen;
}



Measured memory_bytes: 384