akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/14  Problem: 076_abc_c / Link: https://abc076.contest.atcoder.jp/tasks/abc076_c?lang=en  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	string T; cin >> T;
	string S; cin >> S;
	vector<string>vs;
	FOR(i, 0, SZ(T) - SZ(S)+1) {
		int ok = 1;
		FOR(j, 0, SZ(S)) {
			if (T[i + j] == '?'||S[j] == T[i + j]) {
				;
			}
			else {
				ok = 0;
			}
		}
		if (ok) {
			string a = T.substr(0,i)+S+ T.substr(i+SZ(S));
			FOR(i, 0, SZ(T))if (a[i] == '?')a[i] = 'a';
			vs.push_back(a);
		}
	}

	if (SZ(vs) == 0) {
		cout << "UNRESTORABLE" << endl;
	}
	else SORT(vs),cout << vs[0] << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
#define mod 1000000007
#define all(x) (x).begin(),(x).end()
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define NREP(i, n) for(int i = 1; i <= (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int nums(int n){
	return to_string(n).length();
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	cout << fixed << setprecision(7);
////////////////////////////////////////////
	int n,k;
	cin >> n >> k;
	if(n<10){
		cout << k+(100*(10-n)) << endl;
	}else{
		cout << k << endl;
	}

	
///////////////////////////////////////////
}


Measured memory_bytes: 256
# 60 -> {2:2, 3:1, 5:1}
def factorization(n):
    pf_cnt = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i == 0:
            cnt = 0
            while temp%i == 0:
                cnt += 1
                temp //= i
            pf_cnt[i] = cnt

    if temp != 1: pf_cnt[temp] = 1
    if not pf_cnt: pf_cnt[n] = 1

    return pf_cnt


n = int(input())
prime_cnts = {}
for i in range(1,n+1):
    fac = factorization(i)
    for prime, cnt in fac.items():
        prime_cnts.setdefault(prime, 0)
        prime_cnts[prime] += cnt


cnt_74 = 0
cnt_24 = 0
cnt_14 = 0
cnt_4 = 0
cnt_2 = 0
for prime, cnt in prime_cnts.items():
    if cnt >= 74:
        cnt_74 += 1
    if cnt >= 24:
        cnt_24 += 1
    if cnt >= 14:
        cnt_14 += 1
    if cnt >= 4:
        cnt_4 += 1
    if cnt >= 2:
        cnt_2 += 1

ans = 0
ans += cnt_74
ans += cnt_14*(cnt_4-1)
ans += cnt_24*(cnt_2-1)
ans += (cnt_2-2) * cnt_4*(cnt_4-1)//2
print(ans)

Measured memory_bytes: 38384
#include<iostream>
using namespace std;
int main(){
	int a, b;
	cin >> a >> b;
	if (a >= 13){
		cout << b << endl;
	}
	if (6 <= a&&a <= 12){
		cout << b / 2 << endl;
	}
	if (a <= 5){
		cout << b * 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int n, k, s;
    cin >> n >> k >> s;

    for(int i = 0; i < n; i++){
        if(i < k){
            cout << s << endl;
        } else {
            cout << (int)1e9 - 3 << endl;
        }
    }
}

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

#define WHITE 0
#define BLACK 1

int adj[50][50];
int N, M;
int color[50];

int dfs(int i){
    if(color[i]==BLACK){
        return 0;
    }else if(color[i]==WHITE){
        color[i] = BLACK;
        for(int j=0; j<N; j++){
            if(adj[i][j]==1){
                dfs(j);
            }
        }
        return 0;
    }
}
int main(){
    cin >> N >> M;
    int a, b;
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            adj[i][j] = 0;
        }
    }
    int edge[M][2];
    for(int i=0; i<M; i++){
        cin >> a >> b;
        adj[a-1][b-1] = 1;
        adj[b-1][a-1] = 1;
        edge[i][0] = a-1;
        edge[i][1] = b-1;
    }
    int counter = 0;
    for(int i=0; i<M; i++){
        for(int j=0; j<N; j++){
            color[j] = WHITE;
        }
        adj[edge[i][0]][edge[i][1]] = 0;
        adj[edge[i][1]][edge[i][0]] = 0;
        dfs(0);
        for(int j=0; j<N; j++){
            if(color[j]==WHITE){
                counter += 1;
                break;
            }
        }
        adj[edge[i][0]][edge[i][1]] = 1;
        adj[edge[i][1]][edge[i][0]] = 1;
    }
    cout << counter << endl;

return 0;
}


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

using namespace std;

#define nMAX 100 
#define vMAX 1000
#define WMAX 10000

int main(){

	int n,W;
	int v[nMAX+1],w[nMAX+1];
	int dp[nMAX+1][WMAX+1];

	cin>>n>>W;
	for(int i=0;i<n;i++){
		cin>>v[i]>>w[i];
	}

	for(int i=0;i<=W;i++) dp[0][i]=0;

	for(int i=0;i<n;i++){
		for(int j=0;j<=W;j++){
			if(j<w[i]){
				dp[i+1][j]=dp[i][j];
			}
			else{
				dp[i+1][j]=max(dp[i][j-w[i]]+v[i],max(dp[i][j],dp[i+1][j-w[i]]+v[i]));
			}
		}
	}
	cout<<dp[n][W]<<endl;
}

Measured memory_bytes: 5104
#include <bits/stdc++.h>
using namespace std;
long long f[101][100001],w[101],v[101];
int main()
{
	long long i,j,n,c,sum=0;
	scanf("%lld%lld",&n,&c);
	for(i=1;i<=n;i++)
	{
		scanf("%lld%lld",&w[i],&v[i]);
		sum+=v[i];
	}
	for(i=0;i<=100;i++)
		for(j=0;j<=100000;j++)
			f[i][j]=INT_MAX;
	f[0][0]=0;
	for(i=1;i<=n;i++)
	{
		for(j=0;j<=sum;j++)
		{
			f[i][j]=f[i-1][j];
			if(j>=v[i])
				f[i][j]=min(f[i][j],f[i-1][j-v[i]]+w[i]);
		}
	}
	for(i=sum;i>=0;i--)
		if(f[n][i]<=c)
		{
			printf("%lld",i);
			return 0;
		}
	printf("0");
	return 0;
}

Measured memory_bytes: 79104
def lscan; gets.split.map(&:to_i); end
def bye(msg); puts msg.to_s; exit; end

s = gets.chomp
n = s.size
m = n/2

bye 'No' if s != s.reverse
bye 'No' if s[0..(m-1)] != s[0..(m-1)].reverse
bye 'No' if s[(m+1)...n] != s[(m+1)...n].reverse
bye 'Yes'

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

int main() {
  long long a;
  long double b;
  cin>>a>>b;
  if(a==0||b==0){
    cout<<"0"<< endl;
    return 0;
  }
  
  
   long long ans=a*b/1; 
  cout<<ans<< endl;
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e;
int main(){
	cin>>a>>b>>c>>d;
	for(int i=0;i<=a;i++)
	for(int j=0;j<=b;j++)
	for(int k=0;k<=c;k++)
	if(i*500+j*100+k*50==d)
	e++;
	cout<<e<<endl;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N;
vector<int> G[100010];

int pre[100010];
bool checked[100010];

int dfs(int v, int pre)
{
	int res = 1;
	for (auto e : G[v])
	{
		if (e == pre || checked[e])continue;
		res += dfs(e, v);
	}
	return res;
}

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

	cin >> N;
	int s, t;
	rep(i, 0, N - 1)
	{
		cin >> s >> t;
		s--, t--;
		G[s].push_back(t);
		G[t].push_back(s);
	}

	fill(pre, pre + N, INF);

	queue<pii> q;
	q.push(mp(0, 0));
	checked[0] = true;
	pii sp;
	while (true)
	{
		auto p = q.front();
		q.pop();
		if (p.first == N - 1)
		{
			int tp = N - 1;
			rep(i, 0, (p.second - 1) / 2)
			{
				tp = pre[tp];
			}
			sp = mp(pre[tp], tp);
			break;
		}
		for (auto e : G[p.first])
		{
			if (checked[e])continue;
			checked[e] = true;
			pre[e] = p.first;
			q.push(mp(e, p.second + 1));
		}
	}

	fill(checked, checked + N, false);
	checked[sp.second] = true;
	int res0 = dfs(sp.first, -1);

	fill(checked, checked + N, false);
	checked[sp.first] = true;
	int res1 = dfs(sp.second, -1);

	if (res0 > res1)
	{
		cout << "Fennec" << endl;
	}
	else
	{
		cout << "Snuke" << endl;
	}

	return 0;
}

Measured memory_bytes: 8960
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int A,B,ans=0;
  cin>>A>>B;
  FOR(i,A,B+1){
    string s=to_string(i);
    if(s[0]==s[4]&&s[1]==s[3])ans++;
  }
  cout<<ans<<endl;
}


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

using namespace std;
#define rep(i,n) for (int i = 0; i < n; i++)
#define vi vector<int>

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

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

int main(){
  int n; cin >> n;
  vi a(n); rep(i, n) cin >> a[i];
  vi lgcd(n),rgcd(n);

  lgcd[0] = a[0];
  for (int i = 1; i < n; i++) lgcd[i] = gcd(lgcd[i-1],a[i-1]);

  rgcd[n-1] = a[n-1];
  for (int i = n-2; i >= 0; i--) rgcd[i] = gcd(rgcd[i+1],a[i+1]);

  int ans = 0;
  chmax(ans,rgcd[0]);// i = 0 は別処理
  for(int i = 1; i < n-1; i++){
    chmax(ans, gcd(lgcd[i],rgcd[i]));
  }
  chmax(ans, lgcd[n-1]);// i = n-1 も別処理

  std::cout << ans << '\n';
}


Measured memory_bytes: 1408
input_data = []
for i in range(5):
    input_data.append(int(input()))

min_value=10
min_index=0
for i, data in enumerate(input_data):
    temp = data%10
    if temp < min_value and temp!=0:
        min_value = temp
        min_index = i

sum_value=0
for i, data in enumerate(input_data):
    if i != min_index:
        if data%10 != 0:
            sum_value += (int(data/10)+1) *10
        else:
            sum_value += data
    else:
        sum_value += data
print(sum_value)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define mp make_pair
#define ld long double
#define ull unsigned long long int
#define mod 1000000007
int a[30][30];
int dp[22][2050000];
int n;
int recurs(int pos,int k)
{
	if(dp[pos][k]!=-1) return dp[pos][k];
	ll ans=0;
	for (int i = 0; i < n; ++i)
	{
		if(a[pos][i]==0) continue;
		if((k&(1<<i))!=0) continue;
		if(pos==(n-1)) 
		{
			return 1;
		}
		ans=(ans+recurs(pos+1,k|(1<<i)))%mod;
	}
	dp[pos][k]=ans;
	return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);//this works only
    cin.tie(NULL);// when first all inputs are from user
    cout.tie(NULL);//you will see all outputs afterwards
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for (int i = 0; i < n; ++i)
    {
    	for (int j = 0; j < n; ++j)
    	{
    		cin>>a[i][j];
    	}
    }
    int ans=recurs(0,0);
    cout<<ans;
    return 0;
}

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

int main(){
    long long H, N;
    cin >> H >> N;

    long long A[N-1];
    for (int i = 0; i < N; i++){
        cin >> A[i];
    }

    int ans = 0;
    int i = 0;

    while (H > 0 && i < N){
        H = H - A[i];
        i++;
    }

    if (H > 0){
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }

}


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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}


signed main() {
    //my-code
    ll x; cin >> x;
    ll cur = 100;
    ll cnt = 0;
    while(cur < x) {
        cur = (ll)(cur * 1.01);
        cnt++;
    }
    print(cnt);

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#ifdef CHECK_

Mod<> facts[212345];

void init() {
  facts[0] = 1;
  Mod<> a = 1;
  for(long i = 1; i < 212345; ++i) {
    a *= i;
    facts[i] = a;
  }
}

Mod<> nCr(long n, long r) {
  // Mod<> a = 1;
  // Mod<> b = 1;
  // for(long i = 0; i < r; ++i) {
  //   a *= n - i;
  // }
  // a = facts[n]
  // b = facts[r];
  // for(long i = 1; i <= r; ++i) {
  //   b *= i;
  // }
  return facts[n] / (facts[r] * facts[n-r]);
}

int main() {
  init();
  long h = get<long>();
  long w = get<long>();
  long a = get<long>();
  long b = get<long>();

  Mod<> res = 0;
  for(long i = 0; i < h - a; ++i) {
    int h1 = i;
    int w1 = b - 1;
    int h2 = h - i - 1;
    int w2 = w - b - 1;
    res += nCr(h1 + w1, h1) * nCr(h2 + w2, h2);
  }
  printf("%ld\n", res.get());
  
  return 0;
}

#else

template<typename T>
T get() { return 0; }
template<>
int get() { int x; scanf("%d", &x); return x; }
template<>
long get() { long x; scanf("%ld", &x); return x; }

template<typename T>
void put(T x) {}
template<>
void put(int x) { printf("%d\n", x); }
template<>
void put(long x) { printf("%ld\n", x); }
template<>
void put(std::string str) { printf("%s\n", str.c_str()); }
template<>
void put(const char* str) { printf("%s\n", str); }

template<typename T>
T pow(T x, long n) {
  T res = 1;
  T p = x;
  while( n != 0 ) {
    if( n & 0x01 ) res *= p;
    p *= p;
    n >>= 1;
  }
  return res;
}

template<long P = 1000000007>
class Mod {
public:
  Mod() : a(0) {}
  Mod(long x) : a(x) {}
  long get() { return a; }
  Mod operator + (Mod x) { return Mod<P>((a + x.get()) % P); }
  Mod operator += (Mod x) { a = (a + x.get()) % P; return *this; }
  Mod operator - (Mod x) { return Mod<P>((a + P - x.get()) % P); }
  Mod operator -= (Mod x) { a = (a + P - x.a) % P; return *this; }
  Mod operator * (Mod x) { return Mod<P>((a * x.get()) % P); }
  Mod operator *= (Mod x) { a = (a * x.a) % P; return *this; }
  Mod operator / (Mod x) { return *this * pow(x, P - 2); }
  Mod operator /= (Mod x) { a = (*this * pow(x, P - 2)); return *this; }
private:
  long a;
};

#define CHECK_
#include __FILE__
#endif



Measured memory_bytes: 1920
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if X - (500 * a + 100 * b + 50 * c) == 0:
                cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    
	string s;
	string t;

	int scount[26] = { 0 };
	int tcount[26] = { 0 };

	cin >> s;
	cin >> t;

	for (int i = 0; i < s.size(); i++) {
		scount[s[i] - 'a']++;
		tcount[t[i] - 'a']++;
	}

	sort(scount, scount + 26);
	sort(tcount, tcount + 26);

	bool ans = true;

	for (int i = 0; i < 26; i++) {
		if (scount[i] != tcount[i]) {
			ans = !ans;
			break;
		}
	}

	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}



	return 0;
}



Measured memory_bytes: 776
#include <iostream>
#include <vector>
#include <cstdlib>
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; }

const long long INF = 1LL << 60;

//input
int N;
long long h[110000];

// DP table
long long dp[110000];

int main() {
    int N, K; cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // initialize
    for (int i = 0; i < 110000; ++i) dp[i] = INF;

    // initial condition
    dp[0] = 0;

    // loop
    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    // answer
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1920
n = input()
s = list(map(int, input().split()))
a = 1
flag0 = False
flag = True
for i in s:
  a*=i
  if a > 1000000000000000000:
    flag = False
    break
for i in s:
  if i == 0:
    flag0 = True
if flag0:
  print(0)
elif flag:
  print(a)
else:
  print(-1)

Measured memory_bytes: 21692
/**
 * Title:
 * Url:
 */
#include<iostream>
#include<string>

using namespace std;

#define ll long long

int main() {
    string n; cin >> n;
    bool flag = false;
    for(int i=0; i<3; i++) {
        if(n[i]=='7') {
            flag = true;
        } 
    }
    if(flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

struct Que {
  int a,b,c,d;
  //  Que(int a,int b,int c, int d) : a(a), b(b), c(c), d(d) {}
};

int main() {
  int N, M, Q;cin >> N >> M >> Q;
  vector<Que> query(Q);
  rep(i,Q) {
    int a, b, c, d;cin >> a >> b >> c >> d;
    a--;b--;
    query[i].a = a;
    query[i].b = b;
    query[i].c = c;
    query[i].d = d;    
  }
  queue<string> qu;
  qu.push("1");
  int ans = 0;
  while(!qu.empty()) {
    string now = qu.front();
    // cout << now << endl;
    qu.pop();
    int siz = now.size();
    if(siz == N) {
      int sum = 0;
      for (auto q : query) {
	if(now[q.b] - now[q.a] == q.c) {
	  sum += q.d;
	}
      }
      ans = max(ans, sum);
      continue;
    }
    int last = now[siz - 1] - '0';
    for (int add = last; add <= M ; add++) {
      string nxt = now;
      nxt += add + '0';
      qu.push(nxt);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4724
N, M = map(int, input().split())
S_list = list(map(int, input().split()))
T_list = list(map(int, input().split()))

LARGE = 10**9+7

DP = [[0]*(M+1) for _ in range(N+1)]
# DP[i][j]
# S = S[i:], T = T[j:]

for i in range(N + 1):
    DP[i][M] = 1
for j in range(M + 1):
    DP[N][j] = 1

for i in range(N - 1, -1, -1):
    for j in range(M - 1, -1, -1):
        if S_list[i] == T_list[j]:
            DP[i][j] = DP[i][j+1] + DP[i+1][j]
        else:
            DP[i][j] = DP[i][j+1] + DP[i+1][j] - DP[i+1][j+1]
        DP[i][j] = DP[i][j] % LARGE

print(DP[0][0])


Measured memory_bytes: 74332
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
namespace AtCoder_Beginner_Contest_13
{
    class Program
    {
        //配列にする
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        //Listにする
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
        }
        static void Solve()
        {
            var NK = Sarray();
            var N = NK[0];
            var K = NK[1];
            var Ai = Slist();

            var sum = Ai.Sum();
            var max = Ai.Max();
            if (0 == max)
            {
                WriteLine(0);
                return;
            }
            var dc = yaku(sum).OrderByDescending(e => e.Key);
            foreach (var pk in dc)
            {
                Ai.Sort((l, r) => (int)(r % pk.Key - l % pk.Key));
                var b = 0;
                var e = (int)N - 1;
                var ln = Ai[b] % pk.Key;
                var rn = Ai[e] % pk.Key;
                var ope = 0L;
                while (b < e)
                {
                    if (K < ope)
                        break;
                    if (0 == (ln + rn)%pk.Key)
                    {
                        ope += rn;
                        ln = Ai[++b] % pk.Key;
                        rn = Ai[--e] % pk.Key; ;
                        if (e <= b)
                        {
                            if (ope <= K)
                            {
                                WriteLine(pk.Key);
                                return;
                            }
                        }
                    }
                    else if (pk.Key < ln + rn)
                    {
                        ope += pk.Key - ln;
                        rn = ln + rn - pk.Key;
                        ln = Ai[++b] % pk.Key;
                    }
                    else
                    {
                        ope += rn;
                        ln += rn;
                        rn = Ai[--e] % pk.Key;
                    }
                }
            }
        }
        static Dictionary<long, long> yaku(long n)
        {
            var ret = new Dictionary<long, long>();
            for (long i = 1; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    ret[i] = 1;
                    ret[n / i] = 1;
                }
            }
            return ret;
        }
    }
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

ll f(ll H, ll W) {
	if (H == 0 || W == 0) return 0;
	if (H > W) {
		return H - W + 2 * W * (H/W) + f(W, H % W);
	} else {
		return (W/H) * 2 * H + f(H, W % H);
	}
}
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll N, X; cin >> N >> X;
	print(X + f(N - X, X)); 
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    unsigned long long int x, ans;
    scanf("%lld", &x);
    ans = x / 11;
    ans *= 2;
    x %= 11;
    if (x > 0)
    {
        if (x <= 6)
            ans++;
        else
            ans += 2;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>

using namespace std;

int main()
{
  string S;
  cin >> S;
  
  int A, B, C, D;
  A = S[0] - '0';
  B = S[1] - '0';
  C = S[2] - '0';
  D = S[3] - '0';

  vector<int> v({A, B, C, D});

  for (int i = 0; i < 8; ++i) {
    int sum = v[0];
    for (int j = 0; j <= 2; ++j) {
      if ((i & (1<<j)) == 0) sum -= v[j + 1];
      else sum += v[j + 1];
    }
    if (sum == 7) {
      cout << v[0];
      for (int j = 0; j <= 2; ++j) {
	cout << ((i & 1<<j) == 0 ? '-' : '+');
	cout << v[j + 1];
      }
      cout << "=7" << endl;
      break;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_l

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

ll dp[3005][3005];
ll a[3005];
ll n;

ll go(int i , int j , int turn)
{
     if(dp[i][j] != -1)
        return dp[i][j];
     if(i>j)
        return 0;
     if(i==j)
     {
        dp[i][j] = a[i];
        if(turn==1)
            dp[i][j]*=-1;
        return dp[i][j];
     }

     if(turn == 0)
     {
           dp[i][j] = go(i+1,j,1) + a[i];
           dp[i][j] = max(dp[i][j],go(i,j-1,1) + a[j]);
     }
     else
     {
           dp[i][j] = go(i+1,j,0) - a[i];
           dp[i][j] = min(dp[i][j], go(i,j-1,0) - a[j]);
     }
     return dp[i][j];
}

int main()
{
    cin >> n;
    for(int i=0; i <n ; i++)
        cin >> a[i];
    for(int i=0 ;i<3005 ; i++)
    {
        for(int j=0 ; j<3005 ; j++)
            dp[i][j] = -1;
    }
    cout << go(0,n-1,0);
    /*for(int i=0 ; i<n ; i++)
    {
        for(int j=0 ; j<n ; j++)
            cout << dp[i][j] << " ";
        cout << endl;
    }*/
    return 0;
}


Measured memory_bytes: 74356
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    vector<int> a(3*n);
    for(int i=0;i<3*n;i++){
        cin >> a.at(i);
    }
    sort(a.rbegin(),a.rend());
    long long ans=0;
    for(int i=1;i<2*n;i+=2){
        ans += a.at(i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <numeric>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
typedef long long ll;

vector<int> line_to_array(istream& is, const int cnt, const char sep);
vector<string> split(const string &str, const char sep);
string trim(const string& str, const char* trimCharacterList  = " \t\v\r\n");
bool chk_rcsv(int j, int k, char** t, bool** chk_t, string str, int pos);

int N,M;
string* imgA;
string* imgB;

bool solve(){
    REP(i, N-M+1){
        REP(j, N-M+1){
            REP(k, M){
                REP(l, M){
                    if(imgA[k+i][l+j] != imgB[k][l]){
                        goto brk;
                    }
                }
                if(k==M-1)return true;
            }
        brk:;
        }
    }
    return false;
}

int main(){
    //ifstream cin("inputAB54_B.txt");
    cin >> N >> M;
    
    // new
    imgA = new string [N];
    imgB = new string [M];
    
    REP(i, N) cin >> imgA[i];
    REP(i, M) cin >> imgB[i];
    
    bool success = solve();
    
    //delete
    delete[] imgA;
    delete[] imgB;
    
    string str;
    if(success){
        str = "Yes";
    }else{
        str = "No";
    }
    cout << str << endl;
    
    return 0;
}

vector<int> line_to_array(istream& is, const int cnt, const char sep){
    vector<int> v;
    string str;
    getline(is, str);
    vector<string> words = split(str, sep);
    for (int i=0; i < cnt; i++) {
        v.push_back( atoi(words[i].c_str()) );
    }
    return v;
}

vector<string> split(const string &str, const char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ){
        v.push_back(buffer);
    }
    return v;
}

string trim(const string& str, const char* trimCharacterList)
{
    string result;
    string::size_type left = str.find_first_not_of(trimCharacterList);
    
    if (left != string::npos)
    {
        string::size_type right = str.find_last_not_of(trimCharacterList);
        result = str.substr(left, right - left + 1);
    }
    return result;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
using namespace std;
using ll =long long;
const int MOD = 1000000007;

int main() {
	ll N;
	cin >> N;
	string s;
	cin >> s;
	map<char, ll> as, bs;
	ll big=0;
	ll tmp=0;

	for (ll i = 0; i < N; i++) {
		bs[s[i]]++;

	}
	for (ll i = 0; i < N; i++) {
		tmp = 0;
			as[s[i]]++;
			bs[s[i]]--;
		for (auto i :as) {
			if (i.second >= 1 && bs[i.first] >= 1) {

				tmp++;

			}

		}
		big = max(tmp, big);

		

	}
	cout << big;
}

Measured memory_bytes: 256
n = int(input())

a = list(map(int, input().split()))

ans = 0
d = {}


for i in range(len(a)):
    if a[i] in d.keys():
        d[a[i]] += 1
    else:
        d[a[i]] = 1
max_ = max(a)
arr = [True] * (max_+1) 
ans = 0

for i in range(1, max_+1):
    if i in d.keys() and arr[i]:
        temp = i
        # print("i: ", i)
        while (temp + i) <= (max_):
            # print(temp+i)
            arr[(temp+i)] = False

            temp += i

        if d[i] == 1:
            ans += 1
# print(arr)
print(ans)

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

using namespace std;

typedef long long ll;

typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;

#define all(x) (x).begin(), (x).end()
#define fi first
#define se second

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    ll arr[n];
    ll su[n];
    for(int i=0;i<n;i++){
    	cin >> arr[i];
    }


    su[0] = arr[0];
    ll mod = 1e9+7;
    
    for(int i=1;i<n;i++){
    	su[i] = arr[i] + su[i-1];
    	su[i]%=mod;
    }

    ll ans = 0;
    for(int i=0;i<(n-1);i++){
    	ans+= (arr[i] * (su[n-1]-su[i] + mod)%mod)%mod;
    	ans%=mod;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 6740
import sys
while 1:
        n,m,a = map(int, raw_input().split())
        if not(n or m or a): break
        amida = [range(1,n+1) for i in xrange(1001)]
        l = []
        if m == 0: print a
        else:
                for i in xrange(m):
                        h,p,q = map(int, raw_input().split())
                        l.append((h,p,q))
                        
                l.sort(reverse=True)
                #print sys.stderr, l
                temp = a
                for i in xrange(len(l)):
                        if l[i][1] is temp:
                                temp = l[i][2]
                        elif l[i][2] is temp:
                                temp = l[i][1]

                print temp

Measured memory_bytes: 6064
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<vector>
#include<cstring>
#include<cmath>
#include<cstring>
#include<string>
#include<map>
#include<set>
#include<unordered_map>
#define db double
#define ui unsigned int
#define ll long long
#define ull unsiged ll
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define per(i,r,l)for(int i=r;i>=l;i--)
#define boots ios::sync_with_stdio(0); cin.tie(0)
#define pb push_back
#define pp pop_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define inf  0x3f3f3f3f
#define lnf LLONG_MAX
#define mii map<int,int>
#define mll map<ll,ll>
#define mil map<int,ll>
#define umii unordered_map<char,int>
#define umll unordered_map<ll,ll>
#define umcc unordered_map<char,char>
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pf(n) printf("%lld\n",n)
#define sz size()
using namespace std;
const db pi = 3.1415926535898;
const int MX = 1e3 + 7;
const int esp = 1e-6;
ll INV2, INV6;
ll modulo(ll num, ll MOD = mod) { return ((num%MOD) + MOD) % MOD; }
ll gcd(ll a, ll b) { return ((b == 0) ? a : gcd(b, a%b)); }
unordered_map<ui, ll>mp1, mp;
int n;
struct node
{
	double x, y;
	void get() {
		cin >> x >> y;
	}
}a[MX];
node operator + (node a, node b) {
	return { a.x + b.x, a.y + b.y };
}
double dis(node a)//计算距离
{
	return sqrt(a.x*a.x+a.y*a.y);
}
double cross(node a, node b, node c)//计算叉积
{
	return (b.x - a.x)*(c.y - a.y) - (c.x - a.x)*(b.y - a.y);
}

bool cmp(node a, node b)//极角排序
{
	node c;
	c.x = 0;
	c.y = 0;
	ll m = cross(c, a, b);
	if (m > 0)
		return 1;
	else if (m == 0 && (a.x-b.x) < 0)
		return 1;
	else return 0;
}
int main()
{
	//boots;
	cin >> n;
	rep(i, 0, n-1)a[i].get();
	sort(a, a + n, cmp);
	db ans = 0;
	//cout << ans << endl;
	rep(i, 0, n-1)
	{
		node b;
		b.x = a[i].x, b.y = a[i].y;
		db sum = dis(b);
		for (int j = (i + 1) % n, e = 1; e < n; e++, j=(++j) % n)
		{
			db ant = dis(b + a[j]);
			if (ant >= sum)
			{
				b = b + a[j];
				sum = ant;
			}
		}
		ans = max(sum, ans);	
	}
	printf("%.20f\n", ans);

}

Measured memory_bytes: 256
use std::io;


fn read_line() -> String {
    let mut line = String::new();

    io::stdin().read_line(&mut line)
        .expect("Failed to read line");
    return line;
}
fn to_i(s: &str) -> i64 {
    return s.trim().parse()
        .expect("Please type a number!");
}



fn main() {

    let l1 = read_line();
    let l2 = read_line();
    let l3 = read_line();
    let l4 = read_line();
    let l5 = read_line();
    let l6 = read_line();
    
    let n: i64 = to_i(&l1);
    let a: i64 = to_i(&l2);
    let b: i64 = to_i(&l3);
    let c: i64 = to_i(&l4);
    let d: i64 = to_i(&l5);
    let e: i64 = to_i(&l6);
/*
    println!("{} {} {}", 1, r10(1), 10 );
    println!("{} {} {}", 9, r10(9), 10 );
    println!("{} {} {}", 10, r10(10), 10 );
    println!("{} {} {}", 11, r10(11), 20 );
*/
    let mut v = Vec::new();
    v.push(a);
    v.push(b);
    v.push(c);
    v.push(d);
    v.push(e);
    let l = v.len();

    let mut minIndex = 0;
    let mut minValue = 0;
    for i in 0..l {
        let x = v[i];
        if i==0 {
            minValue = x;
        }
        if x < minValue {
            minValue = x;
            minIndex = i;
        }
    }

    let mut x = minValue;
    if x>n {
        x = n;
    }
    // println!("minValue {} {} n:{}", minValue, x, n);
    let m :i64 = n / x;
    let c :i64 = n % x;
    // println!("{} {}", n, c);
    let mut res = m+5;
    if c==0 {
        res -=1;
    }
    print!("{}", res);
}   

Measured memory_bytes: 4352
[<EntryPoint>]
let main argv =
    let n = System.Console.ReadLine() |> int
    let b = System.Console.ReadLine().Split() |> Array.map int
    let ans =
        [1 .. n-2]
        |> List.map (fun i -> if b.[i-1] < b.[i] then b.[i-1] else b.[i])
        |> List.sum
        |> (+) (b.[0] + b.[n-2])
    printfn "%d" ans
    0




Measured memory_bytes: 14044
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String[] args){
		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		String s;
		String[] t;
		int[] r =new int[5];
		try{
			while((s=reader.readLine()) !=null){
				t =s.split(" ");
				for(int j=0;j<5;j++){
					r[j]=0;
				}
				for(int i=0;i<t.length;i++){
					r[i]=Integer.parseInt(t[i]);
				}
				Arrays.sort(r);
				System.out.println(r[4]+" "+r[3]+" "+r[2]+" "+r[1]+" "+r[0]);
			}
		}catch(IOException e){
			System.out.println(e);
		}
	}
}

Measured memory_bytes: 16900
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  vll A(N);
  REP(i, 0, N) {
    ll a;
    cin >> a;
    A[i] = a;
  }

  ll ans = 0;
  for (;;) {
    REP(i, 0, A.size()) {
      if (A[i] % 2 != 0) {
        cout << ans << endl;
        return 0;
      }
      A[i] /= 2;
    }
    ans++;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f(i,a,b) for(long long i=a;i<b;i++)
typedef long long ll;
using namespace std;

int main(){
	ll num;cin>>num;
	string s,t,ans="";
	cin>>s>>t;
	ll n=2*num,j=0,k=0;
	f(i,0,n){
		if(i&1) {ans+=t[j];j++;}
		else {ans+=s[k];k++;}
	}
	cout<<ans<<"\n";
}

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

using namespace std;

#define MAX 10050
#define INF 1e9

struct P{
  int dist,cost,v;
  bool operator < (const P &p)const{
    if(dist != p.dist){
      return dist > p.dist;
    }
    return cost > p.cost;
  }
};

int N,M;
vector<P> G[MAX];

int dijkstra(){
  int res = 0;
  bool visited[MAX] = {false};
  priority_queue<P> Q;
  Q.push((P){0,0,0});

  while(!Q.empty()){
    P p = Q.top(); Q.pop();
    int v = p.v;
    if(visited[v]) continue;
    visited[v] = true;
    res += p.cost;
    for(int i = 0 ; i < (int)G[v].size() ; i++){
      P e = G[v][i];
      Q.push((P){p.dist+e.dist,e.cost,e.v});
    }
  }
  return res;
}

int main(){
  int u,v,d,c;
  while(cin >> N >> M, N){
    for(int i = 0 ; i < N ; i++){
      G[i].clear();
    }
    for(int i = 0 ; i < M ; i++){
      cin >> u >> v >> d >> c;
      u--; v--;
      G[u].push_back((P){d,c,v});
      G[v].push_back((P){d,c,u});
    }
    cout << dijkstra() << endl;
  }
  return 0;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){if((ll)(a)==inf)cout<<"inf"<<'\n';else if((ll)(a)==-inf)cout<<"-inf"<<'\n';else cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';if((ll)(v[i])==inf)cout<<"inf";else if((ll)(v[i])==-inf)cout<<"-inf";else cout<<(ll)(v[i]);}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
vi parent,rankk;
void init(ll n){
    parent=vi(n);
    rankk=vi(n);
    rep(i,n)parent[i]=i;
}
ll root(ll i){if(parent[i]==i)return i;return root(parent[i]);}
bool same(ll a,ll b){return root(a)==root(b);}
void heigou(ll x,ll y){
    x=root(x);y=root(y);
    if(x==y)return;
    if(rankk[x]<rankk[y])parent[x]=y;
    else if(rankk[x]>rankk[y])parent[y]=x;
    else{parent[y]=x;rankk[x]++;}
}
int main(){
    ll n;cin>>n;
    init(n);
    vi ans(n);
    ll m,k;cin>>m>>k;
    rep(i,m){
        ll a,b;cin>>a>>b;a--;b--;
        heigou(a,b);
        ans[a]--;ans[b]--;
    }
    rep(i,k){
        ll a,b;cin>>a>>b;a--;b--;
        if(root(a)==root(b)){ans[a]--;ans[b]--;}
    }
    vi num(n);
    rep(i,n)num[root(i)]++;
    rep(i,n)ans[i]+=num[root(i)];
    rep(i,n)ans[i]--;
    outv(ans);
}

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

int main() {
  int n, i;
  cin >> n;
  
  vector<int> a(n), b(n);
  for(i = 0; i < n; i++){
    cin >> a.at(i);
    b.at(i) = a.at(i);
  }
  
  sort(b.begin(), b.end());
  
  if(b.at(n - 1) == b.at(n - 2)){
    for(i = 0; i < n; i++){
      cout << b.at(n - 1) << endl;
    }
  }
  else{
    for(i = 0; i < n; i++){
      if(a.at(i) == b.at(n - 1)){
        cout << b.at(n - 2) << endl;
      }
      else{
        cout << b.at(n - 1) << endl;
      }
    }
  }
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rept(i,k,n) for(int i = (k); i < (int)(n); i++)
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define X first
#define Y second

typedef long long ll;
typedef pair<double,double> Pdd;
typedef pair<int,int> Pii;

int n;
vector<vector<int> > tree;

int main(){
    while(1){
        int n;
        cin>>n;
        if(!n) return 0;
        vector<Pdd> xy(n);
        rep(i,n) cin>>xy[i].X>>xy[i].Y;
        int ans =1;
        rep(i,n) rep(j,n){
            if(i==j) continue;
            double dx=xy[i].X-xy[j].X, dy=xy[i].Y-xy[j].Y;
            double d = sqrt(dx*dx+dy*dy);
            if(d>2.000001)continue;
            double dr = sqrt(1.0-d*d/4);
            double xx=(xy[i].X+xy[j].X)/2+-dy/d*dr;
            double yy=(xy[i].Y+xy[j].Y)/2+dx/d*dr;
            int cnt=0;
            rep(k,n){
                if(pow(xy[k].X-xx,2.0)+pow((xy[k].Y-yy),2.0)<1.000001)cnt++;
            }
            ans = max(ans,cnt);
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3180