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

using namespace std;

typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<pair<int, int> > VII;

int main() {
  
  const int TS = 530, TE = 1270;
  const int SPAN = TE-TS;
  int N, M;
  while(cin >> N >> M, N) {
    int r; cin >> r;
    VVI dat(M, VI(SPAN, 0));
    for(int i=0; i<r; i++) {
      int t, n, m, s; cin >> t >> n >> m >> s;
      m --; t -= TS;
      if(s) dat[m][t] ++;
      else dat[m][t] --;
    }
    
    for(int i=0; i<M; i++) {
      // imos PCs login: 1 logout: -1
      for(int j=0; j<SPAN; j++) {
	dat[i][j+1] += dat[i][j];
      }
    }
    
    VVI dat2(M, VI(SPAN, 0));
    
    for(int i=0; i<M; i++) {
      // 複数のPCをひとまとめにして、更に時間の累積和を取る
      for(int j=0; j<SPAN; j++) {
	dat2[i][j+1] = dat2[i][j] + (dat[i][j] > 0);
      }
    }
    
    int q;
    cin >> q;
    for(int i=0; i<q; i++) {
      int ts, te, m;
      cin >> ts >> te >> m; m --; ts -= TS; te -= TS;
      cout << dat2[m][te] - dat2[m][ts] << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 57868
import bisect
n,k = map(int,input().split())
a= list(map(int,input().split()))
a.sort()
c = []
d = 0

while d <= n-1:
    s = bisect.bisect_right(a,a[d])
    c.append(s-d)
    d = s
c.sort()

#print(c)

l = len(c)
d = c[:l-k:]

#print(d)

print(sum(d))

Measured memory_bytes: 25876
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int r,w,c,d;
	while(true){
	cin>>r>>w>>c>>d;
	if(!(r+w+c+d))break;
	w=w*c-r;
	if(w<=0){cout<<"0"<<endl;goto loop;}
	if(w%d==0)cout<<w/d<<endl;
	else cout<<w/d+1<<endl;
	loop:;
	}
	return 0;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, S; cin >> N >> S; 
	long long A[3010] = {}; 
	for(int i = 0; i < N; i++) cin >> A[i]; 
	long long P = 998244353;  
	long long dp[3010][3010] = {}; 
	dp[0][0] = 1LL; 
	for(long long i = 0; i < N; i++){
		for(long long j = 0; j < S; j++){
			dp[i+1][j] += dp[i][j]; dp[i+1][j] %= P; 
			if(j == 0 && A[i] == S){
				dp[i+1][S] += (i + 1) * (N - i); dp[i+1][S] %= P; 
			}
			else if(j == 0){
				dp[i+1][A[i]] += i + 1; dp[i+1][A[i]] %= P; 
			} 
			else if(j + A[i] == S){
				dp[i+1][S] += dp[i][j] * (N - i) % P; 
				dp[i+1][S] %= P; 
			}
			else if(j + A[i] > S) continue; 
			else{
				dp[i+1][j + A[i]] += dp[i][j]; 
			}
		}
		dp[i+1][S] += dp[i][S]; dp[i+1][S] %= P; 
	}
	cout << dp[N][S] << endl; 
}

Measured memory_bytes: 71040
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)



int main(){
    int k,n;
    cin>>k>>n;
    vector<int> p(n);
    int ans=0;
    rep(i,n) cin>>p[i];
    int a=p[0];
    int b;
    rep(i,n-1){
        b=p[i+1];
        ans=max(ans,abs(a-b));
        a=b;
    }
    ans=max(ans,abs(k-p[n-1]+p[0]));
    cout<<(k-ans)<<endl;
}

Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	vector<int> a(n);

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

	vector<int> mi(n);
	vector<int> ma(n);

	int buf = -1;
	for (int i = n-1; i >=1; i--) {
		buf = max(buf, a[i]);

		ma[i-1] = buf;
	}

	int d = -1;
	for (int i = 0; i < n-1; i++) {
		d = max(d, ma[i] - a[i]);
	}

	int ans = 0;
	for (int i = 0; i < n-1; i++) {
		if ((ma[i] - a[i]) == d)ans++;
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 1408
using System;

namespace C_sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var items = Console.ReadLine().Split(' ');

                var op = items[1];
                if (op == "?")
                {
                    break;
                }

                var a = int.Parse(items[0]);
                var b = int.Parse(items[2]);

                switch (op)
                {
                    case "+":
                        Console.WriteLine(a + b);
                        break;

                    case "-":
                        Console.WriteLine(a - b);
                        break;
                    
                    case "*":
                        Console.WriteLine(a * b);
                        break;
                    default:
                        Console.WriteLine(a / b);
                        break;
                }
            }
        }
    }
}



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

int main(){
    char S[3];
    cin >> S;
    int c=0;
    rep(i,3){
        if(S[0]=='R'&&S[1]=='R'&&S[2]=='R'){
            c=3;
        }else if(S[0]=='R'&&S[1]=='R'){
            c=2;
        }else if(S[1]=='R'&&S[2]=='R'){
            c=2;
        }else if(S[0]=='R'||S[1]=='R'||S[2]=='R'){
            c=1;
        }else{c=0;}
    }
    cout << c <<endl;
}

Measured memory_bytes: 3588
#include <iostream>

int gcd(int x, int y)
{
    if(x < y){
        std::swap(x, y);
    }
    while(y > 0){
        int r = x % y;
        x = y;
        y = r;
    }
    return x;
}
int main()
{
    int x, y;
    std::cin >> x;
    std::cin >> y;
    std::cout << gcd(x, y) << std::endl;
    return 0;
}

Measured memory_bytes: 1160
# 4
n = gets.chomp.to_i

# 1 2 4 3
a = gets.chomp.split(" ").map(&:to_i);

# 1 2 3 4
b = a.min(n)

u = 0

for i in 0..(n-1) do
  if a[i] != b[i]
    u += 1
  end
end

if u == 0 || u == 2
  puts "YES"
else
  puts "NO"
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;

int n, las, siz, tot;
int a[N], b[N];
char s[N];

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	if (s[1] == '0' || s[n] == '1') return 0 * puts("-1");
	for (int i = 1; i < n; ++i) {
		if (s[i] != s[n - i]) return 0 * puts("-1");
	}
	las = 1, siz = 1, tot = 1;
	for (int i = 2; i < n; ++i) {
		if (s[i] == '1') {
			int del = i - siz - 1;
			++tot;
			a[tot - 1] = tot;
			b[tot - 1] = las;
			las = tot;
			for (int j = 1; j <= del; ++j) {
				++tot;
				a[tot - 1] = tot;
				b[tot - 1] = las;
			}
			siz = i;
		}
	}
	++tot;
	a[tot - 1] = tot;
	b[tot - 1] = las;
	for (int i = 1; i < n; ++i) {
		printf("%d %d\n", a[i], b[i]);
	}
	return 0;
}


Measured memory_bytes: 2304
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]
cnt = 0
c = Counter(x[0] for x in s)
for x in s:
    if x[0] in "MARCH":
        cnt += 1
ans = cnt * (cnt - 1) * (cnt - 2) // 6
for k, v in c.items():
    if k not in "MARCH":
        continue
    if v >= 2:
        ans -= v * (v - 1) // 2 * (cnt - v)
    if v >= 3:
        ans -= v * (v - 1) * (v - 2) // 6
print(ans)


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

#include<algorithm>

#include<cstring>

#include<cmath>

#include<cstdlib>

#include<string.h>

using namespace std;

#define pb push_back

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

#define  rep(i,n,v) for(i=n;i<v;i++)

#define per(i,n,v) for(i=n;i>v;i--)

#define ff first 

#define ss second 

#define pp pair<ll,ll>

#define ll  long long

#define endl '\n'

void solve()

{

  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;

  string s, r, y;

  cin>>s;

  if(s[1]=='B') cout<<"ARC";

  else cout<<"ABC";

}

int main()

{

 ios_base::sync_with_stdio(false);

  cin. tie(0);cout. tie(0);

    ll t=1;

  // cin>>t;

    while(t--)

    {

      solve();

    }

    return 0;

}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void uniq(vector<int> &vec){sort(vec.begin(), vec.end());vec.erase(unique(vec.begin(), vec.end()), vec.end());}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}


signed main(){start();
    int n,m,ans=0;
    cin>>n>>m;
    Vi a(n);
    map<int,int> ma;
    REP(i,0,n){
        cin>>a[i];
        a[i]%=m;
    }
    
    ma[a[0]]++;
    REP(i,1,n){
        a[i]=(a[i-1]+a[i])%m;
        ma[a[i]]++;
    }
//    REP(i,0,n) cout<<a[i]<<" ";
    for(auto x : ma){
//        cout<<x.second<<" ";
        if(x.first==0) ans += x.second;
        if(x.second>1) ans += x.second*(x.second-1)/2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4992
// by newbiechd
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>

// Delete the debugging information!
#define debug(x) std::cerr << #x << " = " << (x) << std::endl

const int N_MAX = 300007;
int n, p[N_MAX];
struct FenwickTree {
  int sum[N_MAX];
  void modify(int x) {
    while (x <= n)
      ++sum[x], x += x & -x;
  }
  int query(int x) {
    int ret = 0;
    while (x)
      ret += sum[x], x -= x & -x;
    return ret;
  }
}bit[3];

int main() {
  
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &p[i]);
  
  bool flag = 1;
  long long I[3] = {0, 0, 0};
  for (int i = n; i; --i) {
    flag &= (i & 1) == (p[i] & 1);
    I[i & 1] += bit[i & 1].query(p[i]);
    I[2] += bit[2].query(p[i]);
    bit[i & 1].modify(p[i]);
    bit[2].modify(p[i]);
  }
  printf(flag && (I[0] + I[1]) * 3 == I[2] ? "Yes\n" : "No\n");
  return 0;
}


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

int main(){
  while(1){
    int N;
    scanf("%d", &N);
    if(N==0)break;
    int x[N], y[N];
    int dx[4]={-1,0,1,0};
    int dy[4]={0,-1,0,1};
    x[0] = 0;
    y[0] = 0;
    for(int i=1;i<N;i++){
      int n,d;
      scanf("%d%d", &n, &d);
      x[i] = x[n] + dx[d];
      y[i] = y[n] + dy[d];
    }
    int L,R,U,D;
    L=10000;R=-10000;U=-10000;D=10000;
    for(int i=0;i<N;i++){
      if(x[i] < L)L=x[i];
      if(x[i] > R)R=x[i];
      if(y[i] < D)D=y[i];
      if(y[i] > U)U=y[i];
    }
    printf("%d %d\n", R-L+1, U-D+1);

  }

  return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    vector<pair<int, int>> tasks;
    
    for (int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;

        tasks.emplace_back(b, a);
    }

    sort(begin(tasks), end(tasks));

    int t = 0;
    for (int i = 0; i < N; ++i) {
        t += tasks[i].second;
        if (t > tasks[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


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

int main() {
    int n;

    cin >> n ;

    long array[n];

    for(int i = 0 ; i < n ; i ++){
        cin >> array[i];
    }
    
    for(int j = n - 1 ; j > 0 ; j --){
        cout << array[j] << " " ;
    }

    cout << array[0] << "\n";
}


Measured memory_bytes: 3116
using System;
using System.Collections.Generic;
using System.Linq;
class Ho{
  static void Main(){
    var aho = Console.ReadLine().Split();
    var h = int.Parse(aho[0]);
    var n = int.Parse(aho[1]);
    var a = Console.ReadLine().Split();
    var mon = new List<long>();
    long go = 0;
    foreach(var b in a){
      mon.Add(long.Parse(b));
      go += long.Parse(b);
    }
    var teki = mon.OrderByDescending(x=> x).ToList();
    long hissatu = 0;
    if(n > h) n = h;
    for(var i = 0;i<n;i++){
      hissatu += teki[i];
    }
    Console.WriteLine(go-hissatu);
  }
}

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

#define MAX 210

int n;
long long int x;
vector<long long int> v;

map<long long int, long long int> mp[MAX];

set<int> s;
vector<long long int> ope;

#define MOD 1000000007
long long int ans;

map<long long int, long long int> dp[MAX];

inline long long int dfs(int pos,long long int val) {
	if (pos == n) {
		return val;
	}
	if (mp[pos].count(val))return mp[pos][val];
	mp[pos][val] = 0;
	long long int &z = mp[pos][val];
	if (v[pos] > val) {
		z = dfs(pos + 1, val);
		z *= (n-pos);
		if (z >= MOD)z %= MOD;
		return z;
	}
	long long int w = 1;
	for (int j = pos; j < n; j++) {
		long long int nex = val % v[j];
		long long int tmp=dfs(j + 1, nex);
		tmp *= w;
		if (tmp >= MOD)tmp %= MOD;
		z += tmp;
		w *= (n - j - 1);
		if (w >= MOD)w %= MOD;
	}
	z %= MOD;
	return z;
}

int main() {
	cin >> n;
	scanf("%lld",&x);
	for (int i = 0; i < n; i++) {
		long long int s;
		scanf("%lld", &s);
		v.push_back(s);
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	ans=dfs(0,x);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 33792
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n,cnt = 0;
	int a[100] = {0};
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%d",a+i);
	}
	for(int i = 0; i < n; i++){
		for(int j = n - 1; j >= i + 1; j--){
			if(a[j] < a[j-1]){
				swap(a[j],a[j-1]);
				cnt++;
			}
		}
	}
	for(int i = 0; i < n - 1; i++){
		printf("%d ",a[i]);
	}
	printf("%d\n%d\n",a[n-1],cnt);
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
#include <sstream>
using namespace std;
const constexpr int INF = 1e9;
#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9+7;
struct Less{
   bool operator()(const pair<string, int>&a, const pair<string, int>&b){
        if(a.first==b.first){
            return a.second < b.second;
        }
       return a.first < b.first;
    }
};

ll extGCD(ll a, ll b, ll& x, ll& y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a/b*x;
    return d;
}
ll GCD(ll a, ll b){
    if(a<b) swap(a, b);
    if(b==0) return a;
    return GCD(b, a%b);
}
int par[100010], rr[100010];
void init(){
    for(int i=0; i<100010; ++i){
        par[i]=i;
        rr[i]=0;
    }
}
int root(int x){
    return par[x] == x ? x:par[x] = root(par[x]);
}
bool same(int x, int y){
    return root(x)==root(y);
}
void unite(int x, int y){
    x = root(x);
    y = root(y);
    if(x==y) return ;
    
    if(rr[x]<rr[y]){
        par[x] = y;
    }else{
        par[y] = x;
        if(rr[x]==rr[y]) rr[x]++;
    }
}

ll pow_mod(ll x, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res*x%MOD;
        }
        x = x*x%MOD;
        n>>=1;
    }
    return res;
}
int main() {
    string S, T; cin >> S >> T;
    
    for(int i=S.size()-T.size(); i>=0; --i){
        if(S[i]==T[0]||S[i]=='?'){
            for(int j=0; j<T.size(); ++j){
                if(S[i+j]!=T[j]&&S[i+j]!='?') break;
                if(j==T.size()-1){
                    for(int k=0; k<T.size(); ++k){
                        S[i+k]=T[k];
                    }
                    for(int k=0; k<S.size(); ++k){
                        if(S[k]=='?') S[k]='a';
                    }
                    cout << S << endl;
                    return 0;
                }
            }
        }
    }
    cout << "UNRESTORABLE" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> trp;
typedef vector<ll> vi;
typedef vector<pll> vp;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define pob         pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define sc3(a,b,c)  cin>>a>>b>>c
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"Yes"<<endl
#define prN         cout<<"No"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define	mp3(a,b,c)  make_pair(a,make_pair(b,c))
#define se          second
#define fi          first 
#define sse         second.second
#define sfi         second.first
#define soA         sort(A+1,A+1+n)
#define so(A,n)     sort(A+1,A+1+n)
#define sov(v)      sort(all(v))
#define sovr(v)     sort(all(v),greater<ll>())
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	
	sc2(n,m);
	if(n==m){
		if(n<=m){
			while(m--)cout<<n;
		}
		else while(n--)cout<<m;
	}
	else if(n>m){
		 while(n--)cout<<m;
	}
	else while(m--)cout<<n;
	
	
	
	
	
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	} 		
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{	
	int c, a, b, a1, b1;
	while (cin >> c&&c != 0) {
		a = 0; b = 0;
		for (int i = 0; i < c; i++) {
			cin >> a1 >> b1;
			if (a1 > b1) {
				a += (a1 + b1);
			}
			else if (a1 < b1) {
				b += (a1 + b1);
			}
			else {
				a += a1;
				b += b1;
			}
		}
		cout << a << ' ' << b << endl;
	}
	return 0;
}


Measured memory_bytes: 3092
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Integer[] ary = new Integer[n];
        int sum = 0;
        int max = 0;
        for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(sc.next());
            ary[i] = a;
            sum += a;
            max = Math.max(a, max);
        }
        if (max < sum - max) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  map<ll, ll> m;
  for (int i = 0; i < n; i++){
    ll d;
    cin >> d;
    
    m[d]++;
  }
  ll M;
  cin >> M;
  
  
  int ok = 1;
  for (int i = 0; i < M; i++){
    ll t;
    cin >> t;
    if (m[t] == 0)
      ok = 0;
    else
      m[t]--;
  }
  
  if(ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
    

  return 0;
}


Measured memory_bytes: 12800
//  main.cpp
//  solve
//
//  Created by Ahmed on 11/16/16.
//  Copyright © 2016 Abdellah. All rights reserved.
//


#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>
#include <array>


#define f first
#define s second
#define pb push_back
#define sz(a) (int)a.size()
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(ll (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define eps 1e-6
#define infi 1000000002
#define infll 1000000000000000000ll
#define MX 1000000
#define X real()
#define Y imag()
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c)   cross(vec(a,b) , vec(a,c)) > -eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 100050001
#define mod2 100030001
#define base1 37
#define base2 31
#define que priority_queue<pair<int,int>, vector<pair<int,int>> , greater<pair<int,int> > >
#define rotate(v,t) ((v)*exp(point(0,t)))
#define rotateabout(v,t,a) (rotate(vec(a,v),t)+(a))
#define PI atan(1)*4

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef map<long, long> mll;
typedef complex<long double> point;
typedef pair<point, point> line;
typedef pair<double , point> Circle;




ll N;

int main()
{
    scanf("%lld",&N);
    
    lp(w, 1, 3500) lp(n , 1, 3500) {
        ll x = w*n*N;
        ll y = 4*n*w - N * (n+w);
        if(y > 0 && x%y == 0 && x/y <= 3500) {
            return printf("%lld %d %d\n",x/y , n,w) , 0;
        }
        
    }
    
    return 0;
}

/*
 
 
 */
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
//ios::sync_with_stdio(0);cin.tie(0);

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int a, b, c;
  while (cin >> a >> b >> c, a) {
    int n;
    cin >> n;
    int x = min({a * a + b * b, b * b + c * c, c * c + a * a});
    while (n--) {
      int r;
      cin >> r;
      cout << (x < 4 * r * r ? "OK" : "NA") << endl;
    }
  }
}

Measured memory_bytes: 3048
// {{{ by shik
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#ifdef SHIK
template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, __VA_ARGS__); \
} while (0)

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T, size_t N>
ostream& operator <<( ostream &s, const array<T,N> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
#else
#define dump(...)
#endif

template<typename T>
void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( long long &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }

void R() {}
template<typename T, typename... U>
void R( T& head, U&... tail ) {
    _R(head);
    R(tail...);
}

template<typename T>
void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
template<typename T>
void _W( const vector<T> &x ) {
    for ( auto i=x.cbegin(); i!=x.cend(); i++ ) {
        if ( i!=x.cbegin() ) putchar(' ');
        _W(*i);
    }
}

void W() {}
template<typename T, typename... U>
void W( const T& head, const U&... tail ) {
    _W(head);
    putchar(sizeof...(tail)?' ':'\n');
    W(tail...);
}

#ifdef SHIK
#define FILEIO(...)
#else
#define FILEIO(name) do {\
    freopen(name ".in","r",stdin); \
    freopen(name ".out","w",stdout); \
} while (0)
#endif

// }}}

const int N=2016;
int n;
LL x,a[N],b[N];
int main() {
    R(n,x);
    REP(i,n) R(a[i]);
    REP(i,n) b[i]=1e18;
    LL ans=1e18;
    REP(i,n) {
        LL now=i*x;
        REP(j,n) b[j]=min(b[j],a[(j-i+n)%n]);
        REP(j,n) now+=b[j];
        ans=min(ans,now);
    }
    W(ans);
    return 0;
}


Measured memory_bytes: 256
import * as fs from "fs";
const input = fs.readFileSync("/dev/stdin", "utf8").split("\n");
const n = +input[0];
const h = input[1].split(" ").map(x=>+x);
 
let result = 0;
let max = -Infinity;
for(const x of h){
  if(x>=max) {
    result++;
    max=x;
  }
}
console.log(result);

Measured memory_bytes: 7372
// https://atcoder.jp/contests/abc141/tasks/abc141_e
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using I = int;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (I i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    I N;
    string S;
    cin >> N >> S;
    I len = S.length(), maxv = 0;
    REP(d, len) {
        I cnt = 0;
        REP(i, len - d) {
            if (S[i] == S[i + d]) {
                cnt++;
            } else {
                cnt = 0;
            }
            maxv = max(maxv, min(cnt, d));
        }
    }
    cout << maxv << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main(void){
    string S;
    cin>>S;
    int N,T;
    N=S.size();
    T=0;
    for(int i=0;i<N;i++){
        if(S[i]=='o'){
            T=T+1;
            
        }
    }
    if(T+15-N>=8){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#if defined(LOCAL)
#define PROBLEM_NAME "c"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) debug(x)
#else
#define L(x, ...) (x)
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)
#define max(a,b)({__typeof__(a)__x=(a);__typeof__(b)__y=(b);__x>__y?__x:__y;})
#define min(a,b)({__typeof__(a)__x=(a);__typeof__(b)__y=(b);__x<__y?__x:__y;})

void solve(istream& cin, ostream& cout) {
  l n, m; cin >> n >> m;
  vector<string> ss(n); F(i, 0, n) cin >> ss[i];
  l fours = (n / 2) * (m / 2);
  l twos = 0;
  if (n % 2) twos += m / 2;
  if (m % 2) twos += n / 2;
  l z = 26;
  vl frq(z);
  F(i, 0, n) F(j, 0, m) frq[ss[i][j] - 'a']++;
  F(i, 0, z) {
    l t = min(fours, frq[i] / 4);
    fours -= t; frq[i] -= t * 4;
    t = min(twos, frq[i] / 2);
    twos -= t; frq[i] -= t * 2;
  }
  if (fours == 0 and twos == 0) {
    cout << "Yes" << lf;
  } else {
    cout << "No" << lf;
  }
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


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

int main()
{
	ll int a,b,g;
	cin>>a>>b;
	g=__gcd(a,b);
	ll int l=(a*b)/g;
	cout<<l;
	
	
	
	
	
	
}
	


	
	
	
   



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

typedef long long int ll;
typedef double d;

#define tt int t; cin>>t; while(t--)
#define lo(i, a, b) for(int i=a; i<b; i++)
#define rlo(i, a) for(int i=a; i>0; i--)

#define be(a) a.begin(),a.end()
#define sz(x) x.size()

#define nl cout<<"\n";
#define sp cout<<" ";

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int main()
{
    su;
    ll n,s=100,i=0;
    cin>>n;
    while(s<n)
    {
        s+=(s/100);
        i++;
    }
    cout<<i;
    nl;
    return 0;
}


Measured memory_bytes: 3628
from itertools import product
x, y, z, k = map(int, raw_input().split())
A = map(int, raw_input().split())
B = map(int, raw_input().split())
C = map(int, raw_input().split())
AB = []
for (a, b) in product(A, B):
    AB.append(a+b)
AB.sort(reverse=True)
C.sort(reverse=True)
ABC = []
for i in range(min(k+1, len(AB))):
    for j in range(len(C)):
        ABC.append(AB[i]+C[j])
ABC.sort(reverse=True)
for i in range(min(k, len(ABC))):
    print ABC[i]


Measured memory_bytes: 170240
# -*- coding: utf-8 -*-
import sys
import math
import numpy as np
from itertools import permutations
from functools import reduce
# sys.setrecursionlimit(10000)


def main():
    # 入力処理
    N, M = map(int, input().split())
    edges = [set(map(int, input().split())) for i in range(M)]
    print(edges, file=sys.stderr)

    # アルゴリズム本体
    ps = permutations(range(2,N+1), N-1)

    C = 0
    for p in ps:
        q = [1] + list(p)
        xs = [set((q[i],q[i+1])) in edges for i in range(N-1)]
        if all(xs):
            print(q, file=sys.stderr)
            C += 1

    # 出力
    print(C)


if __name__ == '__main__':
    main()


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

/**
 * Created by Ayushi on 19 Apr 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        StringTokenizer st;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        st = new StringTokenizer(br.readLine(), " ");
        int n = Integer.parseInt(st.nextToken());
        //int m = Integer.parseInt(st.nextToken());
        st = new StringTokenizer(br.readLine(), " ");
        int a;
        int tot = 0;
        while (st.hasMoreTokens()) {
            a = Integer.parseInt(st.nextToken());
            tot += a;
        }
        br.close();

        System.out.println(Math.max(n-tot, -1));
    }
}


Measured memory_bytes: 34028
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n,m;
  cin >> n >> m;
  vector<pair<LL,LL> > ch;
  REP(i,n) {
    LL x;
    cin >> x;
    ch.emplace_back(x,1);
  }
  REP(i,m) {
    LL b,c;
    cin >> b >> c;
    ch.emplace_back(c,b);
  }
  sort(ch.rbegin(),ch.rend());
  LL answer = 0;
  LL left = n;
  REP(i,n) {
    if(!left) break;
    LL tmp = min(ch[i].second, left);
    answer += ch[i].first * tmp;
    left -= tmp;
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<stdio.h>//printf("%.*f\n",*********);
#include<vector>//s.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char('a'=32+'A')
                //to_string,string,substr
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap

#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(a,n) rep(i,n)cin>>a[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int KETA(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}

bool KIBN(string s) {
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i])return false;
	}
	return true;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */

int main(void) {
	rapid_pleaseAC_fast;

	string s;
	cin >> s;
	int cnt = 0;
	rep(i, s.size()) {
		if (s[i] == '1') {
			cnt++;
		}
	}
	cout << cnt << rt;

	please AC;
}
//参考：---

Measured memory_bytes: 256
#include <cstdio>

using namespace std;
int a[200001];
int n;

template<class T>
inline void read(T&a){
    char c=getchar();
    for(a=0;c<'0'||c>'9';c=getchar());
    for(;c>='0'&&c<='9';c=getchar())a=a*10+c-'0';
}

int main(){
    
    
    read(n);
    
    for(int i=1;i<=n;i++){
        read(a[i]);
    }
    int last = 0;
    for(int i=n;i>1;i-=2){
        printf("%d ",a[i]);
        last = i;
    }
    printf("%d ",a[1]);
    int next = (last==3) ? 2 : 3;
    for(int i=next;i<n;i+=2){
        printf("%d ",a[i]);
    }
    
    
    return 0;
}

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

int main()
{

	int a[100][100] = {0},b[100][100] = {0};
	long sum = 0;

	int n, m, l;
	cin >> n >> m >> l;

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

	for(int i = 0; i < m; i++){
		for(int j = 0; j < l; j++){
			cin >> b[i][j];
		}
	}

	for(int i = 0; i < n; i++){
		for(int j = 0; j < l; j++){
			sum = 0;
			for(int k = 0; k < m; k++){
			sum += a[i][k] * b[k][j];
			}
			cout << sum;
			if(j < l - 1){
				cout << ' ';
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define debug(x) cerr<<#x<<" = "<<x
#define sp <<"  "
#define el <<endl
#define fgx cerr<<" ---------------------------------------------- "<<endl
#define uint unsigned int 
#define ULL unsigned long long
#define DB long double
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define rint register int 
inline int read(){
	int nm=0; bool fh=true; char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) fh^=(cw=='-');
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return fh?nm:-nm;
}
#define pli pair<long long,int>
#define M 400020
#define mod 998244353ll
int fs[M],nt[M<<2],to[M<<2],cur[M],tg[M],tmp,r[M<<2];
int n,S,T,vis[M],tim,q[M],hd,tl,u[M],v[M],fa[M];
inline void add(int x,int y){
	nt[tmp]=fs[x],fs[x]=tmp,to[tmp]=y,r[tmp++]=1;
	nt[tmp]=fs[y],fs[y]=tmp,to[tmp]=x,r[tmp++]=0;
}
inline bool bfs(){
	hd=tl=0,q[tl++]=S,tg[S]=++tim,vis[S]=1,cur[S]=fs[S];
	for(int x=q[hd];hd<tl;x=q[++hd]) for(int y,i=fs[x];i!=-1;i=nt[i]) 
		if(r[i]&&tg[y=to[i]]<tim) vis[q[tl++]=y]=vis[x]+1,tg[y]=tim,cur[y]=fs[y];
	return tg[T]==tim;
}
inline int dfs(int x,int mxf=1){
	if(x==T||!mxf) return mxf; int temp=0,rc;
	for(int &i=cur[x];i!=-1&&temp<mxf;i=nt[i]) if(r[i]&&vis[to[i]]==vis[x]+1&&tg[to[i]]==tim)
		rc=dfs(to[i]),r[i]-=rc,r[i^1]+=rc,temp+=rc; if(!temp) tg[x]=0; return temp;
}
inline void solve(int x,int last){
	if(fa[x]>0) return; fa[x]=last;
	for(int i=fs[x];i!=-1;i=nt[i]) if(!r[i]&&to[i]<S) solve(to[i],x);
}
int main(){	
	n=read(),memset(fs,-1,sizeof(fs)),S=n+n,T=S+1; for(int i=1;i<=n;i++) add(i,T);
	for(int i=1;i<n;add(S,i+n),i++) for(int ct=read();ct;--ct) add(i+n,read()); int now=0,x;
	while(bfs()) now+=dfs(S,n-1); if(now<n-1){puts("-1");return 0;}
	for(int i=fs[T];i!=-1;i=nt[i]) if(!r[i]) x=to[i]; solve(x,0);
	for(int i=1;i<=n;i++) if(i!=x) u[fa[i]-n]=i;
	for(int i=1;i<n;i++) v[i]=fa[i+n];
	for(int i=1;i<n;i++) if(!u[i]||!v[i]){puts("-1");return 0;}
	for(int i=1;i<n;i++) printf("%d %d\n",u[i],v[i]);
	return 0;
}

Measured memory_bytes: 30720
#include <iostream>
#include <algorithm>
#include <queue>
#define MAX 101
#define INF 1000000
using namespace std;

int s, d;
int G[MAX][MAX];

typedef pair<int, int> P;

int solve() {
  int cost[MAX];
  priority_queue< P, vector<P>, greater<P> > PQ;
  int ans = 0;
  bool visited[MAX];

  fill(cost, cost+d+1, INF);
  fill(visited, visited+d+1, false);
  cost[0] = 0;
  PQ.push(P(0, 0));

  while(!PQ.empty()) {
    P p = PQ.top(); PQ.pop();
    int v = p.second;
    if(visited[v]) continue;
    visited[v] = true;
    for(int i = 0; i < d+1; i++) {
      if(v == i) continue;
      if(visited[i]) continue;
      if(cost[i] > G[v][i]) {
	cost[i] = G[v][i];
	PQ.push(P(cost[i], i));
      }
    }
  }
  for(int i = 0; i < d+1; i++) {
    ans += cost[i];
    //cout << cost[i] << endl;
  }
  return ans;
}

main() {
  while(( cin >> s >> d ) && s && d) {
    fill(G[0], G[MAX], INF);
    for(int i = 0; i < s; i++) {
      for(int j = 0; j < d; j++) {
	int a;
	cin >> a;
	if(a == 0) a = INF;
	if(i == 0) G[d][j] = G[j][d] = a;
	else       G[d][j] = G[j][d] = min(G[d][j], a);
      }
    }

    for(int i = 0; i < d; i++) {
      for(int j = i+1; j < d; j++) {
	int a;
	cin >> a;
	if(a == 0) a = INF;
	G[i][j] = G[j][i] = a;
      }
    }

    cout << solve() << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long 
#define vl vector
#define pb push_back
#define ff first
#define ss second
using namespace std;

int main()
{
    ll n,m,i,a,b,k;
    cin>>n>>k;
    ll arr[n];
    for(i=0;i<n;i++) cin>>arr[i];
    sort(arr,arr+n);
    ll sum=0;
    for(i=0;i<k;i++) sum+=arr[i];
    cout<<sum;
    
}

Measured memory_bytes: 3604
open System

let readInt () = stdin.ReadLine() |> int
let readIntArray () = stdin.ReadLine().Split(' ') |> Array.map int64
let readString () = stdin.ReadLine()

let A = readInt ()
let B = readInt ()
let C = readInt ()
let X = readInt ()

let solve () : unit = 
    [| for a in 0..A do 
            for b in 0..B do 
                for c in 0..C do
                    yield a * 500 + b * 100 + c * 50 |]
    |> Array.filter (fun a -> a = X)
    |> Array.length
    |> printfn "%d"

[<EntryPoint>]
let main argv = 
    solve()
    0


Measured memory_bytes: 16220
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int pre[100005];
int pos[100005];


signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
	if(fopen("INPUT.txt","r"))
	{
	freopen ("INPUT.txt" , "r" , stdin);
	freopen ("OUTPUT.txt" , "w" , stdout);
	}
#endif  

	int n,k;
	cin>>n>>k;
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		pre[i]=pre[i-1]+a[i];
		pos[i]=pos[i-1]+max(a[i],0LL);
	}
	int mx=0;
	for(int i=k;i<=n;i++)
	{
		mx=max(mx,pos[i-k]+pos[n]-pos[i]);
		mx=max(mx,pos[i-k]+pos[n]-pos[i]+pre[i]-pre[i-k]);
	}
	cout<<mx;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <regex>
#include <set>
#include <cmath>
#include <sstream>
#include <numeric>
#include <set>

using namespace std;


int main()
{
    std::string s;
    std::cin >> s;

    if(s[2] == s[3] && s[4] == s[5])
    {
        std::cout << "Yes";
    } else
    {
        std::cout << "No";
    }
    
    return EXIT_SUCCESS;
}


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

#define pb push_back
#define mp make_pair

ll A, B, N;

void solve()
{
	ll x=min(N,B-1);
	ll y = (A*x)/B;
	ll z = (x/B)*A;
	cout << y-z << '\n';
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> A >> B >> N;
	solve();
	return 0;
}

Measured memory_bytes: 3640
N = gets.to_i
dp = Array.new(N).map{Array.new(3,0)}
N.times{|i|
    h = gets.split.map(&:to_i)
    if i == 0
        dp[i] = h
    else
        3.times{|j|
            3.times{|l|
                if j != l
                    dp[i][j] = [dp[i-1][l] + h[j], dp[i][j]].max
                end
            }
        }
    end
}
puts [dp[N-1][0],dp[N-1][1],dp[N-1][2]].max


Measured memory_bytes: 10108
#include <ctype.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <tgmath.h>

int main(int argc, char **argv)
{
    int n;
    scanf("%d", &n);
    int q = INT_MAX;
    int r = 0;
    for (int i = 0; i < n; i++) {
        int p;
        scanf("%d", &p);
        if (p < q) {
            q = p;
            r++;
        }
    }
    printf("%d\n", r);
    return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define modulo N
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000005



int main(){
	
	int N,K;
	cin>>N>>K;
	
	vector<int> cnt(N,0);
	for(int i=0;i<K;i++){
		int d;
		cin>>d;
		for(int j=0;j<d;j++){
			int a;
			cin>>a;
			cnt[a-1]++;
		}
	}
	
	int ans= 0;
	
	for(int i=0;i<N;i++)if(cnt[i]==0)ans++;
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
const int INF = 1000100100;

int main(){
    ll n,a[200005];
    double p;
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    sort(a,a+n);
    p=a[0];
    rep(i,n-1){
        p=(p+a[i+1])/2.0;
    }
    cout<<p;
}

Measured memory_bytes: 3776