akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<ld, ld>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second

const int INF = 1 << 20;

int main() {
  cin.sync_with_stdio(false);

  int n;
  cin >> n;

  int maxi = -INF;
  int mini = INF;
  for (; n; n--) {
    int x;
    cin >> x;
    mini = min(mini, x);
    maxi = max(maxi, x);
  }

  cout << maxi - mini << '\n';

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

int main() {
	ll q, h, s, d, n;
	cin >> q >> h >> s >> d >> n;
	ll one_l = min(min(q * 2, h) * 2, s);
	ll two_l = min(one_l * 2, d);
	if (n % 2 == 0) {
		cout << n / 2 * two_l << endl;
	}
	else {
		cout << (n / 2)*two_l + one_l << endl;
	}
	return 0;
}

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

int main() {
    int64_t n, p;
    cin >> n;
    p = 1;
    for(int i = 1; i <= n ; i++) {
        p *= i; 
        p %= 1000000007;
    }
    cout << p << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll a, b, x; cin >> a >> b >> x;
    if(a == 0) cout << b/x +1 << endl;
    else cout << b/x - (a-1)/x << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 2e5 + 5;
const int mod = 1e9 + 7;	

int n, a[N], f[N];
pi v[N];

int c(int x){
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(v[i].fi <= x)	continue;
		int p = v[i].fi - x;
		int q = v[i].fi/v[i].se;
		ans += (p-1)/q + 1;
	}
	return ans;
}
 
signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	int k;	cin >> n >> k;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	for(int i = 1; i <= n; i++)
		cin >> f[i];
	sort(a + 1, a + n + 1);
	sort(f + 1, f + n + 1);
	reverse(f + 1, f + n + 1);
	int ans = 0;
	for(int i = 1; i <= n; i++){
		v[i].fi = a[i]*f[i];
		v[i].se = a[i];
	}	
	sort(v + 1, v + n + 1);
	reverse(v + 1, v + n + 1);
	int l = -1, h = v[1].fi;
	while(l+1 < h){
		int m = (l + h) >> 1;
		if(c(m) > k)
			l = m;
		else
			h = m;
	}
	cout << h;
	return 0;
}

Measured memory_bytes: 6528
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int n;
  scan(n);
  vi a(n);
  scan(a);
  double sum = 0;
  rep (i, n) {
    sum += 1.0 / a[i];
  }
  print(1.0 / sum);

  return 0;
}


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

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

  vector<long int> p, q, r;
  for(int i=0; i<a; i++){
    int kari;
    scanf("%d",&kari);
    p.push_back(kari);
  }
  
  for(int i=0; i<b; i++){
    int kari;
    scanf("%d",&kari);
    q.push_back(kari);
  }
  
  for(int i=0; i<c; i++){
    int kari;
    scanf("%d",&kari);
    r.push_back(kari);
  }

  sort(p.begin(),p.end());
  sort(q.begin(), q.end());
  sort(r.begin(), r.end());

  int pr = c-1, pp = a-x , pq = b-y;

  while(r[pr]>p[pp] || r[pr]>q[pq]){
    if(p[pp]<q[pq]){
      p[pp] = r[pr];
      pp++;
    }else{
      q[pq] = r[pr];
      pq++;
    }
    pr--;
    if(pr < 0) break;
    if(pp >= a) break;
    if(pq >= b) break;
  }
  while(pp<a && pr>=0 && r[pr]>p[pp] ){
    p[pp] = r[pr];
    pp++;
    pr--;
  }
  
  long int sum = 0;
  for (int i=a-x; i<a; i++) sum += p[i];
  for (int i=b-y; i<b; i++) sum += q[i];
  cout << sum << endl; 
  return 0;
}

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

int main() {
	int W, H, x, y, r;
	
	cin >> W >> H >> x >> y >> r;
	if (x-r >= 0 && x+r <= W && y-r >= 0 && y+r <= H)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 3128
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#define INF 1LL<<60
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main() {
  ll h, w, n;
  cin >> h >> w >> n;
  ll p[10] = { };
  p[0] = (h-2) * (w-2);
  set<P> s;
  REP(i, n){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    int f[3][3] = { };
    FOR(j, a-2, a+3){
      FOR(k, b-2, b+3){
        if(s.find({j, k}) != s.end()){
           FOR(l, j-2, j+1){
             FOR(m, k-2, k+1){
               if(0 <= l && l < h && 0 <= m && m < w && -2 <= l-a && l-a <= 0 && -2 <= m-b && m-b <= 0){
                 f[l-a+2][m-b+2]++;
               }
            }
          }
        }
      }
    }
    REP(j, 3){
      REP(k, 3){
        if(0 <= a-2+j && a+j < h && 0 <= b-2+k && b+k < w){
          p[f[j][k]]--;
          p[f[j][k]+1]++;
        }
      }
    }
    s.insert({a, b});
  }
  REP(i, 10){
    cout << p[i] << endl;
  }
}

Measured memory_bytes: 6528
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
    int n;

    auto solve_test = [&] () {
        vector<string> g(n);
        for (auto &s : g)
            cin >> s;

        int best = 0;

        for (int i = 0; i < n; i++)
        {
            vector<int> d(n, -1);
            queue<int> q;

            d[i] = 1;
            q.push(i);

            while (!q.empty())
            {
                const int cur = q.front(); q.pop();

                for (int dest = 0; dest < n; dest++)
                {
                    if (g[cur][dest] == '1' && d[dest] == -1)
                    {
                        q.push(dest);
                        d[dest] = d[cur] + 1;
                    }
                }
            }

            best = max(best, *max_element(d.begin(), d.end()));
            for (int k = 0; k < n; k++) {
                for (int j = 0; j < n; j++)
                {
                    if (g[k][j] == '1' && abs(d[k] - d[j]) != 1)
                        return -1;
                }
            }
        }

        return best;
    };

    while (cin >> n)
    {
        auto x = solve_test();
        cout << x << endl;
//        break;
    }
}

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

    cout << fixed;

#ifdef LOCAL
    auto st = clock();

    ifstream fin("../input.txt");

    solve(fin);

    cout << "clock: " << setprecision(4) << (clock() - st) / (double) CLOCKS_PER_SEC << endl;
#else
    solve();
#endif

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
using namespace std;
int main()
{
    lli n,m,i,j,p=0,a=0,res;
    string str;
    cin >> n >> m;
    vector<lli>v(n+1,0);
    vector<lli>s(n+1,0);
    vector<lli>w(n+1,0);
    for(i=0;i<m;i++)
    {
        cin >> res >> str;
        if(str=="WA")
        {
            if(s[res]==0)
            {
                w[res]++;
            }
        }
        else
        {
            s[res]=1;
        }
    }
    for(i=1;i<=n;i++)
    {
        if(s[i])
        {
            a++;
        }
    }
    for(i=1;i<=n;i++)
    {
        if(s[i])
        {
            p+=w[i];
        }
    }
    cout << a << " " << p;
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>

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

  int** a = new int*[n];
  for(int nn = 0; nn < n; nn++){
    a[nn] = new int[m];
    for(int mm = 0; mm < m; mm++){
      std::cin >> a[nn][mm];
    }
  }
  int** b = new int*[m];
  for(int mm = 0; mm < m; mm++){
    b[mm] = new int[l];
    for(int ll = 0; ll < l; ll++){
      std::cin >> b[mm][ll];
    }
  }

  long long** c = new long long*[n];
  for(int nn = 0; nn < n; nn++){
    c[nn] = new long long[l];
    for(int ll = 0; ll < l; ll++){
      long long s = 0;
      for(int mm = 0; mm < m; mm++){
	s += a[nn][mm] * b[mm][ll];
      }
      c[nn][ll] = s;
    }
  }
  
  for(int nn = 0; nn < n; nn++){
    for(int ll = 0; ll < l - 1; ll++){
      std::cout << c[nn][ll] << " ";
    }
    std::cout << c[nn][l - 1] << std::endl;
  }
  
  return 0;
}



Measured memory_bytes: 3240
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
    long N;
    cin >> N;
    vector<long> a(3*N);
    for (int i=0; i<3*N; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    long ans = 0;
    for (int i=0; N+(2*i)<3*N; i++) {
        ans+=a[N+(2*i)];
        //cout << N+(2*i) << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
vector<vector<int> > gr;
vector<bool> control;
vector<int> ele;
vector<int> grup;
void dfs(int u,int t){
	control[u] = 1;
	grup[u] = t;
	for(int v : gr[u])
		if(!control[v])
			dfs(v,t);
}
int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	gr.assign(n+1,vector<int>());
	control.assign(n+1,false);
	ele.assign(n+1,0);
	grup.assign(n+1,0);
	int a,b;
	while(m--){
		scanf("%d %d",&a,&b);
		gr[a].push_back(b);
		gr[b].push_back(a);
	}
	int t = 1;
	for(int i = 1; i <= n; i++){
		if(!control[i]){
			dfs(i,t);
			t++;
		}
	}
	for(int x : grup)
		if(x)
			ele[x]++;
	sort(ele.begin(), ele.end());
	printf("%d\n", ele[n]);
	return 0;
}


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

using namespace std;

int main(){
    string S1,S2;
    cin>>S1>>S2;
    int dp[1001][1001]={0};
    for(int i=0;i<=S1.size();i++){
        dp[i][0]=i;
    }
    for(int i=0;i<=S2.size();i++){
        dp[0][i]=i;
    }
    
    for(int i=0;i<S1.size();i++){
        for(int j=0;j<S2.size();j++){
            dp[i+1][j+1]=min(dp[i][j+1]+1,min(dp[i+1][j]+1,S1[i]==S2[j]?dp[i][j]:dp[i][j]+1));
        }
    }
    
    cout<<dp[S1.size()][S2.size()]<<endl;
    
    return 0;
}



Measured memory_bytes: 7108
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll X;
  cin >> X;
  ll cur_x = 0;
  ll cnt = 0;
  while (cur_x < X) {
    cnt++;
    cur_x += cnt;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> v(N, -1);
    bool ok = true;
    REP(i,M){
        int s, c;
        cin >> s >> c;
        --s;
        if(v[s] == -1){
            v[s] = c;
        }
        else if(v[s] != c){
            ok = false;
        }
    }

    if(!ok) cout << -1 << endl;
    else{
        if(N == 1){
            if(M == 0) cout << 0 << endl;
            else cout << v[0] << endl;
        }
        else{
            if(v[0] == 0) cout << -1 << endl;
            else{
                REP(i,N){
                    if(v[i] != -1) cout << v[i];
                    else{
                        if(i == 0) cout << 1;
                        else cout << 0;
                    }
                }
                cout << endl;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int A, B, C, X;
int count = 0;
 
int main(){
  cin >> A >> B >> C >> X;
  for(int a=0;a<=A;++a){
    for(int b=0;b<=B;++b){
      for(int c=0;c<=C;++c){
        int total = 500*a + 100*b + 50*c;
        if(total == X) ++count;
      }
    }
  }
  cout << count << endl;
  return 0;
}

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

int n;
double p, ans, dp[N];

int main() {
	cin>>n;
	dp[0]=1;
	for (int i=1; i<=n; i++) {
		cin>>p;
		for (int j=n; j>0; j--) dp[j]=dp[j-1]*p+dp[j]*(1-p);
		dp[0]*=1-p;
	}
	for (int i=n; i>n/2; i--) ans+=dp[i];
	printf("%.10f\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

using bigint = boost::multiprecision::cpp_int;



int main(){
    bigint a,b,c;
    cin >> a >> b >> c;
    bigint left = (bigint)2 * a *b;
    bigint right = (bigint)a*a;
    bigint one = (bigint)2*a*c;
    bigint two = (bigint)b*b;
    bigint three = (bigint)2*c*b;
    bigint four = (bigint)c*c;
    if(c-a-b<=0){
        cout << "No" << endl;
    }
    else if(a==b && b==c){
        cout << "No" << endl;
    }else if(a==c || b==c){
        cout << "No" << endl;
    }else if(c==1){
        cout << "No" << endl;
    }
    else if(left < four + right + two - one - three){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il ll ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register ll x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

enum{N=223};

const int b0 = 62;
struct BASE{
	ll s[b0+1];
	il ll operator[](int x)const{ return s[x]; }
	il ll& operator[](int x){ return s[x]; }
	bool insert(ll x){
		rev_rep(i,b0,0) if( x&(1ll<<i) ){
			if( s[i]==0 ){
				s[i] = x;
				return 1;
			}else x^=s[i];
		}
		return 0;
	}
};

ll x[N];
char s[N];

BASE a,b;

int main(){
	int T = ci();
	while( T-- ){
		memset(&a,0,sizeof(a));
		memset(&b,0,sizeof(b));
		int n = ci();
		rep(i,1,n) x[i] = ci();
		scanf("%s",s+1);
		s[n+1] = '0';
		bool fail = 0;
		rep(i,1,n){
			if( s[i]=='1' ) b.insert(x[i]);
			if( s[i]=='1' && s[i+1]=='0' ){
				rep(j,i+1,n) if( s[j]=='0' ) a.insert(x[j]);
				rep(t,0,b0) if( a.insert(b[t]) ){ fail=1; break; }
				if( fail == 1 ) break;
				memset(&a,0,sizeof(a));
				memset(&b,0,sizeof(b));
			}
		}
		printf("%d\n",fail);
	}
	return 0;
}


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

using namespace std;

int main(){
  int ans = 0;
  string S;
  char nowcolor;

  cin >> S;
  nowcolor = S[0];
  

  for(int i = 1;i < S.size();i++){
    if(nowcolor != S[i]){
      ans++;
      nowcolor = S[i];
    }
  }

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


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>

#define N 200000

int main(void){
	int a[N], b[N];
	int i, j, n;

	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", &a[i]);
	}

	j = 0;
	for(i=n-1; i>=0; i=i-2){
		b[j++] = a[i];
	}
	j=n-1;
	for(i=n-2; i>=0; i=i-2){
		b[j--] = a[i];
	}

	for(i=0; i<n; i++){
		printf("%d ", b[i]);
	}
	printf("\n");


	return 0;
}

Measured memory_bytes: 3712
'use strict'

const main = (input) => {
    input = input.split(' ').map(v => parseInt(v))
    const a = input[0]
    const b = input[1]
    const c = input[2]
    const d = input[3]
    if(a * b >= c * d){
        console.log(a * b)
    }else{
        console.log(c * d)
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 9420
#include <iostream>

int main (void)
{
	
	int S;
	std::cin >> S;
	int h = S / 3600;
	int m = ( S - h * 3600 ) / 60;
	int s = S % 60;
	std::cout << h << ":" << m << ":" << s << std::endl;
	
	return 0;
}

Measured memory_bytes: 3084
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

typedef pair < int , pair < int , int > > pll;

const int N = 1e5+5;

int n;
int m;
int dist[N];
int indeg[N];
vector < pair < int , int > > adj[N];

int main(){
    memset(dist , -1 , sizeof dist);
    scanf("%d%d" , &n , &m);
    for(int i = 1; i <= m; i++){
        int l , r , d;
        scanf("%d%d%d" , &l , &r , &d);
        adj[l].push_back({r , d});
        indeg[r]++;
    }
    int bad = 0;
    for(int i = 1; i <= n; i++){
        if(!indeg[i]){
            queue < int > q;
            q.push(i);
            dist[i] = 0;
            while(!q.empty()){
                int u = q.front();
                q.pop();
                for(auto nw : adj[u]){
                    int v = nw.first;
                    int d = nw.second;
                    if(dist[v] == -1){
                        dist[v] = dist[u] + d;
                        if(dist[v] > 1e9)
                            bad = 1;
                        q.push(v);
                    } else {
                        if(dist[v] != d + dist[u]){
                            bad = 1;
                        }
                    }
                }
            }
        }
    }
    for(int i = 1; i <= n; i++){
        if(dist[i] == -1)
            bad = 1;
    }
    puts(bad ? "No" : "Yes");
}


Measured memory_bytes: 6784
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;

int main(){
  string O,E;
  cin>>O>>E;

  for(int i=1;i<=(int)O.size()+E.size();i++){
    if(i%2==1){
      cout<<O[i/2];
    }else{
      cout<<E[i/2-1];
    }
  }
  cout<<endl;
}


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

int keta(int num){
  int ans= 0 ;
  int rem;

  for (int i = 4; i >= 0 ; i--){
    rem = pow(10,i);
    ans += (num / rem); 
    num = num % rem;
  }
  return ans;
}


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

  vector<int64_t> ar(N);
  int inc = 0; //単調増加/現象の判定
  int ans = 1;


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

  for(int i = 1; i < N; i++){
    if (ar[i-1] < ar[i]){
      if(inc == 0) inc = 1;
      if(inc == -1){
        ans ++;
        inc = 0;
      }
      
      
    }else if(ar[i-1] > ar[i]){
      if(inc == 0) inc = -1;
      if(inc == 1){
        ans ++;
        inc = 0;
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <numeric>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i, n) for(int i = 1; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	vector<int> s(3);
	REP(i, 3) cin >> s[i];
	int k; cin >> k;
	int K = 2 * k;
	int last = 0;
	sort(ALL(s));
	last = s[2];
	REP(i, k) {
		last *= 2;
	}
	cout << s[0] + s[1] + last << endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;

//--global--//

int n;
static const int maxN = 16;
int d[maxN];
int dp[1 << maxN][maxN];
int a[maxN][maxN+1];

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

// s =　今までに通った集合, v = 今の頂点
int solve(int s, int v, int *d2){
    //cout << "通った:" << bitset<8>(s) << ", " << v  << " ";
    // v を通ったからdを更新する

    int d3[maxN];
    rep(i, n){
        d3[i] = d2[i];
    }
    if(v == -1){
        v = 0;
    }
    else{
        rep(i, n){
            d3[i] = min(d3[i], a[i][v+1]);
        }
    }
    //
    if(dp[s][0] != -1){
        //cout << "you have traveld already" << endl;
        return dp[s][0];
    }

    if(s == (1 << n)-1){
        //cout << "finish" << endl;
        return dp[s][0] = 0; 
    }
    //cout << endl;

    int res = INTINF;
    rep(u, n){
        if(!(s >> u & 1)){
            //cout << "通る:" << bitset<8>(s) << ", " << v  << ", " << d3[u] << endl;
            res = min(res, solve(s | 1 << u, u, d3) + d3[u]);
            //cout << "res" << res << endl;
        }
    }
    return dp[s][0] = res;
}

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//
    
    while(1){
        cin >> n;
        if(n == 0)break;
        memset(dp, -1, sizeof(dp));

        rep(i, n){
            rep(j, n+1){
                //if(j)cout << " ";
                cin >> a[i][j];
                //cout << a[i][j];
            }
            d[i] = a[i][0];
            //cout << endl;
        }
        int res = solve(0, -1, d);
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 7108
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    if (N == 3) {
        cout << 2 << endl;
        cout << "1 3\n2 3" << endl;
        return 0;
    } else if (N == 4) {
        cout << 4 << endl;
        cout << "1 2\n1 3\n4 2\n4 3\n";
        return 0;
    }
    using P = pair<int, int>;
    vector<P> ans;
    if (N % 2 == 1) {
        int K = N - 1;
        vector<vector<int>> a(K / 2 + 2);
        for (int i = 0; i < K / 2; i++) {
            a[i + 1].push_back(i + 1);
            a[i + 1].push_back(K - i);
        }
        a[0].push_back(N);
        a[K / 2 + 1].push_back(N);
        for (int i = 0; i <= K / 2; i++) {
            for (auto v : a[i]) {
                for (auto u : a[i + 1]) {
                    ans.push_back({v, u});
                }
            }
        }
    } else {
        int K = N;
        vector<vector<int>> a(K / 2 + 1);
        for (int i = 0; i < K / 2; i++) {
            a[i + 1].push_back(i + 1);
            a[i + 1].push_back(K - i);
            if (i == (K / 2 - 1)) {
                a[0].push_back(i + 1);
                a[0].push_back(K - i);
            }
        }
        for (int i = 0; i < K / 2; i++) {
            for (auto v : a[i]) {
                for (auto u : a[i + 1]) {
                    ans.push_back({v, u});
                }
            }
        }
    }
    cout << ans.size() << endl;
    for (auto p : ans) {
        cout << p.first << ' ' << p.second << "\n";
    }
}


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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

///priority_queue< int, vector< int >, greater< int > > minHeap;

void mor()
{
    cout<<"NO";
    exit(0);
}


int main()
{
    ///freopen("output.txt","w",stdout);
 //   freopen("input.txt","r",stdin);

    ///FastIO;
    int t;
    t = 1;
    while(t--)
    {
        int n;
        lli k;
        scn(n);
        scnll(k);
        lli a[n];
        vector<int>cnt(70,0);

        for(int i=0; i<n; i++)
        {
            scnll(a[i]);
            lli num = a[i];

            for(int pos = 0 ; num ; num /= 2, pos++)
            {
                cnt[pos] += (num%2);
            }
        }
        lli ans = 0 , now = 0;
       // cout<<cnt[0]<<endl;
        for(int pos=60; pos>=0; pos--){

            lli o = n-cnt[pos] , l = cnt[pos];
			lli add = (1LL<<pos);
            if(o>l){
                now |= add;
                if(now<=k) ans += add*o;
                else{
                    now ^= add;
                    ans += l*add;
                }
            }
            else{
                ans += add*l;
            }
        }
        cout<<ans;
       // cout<<endl;
    }
    return 0;
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)


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

bool judgeRollString(string s, string t) {
    int n = (int) s.length();
    string roll_t;
    for(int i=1; i<=n; i++) {
        roll_t = t.substr(i) + t.substr(0, i);
        //cout << roll_t << endl;
        if (s==roll_t) {
            return true;
        }
    }
    return false;
}

int main() {
    string s, t;
    cin >> s;
    cin >> t;

    bool ans = judgeRollString(s, t);

    if(ans) printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 256
#include <stdio.h>
#define INFTY 1000000000

int main(){
  int i, j, k, l, o, n, rc[101], m[101][101];

  scanf("%d",&n);
  for(i = 1; i <= n; i++) scanf("%d %d",&rc[i-1],&rc[i]);
  
  for(i = 1; i <= n; i++) m[i][i] = 0;
  
  for(j = 2; j <= n; j++){
    for(i = 1; i <= n-j+1; i++){
      k = i + j - 1;
      m[i][k] = INFTY;
      for(l = i; l <= k-1; l++){
	o = m[i][l] + m[l+1][k] + rc[i-1] * rc[l] * rc[k];
	if(m[i][k] > o) m[i][k] = o;
      }
    }
  }

  printf("%d\n",m[1][n]);

  return 0;
}

Measured memory_bytes: 636
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut a: Vec<_> = a.into_iter().enumerate().collect();
    a.sort_by_key(|(_, e)| Reverse(*e));
    let mi = a[0].0;
    for i in 0..n {
        if i == mi {
            println!("{}", a[1].1);
        } else {
            println!("{}", a[0].1);
        }
    }
}


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

const long long MAX_N = 1e5 + 5;
long long n, q, w;
long long A[MAX_N], B[MAX_N];
long long Arr[MAX_N];

bool cmp (long long a, long long b) {
	return A[a] + B[a] > A[b] + B[b];
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (long long i = 0; i < n; i++)
		cin >> A[i] >> B[i];
		
	for (long long i = 0; i < n; i++)
		Arr[i] = i;
		
	sort(Arr, Arr + n, cmp);
	
	for (long long i = 0; i < n; i++) {
		if (i & 1)
			q += B[Arr[i]];
		else
			w += A[Arr[i]];
	}
	
	cout << w - q << '\n';
	return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] arrayA = new int[a + 1];
        int[] arrayB = new int[a];
        
        for(int i = 0; i < a + 1; i++){
            arrayA[i] = sc.nextInt();
        }
        for(int i = 0; i < a; i++){
            arrayB[i] = sc.nextInt();
        }
        long sum = 0;
        for(int i = 0; i < a; i++){
            long n = Math.min(arrayA[i], arrayB[i]);
            sum += n;
            arrayA[i] -= n;
            arrayB[i] -= n;
            n = Math.min(arrayA[i + 1], arrayB[i]);
            sum += n;
            arrayA[i + 1] -= n;
            arrayB[i] -= n;
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 66320
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
int main(){
	double h,l,a;
	cin>>a;
	h=a;
	l=a;
	while(cin>>a){
		if(a>h)
			h=a;
		if(l>a)
			l=a;
	}
	cout<<fixed<<setprecision(5)<<h-l<<endl;
	return 0;
}

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

#define MOD 1000000009

using namespace std;

typedef long long ll;

// Only computes hash for the strings having upper or lower case alphabets.
// Further Optimisation: Precompute the values of 'p_pow'
long long compute_hash(string const &s)
{
    const int p = 53;
    long long hash_value = 0;
    long long p_pow = 1;
    for (char c : s)
    {
        hash_value = (hash_value + (c - 'a' + 1) * p_pow) % MOD;
        p_pow = (p_pow * p) % MOD;
    }
    return hash_value;
}

vector<int> rabin_karp(string const &s, string const &t)
{
    const int p = 53;
    const int m = 1e9 + 9;
    int S = s.size(), T = t.size();

    vector<long long> p_pow(max(S, T));
    p_pow[0] = 1;
    for (int i = 1; i < (int)p_pow.size(); i++)
        p_pow[i] = (p_pow[i - 1] * p) % m;

    vector<long long> h(T + 1, 0);
    for (int i = 0; i < T; i++)
        h[i + 1] = (h[i] + (t[i] - 'a' + 1) * p_pow[i]) % m;
    long long h_s = 0;
    for (int i = 0; i < S; i++)
        h_s = (h_s + (s[i] - 'a' + 1) * p_pow[i]) % m;

    vector<int> occurences;
    for (int i = 0; i + S - 1 < T; i++)
    {
        long long cur_h = (h[i + S] + m - h[i]) % m;
        if (cur_h == h_s * p_pow[i] % m)
            occurences.push_back(i);
    }
    return occurences;
}

int count_unique_substrings(string const &s)
{
    int n = s.size();

    const int p = 53;
    const int m = 1e9 + 9;
    vector<long long> p_pow(n);
    p_pow[0] = 1;
    for (int i = 1; i < n; i++)
        p_pow[i] = (p_pow[i - 1] * p) % m;

    vector<long long> h(n + 1, 0);
    for (int i = 0; i < n; i++)
        h[i + 1] = (h[i] + (s[i] - 'a' + 1) * p_pow[i]) % m;

    int cnt = 0;
    for (int l = 1; l <= n; l++)
    {
        set<long long> hs;
        for (int i = 0; i <= n - l; i++)
        {
            long long cur_h = (h[i + l] + m - h[i]) % m;
            cur_h = (cur_h * p_pow[n - i - 1]) % m;
            hs.insert(cur_h);
        }
        cnt += hs.size();
    }
    return cnt;
}

vector<int> prefix_function(string s)
{
    int n = (int)s.length();
    vector<int> pi(n);
    for (int i = 1; i < n; i++)
    {
        int j = pi[i - 1];
        while (j > 0 && s[i] != s[j])
            j = pi[j - 1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}

vector<int> KMP(string pattern, string text)
{
    auto n = pattern.length();
    auto m = text.length();

    auto altered_pattern = pattern + '$';
    auto pattern_pi = prefix_function(altered_pattern);

    vector<int> pos;
    int j = pattern_pi[n];
    for (int i = 0; i < m; i++)
    {
        while (j > 0 && text[i] != altered_pattern[j])
            j = pattern_pi[j - 1];
        
        if (text[i] == altered_pattern[j])
            j++;
        else if (j != 0)
            j = pattern_pi[j - 1];

        if (j == n)
        {
            pos.push_back(i - (j - 1) + 1);
            j = pattern_pi[j - 1];
        }
    }

    return pos;
}

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

    string S;
    cin >> S;

    for (int i = 0; i < S.length(); i++)
    {
        S[i] = ((S[i] + N - 'A') % 26) + 'A';
    }

    cout << S;

    return 0;
}


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

int main()
{
    long long A,B,K;
    cin >> A >> B >> K;

    if(A-K < 0)
    {
        B = B - (K-A);
        A = 0;
        if(B<0)
            B = 0;
    }
    else
    {
        A = A-K;
    }
    

    cout << A << " " << B;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
long long a[100010];
int main(){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)scanf("%lld",&a[i]);
int zero=0;
for(int i=0;i<n;i++)if(a[i]==0)zero++;
if(zero>0){
// a[i] contains 0
printf("0\n");
return 0;
}
long long prod=1;
for(int i=0;i<n;i++){
if(a[i]<=1000000000000000000/prod){
// This condition is equivalent to prod*a[i]<=10ˆ18
prod*=a[i];
}else{
printf("-1\n");
return 0;
}
}
printf("%lld\n",prod);
}


Measured memory_bytes: 2512
#include <bits/stdc++.h>
#define rep(i, f, n) for (ll i = (f); i < (ll)(n); i++)
#define repe(i, f, n) for (ll i = (f); i <= (ll)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

const int MAX = 1000;

int main() {
  string s, t;
  cin >> s >> t;
  int ans = MAX;
  repe(i, 0, s.size() - t.size()) {
    int tot = 0;
    rep(j, 0, t.size()) if (s[i + j] != t[j]) tot++;
    ans = min(tot, ans);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3620
from itertools import permutations
from math import factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# 座標 a から b の距離を求める
def calc(a, b):
    x1, y1 = a
    x2, y2 = b
    return ((x1 - x2)** 2 + (y1 - y2)** 2)** 0.5


n = int(readline())
xy = [list(map(int, readline().split())) for _ in range(n)]
l = [i for i in range(n)]
ans = 0
for v in permutations(l):
    for i in range(n-1):
        ans += calc(xy[v[i]],xy[v[i+1]])

ans /= len(list(permutations(l)))
print(ans)

Measured memory_bytes: 8100
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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

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

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

using P=pair<int,int>;
void solve()
{
	int h,w,m;
	cin>>h>>w>>m;
	vector<int>x(m),y(m),r(h),c(w);
	map<P,int>mp;
	rep(i,m){
		cin>>x[i]>>y[i];
		x[i]--;
		y[i]--;
		r[x[i]]++;
		c[y[i]]++;
	}
	int maxr=*max_element(all(r)),maxc=*max_element(all(c));
	ll a=0,b=0;
	rep(i,h){
		if(maxr==r[i])++a;
	}
	rep(i,w){
		if(maxc==c[i])++b;
	}
	int ans=maxr+maxc;
	ll cnt=0;
	rep(i,m){
		if(r[x[i]]==maxr&&c[y[i]]==maxc)++cnt;
	}
	if(cnt>=a*b)ans--;
	cout<<ans;
}

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


Measured memory_bytes: 7932
n, k = map(int, input().split())
A = list(map(int, input().split()))
mod = pow(10,9)+7
ans_p1 = 0
for i in range(n):
    ans_p1 += sum([bool(A[i]>A[j]) for j in range(i+1,n)])

ans_p2 = 0
for i in range(n):
    ans_p2 += sum([bool(A[i]>A[j]) for j in range(n)])
print((ans_p1*k+ans_p2*k*(k-1)//2)%mod)

Measured memory_bytes: 9308
#include<stdio.h>
#include<string.h>

int main(){
  int i=0,sum,count=0;
  char a[1002];
  a[0]='a';
  while(1){
    count=0;
    i=0;
    while(!(a[i]=='\n')){
      i++;
      scanf("%c",&a[i]);
      count++;}
    sum=0;
    for(i=1;i<count;i++){
      sum=sum+(a[i]-'0');}
    if(sum==0) break;
    printf("%d\n",sum);}
  return 0;}
  

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

int main(int argc, char const *argv[]) {
  int a,b,c;
  std::cin >> a>>b>>c;

  if(a+b == c || a+c == b || b+c == a){
    std::cout << "Yes" << '\n';
  }
  else{
    std::cout << "No" << '\n';
  }
  return 0;
}

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

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

	string str;
	cin >> str;
	bool flag[4]={};
	for(int i=0; i<str.size(); i++){
		switch(str[i]){
			case('S'):
				flag[0] = true;
				break;
			case('N'):
				flag[1] = true;
				break;
			case('E'):
				flag[2] = true;
				break;
			case('W'):
				flag[3] = true;
				break;
		}
	}
	if(flag[0]^flag[1] || flag[2]^flag[3]) cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lint long long
//#define P pair<int, int>

int main(){
    int N;
    lint M;
    cin >> N >> M;
    
    vector<lint> A(N);
    
    for(int i = 0; i < N; ++i){
        cin >> A[i];
        A[i] %= M;
    }
    
    vector<lint> sum(N);
    map<lint, lint> cnt;
    lint ans = 0;
    cnt[0]++;
    
    for(int i = 0; i < N; ++i){
        if(i == 0){
            sum[i] = A[0];
        } else {
            sum[i] = (sum[i-1] + A[i]) % M;
        }
        cnt[sum[i]]++;
    }
    

    for(auto e : cnt){
        ans += (e.second) * (e.second - 1) / 2;
    }
    cout << ans << endl;
}

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

#define ll long long int
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0);

ll solve(ll no_of_items,ll knap_cap, vector<ll>val,vector<ll>wt)
{
    ll dp[knap_cap+1][no_of_items+1];

    for(ll col=0;col<=no_of_items;col++)
        dp[0][col]=0;

    for(ll row=0;row<=knap_cap;row++)
        dp[row][0]=0;


    for(ll i=1;i<= knap_cap;i++)
    {
        for(ll j=1;j<=no_of_items;j++)
        {

            if(i>=wt[j-1])
            {

                dp[i][j]= max(dp[i-wt[j-1]][j-1]+val[j-1],dp[i][j-1]);
            }
            else
                dp[i][j]=dp[i][j-1];

        }

    }



    return dp[knap_cap][no_of_items];

}

int main()
{

	ll no_of_items,knap_cap;

	 cin>>no_of_items>>knap_cap;

	 vector<ll>val(no_of_items);
	 vector<ll>wt(no_of_items);

	 f(i,0,no_of_items)
	 {
	     cin>>wt[i]>>val[i];
	 }

	ll ans=solve(no_of_items,knap_cap,val,wt);

	cout<<ans<<"\n";

	return 0;
}













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

void call(int n){
    int i = 1;
 
    

    while (true) {
        int x = i;
        if (x % 3 == 0) {
            cout << " " << i;
        } else {
            while (true) {
                if (x % 10 == 3) {
                    cout << " " << i;
                    break;
                } else {
                    x /= 10;
                    if (!x) {
                        break;
                    }
                }
            }
        }
        if (++i > n) {
            break;
        }
    }
    
    cout << endl;
}

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


Measured memory_bytes: 3096
H,W = [int(i) for i in input().split()]
A = [input() for _ in range(H)]
B = []
for i in range(H-1,-1,-1):
    if not "#" in A[i]:
        del A[i]
for i in range(W):
    flag = True
    for j in range(len(A)):
        if A[j][i] == "#":
            flag = False
    if flag:
        B.append(0)
    else:
        B.append(1)
for i in A:
    tmp = ""
    for j in range(len(i)):
        if B[j]:
            tmp+=i[j]
    print(tmp)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 5050;
int N, K;
int a[MAX];
bool dp[MAX][MAX];
int abuf[MAX];

bool check(const int limit) {
    if (limit < 0) {
        return false;
    }
    memset(dp, false, sizeof(dp));
    dp[0][0] = true;
    REP(i, N) {
        REP(j, K) {
            if (abuf[i] + j <= K) {
                dp[i + 1][abuf[i] + j] |= dp[i][j];
            }
            dp[i + 1][j] |= dp[i][j];
        }
    }
    FOR(i, limit, K) if (dp[N][i]) {
        return false;
    }
    return true;
}

int main(void) {
    scanf("%d%d", &N, &K);
    a[0] = 0;
    REP(i, N) {
        scanf("%d", a + i + 1);
    }
    sort(a, a + N + 1);
    if (accumulate(a, a + N + 1, 0ll) < K) {
        cout << N << endl;
        return 0;
    }
    int low = 0, high = N;
    while (high - low > 1) {
        const int mid = (high + low) / 2;
        //DEBUG(mid)
        int id = 0;
        REP(i, N + 1) if (i != mid) {
            abuf[id++] = a[i];
        }
        (check(K - a[mid]) ? low : high) = mid;
    }
    cout << low << endl;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	string S;
	cin >> S;
	int ans = 700;
	for (int i = 0; i < 3; i++) {
		if (S[i] == 'o')ans += 100;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<limits>
#include<math.h>

using namespace std;

bool isOn(int x, int bit){
  return (bit >> (x-1)) & 0b1;
}

int main(){
  int n, m; cin >> n >> m;
  int s[10][10], k[10], p[10];

  for(int i=0; i<m; ++i){
    cin >> k[i];
    for(int l=0; l<k[i]; ++l) cin >> s[i][l];
  }
  for (size_t i = 0; i < m; i++) cin >> p[i];


  long long ans = 0;
  for(int i=0; i<pow(2, n); ++i){
    for (size_t l = 0; l < m; l++) {
      int cnt = 0;
      for (size_t ii = 0; ii < k[l]; ii++) cnt += isOn(s[l][ii], i);
      if(cnt % 2 != p[l]) break;
      if(l == m-1) ++ans;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main {
    public static void main(String[] args) throws IOException {
       Scanner in = new Scanner(System.in);
       int W = in.nextInt();
       int H = in.nextInt();
       int x = in.nextInt();
       int y = in.nextInt();
       int r = in.nextInt();

       if(0 <= x-r && x+r <= W &&
		0 <= y-r && y+r <= H) {
       	    System.out.println("Yes");
	} else {
	    System.out.println("No");
	}
    }
}

Measured memory_bytes: 17360