akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main(){	
	int n;
	while (cin >> n, n){
		map<char, char> mp;
		while (n--){
			char c, d;
			cin >> c >> d;
			mp[c] = d;
		}
		int m;
		cin >> m;
		while (m--){
			char c;
			cin >> c;
			if (mp.count(c)){
				cout << mp[c];
			}
			else{
				cout << c;
			}
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1188
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  vector<int> v(4);
  rep(i,4){
    cin >> v[i];
  }
  sort(all(v));
  bool flag=false;
  rep(i,4){
    if(v[0]==1&&v[1]==4&&v[2]==7&&v[3]==9){
      flag=1;
    }
  }
  if(flag){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#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 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>void tf(bool b,S t,S f){cout<<(b?t:f)<<endl;}
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 T>void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}

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);}
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;}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vl a(n),b(n),c(n);
	rep(i,n)cin>>a[i];
	rep(i,n)cin>>b[i];
	rep(i,n)c[i]=a[i]-b[i];
	if(accumulate(all(a),0ll)<accumulate(all(b),0ll)){
		cout<<-1<<endl;
		return 0;
	}
	sort(all(c));
	ll d=0;
	int ans=0;
	rep(i,n)if(c[i]<0){d-=c[i];ans++;}
	sort(rall(c));
	rep(i,n){
		if(d<=0)break;
		ans++;
		d-=c[i];
	}
	// cout<<c<<endl;
	// cout<<d<<endl;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7


def solve(N, K, A):
    ans = 1
    # K = N の場合は明らか
    if K == N:
        for i in range(K):
            ans *= A[i]
            ans %= MOD
    # Ai の全ての数が負かつ K が奇数のとき、
    elif max(A) < 0 and K % 2 == 1:
        A.sort(reverse=True)
        # 絶対値が小さい方から K 個の積
        for i in range(K):
            ans *= A[i]
            ans %= MOD
    # それ以外の場合、積は必ず非負
    else:
        # {Ai} を絶対値の降順にソート
        A.sort(key=abs, reverse=True)
        # 最初の K 個の積
        sign = 1
        for i in range(K):
            ans *= A[i]
            ans %= MOD
            if A[i] < 0:
                sign *= -1
            elif A[i] == 0:
                sign *= 0
        # P が負の場合
        if sign < 0:
            small_nonneg = [a for a in A[K:] if a >= 0]
            small_neg = [a for a in A[K:] if a < 0]
            large_nonneg = [a for a in A[:K] if a >= 0]
            large_neg = [a for a in A[:K] if a < 0]
            if not small_neg or not large_nonneg:
                ans *= max(small_nonneg)
                ans %= MOD
                ans *= pow(max(large_neg), MOD - 2, MOD)
                ans %= MOD
            elif not small_nonneg or not large_neg:
                ans *= min(small_neg)
                ans %= MOD
                ans *= pow(min(large_nonneg), MOD - 2, MOD)
                ans %= MOD
            else:
                if min(small_neg) * max(large_neg) > max(small_nonneg) * min(
                    large_nonneg
                ):
                    # (2) 正の数を 1 つ取り除き、負の数を 1 つ加える
                    ans *= min(small_neg)
                    ans %= MOD
                    ans *= pow(min(large_nonneg), MOD - 2, MOD)
                    ans %= MOD
                else:
                    # (1) 負の数を 1 つ取り除き、非負の数を 1 つ加える
                    ans *= max(small_nonneg)
                    ans %= MOD
                    ans *= pow(max(large_neg), MOD - 2, MOD)
                    ans %= MOD
    return ans


print(solve(N, K, A))


Measured memory_bytes: 120276
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

#define MAX_H 100
#define MAX_W 100

int H, W;
string a[MAX_H];
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);


	cin >> H >> W;
	rep(i, 0, H) cin >> a[i];

	vector<int> del_col, del_row;
	rep(i, 0, H) {
		bool flag = true;
		rep(j, 0, W) {
			if(a[i][j] == '#') {
				flag = false;
				break;
			}
		}
		if(flag) del_row.push_back(i);
	}

	rep(i, 0, W) {
		bool flag = true;
		rep(j, 0, H) {
			if(a[j][i] == '#') {
				flag = false;
				break;
			}
		}
		if(flag) del_col.push_back(i);
	}

	vsort(del_col);
	vsort(del_row);

	rep(i, 0, H) {
		if(binary_search(del_row.begin(), del_row.end(), i)) continue;
		rep(j, 0, W) {
			if(binary_search(del_col.begin(), del_col.end(), j)) continue;
			cout << a[i][j];
		}
		cout << endl;
	}
					
	

}


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

int main() {

    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i=0; i<s.size(); i++)
        s[i] = ((int(s[i]) + n) - int('A')) % 26 + int('A');
    cout << s;
    return 0;

}

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)

int main() {
	int n, k, r, s, p;
	string t;
	cin >> n >> k >> r >> s >> p >> t;
	vector<ll> score(n);
	vector<char> te(n);
	map<char, char> win;
	map<char, int> scores;
	win['r'] = 'p';
	win['s'] = 'r';
	win['p'] = 's';
	scores['r'] = r;
	scores['p'] = p;
	scores['s'] = s;
	
	FOR(i, 0, n - 1) {
		if (i - k >= 0 && te[i - k] == win[t[i]]) {
			if (i + k < n) {
				if (t[i + k] == win[t[i]]) {
					te[i] = t[i];
				}
				else {
					te[i]=win[win[t[i]]];
				}
			}
			else {
				te[i] = t[i];
			}
		}
		else {
			te[i] = win[t[i]];
			score[i] = scores[te[i]];
		}
	}
	ll res = accumulate(ALL(score), 0LL);
	pv(res);
	return(0);
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,a,b; cin>>n>>a>>b;
	cout<<min(n*a,b)<<'\n';
	
}


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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int lower = max(A, C);
    int upper = min(B, D);
    int ans = max(upper - lower, 0);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<vector>

namespace ProconLib{

    template<typename cost_t>
    constexpr cost_t INF(){return cost_t(1e15);}
    template<class graph_t,class cost_t,cost_t INF=INF<cost_t>()>
    bool BellmanFord(int s,graph_t& g,std::vector<cost_t> &d){
        int n=g.size();
        d.assign(n,INF);
        bool update=true;
        d[s]=0;
        for(int loop=0;update;loop++){
            if(loop>=n+1){
                return false;
            }
            update=false;
            for(int i=0;i<n;i++){
                if(d[i]==INF) continue;
                for(int j=0;j<g[i].size();j++){
                    int to=g[i][j].to;
                    cost_t w=d[i]+g[i][j].cost;
                    if(d[i]<INF && d[to]>w){
                        update=true;
                        d[to]=w;
                    }
                }
            }
        }
        return true;
    }

    // using Weight=long long;
    // struct Edge{
    //     int to;
    //     Weight cost;
    // };
    // using Edges=std::vector<Edge>;
    // using Graph=std::vector<Edges>;
}

#include<bits/stdc++.h>
using ll=long long;
using namespace std;
using namespace ProconLib;

struct Edge{
    int to;
    ll cost;
};
using Graph=vector<vector<Edge>>;
int main(){
    int n,m,p;
    cin>>n>>m>>p;
    Graph revG(n);
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        revG[b].push_back(Edge{a,p-c});
    }

    Graph g(n);
    {
        stack<int> st;
        st.push(n-1);
        vector<int> ok(n);
        ok[n-1]=true;
        while(!st.empty()){
            auto v=st.top(); st.pop();
            for(auto &e:revG[v]){
                if(!ok[e.to]){
                    st.push(e.to);
                    ok[e.to]=true;
                }
            }
        }
        for(int i=0;i<n;i++){
            for(auto &e:revG[i]){
                if(ok[e.to] && ok[i]) g[e.to].push_back(Edge{i,e.cost});
            }
        }
    }
    
    vector<ll> d;
    auto ret=BellmanFord(0,g,d);
    cout<<(ret ? max(-d[n-1],0LL) : -1LL)<<endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,a[110],s[110];
int main()
{
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		s[a[i]]++;
	}
	sort(a,a+n);
	if (s[a[0]]>2)
	{
		puts("Impossible");
		return 0;
	}
	for (int i=a[0]+1;i<=2*a[0]-s[a[0]]+1;i++)
	{
		if (s[i]<s[a[0]])
		{
			puts("Impossible");
			return 0;
		}
	}
	if (a[n-1]>2*a[0]-s[a[0]]+1)
	{
		puts("Impossible");
	}
	else
	{
		puts("Possible");
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

vector<P> prime_factor(int num) {
  vector<P> ret;
  for (int i=2; i*i<=num; ++i) {
    int count = 0;
    while (num%i == 0) {
      num /= i;
      ++count;
    }
    if (count != 0) ret.push_back(P(i, count));
  }
  if (num != 1) ret.push_back(P(num, 1));
  return ret;
}

vi divisor(int &num) {
  vi ret;
  ret.push_back(1);
  for (auto p : prime_factor(num)) {
    int sz = ret.size();
    int x, y;
    tie(x,y) = p;
    rep(i,sz) {
      int d = ret[i];
      rep(j,y) {
        d *= x;
        ret.push_back(d);
      }
    }
  }
  sort(ret.begin(), ret.end(), greater<int>());  // , greater<int>()
  // ret.erase(ret.begin());
  // ret.pop_back();
  return ret;
}

void solve() {
  int N, M; cin >> N >> M;
  for (auto v : divisor(M)) {
    if (M/v >= N) {
      cout << v << endl;
      return;
    }
  }
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 256
input_one=int(input())
array=[]
a={"AC":0,"WA":0,"TLE":0,"RE":0}
for i in range(input_one):
    array.append(input())
for i in array:
    if i=="AC":
        a[i]+=1
    elif i=="WA":
        a[i]+=1
    elif i=="TLE":
        a[i]+=1
    elif i=="RE":
        a[i]+=1
    else:
        print()
print("AC x",a["AC"])
print("WA x",a["WA"])
print("TLE x",a["TLE"])
print("RE x",a["RE"])



Measured memory_bytes: 16224
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a>b)
  {
    for(int i=0;i<a;i++)cout<<b;
  }
  else
  {
   for(int i=0;i<b;i++)cout<<a;
 
  }  
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#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>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main()
{
	int n,k;
	scanf("%d %d",&n,&k);
	vector<int> vec(n+1 , 0);
	int count = n;
	for(int i = 0;i<k;i++)
	{
		int d;s(d);
		for(int j = 0;j<d;j++)
		{
			int x;s(x);
			if(vec[x] == 0) count--;
			vec[x] = 1;
		}
	}
	
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    string N;
    int K;
    cin >> N >> K;
    int d = (int)N.size();
    vector<vector<vector<ll>>> dp(d, vector<vector<ll>>(K+1, vector<ll>(2, 0)));
    vector<int> n(d);
    for (int i = 0; i < d; i++) n[i] = N[i] - '0';
    dp[0][1][0] = n[0]-1;
    dp[0][1][1] = 1;
    for (int i = 1; i < d; i++) dp[i][1][0] = 9;
    for (int i = 1; i < d; i++){
        for (int j = 1; j <= K; j++) {
            if (n[i] > 0) {
                dp[i][j][1] += dp[i-1][j-1][1];
                dp[i][j][0] += dp[i-1][j][1] + dp[i-1][j-1][1] * (n[i]-1) + dp[i-1][j][0] + dp[i-1][j-1][0]*9;
            }else {
                dp[i][j][1] += dp[i-1][j][1];
                dp[i][j][0] += dp[i-1][j][0] + dp[i-1][j-1][0] * 9;
            }
        }
    }
    cout << dp[d-1][K][0] + dp[d-1][K][1] << endl;
    return 0;
}


Measured memory_bytes: 256
a= int(input())
b= int(input())
c= int(input())
x= int(input())
ans=0
for i in range (a+1):
    for j in range (b+1):
        for k in range (c+1):
            if 500*i+100*j+50*k == x:
                ans = ans + 1
            else:
                pass
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int main(void){
  int N,D;
  cin >> N >> D;

  vector<vector<double> >point(N,vector<double>(D,0));

  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){
      cin >> point[i][j];
    }
  }

  int ans = 0;

  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      double dis = 0;
      for(int k=0;k<D;k++){
        dis += (point[i][k] - point[j][k]) * (point[i][k] - point[j][k]);
      }
      double distance = sqrt(dis);
      if(ceil(distance) == floor(distance))
        ans ++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int main()
{
    double w,h,x,y;
    cin>>w>>h>>x>>y;
    double m,n;
    m = x*h;
    n = y*w;
    printf("%.6f ",w*h/2);
    if(w/2==x&&h/2==y){
        printf("1");
    }
    else{
        printf("0");
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}



signed main()
{
	IOS();
	int N;
	vector<int>ans;
	vector<int>cnt(1010,0);
	rep(i,1,1001){
		rep(j,i+1,1001){
			int t = (i+j)*(j-i+1)/2;
			if(t>1000)continue;
			cnt[t]++;
		}
	}
	while(1){
		cin>>N;
		if(N==0)break;
		cout<<cnt[N]<<endl;
	}
}



Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a+b) * h / 2 << endl;
    return 0;
}


Measured memory_bytes: 3504
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

i64 x[50], y[50];
int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
        x[i] *= 2;
        y[i] *= 2;
    }

    double a = 1e12;
    i64 mi = 0, mj = 0;
    for (i64 i = 0; i <= 2000; ++i) {
        for (i64 j = 0; j <= 2000; ++j) {
            double s = 0;
            for (i64 k = 0; k < n; ++k) {
                i64 d = x[k] - i, e = y[k] - j;
                s = max(s, double(d * d + e * e));
            }
            if (s < a) {
                a = min(a, s);
                mi = i;
                mj = j;
            }
        }
    }
    // cerr << mi << ',' << mj << endl;

    double li = 0, lj = 0;
    for (double i = mi - 2; i <= mi + 2; i += 0.01) {
        for (double j = mj - 2; j <= mj + 2; j += 0.01) {
            double s = 0;
            for (i64 k = 0; k < n; ++k) {
                double d = x[k] - i, e = y[k] - j;
                s = max(s, double(d * d + e * e));
            }
            if (s < a) {
                a = min(a, s);
                li = i;
                lj = j;
            }
        }
    }
    
    for (double i = li - 0.02; i <= li + 0.02; i += 0.0001) {
        for (double j = lj - 0.02; j <= lj + 0.02; j += 0.0001) {
            double s = 0;
            for (i64 k = 0; k < n; ++k) {
                double d = x[k] - i, e = y[k] - j;
                s = max(s, double(d * d + e * e));
            }
            if (s < a) {
                a = min(a, s);
                //li = i;
                //lj = j;
            }
        }
    }

    printf("%.15f\n", sqrt(double(a) / 4));
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define ll long int
using namespace std;
int main()
{
    ll w,n,ans=0; cin>>n>>w;
    ll a[n],b[n];
    for(ll i=0;i<n;i++)   cin>>a[i]>>b[i];
    ll dp[w+1];
    memset(dp,0,sizeof(dp));
    //dp[0]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=w;j>=0;j--)
        {
            if(a[i-1]<=j) 
             dp[j]=max(b[i-1]+dp[j-a[i-1]],dp[j]);
        }
    }
    cout<<dp[w];
}

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

typedef long long ll;

int main() {
    int N;
    string S, T;
    cin >> N;
    cin >> S >> T;
    string ans = "";
    for (int i=0;i<N;i++){
        ans += S[i];
        ans += T[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

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

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 3e3 + 1;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

ll dp[N];

pii p[N];

int main(){
    #ifdef KAZAKH
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, t;
    cin >> n >> t;
    for (int i = 0; i < n; i++){
        cin >> p[i].x >> p[i].y;
    }
    sort(p, p + n);
    ll ans = 0;
    for (int i = 0; i < n; i++){
        ans = max(ans, dp[t-1] + p[i].y);
        for (int j = t; j  >= p[i].x; j--){
            dp[j] = max(dp[j], dp[j-p[i].x] + p[i].y);
        }
    }
    ans = max(ans, dp[t]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mms(a,n) memset(a,0,sizeof((a)[0])*(n))
#define mmp(a,b,n) memcpy(a,b,sizeof((b)[0])*(n))
#define lowbit(x) ((x)&-(x))
#define pb push_back
#define fi first
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define fo(i,l,r) for(register int i=l,_lim_=r;i<=_lim_;i++)
#define fd(i,r,l) for(register int i=r,_lim_=l;i>=_lim_;i--)
#define fos(i,l,r,d) for(register int i=l,_lim_=r;i<=r;i+=d)
#define fol(i,l,r) for(register ll i=l,_lim_=r;i<=_lim_;i++)
#define fdl(i,r,l) for(register ll i=r,_lim_=l;i>=_lim_;i--)
#define fosl(i,l,r,d) for(register ll i=l,_lim_=r;i<=r;i+=d)
#define Clear(a) memset(a,0,sizeof(a))
#define Copy(a,b) memcpy(a,b,sizeof(b))
#define ALL(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ldb;
typedef double db;
typedef pair<int,int> pi;
const int N=100005;
int n,m,a[N],fa[N],blk;
vector<int>e[N],E; ll ans;
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
int main(){
    scanf("%d%d",&n,&m);
    fo(i,1,n)scanf("%d",&a[i]),fa[i]=i,blk++;
    for(int i=1,u,v;i<=m;i++){
        scanf("%d%d",&u,&v);u++;v++;
        if(find(u)!=find(v))
        fa[find(u)]=find(v),blk--;
    } fo(i,1,n)e[find(i)].pb(a[i]);
    if(blk==1)puts("0"),exit(0);
    int cur=blk-2;
    fo(i,1,n)
        if(e[i].size()){
            sort(ALL(e[i]));
            ans+=e[i][0];
            fo(j,1,int(e[i].size())-1)E.pb(e[i][j]);
        }
    sort(ALL(E));
    if(cur>E.size())puts("Impossible"),exit(0);
    fo(i,0,cur-1)ans+=E[i];
    cout<<ans<<endl; return 0;
}




Measured memory_bytes: 6528
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using pii = pair<int, int>;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
template<typename T> void dbg(T x) { cout << x << "\n"; }
template<typename T, typename U> static void chmin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void chmax(T &x, U y) { if (x < y) x = y; }

int n;
string s, t;

int main() {
    cin >> n >> s >> t;
    string a = "";
    rep(i, n) {
        if (s[i] == t[i]) {
            a += "x";
        }
        else {
            a += "y";
            i++;
        }
    }

    ll ans = 1;
    if (a[0] == 'x') ans *= 3;
    if (a[0] == 'y') ans *= 6;
    char pre = a[0];
    FOR(i, 1, a.size()) {
        if (pre == 'x') {
            ans *= 2;
        }
        else {
            if (a[i] == 'y') ans *= 3;
        }
        ans %= MOD;
        pre = a[i];
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main() {
    string s;
    cin >> s;
    int ssize = s.size() - 1;
    if (s.at(ssize) != 's') {
        s += "s";
    }
    if (s.at(ssize) == 's') {
        s += "es";
    }
    cout << s << endl;
    return 0;
}


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

int main(){
  string s,log="xxx";
  cin>>s;
  int i=0;
  while(s.size()>i){
    if(i+4<s.size()){
      string a=s.substr(i,5);
      if(a=="dream"||a=="erase"){
        log = a;
        i+=5;
        continue;
      }
    }if(i+5<s.size()){
      string a=s.substr(i,6);
      if(a=="eraser"){
        log = a;
        i+=6;
        continue;
      }
    }if(i+6<s.size()){
      string a=s.substr(i,7);
      if(a=="dreamer"){
        log =a;
        i+=7;
        continue;
      }
    }if(i+1<s.size()){
      if(log=="dream"){
        string x=s.substr(i,2);
        if(x=="er"){
          i+=2;
          log = "dreamer";
          continue;
        }
      }
    }if(i<s.size()){
       if(log=="erase"){
        char x=s.at(i);
        if(x=='r'){
          i++;
          log ="eraser";
          continue;
        }
      }if(i==s.size()-1) break;
    }cout<<"NO"<<endl; return 0;
  }
  cout<<"YES"<<endl;
}

Measured memory_bytes: 512
import bisect
import math
a, b, q = map(int, input().split())
inf = float("inf")
s = [-inf] + [int(input()) for _ in range(a)] + [inf]
t = [-inf] + [int(input()) for _ in range(b)] + [inf]

results = ""
for _ in range(q):
    x = int(input())
    si = bisect.bisect_right(s, x)
    spos = [s[si], s[si - 1]]

    ti = bisect.bisect_right(t, x)
    tpos = [t[ti], t[ti - 1]]

    result = float("inf")
    for svalue in spos:
        for tvalue in tpos:
            if svalue == tvalue == inf or svalue == tvalue == -inf:
                continue
            result = min(
                abs(x - svalue) + abs(svalue - tvalue),
                abs(x - tvalue) + abs(tvalue - svalue),
                result
            )

    results += str(result) + "\n"
print(results)


Measured memory_bytes: 14992
import sys
max_int = 1000000001  # 10^9+1
min_int = -max_int

n = input()

if n[-1] in ['2', '4', '5', '7', '9']:
    print('hon')
elif n[-1] in ['0', '1', '6', '8']:
    print('pon')
else:
    print('bon')


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

int sum(string s){
    int sum = 0 ;
    for(int i=0;i<s.size();i++){
        sum += s.at(i)-'0' ;
    }
    return sum ;
}

int main(){
    while(1){
        string s ; cin >> s ;
        if(s=="0") break ;
        cout << sum(s) << endl ;
    }
}


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

int main(){
    int n,m;
    string s;
    cin>>n;
    map<string,int> mp;
    for(int i=0;i<n;i++){
        cin>>s;
        mp[s]++;
    }
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>s;
        mp[s]--;
    }
    m=0;
    for(auto x:mp) m=max(m,x.second);
    cout<<m<<endl;
    return 0;
}

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

string strplus(string x,string y){
  if(x.size()>80||y.size()>80)return "overflow";
  string ans="";
  int xa[80],ya[80],za[80];
  for(int i=0;i<80;i++)xa[i]=ya[i]=za[i]=0;
  for(int i=0;i<(int)x.size();i++)xa[i]=x[x.size()-1-i]-'0';
  for(int i=0;i<(int)y.size();i++)ya[i]=y[y.size()-1-i]-'0';
  for(int i=0;i<80;i++){
    za[i]+=xa[i]+ya[i];
    if(za[i]>=10){
      za[i]-=10;
      if(i==79)return "overflow";
      else za[i+1]++;
    }
  }
  int flg=0;
  for(int i=79;i>=0;i--){
    if(flg==0&&za[i]==0)continue;
    else{
      flg=1;
      ans+=(za[i]+'0');
    }
  }
  if(ans=="")return "0";
  else return ans;
}
int main(){
  int n;
  string a,b;
  cin>>n;
  while(n--){
    cin>>a>>b;
    cout<<strplus(a,b)<<endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	int res = min(b, d) - max(a, c);

	cout << max(res, 0) << '\n';
	return 0;
}


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

#define ll long long

using namespace std;

int main(){

	ll n;
	cin >> n;

	vector<ll> a(n);
	vector<ll> b(n);
	vector<ll> c(n);

	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i] >> c[i];
	}

	vector<vector<ll>> dp;

	for(int i = 0 ; i < 3; i++){
		vector<ll> row(n);
		dp.push_back(row);
	}

	dp[0][0] = a[0];
	dp[1][0] = b[0];
	dp[2][0] = c[0];

	for(int i = 1; i < n; i++){
		dp[0][i] = max(dp[1][i-1], dp[2][i-1]) + a[i];
		dp[1][i] = max(dp[0][i-1], dp[2][i-1]) + b[i];
		dp[2][i] = max(dp[0][i-1], dp[1][i-1]) + c[i];
		
	}
	ll ans = max(dp[0][n-1], max(dp[1][n-1], dp[2][n-1]));
	cout << ans << "\n";
}

Measured memory_bytes: 8620
#include <stdio.h>

int main(void){

  int n,i,j,s;

  for(;;){

    scanf("%d",&n);
    if(n==0)break;

    int p=0;

    for(i=1;i<n;i++){
      s=i;
      for(j=1;n>s;j++){
	s += i+j;
	if(s==n)p++;
      }
    }
    
    printf("%d\n",p);
  }

  return 0;
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int A, B, X; cin >> A >> B >> X;

    if(B >= X-A && A<= X) cout << "YES" << endl;
    else cout << "NO" <<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define int long long
#define double long double
const int INF = (int) 1e9 + 9;
const int maxn = (int) 1e6 + 6;
using namespace std;

int arr[11][11];

signed main() {

      int n; cin >> n;

      for(int i = 1; i <= n; i++){
            int last = i % 10;
            if(last == 0) continue;
            int first = i;
            while(first >= 10){
                  first /= 10;
            }
            arr[first][last]++;
      }

      int ans = 0;
      for(int i = 0; i < 10; i++) {
            for(int j = 0; j < 10; j++) {
                  ans += arr[i][j] * arr[j][i];
            }
      }

      cout << ans << endl;


return 0;
}

Measured memory_bytes: 256
while(1):
    [inp, s]=raw_input().split()
    if s=='X':
        break
    else:
        words=[]
        if '_' in inp:
            words=inp.split('_')
        else:
            w=inp[0].lower()
            for c in inp[1:]:
                if c.isupper():
                    words.append(w)
                    w=c.lower()
                else:
                    w+=c
            words.append(w)
        if s=='D':
            print '_'.join(words)
        else:
            if s=='U':
                words=[w[0].upper()+w[1:] for w in words]
            else:
                words=[words[0]]+[w[0].upper()+w[1:] for w in words[1:]]
            print ''.join(words)

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

const int MOD = 1000000007;

/*
int64_t modpow(int64_t x, int64_t n) {
    x = x%MOD;
    if(n==0) return 1;  //再帰の終了条件

    else if(n%2==1) {
        return (x*modpow(x, n-1))%MOD;  //nが奇数ならnを1ずらす
    }
    else return modpow((x*x)%MOD, n/2)%MOD;  //nが偶数ならnが半分になる
}
*/

int64_t modpow(int64_t x, int64_t n) {
    int64_t ret = 1;
    while (n != 0) {
        if (n & 1 == 1) {
            ret *= x;
            ret %= MOD;
        }
        x *= x;
        x %= MOD;
        n >>= 1;
    }
    return ret;
}

int64_t comb(int64_t n, int64_t k) {
    int64_t x = 1;
    for(int i=n-k+1; i<=n; i++) {
        x = x*i%MOD;
    }

    int64_t y = 1;
    for(int i=1; i<=k; i++) {
        y = y*i%MOD;
    }
    y = modpow(y, MOD-2);

    return x*y%MOD;
}

int main() {
    int n,a,b;
    cin>>n>>a>>b;

    int all = modpow(2,n) -1;
    int muri = comb(n,a) + comb(n,b);

    int ans = all - muri;
    while(ans<0) {
        ans += MOD;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String... args) throws Exception{
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(reader.readLine());
        int[] A = new int[N];
        String[] strA = reader.readLine().split(" ");
        for (int i = 0; i < N; i++) {
            A[i] = Integer.parseInt(strA[i]);
        }
        Arrays.sort(A);
        label: for (int i = A[1]; 0 < i; i--) {
            int count = 0;
            for (int j =0; j < N; j++) {
                if (0 < A[j] % i && 1 < ++count) {
                    continue label;
                }
            }
            System.out.println(i);
            return;
        }
    }
}


Measured memory_bytes: 43732
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
	int n;
	int a, b;
	string c;
	int hyou[100][2];
	string abc = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		cin >> c;
		for (int i = 0; i < n; i++) {
			cin >> hyou[i][0] >> hyou[i][1];
			hyou[i][0] -= 1;
			hyou[i][1] -= 1;
		}
		for (int i = n-1; i >= 0; i--) {
			for (int j = 0; j < 26; j++) {
				if (c[hyou[i][0]] == abc[j]) {
					a = j;
					break;
				}
			}
			for (int j = 0; j < 26; j++) {
				if (c[hyou[i][1]] == abc[j]) {
					b = j;
					break;
				}
			}
			int sa = abs(hyou[i][0]-hyou[i][1]);
			c[hyou[i][0]] = abc[a+sa];
			c[hyou[i][1]] = abc[b+sa];
			swap(c[hyou[i][0]], c[hyou[i][1]]);
		}
		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int b[n - 1];
    rep(i, 0, n - 1) cin >> b[i];
    int a[n];
    if (n == 2) cout << b[0] * 2 << endl;
    else {
        a[0] = b[0];
        rep(i, 1, n - 1) {
            a[i] = min(b[i - 1], b[i]);
        }
        a[n - 1] = b[n - 2];
        int ans = 0;
        rep(i, 0, n) ans += a[i];
        cout << ans << endl;
    }

    return 0;
}


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

#define ll long long
#define endl "\n"
#define ios ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);

using namespace std;

const int N = 3e5;
vector <int> g[N];
int n, m, used[N], ans = 0, cnt = 0;

void dfs(int v) {
    ++ cnt;
    used[v] = 1;
    for (int i = 0; i < g[v].size(); ++ i) {
        int to = g[v][i];
         if (used[to] == 1) {
            ;
         }
         else {
            dfs(to);
         }
    }
}

int main() {
    ios
    cin >> n >> m;
    for (int i = 0; i < m; ++ i) {
        int u, v;
        cin >> u >> v;
        g[v].push_back(u);
        g[u].push_back(v);
    }
    for (int i = 1; i <= n; ++ i) {
        if (used[i] == 0) {
            dfs(i);
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    cout << ans;
}


Measured memory_bytes: 23952
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define speed                   \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define ll long long
#define pb push_back
#define mem1(a) memset(a, -1, sizeof(a))
#define mem0(a) memset(a, 0, sizeof(a))
#define endl "\n"
#define mod1 1000000007
#define mod 998244353
#define ff first
#define ss second
#define MAX 500005
#define N 200005
#define INF 1000000009
#define all(v) v.begin(), v.end()
#define sbit(a) __builtin_popcount(a)
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef pair<ll, ll> pll;
typedef pair<pll, ll> ppl;
typedef map<ll, ll> mpll;
typedef map<vector<ll>, ll> mpvl;
ll power(ll x, ll y, ll p)
{
  ll res = 1;

  x = x % p;

  if (x == 0)
    return 0;
  while (y > 0)
  {

    if (y & 1)
      res = (res * x) % p;

    y = y >> 1;
    x = (x * x) % p;
  }

  return res;
}
void solve()
{
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  vector<ll>v;
  v.pb(a*c);
  v.pb(a*d);
  v.pb(c*b);
  v.pb(b*d);
  sort(all(v),greater<ll>());
  cout<<v[0]<<endl;
}

int main()
{
  speed;
  ll kk;
  kk = 1;
  //cin >> kk;
  while (kk--)
  {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3664
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
ll gcd ( ll a, ll b ) {
    if ( a % b == 0 ) return b;
    return gcd( b, a % b );
}
ll lcm ( ll a, ll b ) {
    return a / gcd( a, b ) * b;
}
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    vector<ll> t(n);
    rep(i, n) cin >> t[i];
    ll num = 0;
    if ( n == 1 ) {
        cout << t[0] << endl;
        return 0;
    }
    rep(i, n-1) {
        if ( i == 0 ) num = lcm(t[0], t[1]);
        else          num = lcm(num, t[i+1]);
    }
    cout << num << endl;
    return 0;
}


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

using namespace std;

int n, m;
int a[110];
int sum;
double aver;
int cou;

int main(void)
{
	scanf("%d %d", &n, &m);
	
	for(int i = 0 ; i < n ; i++)
	{
		scanf("%d", &a[i]);
		sum += a[i];
	}
	
	sort(a, a + n);
	
	aver = (double)sum / (double)(4 * m);
	
	for(int i = n - 1 ; i >= 0 ; i--)
	{
		if((double)a[i] >= aver)
			cou++;
		else
			break;
	}
	
	if(cou >= m)
		printf("Yes");
	else
		printf("No");
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
  int n,m;
  cin>>n>>m;
  char c[n][m];
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<m;j++)
      cin>>c[i][j];
  }
  ll md=1e9+7;
  ll dp[n][m];
  dp[0][0]=1;
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<m;j++)
    {
      if(i==0 && j==0)
        continue;
      if(c[i][j]=='#')
      {
        dp[i][j]=0;
        continue;
      }
      if(i==0 && dp[i][j-1]==0)
      {
        dp[i][j]=0;
        continue;
      }
      if(j==0 && dp[i-1][j]==0)
      {
        dp[i][j]=0;
        continue;
      }
      if(i==0 || j==0)
      {
        dp[i][j]=1;
        continue;
      }
      dp[i][j]=(dp[i-1][j]+dp[i][j-1])%md;
    }
  }
  cout<<dp[n-1][m-1]<<endl;
}


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

int main(){
	int a[5];
	for(int i=1;i<6;i++){
		cin>>a[i];
	}
	sort(a+1,a+6);
	for(int i=5;i>0;i--){
		if(i==1)cout<<a[i];
		else cout<<a[i]<<' ';
		
}
	cout<<endl;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
int n,a,t,mini=1000000000;
int main(){
	cin>>n;
	for (int i=1;i<n;i++){
		t=i,a=0;
		while (t){
			a+=t%10;
			t/=10;
		}
		t=n-i;
		while (t){
			a+=t%10;
			t/=10;
		}
		mini=min(mini,a);
	}
	cout<<mini;
	return 0;
} 

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

int main(){
  double l;
  cin >> l;
  double length = l/3;  
  double ans = pow(length, 3);
  printf("%.6f\n", ans);
}

Measured memory_bytes: 256
object Main extends App {
  import scala.io.StdIn._

  val n = readInt
  val detective = readLine.trim.split(' ').map(_.toInt)
  val r0 = detective.count(_ % 3 == 0)
  val r1 = detective.count(_ % 3 == 1)
  val r2 = detective.count(_ % 3 == 2)

  if (n == r0) println(1)
  else {
    val large = math.max(r1, r2)
    val small = math.min(r1, r2)
    if (large <= small + 2) println(r0 + r1 + r2)
    else println(r0 + small * 2 + 3)
  }

  implicit class Scope[T](val value: T) extends AnyVal {
    @inline
    def let[A](func: T ⇒ A): A = func(value)
  }
}


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

int main() {
    string S;
    cin >> S;
    int L = S.size();
    string ans = "AC";
    if(S[0] != 'A'){
        ans = "WA";
        }
    int cnt = 0;
    for(int i = 1; i < L; ++i){
        if(isupper(S[i])){
            if(i == 1 || i == L - 1 || S[i] != 'C'){
                ans = "WA";
                }
            ++cnt;
            }
        }
    if(cnt != 1){
        ans = "WA";
        }
    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);

        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
            break;
            
            }int i, j;
            

            for ( j = 0 ; j < H; j++) {
                 for ( i = 0 ; i < W; i++){
                     if ((i+j) % 2 == 0){
                 System.out.printf("#");
                }else{
                System.out.printf(".");
                }
        }System.out.printf("\n");
    }System.out.printf("\n");
}
    }
}


Measured memory_bytes: 58408
#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,m;
	cin >> n >> m;
	
	vector<vector<int>> jobs(m);
	
	rep(i,n){
		int a, b;
		cin >> a >> b;
		if(a > m) continue;
		jobs[m-a].push_back(b);
	}

	priority_queue<int> q;
	int ans = 0;
	
	for(int i = m-1; i >= 0; i--){
		for(int j : jobs[i]){
			q.push(j);
		}
		if(!q.empty()){
			ans += q.top();
			q.pop();
		}
	}
	
	cout << ans << endl;

}

Measured memory_bytes: 5632
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var q = int.Parse(line[1]);
        var s = Console.ReadLine().Trim();
        var z = new List<int>();
        for (int i = 0; i < n - 1; i++)
            if (s[i] == 'A' && s[i + 1] == 'C') z.Add(i + 1);
        var a = z.ToArray();
        for (int i = 0; i < q; i++)
        {

            line = Console.ReadLine().Trim().Split(' ');
            var L = int.Parse(line[0]);
            var r = int.Parse(line[1]);
            if (a.Length == 0) { Console.WriteLine(0); goto next; }
            var ansr = getAns(a, r);
            var ansL = getAns(a, L);
            Console.WriteLine(ansr - ansL);
            next:;
        }
    }
    static int getAns(int[] a, int b)
    {
        var t = UpperBound(a, b);
        if (t <= 0) return 0;
        var ep = a[t - 1] + 1;
        return b < ep ? t - 1 : t;
    }
    public static int UpperBound<T>(T[] arr, int start, int end, T value, IComparer<T> comparer)
    {
        int low = start;
        int high = end;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (comparer.Compare(arr[mid], value) <= 0)
                low = mid + 1;
            else
                high = mid;
        }
        return low;
    }
    public static int UpperBound<T>(T[] arr, T value)
    {
        return UpperBound(arr, 0, arr.Length, value, Comparer<T>.Default);
    }
}

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

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
 long long int ans=INF;
  
  for(int i=-100;i<=100;i++){
  int cost=0;
    rep(j,n){
  cost+=(a[j]-i)*(a[j]-i);
  }
  if(cost<ans) ans=cost;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var s string
  fmt.Scanf("%s", &s)
  
  ans := s
  if len(s) == 3 {
    ans = s[2:3] + s[1:2] + s[0:1]
  }
  fmt.Printf("%s\n", ans)
}

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

int main() {
    int ab_Dis;//初期の距離
    int ab_v;//相対速度
    int a, b, a_v, b_v, T;//初期位置、各速
    int flag = 0;

    cin >> a >> a_v >> b >> b_v >> T;

    if (a > b)ab_Dis = a - b;
    else if (a < b)ab_Dis = b - a;
    else ab_Dis = 0;

    if (a_v > b_v) {
        ab_v = a_v - b_v;
        for (int i = 1; i <= T; i++) {
            if (ab_Dis <= ab_v * i) {
                flag = 1; break;
            }
        }
    }
    else ab_v = 0;

    if(flag == 1)cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3592
n,d=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
ans=0
cnt=0
for i in range(n-1):
    for j in range(i+1,n):
        siki=0
        for k in range(d):
            siki+=((l[i][k]-l[j][k])**2)
        han=siki**0.5
        if han%1 == 0:
            cnt += 1
print(cnt)

Measured memory_bytes: 3188