akhauriyash/Code-Regression huggingface dataset:
from collections import deque
alfabet=deque(input())
n=int(input())
reverse=0
for i in range(n):
  operation_list=list(input().split())
  if int(operation_list[0])==1:
    reverse+=1
  else:
    if int(operation_list[1])==2 and reverse%2==0:
      alfabet.append(operation_list[2])
    elif int(operation_list[1])==2 and reverse%2==1:
      alfabet.appendleft(operation_list[2])
    elif int(operation_list[1])==1 and reverse%2==0:
      alfabet.appendleft(operation_list[2])
    elif int(operation_list[1])==1 and reverse%2==1:
      alfabet.append(operation_list[2])
if reverse%2!=0:
  alfabet.reverse()
print(''.join(alfabet))   

Measured memory_bytes: 14296
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()

if n==1:
    print("Hello World")
    exit()
a = INT()
b = INT()
print(a+b)

Measured memory_bytes: 3444
import sys
import socket

if socket.gethostname() == 'N551J':
    sys.stdin = open('d1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    h, w, d = read_int_list()
    c = [[0] * w for _ in range(h)]
    if d % 2 == 1:
        for i in range(h):
            for j in range(w):
                c[i][j] = (i + j) % 2
    else:
        for i in range(h):
            for j in range(w):
                x = i + j
                y = i - j
                x -= x % 2
                y -= y % 2
                x //= 2
                y //= 2
                if x % d < d // 2:
                    c[i][j] += 1
                if y % d < d // 2:
                    c[i][j] += 2

    s = 'RYGB'
    res = [''.join(map(s.__getitem__, row)) for row in c]

    # print()
    # for i in range(h):
    #     for j in range(w):
    #         if (i + j) % 2 == 1:
    #             # print('.', end='')
    #             print(c[i][j], end='')
    #         if (i + j) % 2 == 0:
    #             print(c[i][j], end='')
    #     print()
    # print()
    # return []

    return res


def main():
    res = solve()
    print(*res, sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 6132
N = int(input())

def calculate(n):

    memo =  [0 for i in range(N+1)] # 0-N

    for index in range(1,n+1):
        pow6 = 6
        pow9 = 9
        if index < 6:
            memo[index] = index
        elif index == 6:
            memo[index] = 1
        elif index == 9:
            memo[index] = 1
        else:
            values = []

            while pow6 <= index:
                values.append(1 + memo[index - pow6])
                pow6 = pow6 * 6

            while pow9 <= index:
                values.append(1 + memo[index - pow9])
                pow9 = pow9 * 9

            values.append(1+memo[index-1])
            minValue = min(values)

            memo[index] = minValue

    return memo

result = calculate(N)
print(result[N])

Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
int a,b;
int A[105][105];
int main(){
	cin>>a>>b;
	--a,--b;
	printf("%d %d\n",99,99);
	if(!a)++b;
	int L=2,R=2;
	for(int i=1;i<=a;++i){
		A[L-1][R-1]=A[L][R-1]=A[L+1][R-1]=A[L-1][R]=A[L+1][R]=A[L-1][R+1]=A[L][R+1]=A[L+1][R+1]=1;
		R+=3;
		if(R>99)R-=99,L+=3;
	}
	for(int i=1;i<=b;++i){
		A[L][R]=1;
		R+=3;
		if(R>99)R-=99,L+=3;
	}
	for(int i=1;i<=99;++i){
		for(int j=1;j<=99;++j)putchar(A[i][j]?'#':'.');putchar('\n');
	}
	return 0;
}

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

using namespace std;

int main(void){
    int N, cnt;

    cin >> N;

    vector<int> l(N);

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

    sort(l.begin(), l.end());

    cnt = 0;
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            
            cnt += int(lower_bound(l.begin(), l.end(), l[i] + l[j]) - (l.begin() + j)) - 1;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
from math import ceil 
L=[]
X=0
M=int(input())
L.append(M)
for i in range(4) :
  A=int(input())
  L.append(A)
  if A%10 < M%10 and A%10!=0 :
    M=A
L.remove(M)
for i in L :
  X+=ceil(i/10)*10
print(X+M)

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

using namespace std;

const int N = 606; 
int a[N][N], R[N][N], C[N][N];

void solve() {
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        string s; cin >> s;
        for (int j = 0; j < w; j++) {
            if (s[j]=='#') a[i+j][i-j+w] = 1;
        }
    }
    int n = h+w;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            R[i][j+1] = R[i][j] + a[i][j];
            C[i+1][j] = C[i][j] + a[i][j];
        }
    }

    int res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (a[i][j]) {
                for (int k = 0; k < n; k++) {
                    if (j+k < n && a[i][j+k]) {
                        res += (i-k<0?0: R[i-k][j+k+1] - R[i-k][j+1]);
                        res += (i+k>=n?0:R[i+k][j+k] - R[i+k][j]);
                    }
                    if (i+k < n && a[i+k][j]) {
                        res += (j-k<0?0: C[i+k][j-k] - C[i][j-k]);
                        res += (j+k>=n?0:C[i+k+1][j+k] - C[i+1][j+k]);
                    }
                }
            }
        }
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=2e5+100;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
LL A[maxn];
int T,n,m,k;
 
int main()
{
    cin>>n>>k;
    LL res=1,sign=1;
    for(int i=1;i<=n;i++)
        cin>>A[i];
    sort(A+1,A+1+n);
    int l=1,r=n;
    if(k&1)
    {
        res*=A[r--];
        k--;
        if(res<0) sign=-1;
    }
    while(k>0)
    {
        LL x=A[l]*A[l+1],y=A[r]*A[r-1];
        if(x*sign>y*sign)
        {
            res=x%mod*res%mod;
            l+=2;
        }
        else
        {
            res=y%mod*res%mod;
            r-=2;
        }
        k-=2;
    }
    cout<<(res+mod)%mod<<endl;
}

Measured memory_bytes: 5092
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vi a(n);
	unordered_map<int, int> cnt;
	ll sum = 0LL;
	rep(i, n) cin >> a[i], cnt[a[i]]++, sum += a[i];
	int q;
	cin >> q;
	rep(i, q){
		ll b, c;
		cin >> b >> c;
		sum -= (ll)(1LL * b * cnt[b]);
		sum += (ll)(1LL * c * cnt[b]);
		cnt[c] += cnt[b];
		cnt[b] = 0;
		cout << sum << endl;
	}
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 7496
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

int main()
{
    int N, odd=0, even4=0;
    cin >> N;
    vector<ll> a(N);
    for(int i=0;i<N;++i){
        cin >> a[i];
        if(a[i] % 2) ++odd;
        if(a[i] % 4 == 0) ++even4;
    }

    bool ans;
    if(odd - 1 < even4) ans = true;
    else{
        if(odd-1 == even4 && odd + even4 == N) ans = true;
        else ans = false;
    }

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<int, ll> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
// const ll MAXN = 

int r, s, p;
vector<int> tms;
/********** Good Luck :) **********/
int main () {
    TIME(main);
    IOS();

    cin >> r >> s >> p;

    REP (i, p) {
        int x, y;
        cin >> x >> y;
        int c = y <= s ? s+1-y : y-s;
        tms.eb(r+1-x+c);
    }

    sort(ALL(tms));
    debug(tms);

    int lst = -1;
    for (auto v : tms) {
        if (v > lst) {
            lst = v;
        } else {
            lst++;
        }
    }

    cout << lst << endl;

    return 0;
}



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

int arr[60];
long long cur[52][2600][52];

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

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

    cur[0][0][0]=1;

    for(int i=1;i<=n;i++)
    {
        cur[i][0][0]=1;
        for(int s=0;s<=smax;s++)
        {
            for(int j=1;j<=n;j++)
            {
                if(s==arr[i-1])
                {
                   // cout<<"#";
                    //if(j==1)
                      //  cout<<cur[i-1][s-arr[i-1]][j-1]<<"**";
                }
                cur[i][s][j]=cur[i-1][s][j];
                if(s-arr[i-1]>=0)
                    {
                        cur[i][s][j]+=cur[i-1][s-arr[i-1]][j-1];
                        //cout<<cur[i][s][j]<<" ";
                    }
            }
        }

       // cout<<endl<<endl;
        //int xyz;
        //cin>>xyz;

    }

    long long ans=0;
    for(int i=1;i<=smax;i++)
    {
        if(i%A==0)
        {
            if(i/A<=n)
                ans+=cur[n][i][i/A];
        }
    }
    cout<<ans;
    return 0;
}


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


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

    int a,b;
    cin>>a>>b;

    cout<<max({a+b,a-b,a*b})<<"\n";
    
    return 0;
}


Measured memory_bytes: 3644
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
--import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Fixed
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
import System.IO
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete

f n
  | odd n = 1 + 4 * subt (n`div`2)
  | even n = 2 * subt (n`div`2)
  where
    subt 0 = 0
    subt x = 1 + 3 * subt (x-1)

main = map (f . readInt) . lines <$> getContents >>= mapM_ print


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

using namespace std;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    string t = "";
    if (n % 2 == 1){
        cout << "No" << endl;
        return 0;
    }
    
    for (int i = 0; i < n / 2; i++){
        t += s[i];
    }
    // cout << t << endl;
    for (int i = 0; i < n / 2; i++){
        if (s[n/2+i] != t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <boost/numeric/interval.hpp>
#include <iostream>

int getCommonTimeLength(const boost::numeric::interval<int> alice, 
const boost::numeric::interval<int> bob) {
  try {
    const auto common = boost::numeric::intersect(alice, bob);
    return common.upper() - common.lower();
  } catch (...) {
    return 0;
  }
}

int main() {
  int a, b, c, d;
  std::cin >> a >> b >> c >> d;
  std::cout << getCommonTimeLength({a, b}, {c, d}) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,m;
    cin>>n>>m;
    int ans;
    ans=(n*(n-1))/2+(m*(m-1))/2;
    cout<<ans<<endl;
}

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

class Node {
  public:
    vector<int> edge;
    Node() {
    }
};

int main()
{
  int nnode, nedge;
  cin >> nnode >> nedge;
  vector<vector<int>> graph(nnode);
  for (int i = 0; i < nedge; i++) {
    int from, to;
    cin >> from >> to;
    from--;
    to--;
    graph.at(from).push_back(to);
  }

  double res = 1e9;
  for (int block = 0; block < nnode; block++) { // when block == nnode - 1, no removal
    vector<double> v(nnode);
    v.back() = 0;
    for (int i = nnode-2; 0 <= i; i--) {
      if (i == block) {
        double sum = 0;
        double maxi = 0;
        for (int to : graph.at(i)) {
          sum += v.at(to);
          maxi = max(maxi, v.at(to));
        }
        v.at(i) = (sum - maxi) / (graph.at(i).size() - 1) + 1;
      } else {
        double sum = 0;
        for (int to : graph.at(i)) {
          sum += v.at(to);
        }
        v.at(i) = sum / graph.at(i).size() + 1;
      }
    }
    res = min(res, v.front());
  }
  printf("%.10lf\n", res);
  return 0;
}


Measured memory_bytes: 1408
n=int(input())
l=list(map(int,input().split()))
counter=0
for i in range(n):
    minj=i
    for j in range(i,n):
        if l[j]<l[minj]:
            minj=j
    if i !=minj:
        l[i],l[minj]=l[minj],l[i]
        counter+=1
for i in range(n):
    if i!=n-1:
        print(l[i],end=' ')
    else:
        print(l[i])
print(counter)


Measured memory_bytes: 5608
from operator import itemgetter
N, M = map(int, input().split())
table = []
for i in range(M):
  a,b = map(int, input().split())
  table.append((a,b))
t = 0
ans = 0
table.sort(key=itemgetter(1))
for a,b in table:
  if t < a:
    ans += 1
    t = b-1
print(ans)

Measured memory_bytes: 18328
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const a = parseInt(args[0][0], 10)
	const b = parseInt(args[0][1], 10)
	if (a * b * 1 % 2 === 1) console.log('Yes')
	else if (a * b * 2 % 2 === 1) console.log('Yes')
	else if (a * b * 3 % 2 === 1) console.log('Yes')
	else console.log('No')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 9420
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
vector<int> p(200000);
int root(int a){
    if(p[a]==a){
        return a;
    }else{
        p[a]=root(p[a]);
        return p[a];
    }
}
int main(){
    ll n,m;
    cin >> n >> m;
    rep(i,0,n){
        p[i]=i;
    }
    rep(i,0,m){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        p[root(a)]=root(b);
    }
    map<int,int> data;
    rep(i,0,n){
        data[root(i)]++;
        //cout<<root(i)<<endl;
    }
    int Max = -1;
    for(auto p = data.begin();p!=data.end();p++){
        Max = max(p->second,Max);
    }
    cout<<Max<<endl;
    
    return 0;
}


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

#define ll long long

ll sum(int i, int j, ll* sum) {
    if (i == 0)
        return sum[j];
    return sum[j] - sum[i-1];
}

int main() {
    int N; cin >> N;
    int arr[N];
    for (int i=0; i<N; i++) scanf("%d", arr+i);

    ll s[N];
    s[0] = arr[0];
    for (int i=1; i<N; i++) 
        s[i] = s[i-1] + arr[i];

    ll dp[2][N][N];
    for (int i=0; i<N; i++) 
        dp[0][i][i] = dp[1][i][i] = arr[i];

    for (int len=2; len<=N; len++) {
        for (int i=0; i+len-1<N; i++) {
            int j=i+len-1;

            dp[0][i][j] = sum(i,j, s) - min(dp[1][i+1][j], dp[1][i][j-1]);
            dp[1][i][j] = sum(i,j, s) - min(dp[0][i+1][j], dp[0][i][j-1]);

        }
    }

    cout << 2*dp[0][0][N-1] - s[N-1] << endl;

    return 0;
}

Measured memory_bytes: 140288
#include <stdio.h>
#include <stdlib.h>
void swap(int *, int *);

int main(){
  int N,*A,i,j,flag,count=0;

  scanf("%d",&N);
  A=(int*)malloc(sizeof(int)*N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);

  flag=1;
  i=0;
  while(flag){
    flag=0;
    for(j=N-1;j>=i+1;--j){
      if(A[j]<A[j-1]){
	swap(&A[j],&A[j-1]);
	flag=1;
	count++;
      }
    }
    i++;
  }

  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i!=N-1) printf(" ");
  }
  printf("\n%d\n",count);
  return 0;
}

void swap(int *x,int *y){
  int tmp;
  tmp=*x;
  *x=*y;
  *y=tmp;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
    string n;
    cin >> n;
    rep(i, n.size()){
        if(n[i] == '9') n[i] = '1';
        else n[i] = '9';
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3576
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_2-B: Selection Sort

#include <algorithm>
#include <iostream>

static void print_ints(const int as[], const unsigned int n)
{
  auto sep = "";
  for (auto i = 0u; i < n; ++i) {
    std::cout << sep << as[i];
    sep = " ";
  }
  std::cout << std::endl;
}

static void print_int(const unsigned int n)
{
  std::cout << n << std::endl;
}

static unsigned int swap_count = 0u;

static void swap(int& a, int& b)
{
  ++swap_count;
  std::swap(a, b);
}

static void selection_sort(int as[], const unsigned int n)
{
  for (auto i = 0u; i < n-1; ++i) {
    auto min_j = i;
    for (auto j = i+1; j < n; ++j) {
      if (as[j] < as[min_j]) {
        min_j = j;
      }
    }
    if (i != min_j) {
      swap(as[i], as[min_j]);
    }
  }
}

int main()
{
  unsigned int n;
  std::cin >> n;
  int as[n];
  for (auto i = 0u; i < n; ++i) {
    std::cin >> as[i];
  }

  selection_sort(as, n);
  print_ints(as, n);
  print_int(swap_count);
}

// eof

Measured memory_bytes: 3088
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

#define INF 0xc0c0c0c0
#define NINF 0x3f3f3f3f

#define FOR(i, a, b) for((i)=a; i<b; ++(i))
#define EFOR(i, a, b) for((i)=a; i>b; --(i))

#define MLC(n, type) (type*)malloc(n*sizeof(type))
#define CLC(n, type) (type*)calloc(n, sizeof(type))

#define MAXN 100001

void solver(int *hData, int hSize) {
	long long int dp[MAXN] = {0};
	int i = 0;

	if (hSize < 2) {
		return;
	}

	dp[1] = abs(hData[1]-hData[0]);

	FOR(i, 2, hSize) {
		dp[i] = min(abs(hData[i]-hData[i-2]) + dp[i-2], abs(hData[i] - hData[i-1]) + dp[i-1]);
	}

	printf("%lld\n", dp[hSize-1]);
	return;
}

int main() {
	int i,n;
	int a[MAXN] = {0};

	scanf("%d", &n);

	FOR(i, 0, n) {
		scanf("%d", &a[i]);
	}

	solver(a, n);
	return 0;
}


Measured memory_bytes: 1280
parseInt(x) = parse(BigInt, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	a = readline() |> parseInt
	b = readline() |> parseInt
	if a>b
		println("GREATER")
	elseif b>a
		println("LESS")
	else
		println("EQUAL")
	end
end

main()

Measured memory_bytes: 167312
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all(C) std::begin(C), std::end(C)

int32_t c[3][3];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);
	for (size_t i = 0; i < 3; i++)
		for (size_t j = 0; j < 3; j++)
	{
			in >> c[i][j];
	}

	bool ok = true;
	int bace = c[0][1] - c[0][0];
	for (size_t i = 0; i < 3; i++)
	{
		ok &= bace == c[i][1] - c[i][0];
	}
	bace = c[0][2] - c[0][0];
	for (size_t i = 0; i < 3; i++)
	{
		ok &= bace == c[i][2] - c[i][0];
	}
	bace = c[0][2] - c[0][1];
	for (size_t i = 0; i < 3; i++)
	{
		ok &= bace == c[i][2] - c[i][1];
	}

	bace = c[1][0] - c[0][0];
	for (size_t i = 0; i < 3; i++)
	{
		ok &= bace == c[1][i] - c[0][i];
	}
	bace = c[2][0] - c[0][0];
	for (size_t i = 0; i < 3; i++)
	{
		ok &= bace == c[2][i] - c[0][i];
	}
	bace = c[2][0] - c[1][0];
	for (size_t i = 0; i < 3; i++)
	{
		ok &= bace == c[2][i] - c[1][i];
	}
	if (ok) {
		out << "Yes" << endl;

	}
	else {
		out << "No" << endl;
	}

	return 0;
}
#endif


Measured memory_bytes: 888
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		int[] h = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			h[i] = sc.nextInt();
		}
		int anscx = 0;
		int anscy = 0;
		int ansh = 0;
		boolean bre = false;
		out: for (int cx = 0; cx <= 100; cx++) {
			for (int cy = 0; cy <= 100; cy++) {
				int sample = 0;
				for (int i = 0; i < n; i++) {
					if (h[i] != 0) {
						sample = Math.abs(x[i] - cx) + Math.abs(y[i] - cy) + h[i];
						break;
					}
				}
				for (int i = 0; i < n; i++) {
					int tmp = Math.abs(x[i] - cx) + Math.abs(y[i] - cy) + h[i];
					if (h[i] == 0) {
						if (sample > tmp) {
							bre = true;
							break;
						}
					} else if (tmp != sample){
						bre = true;
						break;
					}
				}
				if (!bre) {
					anscx = cx;
					anscy = cy;
					ansh = sample;
					break out;
				} else {
					bre = false;
				}
			}
		}
		System.out.println(anscx + " " + anscy + " " + ansh);
	}
}

Measured memory_bytes: 23636
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int n[3];
	REP(i, 3) cin >> n[i];
	sort(n, n + 3);
	if (n[0] == 5 && n[1] == 5 && n[2] == 7) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#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 ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

bool isOK(ll key, ll K, vector<ll> A) {
    if (key == 0)
        return false;
    ll cnt = 0;
    rep(i, A.size()) {
        if (A[i] < key)
            cnt = cnt;
        else if (A[i] % key == 0)
            cnt += A[i] / key - 1;
        else
            cnt += A[i] / key;
    }

    if (cnt <= K)
        return true;
    else
        return false;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) { cin >> A[i]; }

    ll ok = *max_element(all(A)) + 1, ng = -1;

    while (abs(ok - ng) > 1) {
        ld mid = (ok + ng) / 2;
        if (isOK(mid, K, A))
            ok = mid;
        else
            ng = mid;
    }

    ll ans = ok;

    cout << ans << endl;
}

Measured memory_bytes: 6352
# -*- coding: utf-8 -*-
"""
A - Right Triangle
https://atcoder.jp/contests/abc116/tasks/abc116_a

"""
import sys


def solve(a, b, c):
    s = (a + b + c) / 2
    return int((s*(s-a)*(s-b)*(s-c))**0.5)

def main(args):
    a, b, c = map(int, input().split())
    ans = solve(a, b, c)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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

bool palind(string x){
    auto size = x.size();
    for(int i=0; i<size/2; i++){
        if(x[i] != x[size-1-i]) return false;
    }
    return true;
}

bool check(){
    int length1 = (s.size()-1)/2;
    int length2 = s.size()-(s.size()+3)/2+1;
    return palind(s) && palind(s.substr(0,length1)) && palind(s.substr((s.size()+3)/2-1, length2));
}
int main(){
    cin >> s;
    if(check()) printf("Yes");
    else printf("No");
}

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

int main() {
    using namespace std;
    unsigned long N, M;
    cin >> N >> M;
    vector<pair<unsigned long, unsigned long>> souv(N);
    for(auto& i : souv){
        cin >> i.first >> i.second;
        --i.first;
    }
    vector<unsigned long> ans(M + 1);
    unsigned long lim{0};
    const auto& add = [&ans, &lim](unsigned long i, unsigned long x) -> void { if(i > lim)ans[i] += x; };
    for(const auto& i : souv){
        lim = i.second - i.first;
        ans[lim] += (i.second / (lim + 1) == i.first / (lim + 1));
        for(unsigned long j{1}, k{i.second}; k > lim; ++j, --k){
            k = min(i.second / j, k);
            j = max(j, i.second / k);
            add(k, i.second / k - i.second / (k + 1));
        }
        for(unsigned long j{1}, k{i.first}; k > lim; ++j, --k){
            k = min(i.first / j, k);
            j = max(j, i.first / k);
            add(k, i.first / (k + 1) - i.first / k);
        }
    }
    partial_sum(ans.rbegin(), ans.rend(), ans.rbegin());
    copy(ans.begin() + 1, ans.end(), ostream_iterator<unsigned long>(cout, "\n"));
    return 0;
}

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

//https://qiita.com/tubo28/items/e6076e9040da57368845
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 n: usize = read();
    let m: usize = read();

    if n == 1 && m == 1 {
        println!("1");
    }else if n == 1 && m >= 2 {
        println!("{}",m-2);
    }else if m == 1 && n >= 2 {
        println!("{}",n-2);
    }else{
        println!("{}",(n-2)*(m-2));
    }
}


Measured memory_bytes: 4352
void main() {
	auto ip = readAs!(int[]), N = ip[0], M = ip[1], C = ip[2];
	auto B = readAs!(int[]);
	auto A = readMatrix!int(N, M);
	ulong cnt;
	foreach(i; 0..N) {
		auto arr = A[i];
		long tmp;
		foreach(j; 0..M) {
			tmp += arr[j]*B[j];
		}
		tmp += C;
		if(tmp > 0) cnt++;
	}
	cnt.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
bool cmp(int a,int b)
{
	return a>b;
}
int a[200010];
int main()
{
	int n,k;
	while(~scanf("%d %d",&n,&k))
	{
		memset(a,0,sizeof(a));
		int b;
		for(int i=0;i<n;i++)
		{
			scanf("%d",&b);
			a[b]++;
		}
		sort(a,a+200010,cmp);
		int sum=0;
		for(int i=0;i<k;i++)
		{
			sum+=a[i];
		}
		printf("%d\n",n-sum);
	}
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

int main(){
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < w+2; i++) {
        cout << '#';
    }
    cout << endl;
    for (int i = 0; i < h; i++) {
        string s;
        cin >> s;
        cout << '#' << s << '#' << endl;
    }
    for (int i = 0; i < w+2; i++) {
        cout << '#';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
/* Simplicity and Goodness */

#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;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;


void solve()
{
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);

    char a[n][m];

    rep(i, 0, n) {
        rep(j, 0, m)
        cin >> a[i][j];
    }

    int ways = 0;

    for(int row=0; row<(1<<n); row++) {
        for(int col=0; col<(1<<m); col++) {
            int here = 0;

            rep(i, 0, n) {
                rep(j, 0, m) {
                    if((row>>i)&1) continue;
                    if((col>>j)&1) continue;
                    here += a[i][j] == '#';
                }
            }

            ways += here == k;
        }
    }

    prin(ways);
}

int main()
{
    int t = 1;
    // scn(t);
    
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3760
#include <stdio.h>
#define N 100000
int Partition(int * ,int ,int );
int A[N];

main(){

  int i,n,se;

  scanf("%d",&n);

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

   se = Partition(A,0,n - 1);

  for(i = 0 ; i < n ; i++ ){
    if(i != 0) printf(" ");
    if(i == se) printf("[%d]",A[i]);
    else printf("%d",A[i]);
  }

  printf("\n");

  return 0;
  
}

int Partition(int *A, int p,int r){
  int x,i,ch,j;

  x = A[r];
  i = p - 1;
  for(j = p ; j <= r - 1; j++){
    if(A[j] <= x){
      i = i + 1;
    ch = A[i];
    A[i] = A[j];
    A[j] = ch;
    }
  }
  ch = A[i + 1];
  A[i + 1] = A[r];
  A[r] = ch;

  return i + 1;
}

Measured memory_bytes: 992
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());
        int k = Integer.parseInt(sc.next());

        double result = 0;
        if (n < k) {
            for (int i = 1; i <= n; i++) {
                int count = 0;
                int num = i;
                while (num < k) {
                    num *= 2;
                    count++;
                }
                result += 1.0 / (Math.pow(2, count));
            }
            result /= n;
        } else {
            for (int i = 1; i < k; i++) {
                int count = 0;
                int num = i;
                while (num < k) {
                    num *= 2;
                    count++;
                }
                result += 1.0 / (Math.pow(2, count));
            }
            result /= n;
            int win = n - k + 1;
            result += 1.0 * win / n;
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 21972
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
int x,a,b;
cin>>x>>a>>b;
if(x>a&&x>b)
{
if(x-a>x-b)
{
cout<<"B"<<endl;
}
else{
cout<<"A"<<endl;
}
}
else if(x<a&&x<b){
if(a-x>b-x)
{
cout<<"B"<<endl;
}
else 
{
cout <<"A"<<endl;
}
}
else  if(a>x&&x>b){
if(a-x>x-b)
{
cout<<"B"<<endl;
}
else{
cout<<"A"<<endl;
}
}
else{
if(x-a>b-x){
cout<<"B"<<endl;
}
else {
cout<<"A"<<endl;
}
}

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
using namespace std; 

int n,a[100001],dp[100001];


int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        dp[i]=1000000001;
    }
    for(int i=0;i<n;i++){
        int j;
        j=lower_bound(dp,dp+n,a[i])-dp;
        dp[j]=a[i];
    }
    for(int i=0;i<n;i++){
        if(dp[i]==1000000001){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<n<<endl;
    return 0;
}

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

using namespace std;

int main() {
  long long q, h, s, d;
  cin >> q >> h >> s >> d;
  long long n;
  cin >> n;
  s = min({q * 4, h * 2, s});
  cout << min(s * n, d * (n / 2) + s * (n & 1)) << endl;
}

Measured memory_bytes: 256
use std::collections::HashSet;
use std::cmp::max;

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let t: Vec<char> = s.trim().chars().collect();
    let n = t.len();
    let mut set = HashSet::new();
    for c in "ACGT".chars(){
        set.insert(c);
    }
    // charにしないと駄目じゃないか
    let mut ans = 0;
    for i in 0..n{
        for j in i..n{
            let mut flag = true;
            for k in i..j+1{
                if !set.contains(&t[k]){
                    flag = false;
                    break
                }
            }
            if flag{
                ans = max(ans, j-i+1);
            }
        }
    }
    println!("{}", ans);

}

Measured memory_bytes: 4476
h,m,M=60;P(s){printf("0%d:%02d:%02d\n",s/M/M,s/M%M,s%M);}main(s){for(;scanf("%d%d%d",&h,&m,&s),h+1;P(s*3))P(s=7200-h*M*M-m*M-s);exit(0);}

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

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

    string event;

    for (int n = 0; n != N; ++n) {
        
        int runners = 0, points = 0, out = 0;
        
        while (out < 3) {
            cin >> event;
            if (event == "OUT") out++;
            if (event == "HIT") {
                if (runners == 3) {
                    points++;
                }    
                else {
                    runners++;
                }
            }
            if (event == "HOMERUN") {
                points += runners + 1;
                runners = 0;
            }
        }
        cout << points << endl;
    }
}

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

long long int gcd(long long int x, long long int y)
{
	long long int t;
	while((t = x % y) != 0){
		x = y;
		y = t;
	}
	return y;
}

int main()
{
	long long int a, b, c, d;
	cin >> a >> b >> c >> d;
	a -= 1;
	cout << (b - b / c - b / d + b / (c * d / gcd(c, d))) - (a - a / c -a / d + a / (c * d / gcd(c, d))) << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
class p
{
  static void Main()
  {
    string s = Console.ReadLine();
    bool result = true;
    
    // Aチェック
    if (s[0] != 'A') {
      result = false;
    }
    // Cチェック
    int index = s.IndexOf("C");
    if (index < 2 || s.Length - 2 < index) {
      result = false;
    }
    // 小文字チェック
    for (int i = 1; i < s.Length; i++) {
      if (i == index) { continue; }
      if (s[i] < 'a' || 'z' < s[i]) {
        result = false;
        break;
      }
    }
    Console.WriteLine(result ? "AC" : "WA");
  }
}

Measured memory_bytes: 13280
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (n == i * j) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

}

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

int main() {
  string n;
  cin >> n;
  if(n.at(1)==n.at(2) && (n.at(0)==n.at(1) || n.at(2)==n.at(3))){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int H = int.Parse(str[0]);
        int W = int.Parse(str[1]);
        int h = int.Parse(str[2]);
        int w = int.Parse(str[3]);
        if(H % h == 0 && W % w == 0){
            sb.Append("No\n");
            return;
        }
        int[,] A = new int[H,W];
        if(H % h != 0){
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    A[i,j] = i % h == h - 1 ? - 1 - 10000*(h - 1) : 10000; 
                }
            }
        }
        else{
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    A[i,j] = j % w == w - 1 ? - 1 - 10000*(w - 1) : 10000; 
                }
            }
        }
        sb.Append("Yes\n");
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                sb.Append(A[i,j]+" ");
            }
            sb.Append("\n");
        }
    }
}

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

int main(){
ll a,b,c ;
cin >> a >> b >> c ;
if( c - a - b > 0 && (c - a - b)*( c - a - b ) > 4 * a * b ) cout << "Yes" << endl ;
else cout << "No" << endl ;
}

Measured memory_bytes: 3640
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

template<ull mod,ull phi_mod=mod-1>
class basic_mod_int{
    private:
        using mod_int=basic_mod_int<mod,phi_mod>;
        ull num;
        static ull pow_mod(ull x,ull y){x%=mod;return(y==0?1:y%2==0?pow_mod(x*x%mod,y/2):x*pow_mod(x,y-1))%mod;}
    public:
        basic_mod_int()=default;
        basic_mod_int(ull num):num(num%mod){}
        explicit operator ull()             const{return num;}
        bool    operator==(const mod_int&mi)const{return num==mi.num;}
        bool    operator!=(const mod_int&mi)const{return !operator==(mi);}
        mod_int operator~ ()                const{return pow_mod(num,phi_mod-1);}
        mod_int operator+ (const mod_int&mi)const{return num+mi.num;}
        mod_int operator- (const mod_int&mi)const{return num-mi.num+mod;}
        mod_int operator* (const mod_int&mi)const{return num*mi.num;}
        mod_int operator/ (const mod_int&mi)const{return num*(~mi).num;}
        mod_int&operator+=(const mod_int&mi)     {return*this=operator+(mi);}
        mod_int&operator-=(const mod_int&mi)     {return*this=operator-(mi);}
        mod_int&operator*=(const mod_int&mi)     {return*this=operator*(mi);}
        mod_int&operator/=(const mod_int&mi)     {return*this=operator/(mi);}
};
using mod_int=basic_mod_int<1000000007>;
mod_int factorial_mod(ull n)
{
    mod_int ret=1;
    for(ull i=1;i<=n;++i){
        ret*=i;
    }
    return ret;
}
int main()
{
    ll x=in(),y=in();
    if((2*y-x)%3!=0||(2*x-y)%3!=0){
        cout<<0<<endl;
    }else{
        ll a=(2*y-x)/3,b=(2*x-y)/3;
        if(a<0||b<0){
            cout<<0<<endl;
            return 0;
        }
        cout<<(ull)(factorial_mod(a+b)*~(factorial_mod(a)*factorial_mod(b)))<<endl;
    }
}


Measured memory_bytes: 256
#require 'prime'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
h,w=gsmi
putsend 1 if h==1||w==1
if h.odd? && w.odd?
  puts h*w/2+1
else
  puts h*w/2
end

Measured memory_bytes: 1788
// Sat May  2 17:37:17 IST 2020         
#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)        for(int ii = (int)a ; ii < (int)b  ; ii++ )
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long    
#define MOD                998244353 
#define pb                 push_back
#define f1                 first 
#define s1                 second    
#define all(x)             (x).begin(),(x).end() 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
#define tough_nut          numeric_limits<int64>::min()
const double pi=3.141592653589793238;
using namespace std ;     
using namespace __gnu_pbds;
 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
const int N = 2e5; 
const int INF = 2e9;
int tests(){
    int n ; 
    bool ok = false ;
    int k,A,B;
    cin >> k ;
    cin >> A >> B  ;
    for(int i = A ; i<= B ; i++ )
        ok |= (i%k == 0 );
    cout <<  (ok ? "OK" : "NG") << '\n';
    return 0;
}   
int32_t main(){
    I__O ;    
    int cases = 1 ; 
    // cin >> cases ; 
    forn(iii,1,cases+1){   
        // cout << "Case #" << iii << ": ";
        tests(); 
    }
    return 0 ; 
}
 
// -Wall -Wextra -O2
// -pedantic -std=c++11
// -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC


Measured memory_bytes: 3636
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::*,
    std::{cmp::*, collections::*, convert::*, iter::*, marker::*, mem::*, ops::*},
};
fn main() {
    input! {//
        n:usize,
    }

    let v = vec![
        "pon", "pon", "hon", "bon", "hon", "hon", "pon", "hon", "pon", "hon",
    ];

    println!("{}", v[n % 10]);
}


Measured memory_bytes: 2100
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d,l;
	int jp,ma,sum,abc,sa;
	bool bo=false;
	cin>>l>>a>>b>>c>>d;
	if(a%c!=0){
		jp=a/c;
		jp++;
	}
	else{
		jp=a/c;
	}
	if(b%d!=0){
	ma=b/d;
	ma++;
	}
	else {
		ma=b/d;
	}
	sum=jp+ma;
	sa=jp-ma;
	if(sa<0){
		sa*=-1;
		bo=false;
	}
	else{
		bo=true;
	}
	if(bo==false){
	cout<<l-ma<<endl;
	}
	else{
		cout<<l-jp<<endl;
	}
	return 0;
}

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 10010010010010010;

int main() {
    int n,a; cin >> n;
    int ans[n];
    rep(i,n) {
        cin >> a;
        ans[a-1] = i+1;
    }
    rep(i,n) {
        printf("%d ", ans[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 4116