akhauriyash/Code-Regression huggingface dataset:
/**
    And in the end, the love you take is equal to the love you make.

        I LOVE YOU LAURA.
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_DISABLE_PERFCRIT_LOCKS

#define findOrder find_by_order
#define orderKey order_of_key

#define isOn(mask, i) (mask & (1 << i))
#define turn(mask, i) (mask |= (1 << i))
#define switch(mask, i) (mask &= ~(1 << i))
#define change(mask, i) (mask ^= (1 << i))
#define lowbit(mask) (mask & (-mask))
#define turnAll(mask, n) (mask = (1 << n) - 1)
#define switchLastBit(mask) (mask & (mask - 1))
#define turnLastZero(mask) (mask | (mask + 1))
#define modulo(x, mod) ((x) & (mod - 1))
#define log2(x) (31 - __builtin_clz(x))

#define mkp make_pair
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define ins insert
#define rsz resize
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define debug(x) (cerr << x << " ")

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdb;
typedef pair<int, ii> tri;
typedef complex<ld> cd;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vdb;
typedef vector<cd> vcd;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vll> matrix;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_tree;

const ll mod = 1e9+7;
const int maxn = 3005;
const int pi = 2 * acos(0.0);
const db eps = 1e-9;

string s, t, ans;
int dp[maxn][maxn];

vs LCS (int m, int n){
    vs x;

    if (m == 0 || n == 0){
        x.pb("");
        return x;
    }

    if (s[m - 1] == t[n - 1]){
        vs tmp = LCS(m - 1, n - 1);

        for (auto str: tmp) x.pb(str + s[m - 1]);
    }
    else{
        if (dp[m - 1][n] >= dp[m][n - 1]){
            x = LCS(m - 1, n);
        }
        else{
            vs tmp = LCS(m, n - 1);
            for (auto i: tmp) x.pb(i);
        }
    }
    return x;
}

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

    cin >> s >> t;

    int m = sz(s), n = sz(t);

    for (int i = 0; i <= m; i++){
        for (int j = 0; j <= n; j++){
            if (i == 0 || j == 0){
                dp[i][j] = 0;
                continue;
            }

            if (s[i - 1] == t[j - 1]){
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else{
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }

    vs ans = LCS(m, n);

    cout << ans[0] << "\n";

    return 0;
}


Measured memory_bytes: 36224
#include <bits/stdc++.h>
using namespace std;
int f(int n){
    if(n<6) return 0;
    int ans=0;
    for(int x=1;x*x<=n;x++){
         for(int y=x;x*x+y*y<=n;y++){
             for(int z=y;x*x+y*y+z*z<=n;z++){
                 if(x*x+y*y+z*z+x*y+x*z+y*z==n){
                 	if(x!=y and y!=z and x!=z) ans+=6;
                 	else if(x==y and y==z and x==z) ans++;
                 	else ans+=3;
                 }
             }
         }
    }
    return ans;
}

int main() {
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cout<<f(i)<<"\n";
    }
	return 0;
}


Measured memory_bytes: 3480
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ll n;
  cin >> n;
  ll a[n];
  for (ll i = 0; i < n; ++i) cin >> a[i];
  sort(a, a+n);
  ll ans = 0;
  ll prev = -1;
  for (ll i = 0; i < n; ++i) {
    if (prev == a[i]) {ans--; prev = -1;}
    else {ans++; prev = a[i];}
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int a,b,c;
	int n;
	int x;
	while(true){
		scanf("%d%d%d",&a,&b,&c);
		if(a==0&&b==0&&c==0)return 0;
		scanf("%d",&n);
		if(a>b)swap(a,b);
		if(b>c)swap(b,c);
		if(a>c)swap(a,c);
		int z=a*a+b*b;
		for(int i=0;i<n;i++){
			scanf("%d",&x);
			if(z<(2*x)*(2*x))printf("OK\n");
			else printf("NA\n");
		}
	}
}

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

#pragma GCC optimize("O3")

using namespace std;

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

typedef long long ll;

void solve(){
	ll n, k;
	cin >> n >> k;
	n %= k;
	cout << min(n, k - n);
}

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

	solve();
    
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
double p[3010];
double dp[3010][3010];

signed main(){
	cin>>N;
	REP(i,N){
		cin>>p[i];
	}
	dp[0][0]=1;
	REP(i,N){
		for(int j=0;j<=i;j++){
			dp[i+1][j+1]+=dp[i][j]*p[i];
			dp[i+1][j]+=dp[i][j]*(1-p[i]);
		}
	}
	int s;
	if(N%2==1){
		s=ceil2(N,2);
	}
	else{
		s=N/2+1;
	}
	double ans=0;
	for(int i=s;i<=N;i++){
		ans+=dp[N][i];
	}
	setdouble(10,ans);
	cout<<endl;
	return 0;
}


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

int main(){
        vector <int > ans (26,100);
        int n=0;
        cin >> n;
        for (int i=0;i<n;i++){
                vector <int > res (26);
                string s="";
                cin >> s;
                for (int j=0;j<s.size();j++) res[s[j]-'a']++;
                for (int i=0;i<26;i++) ans[i]=min(ans[i],res[i]);
        }
        for (int i=0;i<26;i++){
                char curr='a'+i;
                string temp (ans[i],curr);
                cout << temp;
        }
}


Measured memory_bytes: 256
// D - Derangement

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int p[100001];

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

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

	int ans = 0;
	for (int i=2; i<=N; i++) {
		if (p[i-1] == i-1 && p[i] == i) {
			swap(p[i-1], p[i]);
			ans++;
		}
	}

	if (p[1] == 1) {
		swap(p[1], p[2]);
		ans++;
	}

	for (int i=2; i<=N; i++) {
		if (p[i] == i) {
			swap(p[i-1], p[i]);
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
import java.util.*;
public 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();
		int D = sc.nextInt();
		int flag = 0;
		
		while(true){
			C = C - B;
			if (C <= 0){
				break;
			}
			A = A - D;
			if (A <= 0){
				flag = 1;
				break;
			}
		}
		
		if (flag == 0){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	}
}


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

int main(){
	using ll = long long;
	ll h, w;
	cin >> h >> w;
	ll ans = 1ll << 60;
	for(ll i = 1; i <= (h + 2) / 3; i++){
		ll a = w * i, b = (h - i) * (w / 2 + (w & 1)), c = h * w - a - b;
		ans = min(ans, max(a, max(b, c)) - min(a, min(b, c)));
		b = w * ((h - i) / 2 + ((h - i) & 1)), c = h * w - a - b;
		ans = min(ans, max(a, max(b, c)) - min(a, min(b, c)));
	}
	for(ll i = 1; i <= (w + 2) / 3; i++){
		ll a = h * i, b = (w - i) * (h / 2 + (h & 1)), c = h * w - a - b;
		ans = min(ans, max(a, max(b, c)) - min(a, min(b, c)));
		b = h * ((w - i) / 2 + ((w - i) & 1)), c = h * w - a - b;
		ans = min(ans, max(a, max(b, c)) - min(a, min(b, c)));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MAX 26
#define NIL -1

struct Node {
	int p, l, r; //??????????????????
};
struct Node T[MAX];

//???????????????
void pre(int id) {
	if (id == NIL)return;
	cout << " " << id;
	pre(T[id].l);
	pre(T[id].r);
}

//???????????????
void in(int id) {
	if (id == NIL)return;
	in(T[id].l);
	cout << " " << id;
	in(T[id].r);
}

//???????????????
void post(int id) {
	if (id == NIL)return;
	post(T[id].l);
	post(T[id].r);
	cout << " " << id;
}


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

	//?????????
	for (int i = 0; i < n; i++) {
		T[i].p = T[i].l = T[i].r = -1;
	}

	for (int i = 0; i < n; i++) {
		int id, l, r; cin >> id >> l >> r;
		T[id].l = l;
		T[id].r = r;
		if (l != NIL)T[l].p = id;
		if (r != NIL)T[r].p = id;
	}

	//??????????????????
	int root;
	for (int id = 0; id < n; id++) {
		if (T[id].p == NIL) { root = id; }
	}

	cout << "Preorder" << endl;
	pre(root);
	cout << endl;

	cout << "Inorder" << endl;
	in(root);
	cout << endl;

	cout << "Postorder" << endl;
	post(root);
	cout << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }

const int q = 1e9+9;



int main()
{
    string s;
    ll k;
    cin >> s >> k;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == '1') {
            --k;
        } else {
            k = 0;
        }
        if(k <= 0) {
            cout << s[i] << endl;
            return 0;
        }
    }


    return 0;
}
// gotcha;


Measured memory_bytes: 256
#include<iostream>
#include<stack>
using namespace std;
static const int N = 100;
static const int white = 0;
static const int gray = 1;
static const int black = 2;

int n,a[N][N];
int color[N],d[N],f[N],tt;
int nt[N];

int next(int u){
    for(int v = nt[u];v < n;v++){
        nt[u] = v + 1;
        if(a[u][v])return v;
    }
    return -1;
}

void dfs_visit(int r){
    for(int i= 0;i < n;i++)nt[i] = 0;
    
    stack<int> S;
    S.push(r);
    color[r] = gray;
    d[r] = ++tt;
    
    while(!S.empty()){
        int u = S.top();
        int v = next(u);
        if(v != -1){
            if(color[v] == white){
                color[v] = gray;
                d[v] = ++tt;
                S.push(v);
            }
        }
        else{
            S.pop();
            color[u] = black;
            f[u] = ++tt;
        }
    }
}

void dfs(){
    for(int i = 0;i < n;i++){
        color[i] = white;
        nt[i] = 0;
    }
    tt = 0;
    
    for(int u = 0;u < n;u++){
        if(color[u] == white)dfs_visit(u);
    }
    for(int i = 0;i < n;i++){
        cout << i + 1 << " " << d[i] << " " << f[i] << endl;
    }
}

int main(){
    int u,k,v;
    
    cin >> n;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++)a[i][j] = 0;
    }
    for(int i = 0;i < n;i++){
        cin >> u >> k;
        u--;
        for(int j = 0;j < k;j++){
            cin >> v;
            v--;
            a[u][v] = 1;
        }
    }
    dfs();
    
    return 0;
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,k,a[200005]={0},mx=0,sum=0;
	cin>>m>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	k=a[n];
	for(int i=n;i>1;i--){
		a[i]-=a[i-1];
		sum+=a[i];
		mx=max(mx,a[i]);
	}
	a[1]+=m-k;
	sum+=a[1];
	mx=max(mx,a[1]);
	cout<<sum-mx<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
 
using namespace std;
using i64=long long int;
 
int main() {
  int X;
  cin >> X;
  
  if (X == 3 || X == 5 || X == 7) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void yes(){
  cout << "Yes" << endl;
  exit(0);
}

void no(){
  cout << "No" << endl;
  exit(0);
}

int main(){
  ll n; cin >> n;
  vector<ll> a(n);
  ll maxi = 0, mini = 1e18;
  REP(i,n) {
    cin >> a[i];
    maxi = max(maxi,a[i]);
    mini = min(mini,a[i]);
  }
  if(maxi-mini>1) no();
  if(maxi==mini){
    if(maxi==n-1 || 2*maxi<=n) yes();
    else no();
  }
  
  ll alone = 0;
  REP(i,n) if(a[i]==mini) alone++;
  if(alone<maxi && 2*(maxi-alone)<=n-alone) yes();
  else no();
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#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 mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair

/*int P[10010];
void init(int n){//Union-find
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？
//セグメント木？？
*/

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
/*ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/

//cerrはコメントアウトしなくても通る

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    vector<int> idx(n);
    rep(i,n) idx[a[i]]=i;
    set<int> s;
    ll ans=0;
    for(int x=n-1;x>=0;--x){
        int i=idx[x];
        ll c=0;
        {// cの計算
            s.insert(i);//大きい方から投入するので毎回大小比較してsetに入れる必要がない　そのため早い
            vector<int> l(2,-1);
            vector<int> r(2,n);
            {//　lの計算
                auto it =s.find(i);
                rep(j,2){
                    if(it==s.begin())break;
                    --it;
                    l[j]=*it;
                }
            }
            {// rの計算
                auto it =s.find(i);
                rep(j,2){
                    ++it;
                    if(it==s.end())break;
                    r[j]=*it;
                }
            }
            vector<int> ls(2);
            ls[0]=i-l[0];
            ls[1]=l[0]-l[1];
            vector<int> rs(2);
            rs[0]=r[0]-i;
            rs[1]=r[1]-r[0];
            c=(ll)ls[0]*rs[1]+(ll)ls[1]*rs[0];
        }
        ans+=c*(x+1);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
template <class t>
bool ckmin(t& a, const t& b) {
    return a > b ? a = b, true : false;
}
template <class t>
bool ckmax(t& a, const t& b) {
    return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
    if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p);
template <class T>
struct IsC {
    template <class C>
    static char test(typename C::const_iterator*);
    template <class C>
    static int test(...);
    static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
    static const bool value = false;
};
template <class C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream& o,
                                                             const C& c) {
    o << '[';
    for (auto it = c.begin(); it != c.end();)
        o << *it << (++it != c.end() ? ", " : "");
    return o << ']';
}
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p) {
    return o << '(' << p.fi << ", " << p.se << ')';
}

void solve() {
    int h1, h2, m1, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << h2 * 60 + m2 - (h1 * 60 + m1) - k << endl;
}

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

    int tt = 1;
    FOR (t, 1, tt + 1) {
	// cout << "Case #" << t << ": ";
	solve();
    }

    return 0;
}


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

  
int main() {
int a, b, c;
cin >> a >> b >> c;
int mi = min(a, b);
int ans = mi + min(max(a, b), c);
print(ans);

}


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


int main()
{
  int a, b, h, m;
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &h);
  scanf("%d", &m);
  double hk = h*30+m*0.5;
  int mk = m*6;
  double rad = (hk - mk)*M_PI/180;
  double da = a*a;
  double db = b*b;
  // printf("%.20lf\n", da);
  // printf("%.20lf\n", da);
  // long long int x = a*a+b*b-2*a*b*cos(rad)*10000000000;
  // double l = sqrt(x)/100000.0;
  double l = sqrt(a*a+b*b-2*a*b*cos(rad));
  printf("%.20lf\n", l);
  // printf("Hello World!\n");
  return 0;
}

Measured memory_bytes: 2600
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {

	public static int oo = (int)1e9;
	
	public static void solve() {
		int n = s.nextInt();
		int k = s.nextInt();
		int S = s.nextInt();
		if(S == oo) {
			oo--;
		}
		int[] ans = new int[n];
		Arrays.fill(ans, oo);
		for(int i = 0; i < k; i++) {
			ans[i] = S;
		}
		for(int i = 0; i < n; i++) {
			out.print(ans[i] + " ");
		}
	}

	public static void main(String[] args) {
		new Thread(null, null, "Thread", 1 << 27) {
			public void run() {
				try {
					out = new PrintWriter(new BufferedOutputStream(System.out));
					s = new FastReader(System.in);
					solve();
					out.close();
				} catch (Exception e) {
					e.printStackTrace();
					System.exit(1);
				}
			}
		}.start();
	}

	public static PrintWriter out;
	public static FastReader s;

	public static class FastReader {

		private InputStream stream;
		private byte[] buf = new byte[4096];
		private int curChar, snumChars;

		public FastReader(InputStream stream) {
			this.stream = stream;
		}

		public int read() {
			if (snumChars == -1) {
				throw new InputMismatchException();
			}
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException E) {
					throw new InputMismatchException();
				}
			}
			if (snumChars <= 0) {
				return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int number = 0;
			do {
				number *= 10;
				number += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return number * sgn;
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			long sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long number = 0;
			do {
				number *= 10L;
				number += (long) (c - '0');
				c = read();
			} while (!isSpaceChar(c));
			return number * sgn;
		}

		public int[] nextIntArray(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = this.nextInt();
			}
			return arr;
		}

		public long[] nextLongArray(int n) {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = this.nextLong();
			}
			return arr;
		}

		public String next() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndofLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public boolean isEndofLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}

	
}


Measured memory_bytes: 41516
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste

// #include "UnionFind.hpp"
// #include "power.hpp"

signed main() {
    double N, K;
    cin >> N >> K;
    double ans = 0;
    double sheets = (double)1 / N;
    for (int i = 1; i <= N; i++) {
        double times = ceil(log2(K / i));
        if (i >= K) {
            ans += sheets * 1;
        } else {
            ans += sheets * pow(0.5, times);   
        }
    }
    cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define REV(v) reverse(v.begin(),v.end())
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
#define dout(n) cout<<# n<<" = "<<n<<endl;
#define v1out(v) FOR(j,0,v.size()){cout<<v[j]; if(j!=(ll)v.size()-1)cout<<" ";else cout<<endl; }
#define v2out(v) FOR(i,0,v.size())v1out(v[i]);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> v(n+1);
    FOR(i,0,n-1){
        ll in;
        cin>>in;
        v[in]++;
    }
    FOR(i,1,n+1){
        cout<<v[i]<<endl;
    }
}

Measured memory_bytes: 4764
#include<bits/stdc++.h>
using namespace std;
long long n[50050],f[100050],zs,a,lefts,rights;
bool b[100050];
int main(){
    b[0]=1,b[1]=1;
    for(int s=2;s<=100005;s++){
        if(!b[s]) n[zs++]=s;
        for(int v=0;v<zs;v++){
            if(s*n[v]>100005)break;
            b[n[v]*s]=true;
            if(s%n[v]==0)break;
        }
    }
    cin>>a;
    for(int s=2;s <= 100005;s++){
        if(s%2==1&&b[s]==0&&b[(s+1)/2]==0)
        f[s]=1;
        f[s]+=f[s-1];
    }
    while(a--){
        cin>>lefts>>rights;
        cout<<f[rights]-f[lefts-1]<<endl;
    }
    return 0;
}

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

void Main() {
    // input
    string S;
    cin >> S;




    // process
    string ans;
    if (S[size(S)-1] == 's') {
        ans = S + "es";
    } else {
        ans = S + "s";
    }


    // output
    cout << ans << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int n,m,j,k,i;
int ans[200050];
bool b[100500];
vector<int> p[100500];
int main()
{
    cin>>n>>m;
    b[1]=false;
    for(int i=2;i<=n;i++)
        b[i]=true;
    int count=1;
    for(i=0;i<m;i++) {
        scanf("%d%d", &j, &k);
        p[j].push_back(k);
        p[k].push_back(j);
    }
    queue<int>q;
    q.push(1);
    while(!q.empty()){
        int now=q.front();
        q.pop();
        for(int i=0;i<p[now].size();i++){
            int y=p[now][i];
            if(b[y]){
                ans[y]=now;
                b[y]=false;
                q.push(y);
                count++;
            }
        }
    }
    if(count<n)
        printf("No\n");
    else{
        cout<<"Yes"<<endl;
        for (i = 2; i <= n; i++)
            cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 10532
#include <stdio.h>

int calc(int n,int num,int s){
    //printf("%d %d %d\n",s,num,s);
    if(s==0&&n==0) {
        //printf("               return 1\n");
        return 1;
    }
    if(num>9){
        //printf(" return 0\n");
        return 0;
    }
    return (calc(n,num+1,s)+calc(n-1,num+1,s-num));
}

int main(){
    int n,s;
    
    while(1){
        scanf("%d%d",&n,&s);
        if(!n&&!s) return 0;
        
        printf("%d\n",calc(n,0,s));
    }
}

Measured memory_bytes: 600
n = int(input())
d = [list(map(int, input().split(" "))) for i in range(n)]
count = 0
for i in range(n):
  if d[i][0] == d[i][1]:
    count += 1
  else:
    count = 0
  if count == 3:
    break
print("Yes") if count >= 3 else print("No")

Measured memory_bytes: 9184
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

ll gcd(ll a, ll b) {
    if(b == 0) return a;
    return gcd(b, a%b);
}

struct C {
        int i;
        int j;
        C(){}
        C(int _i, int _j): i(_i), j(_j) {}
    };


int d(C a, C b) {
    return abs(a.i - b.i) + abs(a.j - b.j);
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int H, W, D;
    cin >> H >> W >> D;

    int M = H*W+1;
    C c[M];
    REP(i, H) {
        REP(j, W) {
            int a;
            cin >> a;
            c[a] = C(i, j);
        }
    }

    int S[M];
    REP(i, M) {
        if (i < D) S[i] = 0;
        else {
            S[i] = S[i-D] + d(c[i-D], c[i]);
        }
    }

    int Q;
    cin >> Q;

    REP(i, Q) {
        int l, r;
        cin >> l >> r;

        cout << S[r] - S[l] << endl;
    }

}


Measured memory_bytes: 2176
#include <stdio.h>
 
using namespace std;
 
int main(){
    int a,b;
    char op;
    while(true){
        scanf("%d %c %d",&a,&op,&b);
        if(op == '?') break;
        switch(op){
        case '+':
            printf("%d\n",a+b);
            break;
        case '-':
            printf("%d\n",a-b);
            break;
        case '/':
            printf("%d\n",a/b);
            break;
        case '*':
            printf("%d\n",a*b);
            break;
        }
    }
}


Measured memory_bytes: 2704
#include <iostream>
#include <string>

using namespace std;

int main(){
	int x = 0;
	int N;
	string S;
	int max = 0;

	cin >> N >> S;

	for(int i = 0; i < N; i++){
		if(S.at(i) == 'I'){
			x++;
		}else if(S.at(i) == 'D'){
			x--;
		}

		if(max < x){
			max = x;
		}

	}

	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
def dist(x,y):
    return abs(x[0]-y[0])+abs(x[1]-y[1])
N = int(input())
X = [list(map(int,input().split())) for _ in range(N)]
flag = 0
t1,x1,y1 = 0,0,0
for i in range(N):
    t2,x2,y2 = X[i]
    d = dist((x1,y1),(x2,y2))
    dt = t2-t1
    if dt>=d and (dt-d)%2==0:
        t1,x1,y1 = X[i]
    else:
        flag=1
        break
if flag==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 90300
n = int(input())
h = [int(x) for x in input().split()]

dp = [0] * n
dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2, n):
    dp[i] = min( dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]) )

print(dp[n-1])


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

using namespace std;
		
int main(void){
	double x1,x2,y1,y2;
	cin>>x1>>y1>>x2>>y2;
	cout.precision(12);
	cout<<fixed<<hypot(x2-x1,y2-y1)<<endl;
	return 0;
}

Measured memory_bytes: 1292
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

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

	int ans = 0;
	if (x >= 400 && x < 600) { ans = 8; }
	if (x >= 600 && x < 800) { ans = 7; }
	if (x >= 800 && x < 1000) { ans = 6; }
	if (x >= 1000 && x < 1200) { ans = 5; }
	if (x >= 1200 && x < 1400) { ans = 4; }
	if (x >= 1400 && x < 1600) { ans = 3; }
	if (x >= 1600 && x < 1800) { ans = 2; }
	if (x >= 1800 && x < 2000) { ans = 1; }
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3640
//aea ctmr https://codeforces.com/contest/1271/submission/66946806
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
    
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define PI 3.14159265358979323846
 
typedef long double ld;
typedef long long ll;
const ll N = 105000;
const ll mod = 1e9 + 7;
using namespace std;
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);}
#else
#define trace(...)
#endif
 
vector <pair <int, int>> xd;

int main(){

    ll n;
    cin >> n;
    if(n % 2 == 1) {cout << 0 << endl; return 0;}
    n /= 10;
    ll ans = 0;
    while(n > 0){
        ans += n;
        n /= 5;
    }

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

Measured memory_bytes: 256
def main():
  N = int(input())
  A = list(map(int, input().split()))
  Q = int(input())
  num = [0] * 100005
  for i in A:
    num[i] += 1
  ans = sum(A)
  for i in range(Q):
    b, c = map(int, input().split())
    ans += (c-b)*num[b]
    print(ans)
    num[c] += num[b]
    num[b] = 0
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 84376
N=int(input())
a=list(map(int,input().split()))
x=a[0]
y=0
for i in range(1,N):
  y+=a[i]
ans=abs(x-y)
for i in range(1,N-1):
  x+=a[i]
  y-=a[i]
  ans=min(ans,abs(x-y))
print(ans)

Measured memory_bytes: 24832
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var str = ReadLine();
        WriteLine((str.Length % 2 == 0) ^ (str[0] == str[str.Length - 1]) ? "Second" : "First");
    }
}


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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

const ll MOD = 1000000007;

int main() {
	int n,k,q;
	int t;

	cin >> n >> k >> q;
	V<int> v(n,0);

	REP(i,q) {
		cin >> t;
		v[t-1] += 1;
	}

	REP(i,n) {
		if(k-q+v[i] > 0) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
}



Measured memory_bytes: 1024
#include <iostream>
using namespace std;
char C[1000][1000];
int Sum[1000][1000][2];
int main() {
	int M,N,K;
	cin >> M >> N >> K;
	for(int i=0;i<M;i++){
		for(int j=0;j<N;j++){
			cin >> C[j][i];
			if(C[j][i]=='J')
				Sum[j][i][0]++;
			if(C[j][i]=='O')
				Sum[j][i][1]++;
			for(int k=0;k<2;k++){
			if(i!=0)
			Sum[j][i][k]+=Sum[j][i-1][k];
			if(j!=0)
			Sum[j][i][k]+=Sum[j-1][i][k];
			if(i!=0 && j !=0)
			Sum[j][i][k]-=Sum[j-1][i-1][k];
		//	cout << Sum[j][i][k] <<" "<< j <<" "<< i <<" "<< k << endl;
			}
		}
	}
	for(int i=0;i<K;i++){
		int a,b,c,d;
		int ans[3];
		cin>>b>>a>>d>>c;
		a--;
		b--;
		c--;
		d--;
		for(int j=0;j<2;j++){
			ans[j]=Sum[c][d][j];
		
	//	cout << ans[j] << " " <<a <<" "<< b<<" " <<" " << c <<" "<<d << endl;
		if(a!=0)
			ans[j]-=Sum[a-1][d][j];
	//	cout << ans[j] << endl;
		if(b!=0)
			ans[j]-=Sum[c][b-1][j];
			
	//	cout << ans[j] << endl;
		if(a!=0&&b!=0)
			ans[j]+=Sum[a-1][b-1][j];
			
	//	cout << ans[j] << endl;
		}
		ans[2]=(c-a+1)*(d-b+1)-(ans[0]+ans[1]);
		cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
	}
		
	return 0;
}

Measured memory_bytes: 9948
function main()
    n, m, x = parse.(Int, split(readline()))
    c = zeros(Int, n);
    a = zeros(Int, n, m);
    for i in 1:n
        xx = parse.(Int, split(readline()))
        c[i] = xx[1]
        a[i, :] = xx[2:end]
    end
    L = n
    comb = Vector{Int}[]
    for i = 0:2^L-1
        cc = Int[]
        str = bitstring(i)
        str[length(str)-L+1:length(str)]
        for j in length(str)-L+1:length(str)
            push!(cc, Int(str[j] - '0'))
        end
        push!(comb, cc)
    end


    money = Int[]
    ok = false
    idxs = []
    for i in eachindex(comb)
        aa = zeros(Int, m)
        mm = 0
        for j in eachindex(comb[i])
            if comb[i][j] == 1
                for k in 1:m
                    aa[k] += a[j, k]
                end
                mm += c[j]
            end
        end
        if all(aa .>= x)
            push!(money, mm)
            push!(idxs, i)
            ok = true
        end
    end

    if ok == false
        println(-1)
    else
        println(minimum(money))
    end
end

main()


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


int main(){
    int n;
    cin >> n;
    int c[n-1], s[n-1], f[n-1];
    rep(i,n - 1){
        cin >> c[i];
        cin >> s[i];
        cin >> f[i];
    }

    rep(i, n - 1){
        int t = 0;
        for(int j = i; j < n - 1; j++){
            if (t < s[j]) t = s[j];
            else if (t % f[j] == 0) t += 0;
            else t += f[j] - t % f[j];
            t += c[j];
        }
        cout << t << endl;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  rep(i,t){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a<b) {
      cout << "No" << endl;
      continue;
    }
    if(b>d) {
      cout << "No" << endl;
      continue;
    }
    if(b<=c) {
      cout << "Yes" << endl;
      continue;
    }

    ll g=gcd(b,d);
    cout << (b-g+a%g<=c?"Yes":"No") << endl; 

  }
}

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

int main(){
  string c;
  cin >> c;
  
  string alpha = "abcdefghijklmnopqrstuvwxyz";
  int i;
  string a;
  for(i=0; i<27; i++){
    if(c.at(0)==alpha.at(i)){
      a = alpha.at(i+1);
      break;
    }
  }
 
  cout << a << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>

using namespace std;

int N, v[100], w[100], W;
int dp[101][10001];
int main(){
  cin >> N >> W;
  for(int i = 0; i < N; i++){
    cin >> v[i] >> w[i];
  }
  for(int i = 0; i < N; i++){
    for(int k = 1; k <= W; k++){
      dp[i+1][k] = dp[i][k];
      if(k >= w[i]){
	dp[i+1][k] = max(dp[i+1][k],dp[i+1][k - w[i]] + v[i]);
	dp[i+1][k] = max(dp[i+1][k], dp[i+1][k-w[i]]);
      }
    }
  }
  cout << dp[N][W] << endl;
}
 

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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    string a, b; cin >> a >> b;
    string c = a + b;
    int d = stoi(c);
    double e = sqrt(d);
    if(floor(e) == e) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
tanni = ['Man', 'Oku', 'Cho', 'Kei', 'Gai', 'Jo', 'Jou', 'Ko', 'Kan', 'Sei', 
        'Sai', 'Gok', 'Ggs', 'Asg', 'Nyt', 'Fks', 'Mts' , 'end']
        
while True :
    m, n = map(int, input().split())
    if m == 0 and n == 0 :
        break

    s = m**n
    #print(s)
    ans = []
    i = 0
    while True :
        ans.append(s % 10**4)
        s = s // 10**4
        if s == 0 :
            break
        else :
            if tanni[i] != 'end' :
                ans.append(tanni[i])
        if tanni[i] != 'end' :
            i += 1
    ans.reverse()
    
    switch = False
    for j in range(len(ans)) :
        if ans[j] == 0 :
            switch = True
        elif switch == False :
            if switch == True :
                switch = False
            else :
                print(ans[j], end='')
    print()
        


Measured memory_bytes: 5600
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	while (true) {
		string s;
		getline(cin, s);
		if (s == ".") return 0;
		stack<int> gogo;
		int ok = 1;
		for (int i = 0; i < s.length(); ++i) {
			if (s[i] == '(') {
				gogo.push(0);
			}
			else if (s[i] == ')') {
				if (gogo.empty() == true || gogo.top() == 1) {
					ok = 0;
					break;
				}
				gogo.pop();
			}
			else if (s[i] == '[') {
				gogo.push(1);
			}
			else if (s[i] == ']') {
				if (gogo.empty() == true || gogo.top() == 0) {
					ok = 0;
					break;
				}
				gogo.pop();
			}
		}
		if (gogo.empty() == true && ok == 1) {
			cout << "yes" << endl;
		}
		else {
			cout << "no" << endl;
		}
	}
}



Measured memory_bytes: 3204
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	ins := strings.Split(readLine(), "")

	for i := 1; i < len(ins); i++ {
		if ins[i] == ins[i-1] {
			fmt.Println("Bad")
			return
		}
	}
	fmt.Println("Good")
}


Measured memory_bytes: 640
#include <iostream>

int main() {
	int m, d;
	std::cin >> m >> d;

	int ans = 0;
	for (int i = 1; i <= m; ++i)
		for (int j = 22; j <= d; ++j)
			if ((j % 10) >= 2 && (j / 10) * (j % 10) == i)
				++ans;

	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.useDelimiter(System.getProperty("line.separator"));
        int n = sc.nextInt();
        String SStr = sc.next();
        int q = sc.nextInt();
        String TStr = sc.next();

        int[] S = toIntAry(SStr, n);
        int[] T = toIntAry(TStr, q);

        int cnt=0;
        for(int i=0; i<q; i++){
        	int key = T[i];
        	if(linearSearch(S,n,key))cnt++;
        }

        System.out.println(cnt);

	}



	private static boolean linearSearch(int[] A, int n, int key) {
		int i=0;
		A[n] = key;				//?????????????°??????????
		while(A[i]!=key)i++;	//????´?????????????????????§while?????????
		if(i!=n){
			return true;		//??????????´??????§?????????????????????NG
		}else{
			return false;		//??????????´?????????????OK
		}
	}



	private static int[] toIntAry(String str, int n) {
        String[] tmp = str.split(" ");
        int[] A = new int[10001];
        for (int i = 0; i < n; i++) {
			A[i] = Integer.parseInt(tmp[i]);
		}
        return A;
	}


}

Measured memory_bytes: 28972
program main
  implicit none
  integer :: a, b, c, d
  read *, a, b, c, d
  if (a + b == c + d) then
    print "(a)", "Balanced"
  else if (a + b < c + d) then
    print "(a)", "Right"
  else
    print "(a)", "Left"
  end if
end program main


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define sort_(a) sort(a.begin(), a.end())
#define rep(i, n) for (int i = 0; i < n; ++i)
typedef long long unsigned int ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen(".testcase", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  long N, M;
  cin >> N >> M;
  vector<vector<long>> AB(N, vector<long>(2));
  rep(i, N) {
    cin >> AB[i][0] >> AB[i][1];
  }
  sort_(AB);
  int n = 0;
  ll ans = 0;
  for (auto x : AB) {
    n = min(M, x[1]);
    ans += x[0] * n;
    M -= n;
    if (M == 0) break;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#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);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int x,y;
    cin >> x >> y;
    int xg,yg;
    if(x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12)
    {
        xg = 1;
    }
    else if(x == 4 || x == 6 || x == 9 || x == 11) {
        xg = 2;
    }
    else{
        xg = 3;
    }
    if(y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)
    {
        yg = 1;
    }
    else if(y == 4 || y == 6 || y == 9 || y == 11) {
        yg = 2;
    }
    else{
        yg = 3;
    }
    if(xg == yg){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func swap(a int, b int) (int, int) {
	return b, a
}

func GCD(a int, b int) int {
	if b > a {
		a, b = swap(a, b)
	}
	if b == 0 {
		return a
	} else {
		return GCD(a%b, b)
	}
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	ans := 0
	K := nextInt()
	for a := 1; a <= K; a++ {
		for b := 1; b <= K; b++ {
			for c := 1; c <= K; c++ {
				tmp := GCD(a, b)
				ans += GCD(tmp, c)
			}
		}
	}
	fmt.Printf("%d\n", ans)
}


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,l;
    string st[102];
    cin>>n>>l;
    for(int i=1;i<=n;i++)
        cin>>st[i];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n-i;j++){
            if(st[j]>st[j+1]) swap(st[j],st[j+1]);
        }
    for(int i=1;i<=n;i++){
        cout<<st[i];
    }   
    return 0;
}

Measured memory_bytes: 256
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(a, b) << ' ' << max(a + b - n, 0ll) << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3604