akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<functional>
#include<map>
using namespace std;
int main()
{
	int n, k,i;
	cin >> n >> k;
	for (i = 1; i < k&&n>0; n--)i *= 2;
	i += k*n;
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a>b){
    printf("a > b\n");
  }else if(a<b){
    printf("a < b\n");
  }else if(a==b){
    printf("a == b\n");
  }
  return 0;
}

Measured memory_bytes: 580
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]
last = [0] * 26
v = 0
    
for d in range(D):
    c_vlist = [0] * 26
    for t in range(26):
        c_last = last[:]
        c_v = v
        c_last[t] = d + 1
        c_v += S[d][t]
        c_v -= sum([C[tt] * (d + 1 - last[tt]) for tt in range(26)])
        c_vlist[t] = c_v
    # final
    f_t = c_vlist.index(max(c_vlist))
    print(f_t + 1)
    
    last[f_t] = d + 1
    v += S[d][f_t]
    v -= sum([C[tt] * (d + 1 - last[tt]) for tt in range(26)])

Measured memory_bytes: 9520
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

// a^n mod を計算する
// O(logn)
ll modpow(ll a, ll n, ll mod=MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// nCr mod を計算する O(n)
const int MAX_N = 1000010;
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX_N; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    ll ans=modpow(2,n);

    COMinit();
    ll tmpa=finv[a];
    for(int i=0;i<=a-1;i++){
        tmpa=(tmpa*(n-i))%MOD;
    }
    ll tmpb=finv[b];
    for(int i=0;i<=b-1;i++){
        tmpb=(tmpb*(n-i))%MOD;
    }

    ans=(ans+MOD-1)%MOD;
    ans=(ans+MOD-tmpa)%MOD;
    ans=(ans+MOD-tmpb)%MOD;

    cout<<ans<<endl;
}



Measured memory_bytes: 27032
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

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

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

    int n;
    while(cin >> n, n){
        vector<long long> p(n);
        long long psum = 0;
        for(int i = 0 ; i < n ; ++i){
            cin >> p[i];
            psum += p[i];
        }

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

        sort(j.rbegin(), j.rend());

        long long ans = psum * n;
        long long jsum = 0;
        for(int i = 0 ; i < n - 1 ; ++i){
            jsum += j[i];
            chmax(ans, (psum + jsum) * (n - i - 1));
        }

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

    cout << flush;

    return 0;
}


Measured memory_bytes: 3912
#include<stdio.h>

int main(void)
{
	for(int i =1 ; i <= 9 ; i++)
	{
		for(int j = 1 ; j <= 9 ; j++)
		{
			printf("%dx%d=%d\n",i ,j ,i*j);
			
		}
	}
	
	
	
	
	
}



Measured memory_bytes: 2688
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  if(a <= b){
    cout << "0\n";
    return 0;
  }
  cout << a - b << "\n";
}

Measured memory_bytes: 3580
#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//

using namespace std;

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

typedef long long ll;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0}; //次に行くところ
int dx[] = {0,1}; //上に同じ


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

  int cnt = 0;
  string s;
  cin >> s;
  if (s[0] == 'R' && s[1] == 'R' && s[2] != 'R'){
    cout << 2 << '\n';
    return 0;
  }
  if (s[0] != 'R' && s[1] == 'R' && s[2] == 'R'){
    cout << 2 << '\n';
    return 0;
  }
  if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R'){
    cout << 3 << '\n';
    return 0;
  }
  if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R'){
    cout << 1 << '\n';
    return 0;
  }
  
  cout << 0 << '\n';
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
  /*int n;
  cin >> n;
  vector<tuple<int,int,int>> s(n);
  for (int i = 0; i < n; i++){
    cin >> get<0>(s[i]);
  }
  sort(get<0>(s)begin()get<0>(s).end());

  for (int i = 0; i < ; i++)
  {
    
  }
  */
  return 0;
}

Measured memory_bytes: 3644
def readinput():
    n,m,x=list(map(int,input().split()))
    dat=[]
    for i in range(n):
        s=list(map(int,input().split()))
        c=s[0]
        a=s[1:]
        dat.append((c,a))
    return n,m,x,dat

def makeTableA(dat,n,m):
    tbl=[[0]*m]*n
    #print(n,len(tbl),m,len(tbl[0]))
    for i in range(n):
        tup=dat[i]
        a=tup[1]
        #print(a)
        #for j in range(m):
        #    tbl[i][j]=a[j]
        tbl[i]=list(a) 
        #print(tbl) 
    return tbl  

def main(n,m,x,dat):
    tblA=makeTableA(dat,n,m)
    #print(tblA)
    tblB=[[0]*(m+2)]*2**n  #
    #print(n,m,len(tblB), len(tblB[0]))  
    for i in range(2**n):
        tblB[i]=[0]*(m+2)
        b=1
        for j in range(n):
            if(i&b==b):
                for k in range(m):
                    #print(j,k)
                    tblB[i][k]+=tblA[j][k]
                    #print(tblB)
                tblB[i][m]+=dat[j][0]
                #print(tblB)
            b=b*2
        tblB[i][m+1]=min(tblB[i][0:m])
        #print(tblB)
    #print(tblB)
    # テーブルをスキャンする
    Pmin=12*10**5+1
    for i in range(2**n):
        if(tblB[i][m+1]>=x):
            price=tblB[i][m]
            if(price < Pmin):
                Pmin=price
    if(Pmin==12*10**5+1):
        Pmin=-1
    return Pmin


if __name__=='__main__':
    n,m,x,dat=readinput()
    ans=main(n,m,x,dat)
    print(ans)


Measured memory_bytes: 11244
n,k=map(int,input().split())

ans=0

for x in range(1,n+1):
  l=x
  if l>=k:
    ans+=(1/n)
  else:
    test=0
    while l<k:
      l=l*2
      test+=1
     
    p=(1/2)**test
    ans+=(1/n)*p
    
print(ans)
      
  

Measured memory_bytes: 9436
def solve():
    N = int(input())
    Ass = []
    for _ in range(N):
        As = list(map(lambda x: int(x)-1, input().split()))
        Ass.append(As+[N])

    games = []
    numReadyss = [[0]*(N) for _ in range(N)]
    iAs = [0] * N
    for i in range(N):
        j = Ass[i][iAs[i]]
        if j > i: i, j = j, i
        numReadyss[i][j] += 1
        if numReadyss[i][j] >= 2:
            games.append((i, j))
    ans = 1
    numOK = 0
    while True:
        if not games:
            print(-1)
            return
        game2s = []
        for i, j in games:
            iAs[i] += 1
            i2 = Ass[i][iAs[i]]
            if i2 == N:
                numOK += 1
            else:
                if i2 > i: i, i2 = i2, i
                numReadyss[i][i2] += 1
                if numReadyss[i][i2] >= 2:
                    game2s.append((i, i2))
            iAs[j] += 1
            j2 = Ass[j][iAs[j]]
            if j2 == N:
                numOK += 1
            else:
                if j2 > j: j, j2 = j2, j
                numReadyss[j][j2] += 1
                if numReadyss[j][j2] >= 2:
                    game2s.append((j, j2))
        if numOK >= N:
            print(ans)
            return
        ans += 1
        games = game2s


solve()


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

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j =0 ; j < m; j++) {
            string s;
            cin >> s;
            if (s == "snuke") {
                cout << (char)('A' + j) << i + 1 << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <map>
#include <unordered_set>
#include <tuple>
#include <queue>
#include <set>
#include <cstring>
#include <functional>
#include <random>
#include <chrono>

#define ar array
#define all(arr) (arr).begin(), (arr).end()
#define range(i, n) for (int i=0; i < n; ++i)
#define rall(arr) (arr).rbegin(), (arr).rend()

typedef long long ll;
typedef long double ld;

using namespace std;

const ll INF = 1e18;
const int INFi = 2e9;
const int maxN = 305;
const int md2 = 998244353;
const int md = 1e9 + 7;

double getTime() { return clock() / (double) CLOCKS_PER_SEC; };

void solve() {
    int n; cin >> n;
    int cnt = 0;
    bool ans = false;
    range(i, n) {
        int d1, d2; cin >> d1 >> d2;
        if (d1 == d2) {
            cnt++;
        } else {
            cnt = 0;
        }
        if (cnt >= 3) {
            ans = true;
        }
    }
    if (ans) cout << "Yes\n";
    else cout << "No\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //cout << setprecision(15) << fixed;
    int tests = 1;
    //cin >> tests;
    range(_, tests) {
        solve();
    }
    return 0;
}

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

int main() {
  int N;
  int v[1000] = {0};
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> v[i];
  }
  
  sort(v, v + N);

  double temp = (double)v[0];
  for (int i = 1; i < N; i++) {
    temp = (temp + (double)v[i]) / 2.0;
  }
  
  cout << temp << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <ctime>
using namespace std;
int n;
int a[11111];
int main() {
    cin >> n;
    cout << 24 - n + 24 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits>
#include <algorithm>
 
template <class T>
std::vector<T> ToFixedArray(std::istream& is, int n) {
	std::vector<T> ret(n);
	auto* dst = ret.data();
	while(n-- > 0)
		is >> *dst++;
	return ret;
}
 
#define _For(idx, from, to, inc, cmp) \
	for(auto idx=(from) ; idx cmp (to) ; inc idx)
#define ForLE(idx, from, to) \
	_For(idx, from, to, ++, <=)
#define ForGE(idx, from, to) \
	_For(idx, from, to, --, >=)
#define ForLT(idx, from, to) \
	_For(idx, from, to, ++, <)
#define ForGT(idx, from, to) \
	_For(idx, from, to, --, >)
#define For(idx, from, to) \
	_For(idx, from, to, ++, <)
 
void DisableIOSync() {
	std::cin.tie(0);
	std::cout.tie(0);
	std::ios::sync_with_stdio(false);
}
using Dist_t = uint32_t;
constexpr auto DistMax = std::numeric_limits<Dist_t>::max()/2;
using DistV = std::vector<Dist_t>;
int main() {
	DisableIOSync();

	using std::cin;
	using namespace std;
	int NCity, NLink, NDest;
	cin >> NCity >> NLink >> NDest;

	auto dest = ToFixedArray<int>(std::cin, NDest);
	for(auto& d : dest)
		--d;

	using DistV = std::vector<Dist_t>;
	DistV dist(NCity * NCity, DistMax);
	const auto fdist = [&dist, NCity](int from, int to) -> decltype(auto) {
		if(from > to)
			std::swap(from, to);
		return dist[from + to*NCity];
	};
	For(i, 0, NCity) {
		fdist(i,i) = 0;
	}
	For(i, 0, NLink) {
		int id0, id1, cost;
		cin >> id0 >> id1 >> cost;
		--id0;
		--id1;
		fdist(id0, id1) = cost;
		fdist(id1, id0) = cost;
	}
	For(inter, 0, NCity) {
		For(from, 0, NCity) {
			if(inter == from)
				continue;
			For(to, from+1, NCity) {
				if(inter == to)
					continue;
				fdist(from, to) =
					std::min(
						fdist(from, to),
						fdist(from, inter) + fdist(inter, to)
					);
			}
		}
	}
	Dist_t res = DistMax;
	std::sort(dest.begin(), dest.end());
	do {
		Dist_t sum = 0;
		For(i, 1, NDest) {
			sum += fdist(dest[i-1], dest[i]);
		}
		res = std::min(res, sum);
	} while(std::next_permutation(dest.begin(), dest.end()));
	std::cout << res << std::endl;
	return 0;
}


Measured memory_bytes: 384
import math
a, b, x = map(int, input().split())
if a*a*b/2 >= x:
  k = (2*x)/(a*b)
  ans = math.degrees(math.atan(b/k))
else:
  l = a*a*b
  xx = l - x
  k = (2*xx)/(a*a)
  ans = math.degrees(math.atan(k/a))
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using i64 = long long;

template <class T>
T pow(T x, T n, T mod) {
    T ret = 1;
    while(n > 0) {
        if ((n & 1) == 1) ret = (ret * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ret;
}

template <class T>
T inverse(T x, T p) { return pow(x, p - 2, p); }

int h, w, n;
constexpr i64 mod = 1000000007;
std::vector<i64> fact, inv;
std::vector<std::pair<int, int>> b;
std::vector<std::deque<int>> q;
std::vector<i64> memo;

i64 calc(int v) {
    if (memo[v]) return memo[v];
    i64 tmp = fact[h - b[v].first + w - b[v].second - 2] % mod * inv[h - b[v].first - 1] % mod * inv[w - b[v].second - 1] % mod;
    for (auto to : q[v]) {
        auto p = fact[b[to].first - b[v].first + b[to].second - b[v].second] % mod * inv[b[to].first - b[v].first] % mod * inv[b[to].second - b[v].second] % mod;
        tmp = (tmp + mod - calc(to) * p % mod) % mod;
    }

    return memo[v] = tmp;
}

int main() {
    std::cin >> h >> w >> n;

    int m = h + w + 2;
    fact.resize(m + 1);
    inv.resize(m + 1);
    fact[0] = 1;
    for (auto i = 1; i <= m; i++) fact[i] = fact[i - 1] * i % mod;
    inv[m] = inverse(fact[m], mod);
    for (auto i = m; i > 0; i--) inv[i - 1] = inv[i] * i % mod;

    b.emplace_back(0, 0);
    for (int i = 0; i < n; i++) {
        int r, c;
        std::cin >> r >> c;
        r--;
        c--;
        b.emplace_back(r, c);
    }

    q.resize(b.size());
    memo.resize(b.size());
    for (int i = 0; i < b.size(); i++) {
        for (int j = 0; j < b.size(); j++) {
            if (i == j) continue;
            if (b[i].first <= b[j].first && b[i].second <= b[j].second) {
                q[i].push_back(j);
            }
        }
    }

    i64 ret = calc(0);

    std::cout << ret << std::endl;

    return 0;
}

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

int main() {
  vector<int>data(6);
  for(int i = 0;i < 6;i++){
    cin >> data[i];
  }
  string s;
  cin >> s;
  for(int i = 0;i < s.size();i++){
    vector<int>nd(6);
    nd = data;
    if(s[i] == 'W'){
      nd[3] = data[0];
      nd[0] = data[2];
      nd[5] = data[3];
      nd[2] = data[5];
      data = nd;
    }
    else if(s[i] == 'E'){
      nd[0] = data[3];
      nd[2] = data[0];
      nd[3] = data[5];
      nd[5] = data[2];
      data = nd;
    }
    else if(s[i] == 'S'){
      nd[1] = data[0];
      nd[5] = data[1];
      nd[4] = data[5];
      nd[0] = data[4];
      data = nd;
    }
    else{
      nd[0] = data[1];
      nd[1] = data[5];
      nd[5] = data[4];
      nd[4] = data[0];
      data = nd;
    }
  }
  cout << data[0] << endl;
}



Measured memory_bytes: 3216
/// kAAzuki Hoshino


#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 int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define MAX 500000
#define K 30
//#define endl '\n'
typedef tree<
int,
null_type,less<int>,
rb_tree_tag,tree_order_statistics_node_update>
ordered_set;
int n,k,cnt;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
cin >> n >> k;
for(int i=1;i<=n;i+=2){
   cnt++;
}
if(cnt>=k){
   cout << "YES" << endl;
}
else {
   cout << "NO" << endl;
}

return 0;}
///....


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  double n, k;
  cin >> n >> k;
  double sum = 0;
  for(double i=1; i<=n; i += 1.0){
    double num = i;
    double cnt = 0;
    while(num < k){
      num *= 2.0;
      cnt += 1.0;
    }
    double winRate = 1.0 / pow(2.0, cnt);
    sum += (1.0/n) * winRate;
  }
   cout << std::setprecision(15) << sum << endl; 
  return 0;
}
      
      

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define se second
#define mp make_pair
#define fi first
#define del(a,vec) vec.erase(std::remove(vec.begin(), vec.end(), a), vec.end());
#define search(f,l,v) binary_search(f,l,v)
#define iter(a,b) vector<int>::iterator a,b
#define lower(v,num) lower_bound (v.begin(), v.end(), num);
#define upper(v,num) upper_bound (v.begin(), v.end(), num); 
#define removecopy(a) unique(a.begin(), a.end()); 
#define ll long long int
namespace Rahul{
    bool isPrime(int n) 
    {if (n <= 1)  return false; if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; }
    ll pow (ll x, ll n,ll mod) {//calculate x^n
    if (n == 0) return 1;

    ll res = pow (x, n / 2,mod);

    res = (res * res) % mod;
    if (n % 2) res = (res * x ) % mod;

    return res;
    }
    ll _gcd(ll a,ll b)
    {
        if(a==0)
            return b;
        else    
            return _gcd(b%a,a);
    }
    //s.erase(s.find(2)) where s={1,2,3,3,2}; 
};

using namespace Rahul;
int main()
{
     ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
     int t;
    //  cin>>t;
    //  while(t--){
        //  int 
    //  }//
    //  
    
    cin>>t;
    cout<<t*t<<endl;
    //  cout<<"hi\n";
     
     
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    while(1) {
        int n,m;
        cin>>n>>m;
        if(n+m==0) break;
        vector<int> a(n);
        cin>>a;
        int ans=0;
        REP(i,n) {
            REPF(j,i+1,n) {
                if(a[i]+a[j]<=m) chmax(ans,a[i]+a[j]);
            }
        }
        cout<<(ans==0?"NONE":to_string(ans))<<endl;
    }
    return 0;
}

Measured memory_bytes: 3248
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut l: f64=read();
    l=l/3f64;
    println!("{}",l*l*l);
}

Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 5000
#define MAX_M 200

long long x[MAX_N+1][MAX_N+1];
long long a[MAX_N+1];
long long b[MAX_M][MAX_N];

void add(int l, int u, int r, int d, long long w) {
    x[l][u] += w;
    x[l][d+1] -= w;
    x[r+1][u] -= w;
    x[r+1][d+1] += w;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    for (int i = 0; i < n-1; i++) {
        cin >> a[i+1];
        a[i+1] += a[i];
    }
    for (int j = 0; j < n; j++) {
        for (int i = 0; i < m; i++) {
            cin >> b[i][j];
        }
    }
    for (int i = 0; i < m; i++) {
        vector<pair<long long, int>> v;
        set<int> s; s.emplace(-1), s.emplace(n);
        for (int j = 0; j < n; j++) {
            v.emplace_back(b[i][j], j);
        }
        sort(v.rbegin(), v.rend());
        for (int i = 0; i < n; i++) {
            int p = v[i].second;
            int l = *(--s.lower_bound(p));
            int d = *s.upper_bound(p);
            add(l+1, p, p, d-1, v[i].first);
            s.emplace(p);
        }
    }
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j < n; j++) {
            x[i][j+1] += x[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= n; j++) {
            x[i+1][j] += x[i][j];
        }
    }
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i; j < n; j++) {
            // a_i -> a_j
            ans = max(ans, x[i][j] - (a[j] - a[i]));
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 203636
k = int(input())
a, b = map(int, input().split())

if k<a:
  if a%k == 0:
    print("OK")
  elif b%k == 0:
    print("OK")
  elif(a+(k-a%k)) <= b:
    print("OK")
  else:
    print("NG")
elif k<=b:
  print("OK")
else:
  print("NG")


Measured memory_bytes: 9204
import sys
sys.setrecursionlimit(1000000)
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque, Counter as cnt

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]
def nlist(n, v):
    if not n: return v.copy()
    return [nlist(n[1:], v) for _ in range(n[0])]

class mod:
    def __init__(self, v=0):
        self.v = v
        self.v %= MOD
    def __add__(self, v):
        self.v += int(v)
        self.v %= MOD
        return self
    def __sub__(self, v):
        self.v -= int(v)
        return self
    def __mul__(self, v):
        self.v *= int(v)
        self.v %= MOD
        return self
    def __int__(self):
        return int(self.v)
    def __str__(self):
        return str(self.v)

# エントリーポイント
def main():
    S = input(str)
    dp = [[0 for _ in range(13)] for _ in range(len(S) + 1)]
    dp[0][0] = 1
    for i, s in enumerate(S):
        i += 1
        loop = range(10) if s == "?" else [int(s)]
        for n in range(13):
            for m in loop:
                dp[i][(n * 10 + m) % 13] += dp[i - 1][n]
                dp[i][(n * 10 + m) % 13] %= MOD
    print(dp[-1][5])

if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main()
{
    int n,m,ans=1;
    cin>>n>>m;
    
    for(int i = 1; i*i <= m; i++)
    {
        if(m%i==0)
        {
            int j = m/i;
            if(j>=n)
            {
                ans=max(ans,i);
            }
            if(i>=n)
            {
                ans=max(ans,j);
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	bool ac[n+1];
	int wa[n+1];
	for(int i=1;i<=n;++i)
		ac[i]=false,wa[i]=0;
	int actot=0,watot=0;
	for(int i=0;i<m;++i){
		int ti;
		string sub;
		cin>>ti>>sub;
		if(ac[ti])
			continue;
		if(sub=="AC"){
			ac[ti]=true;
			++actot;
			watot+=wa[ti];
		}
		else
			++wa[ti];
	}
	cout<<actot<<' '<<watot;
	return 0;
}

Measured memory_bytes: 768
N, K = map(int, input().split())
High = list(map(int, input().split()))

DP = [float('inf')] * N
DP[0] = 0
for i in range(N - 1):
    for j in range(i + 1, min(N, i + K + 1)):
        DP[j] = min(DP[j], DP[i] + abs(High[i] - High[j]))
print(DP[N - 1])

Measured memory_bytes: 55008
import java.util.Scanner;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		int x1 = in.nextInt();
		int y1 = in.nextInt();
		int x2 = in.nextInt();
		int y2 = in.nextInt();

		int x3=0;
		int y3=0;
		int x4=0;
		int y4=0;
		if(x1 == x2){
			if(y1 > y2){
				x3 = x2 + (y1 - y2);
				y3 = y2;
				x4 = x3;
				y4 = y3 + (y1 - y2);
			}else{
				x3 = x2 - (y2 - y1);
				y3 = y2;
				x4 = x3;
				y4 = y3 - (y2 - y1);
			}
		}else if(y1 == y2){
			if(x1 > x2){
				x3 = x2;
				y3 = y2 - (x1 - x2);
				x4 = x3 + (x1 - x2);
				y4 = y3;
			}else{
				x3 = x2;
				y3 = y2 + (x2 - x1);
				x4 = x3 - (x2 - x1);
				y4 = y3;
			}
		}else{
			int dx,dy;
			if(x1 < x2 & y1 < y2){
				dx = x2 - x1;
				dy = y2 - y1;
				x3 = x2 - dy;
				y3 = y2 + dx;
				x4 = x3 - dx;
				y4 = y3 - dy;
			}
			if(x1 > x2 & y1 < y2){
				dx = x1 - x2;
				dy = y2 - y1;
				x3 = x2 - dy;
				y3 = y2 - dx;
				x4 = x3 + dx;
				y4 = y3 - dy;
			}
			if(x1 > x2 & y1 > y2){
				dx = x1 - x2;
				dy = y1 - y2;
				x3 = x2 + dy;
				y3 = y2 - dx;
				x4 = x3 + dx;
				y4 = y3 + dy;
			}
			if(x1 < x2 & y1 > y2){
				dx = x2 - x1;
				dy = y1 - y2;
				x3 = x2 + dy;
				y3 = y2 + dx;
				x4 = x3 - dx;
				y4 = y3 + dy;
			}
		}

		System.out.println(x3 + " " + y3 + " " + x4 + " " + y4);
	}

}

Measured memory_bytes: 23124
#include<iostream>
#include<string>
using namespace std;
const char nc[20]={'0','1','2','3','4','5','6','7', '8','9','A','B','C','D','E','F','G','H','I','J'};
string ans;
int main()
{
    int m,n,k,t;
    cin>>m;
    n=-2;
    ans="";
    if(m==0){
    	cout<<0;
    	return 0;
	}
    while(m!=0){
        k=m%n;
        t=m/n;
        if(k<0)
        {
            k-=n;
            t++;
        }
        m=t;
        ans.push_back(nc[k]);
    }
    for(int i=ans.length()-1;i>=0;i--)
        cout<<ans[i];
    return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  int x = tx - sx;
  int y = ty - sy;

  string ans = "";

  for(int i = 0; i < x; i++){
    ans += "R";
  }

  for(int i = 0; i < y; i++){
    ans += "U";
  }

  for(int i = 0; i < x; i++){
    ans += "L";
  }

  for(int i = 0; i < y; i++){
    ans += "D";
  }

  ans += "D";

  for(int i = 0; i < x + 1; i++){
    ans += "R";
  }

  for(int i = 0; i < y + 1; i++){
    ans += "U";
  }

  ans += "L";
  ans += "U";

  for(int i = 0; i < x+1; i++){
    ans += "L";
  }

  for(int i = 0; i < y+1; i++){
    ans += "D";
  }

  ans += "R";

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

  int n; cin >> n;
  vi s(n);
  for (int i = 0; i < n; ++i) cin >> s[i];
  int q; cin >> q;
  vi t(q);
  for (int i = 0; i < q; ++i) cin >> t[i];

  sort(all(s));

  int cnt = 0;

  for (int i = 0; i < q; ++i) {
    cnt += binary_search(all(s), t[i]);
  }

  cout << cnt << '\n';

  return 0;
}


Measured memory_bytes: 3168
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	int a, b, i;
	int sum_a, sum_b;
	
	sum_a = sum_b = 0;
	
	for (i = 0; i < 4; i++){
		scanf("%d", &a);
		sum_a += a;
	}
	for (i = 0; i < 4; i++){
		scanf("%d", &b);
		sum_b += b;
	}
	
	printf("%d\n", max(sum_a, sum_b));
	
	return (0);
}

Measured memory_bytes: 1020
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
ans = 0
i = 0
while x >= a[i]:
    if i == n-1:
        if a[i] == x:
            ans+=1
            break
        else:
            break
    x -= a[i]        
    i += 1
    ans += 1
print(ans)

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

long long N;
long long a[55];

//bool can(long long num){
//	long long ans = 0;
//	for(long long i = 0; i < N; i++){
//		long long cur = a[i] + num;
//		if((cur - (N - 1))%(N+1) == 0){
//			ans += (cur - (N - 1))/(N+1);
//		}else{
//			ans += (cur - (N - 1))/(N+1) + 1;
//		}
//	}
//	return ans <= num;
//}

bool can(long long num){
	long long ans = 0;
	for(long long i = 0; i < N; i++){
		long long tmp = a[i] + num - N + 1;
		if(tmp <= 0){
			continue;
		}
		if(tmp % (1 + N) == 0){
			ans += tmp / (1 + N);
		}else{
			ans += tmp / (1 + N);
			ans++;
		}
	}
	return ans <= num;
}




int main(){
	cin >> N;
	long long sumi = 0;
	for(long long i = 0; i < N; i++){
		cin >> a[i];
		sumi += a[i];
	}

	//minimum need
	//maxi need = sumi + N * N - 1;
	sumi -= N * (N - 1);

	for(long long i = max((long long)0, sumi); i <= sumi + N * (N - 1); i++){
		if(can(i)){
			cout << i << endl;
			return 0;
		}
	}

}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <stack>
#include <vector>
 
#define ll long long
#define ull unsigned long long
#define ld long double
 
#define gc (c = getchar())
#define gi(x) scanf("%d", &x)
#define gid(x, y) scanf("%d%d", &x, &y)
#define gll(x) scanf("%lld", &x)
#define glld(x, y) scanf("%lld%lld", &x, &y)
#define gllt(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define git(x, y, z) scanf("%d%d%d", &x, &y, &z)
 
#define pi(x) printf("%d\n", x)
#define pid(x, y) printf("%d %d\n", x, y)
#define pcs(ch, cs, x) printf("Case %s%d: %d\n", ch, cs, x)
#define pll(x) printf("%lld\n", x)
#define pllcs(ch, cs, x) printf("Case %s%d: %lld\n", ch, cs, x)
#define plld(x, y) printf("%lld %lld\n", x, y)
#define pllt(x, y, z) printf("%lld %lld %lld\n", x, y, z)
 
#define mp(x, y) std::make_pair(x, y)
#define fcs(x) while (x--)
#define dbg(x) std::cerr << #x << " " << x << std::endl
#define fi freopen("in.txt", "r", stdin)
#define fo freopen("out.txt", "w", stdout)
#define siz(x) (int)x.size()
#define rep(i, x, y) for (int i = x; i <= y; ++i)
#pragma GCC optimize(2)

const int maxn = 20;
int stat[maxn];
std::vector<std::pair<int,int> > vis[maxn];
inline int getcnt(int i){
    int hcnt = 0;
    for(int j = 0; j <= 15; ++ j){
            if ((i >> j) & 1) hcnt ++;
    }
    return hcnt;
}
int main(){
    int n;
    gi(n);
    for(int i = 1; i <= n; ++ i){
        int a;
        gi(a);
        for(int j = 1;j <= a; ++ j){
            int x,y;
            gid(x,y);
            vis[i].push_back(std::make_pair(x,y));
        }
    }
    long long sz = 1ll << n;
    sz --;
    int ret = 0;
    for(int i = 0; i <= sz; ++ i){
        int hcnt = getcnt(i);
        int cu = 0;
        bool flg = true;
        memset(stat, 0 ,sizeof stat);
        for(int j = 0; j < n; ++ j){
            ++ cu;
            if ((i >> j) & 1) stat[cu] = 1;
            else stat[cu] = 0;
        }
        for(int j = 1; j <= n; ++ j){
            if (!flg) break;
            if (stat[j]){
                for(auto it : vis[j]){
                    if(stat[it.first] != it.second){
                        flg = false;
                        break;
                    }
                }
            }
        }
        if (flg){
      //      std::cout << i << std::endl;
            ret = ret < hcnt ? hcnt : ret;
        }
    }
    pi(ret);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[203],ans;
int main(){
	cin>>n;
	for(int i=0;i<2*n;i++)
		cin>>a[i];
	sort(a,a+2*n);
	for(int i=0;i<2*n;i+=2)
		ans+=a[i];
	cout<<ans;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,i,s=0;
  cin>>n;
  long long int a[n];
  for(i=0;i<n;i++)
  {
    cin>>a[i];
  }
  for(i=1;i<n;i++)
  {
    if(a[i]>=a[i-1])
    {
      continue;
    }
    s=s+(a[i-1]-a[i]);
      a[i]=a[i-1];
  }
  cout<<s;
}


Measured memory_bytes: 5188
from collections import deque
n, m = map(int, input().split())
data = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int,input().split())
    data[a - 1].append(b - 1)
    data[b - 1].append(a - 1)

ans = [0] * (n - 1)

def bfs(i, queue, p):
    while len(queue) > 0:
        x = queue.popleft()
        pre = p.popleft()
        for j in range(len(x)):
            if ans[x[j] - 1] == 0 and x[j] != 0:
                ans[x[j] - 1] = pre + 1
                queue.append(data[x[j]])
                p.append(x[j])

queue = deque()
pre = deque()
pre.append(0)
queue.append(data[0])
bfs(0, queue, pre)

if 0 not in ans:
    print("Yes")
    for i in range(len(ans)):
        print(ans[i])
else:
    print("No")

Measured memory_bytes: 37248
N = int(input())
Dn = []
for i in range(N):
    Dn.append(int(input()))
Dn.sort(reverse=True)
count_mochi = 1
for q in range (N-1):
    if Dn[q] != Dn[q+1]:
        count_mochi += 1

print(count_mochi)

Measured memory_bytes: 3060
package main

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

func main() {
	sc := NewScanner()

	n := sc.NextInt()

	if n == 7 || n == 3 || n == 5 {
		fmt.Printf("YES\n")
	} else {
		fmt.Printf("NO\n")

	}
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
import math
 
a,b,x = map(int,input().split())
 
if x >= a**2*b/2:
    theta = math.atan(2*((a**2)*b-x)/(a**3))
else:
    theta = math.atan((a*(b**2))/(2*x))
print(math.degrees(theta))
    

Measured memory_bytes: 2940
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define LL long long
#define INF 100000000
#define mod 1000000007
using namespace std;
int keta(int n,int k){return (n/int(pow(10,double(k-1)))) % 10;} //nの下からk桁目
ll gcd(ll n,ll m){
	if(n<m){ll a=m;m=n;n=a;}
	ll r=n%m;
	while(r!=0){
		n=m;
		m=r;
		r=n%m;
	}
	return m;
}
ll lcm(ll n,ll m){
	return n*m/gcd(n,m);
}

int main(){
	int n;
	cin>>n;
	vector<int> a;
	a.resize(n);
	int b[100001];
	rep(i,100001){
		b[i]=0;
	}
	rep(i,n){
		cin>>a[i];
		b[a[i]]++;
	}
	int ans=0;
	FOR(i,0,99999){
		ans=max(ans,b[i]+b[i+1]+b[i+2]);
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int H, W;
  cin>>H>>W;
  int N;
  cin>>N;
  int a[N];
  for(int i=0;i<N;++i) {
    cin>>a[i];
  }
  vector<int> arr;
  for(int i=0;i<N;++i) {
    for(int j=0;j<a[i];++j) {
      arr.push_back(i+1);
    }
  }
  int ans[H][W];
  int index = 0;
  for(int i=0;i<H;++i) {
    if(i%2==0) {
      for(int j=0;j<W;++j) {
        ans[i][j] = arr[index];
        index++;
      }
    }
    else {
      for(int j=W-1;j>=0;--j) {
        ans[i][j] = arr[index];
        index++;
      }
    }
  }
  for(int i=0;i<H;++i) {
    for(int j=0;j<W;++j) {
      cout<<ans[i][j]<<" ";
    }
    cout<<endl;
  }
}



Measured memory_bytes: 3780
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {
  int a, l;
  while (cin >> a >> l) {
    if (a == 0 && l == 0) { break; }

    map<int, int> mp;
    int i = 0;

    while (true) {
      if ( mp.find(a) != mp.end() ) {
        cout << mp[a] << " " << a << " " << i-mp[a] << endl;
        break;
      }
      mp[a] = i++;
      char c_s[10];
      sprintf(c_s, "%d", a);
      string s = string(c_s);
      int len = s.length();
      // 0埋め
      for (int i = 0; i < l-len; i++) {
        s = "0" + s;
      }
      int big, little;
      sort( s.begin(), s.end(), greater<char>() );
      big = atoi(s.c_str());
      sort( s.begin(), s.end() );
      little = atoi(s.c_str());
      // aの値を更新
      a = big-little;
    }
  }

  return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799;

int n;
map<ll, ll> mp;
map<ll, ll> mpp;
ll ans = 0;
int a[200000];

int main(){
  cin >> n;
  rep(i, n) cin >> a[i];
  for(int i = 1; i <= n; i++){
    mp[i-a[i-1]]++;
  }
  for(int i = 1; i <= n; i++){
    if(mp.count(a[i-1]+i)) mpp[a[i-1]+i]++;
  }
  for(pair<ll, ll> x:mp){
    //cout << x.first << " " <<x.second <<endl;
    ans += mpp[x.first] * x.second;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 27468
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		char x = a.charAt(0);
		if(x>='A'&&x<='Z') {
			System.out.println('A');
		}
		else {
			System.out.println('a');
		}
	}
}

Measured memory_bytes: 35668
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
  	cin >> s;
  	bool f1 , f2;
  	f1 = f2 = false;
  	if(s[0] == 'A' || s[1] == 'A' || s[2] == 'A')
      	f1 = true;
  	if(s[0] == 'B' || s[1] == 'B' || s[2] == 'B')
      	f2 = true;
  	if(f1 and f2)
      	cout << "Yes";
 	else
      	cout << "No";
  	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n+2, 0);
    ll sum = 0;
    rep(i,n){
        cin >> a[i+1];
        sum += abs(a[i+1] - a[i]);
    }
    sum += abs(a[n]);
    for(int i = 1; i <= n; i++){
        ll ans = sum - abs(a[i] - a[i-1]) - abs(a[i+1] - a[i]) + abs(a[i-1] - a[i+1]);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2048
def allb(S):
    for i in S:
        if not i == '.':
            return False
    return True

H,W = list(map(int,input().split()))
masu = [input() for i in range(H)]
masu = [i for i in masu if not allb(i)]
new = [[] for i in range(W)]
for i in range(len(masu)):
    for j in range(len(masu[0])):
        new[j].append(masu[i][j])
new = [i for i in new if not allb(i)]
masu = [[] for i in range(W)]
for i in range(len(new)):
    for j in range(len(new[0])):
        masu[j].append(new[i][j])
for i in masu:
    if i:
        for j in i:
            print(j,end="")
        print()


Measured memory_bytes: 4596
n, m = gets.split.map(&:to_i)
abs = []
n.times{ abs << gets.split.map(&:to_i) }

abs.sort!{|a, b| a[0] <=> b[0] }

yen = 0
abs.each do |ab|
  if ab[1] < m
    yen += ab[1] * ab[0]
    m -= ab[1]
  else
    yen += ab[0] * m
    break
  end
end

p yen


Measured memory_bytes: 10488
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace alg
{
    class Program
    {
        static void Main(string[] args)
        {
            int c25, c10, c5, c1 ,ans;

            int n = int.Parse(Console.ReadLine());

            c25 = n / 25;
            n = n % 25;

            c10 = n / 10;
            n = n % 10;

            c5 = n / 5;
            n = n % 5;

            c1 = n / 1;
            n = n % 1;

            ans = c25 + c10 + c5 + c1;

            Console.WriteLine(ans);

            //Console.ReadLine();

        }
    }
}



Measured memory_bytes: 19948
import sys
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
pr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]
arr = [0] * 5
num = 1
for i in range(1, n+1):
    num *= i
for n in pr:
    tmp = num
    ct = 0
    while True:
        if tmp % n == 0:
            ct += 1
            tmp //= n
        else:
            break
    if ct >= 74:
        arr[0] += 1
    elif ct >= 24:
        arr[1] += 1
    elif ct >= 14:
        arr[2] += 1
    elif ct >= 4:
        arr[3] += 1
    elif ct >= 2:
        arr[4] += 1
ans = 0
if arr[0] == 1:
    ans += 1
if sum(arr[:2]) >= 1:
    ans += ((sum(arr[0:2]) * (sum(arr) - 1)))
if sum(arr[:3]) >= 1:
    ans += ((sum(arr[0:3]) * (sum(arr[:4]) - 1)))
if sum(arr[:4]) >= 2 and arr[4] >= 1:
    s = sum(arr[:4])
    ans += (s * (s-1) * (s-2) // 2)
    ans += (arr[4] * s * (s-1) // 2)
print(ans)

Measured memory_bytes: 3316