akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int A[SIZE];
VI e[SIZE];
void err(){
    puts("NO");
    exit(0);
}
LL dfs(int x,int lt){
    LL r=0;
    if(SZ(e[x])==1){
        return A[x];
    }
    VI d;
    REP(i,SZ(e[x])){
        int y=e[x][i];
        if(y==lt)continue;
        d.PB(dfs(y,x));
        r+=d.back();
    }
    if(r<A[x]||r>2*A[x])err();
    sort(ALL(d));
    int merge=r-A[x];
    int ma=d.back();
    if(r-ma<merge)err();
    return 2*A[x]-r;
}
int main(){
    DRI(N);
    REPP(i,1,N+1)RI(A[i]);
    if(N==2){
        puts(A[1]==A[2]?"YES":"NO");
        return 0;
    }
    REPP(i,1,N){
        DRII(x,y);
        e[x].PB(y);
        e[y].PB(x);
    }
    int root=1;
    while(SZ(e[root])==1)root++;
    puts(dfs(root,root)?"NO":"YES");
    return 0;
}


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

int main(){
  int E,Y;
  
  cin>>E>>Y;
  
  if(E==0){
   if (1868<=Y && Y<=1911){
    cout<<"M"<<Y-1867<<endl;
  } else if(1912<=Y && Y<=1925){
    cout<<"T"<<Y-1911<<endl;
  } else if(1926<=Y && Y<=1988){
    cout<<"S"<<Y-1925<<endl;
  } else {
    cout<<"H"<<Y-1988<<endl;
  }
  }
  
  else if(E==1){
    cout<<1867+Y<<endl;
  } else if(E==2){
    cout<<1911+Y<<endl;
  } else if(E==3){
    cout<<1925+Y<<endl;
  } else if(E==4){
    cout<<1988+Y<<endl;
  }
  return 0;
  
}



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

int main()
{
    string s;
    cin >> s;
    int first = (s[0] - '0') * 10 + s[1] - '0';
    int sec = (s[2] - '0') * 10 + s[3] - '0';
    //cout << first << " "<<sec<<endl;

    if(first <= 12 && sec <= 12 && first > 0 && sec > 0)
        cout << "AMBIGUOUS\n";
    else if(first > 0 && first <= 12 && (sec < 1 || sec > 12 ))
        cout << "MMYY\n";
    else if(sec > 0 && sec <= 12 && (first < 1 || first > 12 ))
        cout << "YYMM\n";
        else cout << "NA\n";
        return 0;
}


Measured memory_bytes: 256
N=int(input(''))

if N==1:
  print('0')

else:
  a=(((10)**N)%(((10)**9)+7))
  b=(((8)**N)%(((10)**9)+7))
  c=(((9)**N)%(((10)**9)+7))
  d=((c*2)%(((10)**9)+7))
  f=((a+b-d)%(((10)**9)+7))
  print(f)

Measured memory_bytes: 10788
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  int x;
  cin >> x;
  int dp[1000000];
  dp[100] = 1;
  dp[101] = 1;
  dp[102] = 1;
  dp[103] = 1;
  dp[104] = 1;
  dp[105] = 1;
  for(int i=106;i<1000001;i++){
    if(dp[i-100] == 1) dp[i]=1;
    if(dp[i-101] == 1) dp[i]=1;
    if(dp[i-102] == 1) dp[i]=1;
    if(dp[i-103] == 1) dp[i]=1;
    if(dp[i-104] == 1) dp[i]=1;
    if(dp[i-105] == 1) dp[i]=1;
  }
  cout << dp[x] << endl;
  return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <functional>
#include <iomanip>
#include <queue>

using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
const int MOD = 1e9+7;
const int INF = 1e9;
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; }

// debug
template<class T>ostream& operator<<(ostream& os, vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& out,const pair<T1,T2>& rhs){out<<"("<<rhs.first<<", "<<rhs.second<<")";return out;}
#include<type_traits>
template<typename T,size_t SIZE,enable_if_t<!is_same<remove_cv_t<T>,char>::value,nullptr_t> = nullptr>ostream& operator<<(ostream& os,T(&arr)[SIZE]){os<<"{";for(size_t i=0;i<SIZE;++i)os<<(i?", ":"")<<arr[i];os<<"}";return os;}
#ifdef LOCAL
    #define debug(v) cerr<<v<<"\n"
#else
    #define debug(...) 42
#endif


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

  vector<pii> p;
  rep(i, N) {
    ll x, l;
    cin >> x >> l;
    p.emplace_back(x + l, x - l);
  }
  ll last = -2e10;
  int ans = 0;
  sort(p.begin(), p.end());
  rep(i, N) {
    ll r = p[i].first, l = p[i].second;
    if (last <= l) {
      ++ans;
      last = r;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2420
#include<iostream>
using namespace std;
int main()  
{
	int n;
	int c=0;
	int max=0;
	string s;
	cin>>n>>s;for(int i=0;i<n;i++)
	{
		if(s[i]=='I')
		{
			c++;
		}
		else
		c--;
		if(max<c)
		{
			max=c;
		}
	}
	cout<<max;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

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

    ll A, B;
    int K;
    cin >> A >> B >> K;
    REP(i, K) {
        if (i % 2 == 0) {
            if (A % 2 == 1) A--;
            B += A / 2;
            A /= 2;
        } else {
            if (B % 2 == 1) B--;
            A += B / 2;
            B /= 2;
        }
    }

    cout << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 384
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define d(x)  cerr << #x << " = " << (x) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 2000000000

const double EPS = 1e-10;
const double PI  = acos(-1.0);
/////////////////////////////////////////////////////////////////////////

int n,a[500010];
void maxheapify(int a[],int i)
{
	int l=i*2;
	int r=l+1;
	int lgt;
	if(l<=n&&a[l]>a[i])
	{
		lgt=l;
	}
	else lgt=i;
	if(r<=n&&a[r]>a[lgt])
	{
		lgt=r;
	}
	if(lgt!=i)
	{
		swap(a[i],a[lgt]);
		maxheapify(a,lgt);
	}
}

void buildmaxheap(int a[])
{
	DFOR(i,n/2+1,1)maxheapify(a,i);
}

int main()
{
	cin>>n;
	FOR(i,1,n+1)cin>>a[i];
	buildmaxheap(a);
	FOR(i,1,n+1)cout<<" "<<a[i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 5000
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    ll X; cin >> X;
    X = abs(X);
    ll ans = (-1 + sqrt(1 + 8 * X)) / 2;
    while(ans * (ans + 1) / 2 < X) {
        ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{

	int n, m, l;
	int A[100][100];
	int B[100][100];
	long C[100][100];

	int ii, jj, kk;
	char c;


	//クリア
	memset(&A[0][0], (int)0, sizeof(int)* 100 * 100);
	memset(&B[0][0], (int)0, sizeof(int)* 100 * 100);
	memset(&C[0][0], (int)0, sizeof(long)* 100 * 100);

	//n, m, lの入力
	scanf("%d %d %d", &n, &m, &l);
	scanf("%c", &c);

	//nxmの行列Aの読み込み
	for (ii = 0; ii < n; ii++) {
		for (jj = 0; jj < m; jj++) {
			scanf("%d", &A[ii][jj]);
			scanf("%c", &c);
		}
	}

	//mxlの行列Bの読み込み
	for (ii = 0; ii < m; ii++) {
		for (jj = 0; jj < l; jj++) {
			scanf("%d", &B[ii][jj]);
			scanf("%c", &c);
		}
	}

	for (ii = 0; ii < n; ii++) {
		for (jj = 0; jj < l; jj++) {
			for (kk = 0; kk < m; kk++) {
				C[ii][jj] += A[ii][kk] * B[kk][jj];
			}
		}
	}

	for (ii = 0; ii < n; ii++) {
		for (jj = 0; jj < l; jj++) {
			printf("%ld", C[ii][jj]);
			if (jj != l - 1) {
				printf(" ");
			}
		}
		printf("\n");
	}

	return 0;

}

Measured memory_bytes: 768
#include<iostream>
#include<map>
#include<algorithm>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <vector>
#include <bitset>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <list>


constexpr int INF = 1050000000;
constexpr int MOD = 1000000007;
constexpr long long LONGINF = 1005000000000000000;
using namespace std;

using ll = long long;


int main() {
	int n, m; cin >> n >> m;

	vector<int> a[200005];

	int aa, bb;

	for (int i = 0; i < m; i++) {
		cin >> aa >> bb;
		a[aa].emplace_back(bb);
	}

	vector<int> x;

	for (auto d : a[1]) {
		x.push_back(d);
	}

	for (auto i:x) {
		for (auto f : a[i]) {
			if (f == n) { cout << "POSSIBLE" << endl; return 0; }
		}
	}


	cout << "IMPOSSIBLE" << endl;


}

Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
int main(){
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double hang = 0.5;
    double mang = 6.0;
    double x, y;
    x = hang * (60 * H + M);
    y = mang * M;
    double z = abs(x - y);
    double C = sqrt(A * A + B * B - 2.0 * A * B * cos(z / 180 * M_PI));
    cout << fixed << setprecision(15) << C << endl;
    return 0;
}

Measured memory_bytes: 4228
import re
S = input()

S = re.sub(r'eraser', '', S)
S = re.sub(r'erase', '', S)
S = re.sub(r'dreamer', '', S)
S = re.sub(r'dream', '', S)

if len(S) == 0:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;

int main()
{
//	freopen("input.txt","r",stdin);
	int m,d;
	cin>>m>>d;
	int res=0;
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=d;j++)
		{
			if(j%10<2 || j<20) continue;
			if((j%10)*(j/10)!=i) continue;
			res++;
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,k;
vector< vector<char> > arr;
vector< vector<ll> > dist;
ll dx[]={0,-1,0,1};
ll dy[]={-1,0,1,0};
ll xs,ys,xe,ye;
ll bfs(){
    queue< pair<ll,ll> > q;
    q.push({xs,ys});
    dist[xs][ys]=0;
    while(!q.empty()){
        auto node=q.front();q.pop();
        if(node.first==xe && node.second==ye)return dist[xe][ye];
        ll x = node.first , y=node.second;
        //cout<<x<<" "<<y<<endl;
        for(ll dir=0;dir<4;dir++){
            for(ll i=1;i<=k;i++){
                ll nx = x + dx[dir]*i ;
                ll ny = y + dy[dir]*i ;
                if(nx<=0 || nx>n || ny<=0 || ny>m)continue;
                if(arr[nx][ny]!='.' || dist[nx][ny]<=dist[x][y])break;
                if(dist[nx][ny]>dist[x][y]+1){
                    dist[nx][ny]=dist[x][y]+1;
                    q.push({nx,ny});
                }
            }
        }
    }
    return -1;
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n>>m>>k;
    cin>>xs>>ys>>xe>>ye;
    arr.assign(n+1,vector<char>(m+1,'.'));
    dist.assign(n+5,vector<ll>(m+5,1e15));
    for(ll i=1;i<=n;i++)for(ll j=1;j<=m;j++)cin>>arr[i][j];
    cout<<bfs();
}



Measured memory_bytes: 59940
#include<bits/stdc++.h>
using namespace std;
int check(int);
int main()
{
  int n;
  cin>>n;
  int i=n;
  while(i>=n)
  {
    if(check(i))
    {
      cout<<i;
      break;
    }
    else
      i++;
  }
  return 0;
}
 int check (int n)
 {
   int c=0;
   for(int i=1;i<=n;i++)
   {
     if(n%i==0)
       c++;
   }
   if(c==2)
     return 1;
   else 
     return 0;
 }

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

int main (int argc, char const* argv[])
{
	string s;
	cin >> s;
	if(s.find("AC") == string::npos) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
# AliceのスコアAとBobのスコアBを整数で入力
A,B = map(int,input().split())
# AとBが同じならDrawを出力
if A == B:
    print("Draw")
# Aが1か、Bが1でなく且つAがBより大きいならAliceを出力
elif  A == 1 or B!= 1 and A > B:
    print("Alice")
# Bの方が強ければBobを出力
else:
    print("Bob")


Measured memory_bytes: 8968
n, y = [int(i) for i in input().split()]
noAnswer = True
count = 0
for i in range(n+1):
  if noAnswer != True:
      break
  for j in range(n+1):
    k = int(y/1000) - i*10 - j*5
    if k>=0 and n==i+j+k:
      noAnswer = False
      print("{} {} {}".format(i, j, k))
      break

if noAnswer:
  print("-1 -1 -1")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}

template<class T>void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void OUT(bool b){tf(b,"YES","NO");}
void Out(bool b){tf(b,"Yes","No");}
void out(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vi a(n);
	cin>>a;
	Out(sum(a)-*max_element(all(a))*2>0);
	return 0;
}

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

int main(){
  int n;
  vector<int> a,b,c;
  int tmp;
  cin >> n;

  for(int i = 0;i < n;i++){ cin >> tmp; a.push_back(tmp); }
  for(int i = 0;i < n;i++){ cin >> tmp; b.push_back(tmp); }
  for(int i = 0;i < n;i++){ cin >> tmp; c.push_back(tmp); }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());

  long long ans, b_num[100010];

  for(int i = 0;i < n;i++){
    b_num[i] = n - (upper_bound(c.begin(), c.end(), b[i]) - c.begin());
  }

  for(int i = n-2;i >= 0;i--){
    b_num[i] = b_num[i+1] + b_num[i];
  }


  ans = 0;
  for(int i = 0;i < n;i++){
    int tmp = upper_bound(b.begin(), b.end(), a[i]) - b.begin();
    if(tmp < n){
      ans += b_num[tmp];
    }
  }

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



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

vector<vector<long long int>>M;

long long int FIRSTCOST;
long long int H, W, S;

typedef pair<long long int, long long int> RETURN;
typedef pair<pair<long long int, long long int>, pair<long long int, long long int>> POINT;

long long int cost( POINT  P ) {
	return M[P.first.first][P.first.second] + M[P.second.first][P.second.second] - M[P.first.first][P.second.second] - M[P.second.first][P.first.second];
}

vector<vector<vector<vector<RETURN>>>>dp;

RETURN saiki( POINT P ) {
	if( FIRSTCOST - cost( P ) > S ) {
		return make_pair( -1, -1 );
	}
	if( dp[P.first.first][P.first.second][P.second.first][P.second.second].first != -2 ) {
		return dp[P.first.first][P.first.second][P.second.first][P.second.second];
	}
	//cout << FIRSTCOST - cost( P ) << " " << S << endl;
	RETURN ret = make_pair( 1, S - (FIRSTCOST - cost( P )) );
	for( size_t i = P.first.first + 1; i < P.second.first; i++ ) {
		POINT up = P, down = P;
		up.second.first = i;
		down.first.first = i;
		auto retup = saiki( up );
		auto retdown = saiki( down );
		if( retup.first != -1 && retdown.first != -1 ) {
			RETURN retmemo = make_pair( retup.first + retdown.first, min( retup.second, retdown.second ) );
			if( ret.first < retmemo.first || (ret.first == retmemo.first&&ret.second < retmemo.second) ) {
				ret = retmemo;
			}
		}
	}
	for( size_t j = P.first.second + 1; j < P.second.second; j++ ) {
		POINT right = P, left = P;
		left.second.second = j;
		right.first.second = j;
		auto retleft = saiki( left );
		auto retright = saiki( right );
		if( retleft.first != -1 && retright.first != -1 ) {
			RETURN retmemo = make_pair( retleft.first + retright.first, min( retleft.second, retright.second ) );
			if( ret.first < retmemo.first || (ret.first == retmemo.first&&ret.second < retmemo.second) ) {
				ret = retmemo;
			}
		}
	}
	return dp[P.first.first][P.first.second][P.second.first][P.second.second] = ret;
}

int main() {
	while( cin >> H >> W >> S, H || W || S ) {
		dp = vector<vector<vector<vector<RETURN>>>>( H + 1, vector<vector<vector<RETURN>>>( W + 1, vector<vector<RETURN>>( H + 1, vector<RETURN>( W + 1, RETURN( -2, -2 ) ) ) ) );
		M = vector<vector<long long int>>( H + 1, vector<long long int>( W + 1 ) );
		for( size_t i = 1; i <= H; i++ ) {
			for( size_t j = 1; j <= W; j++ ) {
				cin >> M[i][j];
			}
		}
		for( size_t i = 0; i < H + 1; i++ ) {
			for( size_t j = 1; j < W + 1; j++ ) {
				M[i][j] += M[i][j - 1];
			}
		}

		for( size_t i = 0; i < W + 1; i++ ) {
			for( size_t j = 1; j < H + 1; j++ ) {
				M[j][i] += M[j - 1][i];
			}
		}

		POINT firstX = make_pair( make_pair( 0, 0 ), make_pair( H, W ) );
		FIRSTCOST = cost( firstX );
		auto ans = saiki( firstX );
		cout << ans.first << " " << ans.second << endl;
	}
}

Measured memory_bytes: 38060
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    while(N != 0){
        int W,H;
        cin >> W >> H;
        vector<vector<int>> G(H,vector<int> (W,0));
        for(int i=0; i<N; i++){
            int x,y;
            cin >> x >> y;
            x--;
            y--;
            G[y][x]++;
        }
        int S,T;
        cin >> S >> T;
        int ans = 0;
        for(int i=T; i<=H; i++){
            for(int j=S; j<=W; j++){
                int sum = 0;
                for(int k=i-T; k<i; k++){
                    for(int l=j-S; l<j; l++){
                        sum += G[k][l];
                    }
                }
                chmax(ans,sum);
            }
        }
        cout << ans << endl;
        cin >> N;
    }
    return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,c,f;
  f=0;
  cin>>N;
  c=N;
  while(c>0){
    f=f+c%10;
    c=c/10;
  }  
  if(N%f==0){
    cout<<"Yes"<<endl;
  }  
  else{
    cout<<"No"<<endl;
  }  
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

int main() {
    string s;
    cin >> s;
    char prepre = s[0];
    char pre = s[1];
    if (s.size()==2){
     if (s[0] == s[1]) printf("1 2\n");
     else printf("-1 -1\n");
     return 0;
    }
    for (int i = 2; i < s.size(); i++){
        if (prepre == s[i]) {
            printf("%d %d\n", i-1,i+1);
            return 0;
        }
        else if (pre == s[i]) {
            printf("%d %d\n", i,i+1);
            return 0;
        }
        else{
            prepre = pre;
            pre = s[i];
        }
    }
    printf("-1 -1\n");
    return 0;
}

Measured memory_bytes: 512
def main():
    h,w = map(int,input().split())
    v = 0
    if h == 1 or w == 1:
        print(1)
        return
    if h %2 == 0:
        v = h // 2
        print(v*w)
        return
    else:
        if w % 2 == 0:
            print(h*w//2)
            return
        else:
            print((w//2)*h*2//2 + h//2+1)
if __name__=='__main__':
    main()


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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define INF 1e9  //
#define INFLL 4e18  //
#define MOD (1e9)+7
#define MP make_pair
#define PB(a) push_back(a)
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

//------------------------------------------------------

int main() {
    int n;
    cin >> n;
    ll L[n + 1];
    L[0] = 2;
    L[1] = 1;

    rep(i, n - 1) {
        L[i + 2] = L[i + 1] + L[i];
    }

    cout << L[n] << endl;

    return 0;
}

Measured memory_bytes: 256
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    A, B = map(int, input().split())
    ans = -1
    for n in range(1500):
        if int(n * 0.08) == A and int(n * 0.1) == B:
            ans = n
            break
    
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 64108
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.immutable._
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}

object Main {
  val m = (1 << 9) - 1

  def solve(sc: => Scanner): Unit = {
    println(getPrimeList.filter(_ % 5 == 4).drop(100).take(sc.nextInt).force.mkString(" "))
  }

  def recursive(now: Int, A: Array[List[Int]]): Int = {
    if (A(now).size == 0) (now) else {
      val next = A(now).head
      A(now) = A(now).filter(_ != next)
      A(next) = A(next).filter(_ != now)
      recursive(next, A)
    }
  }

  def getPermutation(now: Long = 0): Stream[Long] =
    Stream.cons(now, getPermutation(now + 1))


  def getPrimeList(): Stream[Long] =
    getPrimeListRecursive(getPermutation(2))


  def getPrimeListRecursive(A: Stream[Long]): Stream[Long] =
    Stream.cons(A.head, getPrimeListRecursive(A.tail.filter(_ % A.head != 0)))


  def check(A: Array[List[Int]]): Boolean = {
    A.map(_.size == 0).fold(true)((a, b) => a & b)
  }

  def shift(n: Long): Long = {
    if (n == 0) (0) else if (n == 1) (1) else (shift(n - 1) << 1)
  }

  def unShift(n: Long): Long = {
    if (n == 0) (0) else (unShift(n >> 1) + 1)
  }

  def calc(v: Long): Long = (v + 1) * v / 2

  def gcd(i: Long, j: Long): Long = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 43804
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int q;
    cin >> q;
    while(q--){
        string s, t;
        cin >> s >> t;
        int m = t.size();
        reverse(s.begin(),s.end());
        for (auto &&i : s) {
            string tt(t);
            if(i == 'J'){
                for (int j = 0; j < m; ++j) {
                    tt[j] = t[(j+m-1)%m];
                }
            }else if(i == 'C'){
                for (int j = 0; j < m; ++j) {
                    tt[j] = t[(j+1)%m];
                }
            }else if(i == 'E'){
                for (int j = 0; j < m/2; ++j) {
                    tt[j+(m+1)/2] = t[j];
                    tt[j] = t[j+(m+1)/2];
                }
            }else if(i == 'A'){
                reverse(tt.begin(),tt.end());
            }else if(i == 'P') {
                for (int j = 0; j < m; ++j) {
                    if('0' <= tt[j] && tt[j] <= '9'){
                        tt[j] = '0' + (tt[j]-'0'+9)%10;
                    }
                }

            }else {
                for (int j = 0; j < m; ++j) {
                    if('0' <= tt[j] && tt[j] <= '9'){
                        tt[j] = '0' + (tt[j]-'0'+1)%10;
                    }
                }
            }
            t = tt;
        }
        cout << t << "\n";
    }
    return 0;
}


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

int main() {
  int N;
  string S,T;
  cin >> N;
  cin >> S >> T;
  
  string ans = "";
  rep(i,N){
    ans += S.at(i);
    ans += T.at(i);
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    int n, q;
    cin>>n>>q;
    vector<queue<int>> qs(n);
    rep(i, q) {
        int j, t, x;
        cin>>j;
        if (j == 0) {
            cin>>t>>x;
            qs[t].push(x);
        }
        else if (j == 1) {
            cin>>t;
            if (qs[t].empty()) continue;
            cout<<qs[t].front()<<endl;
        }
        else {
            cin>>t;
            if (qs[t].empty()) continue;
            qs[t].pop();
        }
    }
}


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

int main(void){
    int N;
    cin >> N;
    
    vector<int> P(N);
    vector<int> P2(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i];
        P2[i] = P[i];
    }
    
    vector<int> Q(N);
    for (int i = 0; i < N; i++)
        cin >> Q[i];
        
    iota(P2.begin(), P2.end(), 1);
    int count = 0;
    bool flag = false;
    do {
        count++;
        for (int i = 0; i < N; i++) {
            if (P[i] != P2[i])
                break;
            if (i == N-1)
                flag = true;
        }
        if (flag)
            break;
    } while(next_permutation(P2.begin(), P2.end()));
    
    iota(P2.begin(), P2.end(), 1);
    int count2 = 0;
    bool flag2 = false;
    do {
        count2++;
        for (int i = 0; i < N; i++) {
            if (Q[i] != P2[i])
                break;
            if (i == N-1)
                flag2 = true;
        }
        if (flag2)
            break;
    } while(next_permutation(P2.begin(), P2.end()));
    cout << abs(count2-count) << endl;
    
}

Measured memory_bytes: 256
#include <cstdio>
#define NUM 128

int main(void) {
	while(1) {
		int n, m, p;
		int pool = 0, share;
		int num[NUM];
		scanf("%d %d %d", &n, &m, &p);
		if(!n && !p) break;
		for(int i = 0; i < n; i++) {
			scanf("%d", &num[i]);
			pool += 100 * num[i];
		}
		if(!num[m - 1]) share = 0;
		else share = (pool * (100 - p) * 0.01) / num[m - 1];
		printf("%d\n", share);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll gcd(int a,int b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(int a,int b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll INFS=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n-1){
    int p;
    cin>>p;
    p--;
    a[p]++;
  }
  rep(i,n){
    cout<<a[i]<<endl;
  }
}

Measured memory_bytes: 4024
import java.util.Scanner;

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


      int A = sc.nextInt();
      int B = sc.nextInt();
      int C = sc.nextInt();

      if(A <= C && C <= B) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }

    }
}  


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

int n,m;
vector<int>a,b;
bool g[60][60];
bool seen[60];

void dfs(int v){
	seen[v]=true;
	for(int i=0;i<n;i++){
		if(!g[v][i])continue;
		if(seen[i])continue;
		dfs(i);
	}
}

int main(){
	cin>>n>>m;
	a.resize(m),b.resize(m);
	for(int i=0;i<m;i++){
		cin>>a[i]>>b[i];
		a[i]--,b[i]--;
		g[a[i]][b[i]]=true;
		g[b[i]][a[i]]=true;
	}
	int ans=0;
	for(int i=0;i<m;i++){
		g[a[i]][b[i]]=false;
		g[b[i]][a[i]]=false;
		for(int j=0;j<n;j++)seen[j]=false;
		dfs(0);
		bool bridge=false;
		for(int j=0;j<n;j++)if(seen[j]==false)bridge=true;
		if(bridge)ans++;
		g[a[i]][b[i]]=true;
		g[b[i]][a[i]]=true;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
# print('input >>')
N, D = map(int,(input().split()))
XYs = []
for _ in range(N):
    XYs.append(tuple(map(int,(input().split()))))

ans = 0

for XY in XYs:
    X = XY[0]
    Y = XY[1]
    dist = X ** 2 + Y ** 2
    if dist <= D ** 2:
        ans += 1

# print('-----output-----')

print(ans)

Measured memory_bytes: 35996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    int n=s.size();
    int m=t.size();
    int mn=INT_MAX;
    for(int i=0;i+m<=n;i++){
        string k=s.substr(i,m);
        int cnt=0;
        for(int j=0;j<m;j++){
            if(k[j]!=t[j])cnt++;
        }
        mn=min(mn,cnt);
    }
    cout<<mn<<endl;
}


Measured memory_bytes: 3612
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<limits>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1000000000 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

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

	rep(i, k) {
		if (i % 2 == 0) {
			if (a % 2 == 1) {
				a--;
			} 
			b += a / 2;
			a /= 2;
		} else {
			if (b % 2 == 1) {
				b--;
			}
			a += b / 2;
			b /= 2;
		}
	}
	cout << a << " " << b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
deque<char>d,d2;
int main()
{


    string s,s1;
    cin>>s>>s1;
    int n=s.size();
    for(int i=0;i<n;i++){
      d.push_back(s[i]); d2.push_back(s1[i]);
    }
if(s==s1){cout<<"Yes"; return 0;}

    for(int i=0;i<n;i++){
        d.push_front(d[d.size()-1]);
        d.pop_back();
        if(d==d2){cout<<"Yes"; return 0;}

    }
    cout<<"No";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include<map>
#include<set>
using namespace std;

int main() {
    long long n, m;
    cin >> n >> m;
    long long ans;
    if (n >= 3 && m >= 3) ans = (n - 2) * (m - 2);
    else if (n == 2 && m>=2|| m == 2 && n>=2) ans = 0;
    else if (n ==1 && m>=2|| m ==1 && n>=2) ans = (n==1)?m-2:n-2;
    else if (n==1 && m==1) ans=1;
    cout << ans << endl;
}


            


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        int time = h*60+m;
        double hd = 0.5*time;
        double md = 6.0*m;

        double hx = Math.sin(Math.toRadians(hd)) * a;
        double hy = Math.cos(Math.toRadians(hd)) * a;
        double mx = Math.sin(Math.toRadians(md)) * b;
        double my = Math.cos(Math.toRadians(md)) * b;

        double x = (hx - mx);
        if (x<0) {
            x *= -1;
        }
        double y = (hy - my);
        if (y<0) {
            y *= -1;
        }
        double ans = x*x + y*y;
        System.out.println(Math.sqrt(ans));
    }
}


Measured memory_bytes: 35992
#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.first << ' ' << p.second << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define MOD 1000000007
#define zeros(x) x&(x-1)^x
#define fi first
#define se second
#define NMAX 100005
const long double PI = acos(-1);

int n,v[NMAX],k;
ll dp[NMAX];

int main(){
  ios::sync_with_stdio(false);
  cin >> n >> k;
  memset(dp,0x3f,sizeof dp);
  dp[1] = 0;
  for (int i=1;i<=n;i++){
  	cin >> v[i];
  	for (int j=i-1;j>=max(1,i-k);j--){
  		dp[i] = min(dp[i], dp[j] + abs(v[i] - v[j]));
  	}
  }

  cout << dp[n] << '\n';
  return 0;
}

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

using i64 = int64_t;

constexpr int INF = 1e9;

struct Node{
    int y, x, cost;
};

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

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<char>> grid(h, vector<char>(w));
    int black = 0;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            cin >> grid[i][j];
            if(grid[i][j] == '#')black++;
        }
    }

    vector<vector<int>> mini(h, vector<int>(w, INF));
    mini[0][0] = 0;
    queue<Node> que;
    que.push({0, 0, 0});
    bool ok = false;
    while(!que.empty()){
        auto cur = que.front(); que.pop();
        if(cur.y == h-1 && cur.x == w-1){
            cout << h*w - (black + cur.cost + 1) << endl;
            ok = true;
            break;
        }
        for(int d=0;d<4;++d){
            int nx = cur.x + dx[d], ny = cur.y + dy[d];
            if(nx < 0 || nx >= w || ny < 0 || ny >= h)continue;
            if(grid[ny][nx] == '#')continue;
            if(cur.cost+1 >= mini[ny][nx])continue;
            mini[ny][nx] = cur.cost + 1;
            que.push({ny, nx, cur.cost+1});
        }
    }

    if(!ok)cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    string s;
    cin>>s;
    int a=0,b=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='0'){
            a++;
        }else{
            b++;
        }
    }
    cout<<min(a,b)*2<<endl;
      return 0;

}

Measured memory_bytes: 512
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int[] h = new int[N];
        for (int i = 0; i < N; i++) h[i] = in.nextInt();
        System.out.println(minCost(h, N));
    }

    public static int minCost(int[] h, int N) {
        int st1 = 0;
        int st2 = Math.abs(h[1] - h[0]);
        for (int i = 2; i < N; i++) {
            int next = Math.min(st2 + Math.abs(h[i] - h[i-1]), st1 + Math.abs(h[i] - h[i-2]));
            st1 = st2;
            st2 = next;
        }
        return st2;
    }
}


Measured memory_bytes: 50056
// https://atcoder.jp/contests/practice2/tasks/practice2_a?lang=ja

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

int main()
{
    long n, q;
    cin >> n >> q;

    fenwick_tree<long long> fw(n);
    for (long i = 0; i < n; ++i)
    {
        long a;
        cin >> a;
        fw.add(i, a);
    }

    for (long i = 0; i < q; ++i)
    {
        long t;
        cin >> t;
        if (t == 0)
        {
            long p, x;
            cin >> p >> x;
            fw.add(p, x);
        }
        else
        {
            long l, r;
            cin >> l >> r;
            cout << fw.sum(l, r) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 8212
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <sstream>
#include <iomanip>
#include <time.h>
#include <fstream>

using namespace std;

int main(){
	char c;
	cin>>c;
	if ((c=='a')||(c=='e')||(c=='i')||(c=='o')||(c=='u')) cout<<"vowel"<<endl;
	else cout<<"consonant"<<endl;
	return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    i32 n; cin >> n;
    string s;
    vi comp(n);
    cin >> s;
    for(i32 i = 0; i < n-1; ++i) {
        if(s[i] == '(') {
            i32 lidx = i;
            i32 p = 1;
            for(i32 j = lidx+1; j < n; ++j) {
                if(s[j] == '(') ++p;
                else --p;
                if(p == 0) {
                    for(i32 k = lidx; k <= j; ++k) comp[k] = 1;
                    break;
                }
            }
        }
    }
    i32 cntf = 0, cntb = 0;
    for(i32 i = 0; i < n; ++i) {
        if(!comp[i]) {
            if(s[i] == ')') ++cntf;
            else ++cntb;
        }
    }
    string ans;
    rep(i,cntf) ans = ans + '(';
    ans = ans + s;
    rep(i,cntb) ans = ans + ')';

    cout << ans << '\n';


    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i;
	char S[1003];
	scanf("%s", S);
	for (i = 0; S[i] != 0; i++);
	if (S[i-1] == 's') printf("%ses\n", S);
	else printf("%ss\n", S);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1732
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
q = int(input())

counter = Counter(a)
sum_res = sum(a)

for i in range(q):
  b, c = map(int, input().split())
  
  sum_res -= b * counter[b]
  sum_res += c * counter[b]
  
  counter[c] += counter[b]
  counter[b] = 0
  
  print(sum_res)

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

int main() {
  int n, h;
  cin >> n >> h;
  priority_queue<P> que;
  int amax = 0;
  for (int i = 0; i < n; i++) {
    P tmp;
    cin >> tmp.second >> tmp.first;
    que.push(tmp);
    amax = max(amax, tmp.second);
  }
  int cnt = 0;
  while (!que.empty() && que.top().first >= amax) {
      h -= que.top().first;
      que.pop();
      cnt++;
    if (h <= 0) {
      cout << cnt << endl;
      return 0;
    }
  }
  cnt += (h + amax - 1) / amax;
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1400