akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define NIL -1
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

const double PI=(acos(-1));

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int r=0,w=0;
    rep(i,n){
        if(s[i]=='R')++r;
    }
    int ans=r;
    rep(i,n){
        if(s[i]=='R')--r;
        else ++w; 
        int now=max(r,w);
        ans=min(now,ans);
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 3752
# coding: utf-8

n = int(input())

#（↓）n円をおろすときの最小の出金回数をdp[n]に格納する。
#（↓）0円をおろすには0回の出金でよいのでdp[0]=0を初期値として設定する。
dp = [0]

#（↓）おろす金額がi円（=1,2,3,...,n）の場合を順番に考える。
for i in range(1,n+1):

    #（↓）i円を出金するときにありうる出金回数を全部Qに格納する。
    #（↓）全ての出金方法を検討した後で、Qの最小値、すなわちn円をおろすのに
    #（↓）必要な最小の出金回数をdp[i]に格納する。
    Q = []

    Q.append(1+dp[i-1])

    p6 = 1
    while i >= 6**p6:
        Q.append(1+dp[i-6**p6])
        p6 += 1

    p9 = 1
    while i >= 9**p9:
        Q.append(1+dp[i-9**p9])
        p9 += 1

    dp.append(min(Q))

print(dp[n])

Measured memory_bytes: 3860
#include <stdio.h>

int main(void){
    int N, M, X;
    scanf("%d%d%d", &N, &M, &X);
    int a[M];
    int c1 = 0;
    int c2 = 0;
    for(int i = 0; i < M; i++){
        scanf("%d", &a[i]);
        if(a[i] < X) c1 += 1;
        else if(a[i] > X) c2 += 1;
    }
    printf("%d\n", c1 < c2 ? c1 : c2);
    return 0; 
}

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

int main(){
  int n,s[10001],q;
  cin>>n;
  for(int i=0;i<n;i++) cin>>s[i];
  cin>>q;
  int ans=0,b;
  while(q--){
    cin>>b;
    int i=0;
    while(i<n&&s[i]!=b)i++;
    ans+=(i!=n);
  }
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 1196
<?php
//$N = trim(fgets(STDIN));
list($N,$s,$t) =  explode(" ",trim(fgets(STDIN)));
//$A =  explode(" ",trim(fgets(STDIN)));
$s--;$t--;
$to = array();
for($i=0;$i<$N-1;$i++) {
  list($A,$B) =  explode(" ",trim(fgets(STDIN)));
  $A--;$B--;
  $to[$A][]=$B;
  $to[$B][]=$A;
}
//https://atcoder.jp/contests/abc148/submissions/9046008

$dist = array();
$distS = calcDist($s);
$distT = calcDist($t);

$mx=0;
for($i=0;$i<$N;$i++) {
  if ($distS[$i] < $distT[$i]) {
    $mx = max($mx,$distT[$i]);
  }
}
printf("%d\n",$mx-1);

function calcDist($ss)
{
  global $dist;
  $dist = array_fill(0,$N,0);
  dfs($ss);
  return $dist;
}
function dfs($v,$d=0,$p=-1)
{
  global $dist,$to;
  $dist[$v]=$d;
  foreach($to[$v] as $vv) {
    if ($vv == $p) continue;
    dfs($vv,$d+1,$v);
  }
}


Measured memory_bytes: 78328
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int per_size = Integer.parseInt(sc.next());
        int[] p_per= new int[per_size];
        int[] q_per= new int[per_size];
        
        for(int i=0; i<per_size; i++){
            p_per[i] = Integer.parseInt(sc.next());
        }
        for(int i=0; i<per_size; i++){
            q_per[i] = Integer.parseInt(sc.next());
        }
        
        
        //String s = sc.next();
        
        int p_pos=factorial(per_size), q_pos=factorial(per_size);
        boolean pidentiy = false, qidentiy = false;
        ArrayList<Integer> a_perm = new ArrayList<Integer>(per_size);
        
        for(int i=1; i<=per_size; i++){
            a_perm.add(i);
        }
        
        for(int i=1; i<factorial(per_size); i++){
            pidentiy = true;
            qidentiy = true;
            for(int j=0; j<per_size; j++){
                if(a_perm.get(j)!=p_per[j]) pidentiy=false;
                if(a_perm.get(j)!=q_per[j]) qidentiy=false;
            }
            if(pidentiy) p_pos=i;
            if(qidentiy) q_pos=i;
            a_perm = nextPerm(a_perm);
        }
        
        System.out.println(Math.abs(p_pos-q_pos));
    }
    
    private static ArrayList<Integer> nextPerm(ArrayList<Integer> former){
        int pivot=-1;
        int ln = former.size();
        for(int i = ln; i>1; i--){
            if(former.get(i-2) < former.get(i-1)){
                pivot = i-2;
                break;
            }
        }
        if(pivot==-1) return null;
        int pivot_fig = former.get(pivot);
        
        int min_pos=pivot+1;
        int min=former.get(min_pos);
        for(int i=ln-1; i > pivot+1; i--){
            if((former.get(i) < min)&&(former.get(i) > pivot_fig)){
                min_pos=i;
                min=former.get(min_pos);
            }
        }
        Collections.swap(former, pivot, min_pos);
        Collections.sort(former.subList(pivot+1, ln));
        return former;
        
    }
    private static int factorial(int n) {
        int ans=1;
        for(int i=n; i>0; i--){
            ans*=i;
        }
        return ans;
    }
}

Measured memory_bytes: 30976
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

int N, A[10101];
//---------------------------------------------------------------------------------------------------
void _main() {
	while (cin >> N) {
		if (N == 0) return;
		rep(i, 0, N) cin >> A[i];

		int sm = 0;
		rep(i, 0, N) sm += A[i];

		int ans = 0;
		rep(i, 0, N) if (A[i] * N <= sm) ans++;
		printf("%d\n", ans);
	}
}



Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define PB push_back
#define P pair<int,int>



signed main(){
  int d[400][400];
  rep(i,400){
    rep(j,400){
      if(i==j) continue;
      d[i][j]=INT_MAX;
    }
  }

  int n,s,t;
  cin>>n>>s>>t;
  s--;t--;

  rep(i,n){
    if(i==s) continue;
    cout<<"? "<<s+1<<' '<<i+1<<endl;
    cout.flush();
    int c;
    cin>>c;
    d[s][i]=c;
    d[i][s]=c;
  }

  rep(i,n){
    if(i==s||i==t) continue;
    cout<<"? "<<i+1<<' '<<t+1<<endl;
    cout.flush();
    int c;
    cin>>c;
    d[t][i]=c;
    d[i][t]=c;
  }

  vector<P> v;
  rep(i,n){
    if(i==s||i==t) continue;
    if(d[s][i]+d[i][t]==d[s][t]){
      v.PB(P(d[s][i],i));
    }
  }
  sort(all(v));

  vector<int> ans;
  ans.PB(s);
  if(v.size())
    ans.PB(v[0].S);

  int j=0;
  for(int i=1;i<(int)v.size();i++){
    cout<<"? "<<v[j].S+1<<' '<<v[i].S+1<<endl;
    cout.flush();
    int c;
    cin>>c;
    //cout<<v[0].F<<' '<<' '<<c<<' '<<d[v[i].S][t]<<endl;
    if(v[j].F+c+d[v[i].S][t]==d[s][t]){
      ans.PB(v[i].S);
      j=i;
    }
  }

  ans.PB(t);

  cout<<"!";
  rep(i,ans.size()){
    cout<<" "<<ans[i]+1;
  }
  cout<<endl;

}


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

int num_div(int n)
{
  int ans = 1;
  vector<int> x(n + 1);
  int num = n; // 素因数分解する変数num
  for (int i = 2; i <= n; i++)
  {
    while (num % i == 0)
    {            // 素数で割り切れなくなるまで割っていく
      x.at(i)++; // 割った個数を配列に足す
      num /= i;
    }
  }
  for (int i = 2; i <= n; i++)
  {
    ans *= x.at(i) + 1; // それぞれを+1して掛けていく
  }
  return ans;
}

int main()
{
  int N;
  cin >> N;
  int cnt = 0;
  for (int i = 1; i <= N; i++)
  {
    if (i % 2 != 0 and num_div(i) == 8)
      cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 500 + 5 ;
int n, a[N], b[N * N], Id[N] ; 
bool cmp( int x, int y ) {
	return a[x] < a[y] ;
}
signed main()
{
	n = gi() ;
	rep( i, 1, n ) a[i] = gi(), Id[i] = i ;
	sort( Id + 1, Id + n + 1, cmp ) ;
	rep( i, 1, n ) if( a[Id[i]] == a[Id[i - 1]] ) {
		puts("No") ; exit(0) ;
	}
	int cnt = 0 ;
	rep( i, 1, n ) {
		int u = Id[i] - 1 ; 
		rep( j, 1, u ) {
			while( b[cnt + 1] ) ++ cnt ;
			b[++ cnt] = Id[i] ; 
		} 
		while( b[cnt + 1] ) ++ cnt ;
		if( cnt >= a[Id[i]] ) {
			puts("No") ; exit(0) ;
		}
		b[a[Id[i]]] = Id[i] ; 
		
	}
	rep( i, 1, n ) {
		int u = n - Id[i] ;
		while( b[cnt + 1] ) ++ cnt ; 
		if( cnt < a[Id[i]] ) {
			puts("No") ; exit(0) ; 
		}
		rep( j, 1, u ) {
			while( b[cnt + 1] ) ++ cnt ; 
			b[++ cnt] = Id[i] ;
		}
	}
	printf("Yes\n") ;
	rep( i, 1, n * n ) printf("%d ", b[i] ) ;
	return 0 ;
}

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

#define ll long long
#define ld long double
#define pi 3.14159265359

int main() {
    ll N, K; cin >> N >> K;
    ll m = N, n, c;
    c = N / K;
    m -= K * c;
    n = abs(m - K);
    ll ans = min(m, n);
    cout << ans << endl;
    }

Measured memory_bytes: 256
import copy
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a_max = max(a)
n_ = sum(x == a_max for x in a)
if n_ > 1:
    a_max_2 = a_max
    for _ in range(n):
        print(a_max)
else:
    #a_max_2=sorted(set(a))[-2]
    b = copy.copy(a)
    b.remove(a_max)
    a_max_2 = max(b)
    for i in a:
        if i == a_max:
            print(a_max_2)
        else:
            print(a_max)

Measured memory_bytes: 14556
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

vector< int > LeapYear(int a, int b, vector<int > vec){
	for (int i = a; i <= b; i++){
		if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0){
			vec.push_back(i);
		}
	}
	return vec;
}

int main(){
	vector<int > vec;
	int a, b;

	// first input
	cin >> a >> b;

	while (a || b){
		vec.clear();
		vec = LeapYear(a, b, vec);

		// output
		if (!vec.empty()){
			for (int i = 0; i < vec.size(); i++){
				cout << vec.at(i) << endl;
			}
		}
		else{
			cout << "NA" << endl;
		}

		// input
		cin >> a >> b;
		if (a || b){
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1232
n, k = gets.chomp.split(' ').map{|i| i.to_i }
count = 0
sum = 0
maxsum = 0
pp = []
gets.chomp.split(' ').map{|i|
  ii = i.to_i
  pp[count] = ii
  sum += ii
  if count >= k
    sum -= pp[count - k]
    if sum > maxsum
      maxsum = sum
    end
  end
  count += 1
}

if maxsum == 0
  maxsum = sum
end
puts (1.0 * (maxsum + k) / 2)


Measured memory_bytes: 17612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin >> n;
    ll a[n];
    for(ll i=0;i<n;i++){
        cin >> a[i];
    }
   sort(a,a+n);
   cout << a[n/2]-a[n/2-1] << endl;
}

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

int main()
{
    string s,t;

    cin >> s >> t;
    int len = s.size();

    int i;
    for (i = 0; i < len; i++)
    {
        string buf = "";
        for (int j = 0; j < len; j++)
        {
            buf += s[(j + i) % len];
        }
        if(buf == t)break;
    }
    
    if(i == len)cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem A

if __name__ == '__main__':
    # Input
    pocket_money_yen = int(input())
    cake_price_yen = int(input())
    doughnut_price_yen = int(input())

    balance = pocket_money_yen - cake_price_yen
    balance = balance % doughnut_price_yen

    # Output
    print(balance)


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

bool ispra(string st){
    bool flag=true;
    int t=st.size();
    for(int i=0,j=t-1;i<t/2;i++,j--){
        if(st[i]!=st[j]) {
            flag=false;
            break;
        }
    }
    return flag;
}


int main(){
    string s;
    cin>>s;
    int len=s.size();
    string s1=s.substr(0,len/2);
    string s2=s.substr(len/2+1,len/2);
    if(ispra(s) && ispra(s1) && ispra(s2)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define INF 1007654321
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<typename U, typename V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}
 
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 10;

ll fact[MAXN];
ll inv_fact[MAXN];

ll binpow(ll a, ll n) {
    if(n == 0) return 1;
    ll res = 1;
    while(n > 0) {
        if(n % 2 == 1) res = (res*a) % MOD;
        a = (a * a) % MOD;
        n /= 2;
    }
    return res;
}

ll inverse(ll a) {
    // inv(a) = a^(MOD-2) % MOD
    return binpow(a, MOD-2);
}

int main() {
    FAST_IO();
    int N; cin >> N;
    vector<int> A(N+1);
    vector<int> cnt(N);
    rep(i, N+1) cin >> A[i];
    rep(i, N+1) cnt[A[i]-1]++;
    int v, i1 = -1, i2 = -1;
    rep(i, N) if(cnt[A[i]-1] > 1) v = A[i];
    rep(i, N+1) {
        if(A[i] == v && i1 == -1) i1 = i;
        if(A[i] == v && i1 != -1) i2 = i;
    }
    fact[0] = 1;
    inv_fact[0] = 1;
    repp(i, 1, N+1) {
        fact[i] = fact[i-1] * i % MOD;
        inv_fact[i] = inverse(fact[i]);
    }
    // repp(i, 0, N+1) cout << fact[i] << "\t" << inv_fact[i] << "\n";
    int M = N - 1 - (i2 - i1 - 1);
    repp(K, 1, N + 1) {
        // N+1CK - MCK-1
        ll res = fact[N+1] * inv_fact[K] % MOD * inv_fact[N+1-K] % MOD;
        if(K - 1 <= M) res = (res + MOD - fact[M] * inv_fact[K-1] % MOD * inv_fact[M-K+1] % MOD) % MOD;
        cout << res << "\n";
    }
}

Measured memory_bytes: 3584
import math

a,b,h,m = map(int,input().split())

h1 = 360/12*h + 360/12/60*m
m1 = 360/60*m

t = abs(h1-m1)
t = min(t, 360-t)

print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(t))))


Measured memory_bytes: 9360
H,W=map(int,input().split())
s=[input() for i in range(H)]
ans=[]
for row in s:
    ans.append(list(row))

frag="True"
dxy=[(1,0),(0,1),(0,-1),(-1,0)]
for y in range(H):
    for x in range(W):
        if s[y][x]==".": continue
        c=0
        for dx,dy in dxy:
            if x+dx<0 or x+dx>W-1 or y+dy<0 or y+dy>H-1:
                c+=1
                continue
            if s[y+dy][x+dx]==".":
                c+=1
        if c==4:
            print("No")
            exit()
print("Yes")

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


int main(){
  int N;
  cin >> N;
  set<char> S;
  for(int ii=0; ii<N; ii++){
    char s;
    cin >> s;
    S.insert(s);
  }
  cout << (S.size()==3 ? "Three" : "Four") << endl;
  return 0;
}

Measured memory_bytes: 256
/*"Everything in the universe is balanced. Every disappointment
   you face in life will be balanced by something good for you!
                Keep going, never give up."            */

#include "bits/stdc++.h"
using namespace std;

#define ll long long
const ll N=1e6+9;
const ll mod=1e9+7;

ll a[N];

void solve()
{    
    ll n, m ;
    cin >> n ; 
    vector<int> height(n);
    for ( int i=0 ; i<n; i++){
    	cin>>height[i] ;
    }
    vector<int> dp(n);
    dp[0] = 0 ;
    dp[1] = ( abs(height[1]-height[0]) + dp[0] )  ;

    for(int i = 2; i<n; i++ ) {
    	dp[i] = min(abs(height[i]-height[i-1]) + dp[i-1] , abs(height[i]-height[i-2]) + dp[i-2] ) ;
    }
    cout<<dp[n-1];

}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t=1;
    //pre();
    //cin>>t;
    while(t--)
    {
      solve();
    }  
}


// Xorawar

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int x, y, z, k;
    cin >> x >> y >> z >> k;

    vll a(x), b(y), c(z);
    rep(i, 0, x) { cin >> a[i]; }
    rep(i, 0, y) { cin >> b[i]; }
    rep(i, 0, z) { cin >> c[i]; }

    vll ab(x * y);
    rep(i, 0, x) {
        rep(j, 0, y) { ab[i + j * y] = a[i] + b[j]; }
    }

    sort(all(ab), greater<ll>());
    sort(all(c), greater<ll>());

    vll abc(min(k, x * y) * z);
    rep(i, 0, min(k, x * y)) {
        rep(j, 0, z) { abc[i + j * min(k, x * y)] = ab[i] + c[j]; }
    }
    sort(all(abc), greater<ll>());

    rep(i, 0, k) { cout << abc[i] << endl; }

    return 0;
}

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

int main() {

	int a,b;

	cin >> a >> b;

	if (a == 1 && b == 1) {
		cout << "Draw" << endl;
	}
	else if (a == 1 && b != 1) {
		cout << "Alice" << endl;
	}
	else if (a != 1 && b == 1) {
		cout << "Bob" << endl;
	}
	else if (a > b) {
		cout << "Alice" << endl;
	}
	else if (a < b) {
		cout << "Bob" << endl;
	}
	else {
		cout << "Draw" << endl;
	}

	return 0;



}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		String s1 = sc.next().toUpperCase();
		String s2 = sc.next().toUpperCase();
		String s3 = sc.next().toUpperCase();
		sc.close();
		out.printf("%c%c%c%n", s1.charAt(0), s2.charAt(0), s3.charAt(0));
	}
}


Measured memory_bytes: 23892
from collections import defaultdict, deque
import sys
import heapq
import bisect
import itertools
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpl_str(): return list(sys.stdin.readline().split())

n, m = inpl()
a = inpl()
s = sum(a)
cnt = 0
for i in a:
    if i*(4*m) >= s:
        cnt += 1
if cnt >= m:
    print('Yes')
else: 
    print('No')

Measured memory_bytes: 3944
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 5e5 + 123;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

void solve(){
    int n;
    cin >> n;
    int x = n/500;
    n %= 500;
    n /= 5;
    cout << x*1000 + n*5;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; i++){
        //cout << "case #" << i << ": ";
        solve();
    }
    return 0;
}


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

int main(){
    long long N,K;
    N=(long long) 1e10;
    vector <long long> v;
    vector <long long> vd;
    cin >> K;

    long long i=0;
    long long count=0;
    while(  (long long) v.size()<K && i<=N){

        long long ii1,ii2;
        if( vd.size()==0 ){
            long long tmp=1;
            vd.push_back(tmp-1);
            //cout << " ***  first vd new " << vd.back() << endl;
            while(v.size()<=9){
                v.push_back(tmp);
                tmp++;
                //cout << "first v new " << v.back() << endl;
            }
            if(v.back()==10){
                vd.push_back( (long long) v.size()-1);
                //cout << " ***  first vd new " << vd.back() << endl;
            }
        }
        
        ii1 = vd[vd.size()-2];
        //cout << "vd.size ii1 " << vd.size() << " " << ii1 << endl;
        ii2 = vd[vd.size()-1];
        //cout << "vd.size ii2 " << vd.size() << " " << ii2 << endl;

        for( long long i=ii1; i<ii2; i++ ){
            long long v1;
            v1=v[i];
            //cout << "v1 " << v1 << endl;
            stringstream ss;
            ss << v1;
            string S=ss.str();
            for(int j=0; j<=9; j++){
                int jj = S[S.size()-1]-'0';
                //cout << "jj " << jj << endl;
                if( abs(j-jj) <=1 ){
                    long long v2 = 10*v1 + j;
                    if(v2==v.back()){
                        continue;
                    }
                    v.push_back(v2);
                    //cout << "v new " << v.back() << endl;
                }
            }

        }
        vd.push_back(v.size()-1);
        if(v.size()>=K) break;
    }

        cout << v[K-1] << endl;
    

    return 0;
}

Measured memory_bytes: 2420
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<iomanip>
#include<map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF = 1e9 + 7;
int dx[8] = { 1,0,-1,0,1,1,-1,-1 };
int dy[8] = { 0,1,0,-1,1,-1,1,-1 };



int main() {

	int n, m;
	string s[105], t[105];

	cin >> n;

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

	cin >> m;

	for (int i = 0; i < m; i++)cin >> t[i];

	map <string, int> mp;

	for (int i = 0; i < n; i++) {
		mp[s[i]]++;
	}
	for (int i = 0; i < m; i++) {
		mp[t[i]]--;
	}

	int res = 0;

	for (int i = 0; i < n; i++) {
		res = max(res, mp[s[i]]);
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
from math import floor
s_num, c_num = tuple(int(i) for i in input().split(" "))
ans = 0
temp = s_num * 2
if c_num <= temp:
    ans += floor(c_num / 2)
else:
    ans += s_num
    ans += floor((c_num - temp) / 4)
print(ans)


Measured memory_bytes: 2940
w, n = map(int, input().split())
A0 = list(map(int, input().split()))
C = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
A = []
for i in range(n):
    A.append([A0[i], C[A0[i]]])

dp = [-1] * (w + 1)
dp[0] = 0
for i in range(w + 1):
    for j in range(n):
        if A[j][1] <= i:
            dp[i] = max(dp[i], dp[i - A[j][1]] * 10 + A[j][0])
            
print(dp[w])

Measured memory_bytes: 14516
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]

cnt = [0 for _ in range(N)]

for a in A:
    cnt[a - 1] += 1

for c in cnt:
    if Q - c < K:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 8632
#if __has_include("../library/Basic/Debug.hpp")

#include "../library/Basic/Debug.hpp"

#else

/* ----- Header Files ----- */
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>
#include <cstdint>


/* ----- Type Alias ----- */
using Bool = bool;
using Int = long long int;
using Real = long double;
using Char = char;
using String = std::string;
template <class T, class U>
using Pair = std::pair<T, U>;
template <class... Ts>
using Tuple = std::tuple<Ts...>;

template <class T>
using Vector = std::vector<T>;
template <size_t N>
using Bits = std::bitset<N>;
template <class T>
using Queue = std::queue<T>;
template <class T>
using Stack = std::stack<T>;
template <class T>
using Deque = std::deque<T>;

template <class T>
using MaxHeap = std::priority_queue<T>;
template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T>
using Set = std::set<T>;
template <class T, class U>
using Map = std::map<T, U>;

template <class T, class... Us>
using Func = std::function<T(Us...)>;

template <class T>
T genv(T v) { return v; }

template <class T, class... Ts>
auto genv(size_t l, Ts... ts) {
    return Vector<decltype(genv<T>(ts...))>(l, genv<T>(ts...));
}

template <class Cost = Int>
struct Edge {
    Int src, dst;
    Cost cost;
    Edge(Int src = -1, Int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = Int>
using Edges = Vector<Edge<Cost>>;
template <class Cost = Int>
using Graph = Vector<Vector<Edge<Cost>>>;

#endif

/* ----- Misc ----- */
void fastio() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

struct Fout {
    Int precision;
    Fout(Int precision) : precision(precision) {}
};
std::ostream& operator<<(std::ostream& os, const Fout& fio) {
    os << std::fixed << std::setprecision(fio.precision);
    return os;
}


/* ----- Constants ----- */
// constexpr Int INF = std::numeric_limits<Int>::max() / 3;
// constexpr Int MOD = 1000000007;
// constexpr Real PI = acos(-1);
// constexpr Real EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));

int main() {
    Int n, k;
    std::cin >> n >> k;

    Char prev;
    std::cin >> prev;

    Int gnum = 1;
    for (Int i = 1; i < n; ++i) {
        Char c;
        std::cin >> c;
        if (c != prev) ++gnum;
        prev = c;
    }

    for (Int i = 0; i < k; ++i) {
        if (gnum >= 3) {
            gnum -= 2;
        } else if (gnum >= 2) {
            gnum -= 1;
        }
    }

    std::cout << n - gnum << std::endl;
    return 0;
}


Measured memory_bytes: 256
public class Program {
  public static void Main() {
    long n = long.Parse(System.Console.ReadLine());
    long c0 = 0;
    long c1 = 0;
    long c2 = 0;
    long c3 = 0;
	for (int i = 0; i < n; i++) {
      string input = System.Console.ReadLine();
      if (input == "AC") { c0++; }
      if (input == "WA") { c1++; }
      if (input == "TLE") { c2++; }
      if (input == "RE") { c3++; }
    }
    System.Console.WriteLine("AC x {0}", c0);
    System.Console.WriteLine("WA x {0}", c1);
    System.Console.WriteLine("TLE x {0}", c2);
    System.Console.WriteLine("RE x {0}", c3);
  }
}


Measured memory_bytes: 30604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=305,INF=1<<30;
int N;
ll dis[MAX][MAX],dp[1<<17][17];

void floyd(){
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                chmin(dis[i][j],dis[i][k]+dis[k][j]);
            }
        }
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int M,l,s,t;
        cin>>N>>M>>l>>s>>t;
        s--;
        if(N==0) break;
        for(int i=0;i<N;i++) for(int j=0;j<N;j++) dis[i][j]=INF;
        for(int bit=0;bit<(1<<(l+1));bit++) for(int i=0;i<l+1;i++) dp[bit][i]=INF;
        for(int i=0;i<M;i++){
            int a,b,c;cin>>a>>b>>c;
            a--;b--;
            chmin(dis[a][b],ll(c));
            chmin(dis[b][a],ll(c));
        }
        
        floyd();
        
        vector<int> pos(l+1),cost(l+1);
        for(int i=1;i<=l;i++){
            cin>>pos[i]>>cost[i];
            pos[i]--;
        }
        pos[0]=s;
        cost[0]=0;
        
        dp[0][0]=0;
        
        for(int bit=0;bit<(1<<(l+1));bit++){
            for(int i=0;i<l+1;i++){
                if(bit&&(!(bit&(1<<i)))) continue;
                if(dp[bit][i]>t) continue;
                
                for(int j=0;j<l+1;j++){
                    if(i==j) continue;
                    if(bit&(1<<j)) continue;
                    
                    chmin(dp[bit|(1<<j)][j],dp[bit][i]+dis[pos[i]][pos[j]]+cost[j]);
                }
            }
        }
        
        int ans=0;
        
        for(int bit=1;bit<(1<<(l+1));bit+=2) if(dp[bit][0]<=t) chmax(ans,__builtin_popcount(bit)-1);
        
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 21276
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;
    if (N <= K) {
        cout << N * X << endl;
    }
    else {
        cout << K * X + (N - K) * Y << endl;
    }
}

Measured memory_bytes: 256
n = int(input())
a = [0] + list(map(int, input().split())) + [0]
m = []
for i in range(n):
    if a[i] <= a[i + 1] <= a[i + 2] or a[i + 2] <= a[i + 1] <= a[i]:
        m.append(0)
    elif a[i] <= a[i + 2] <= a[i + 1] or a[i + 1] <= a[i + 2] <= a[i]:
        m.append(1)
    elif a[i + 1] <= a[i] <= a[i + 2] or a[i + 2] <= a[i] <= a[i + 1]:
        m.append(-1)

s = sum(abs(a[i] - a[i + 1]) for i in range(n + 1))

for i, m0 in enumerate(m):
    if m0 == 0:
        print(s)
    elif m0 == 1:
        print(s - 2 * abs(a[i + 1] - a[i + 2]))
    elif m0 == -1:
        print(s - 2 * abs(a[i] - a[i + 1]))


Measured memory_bytes: 13920
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    cin >> N;
    ll mi = MOD;
    for(ll i = 1; i <= (ll)sqrt(N); i++) {
        if (N % i == 0) {
            string t1 = to_string(i);
            string t2 = to_string(N / i);
            mi = min(mi, max((ll)t1.size(), (ll)t2.size()));
        }
    }
    print(mi);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int LW = A + B, RW = C + D;
	if (LW > RW) cout << "Left" << endl;
	else if (LW == RW) cout << "Balanced" << endl;
	else cout << "Right" << endl;
	return 0;
}

Measured memory_bytes: 256
S = input()

if S == "SUN":
    print("7")
elif S == "MON":
    print("6")
elif S == "TUE":
    print("5")
elif S == "WED":
    print("4")
elif S == "THU":
    print("3")
elif S == "FRI":
    print("2")
elif S == "SAT":
    print("1")

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n;
    cin >> n;

    ll cnt0 = 0, cnt1 = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        if(a%2 == 0) {
            cnt0++;
        }
        else {
            cnt1++;
        }
    }

    if(cnt1%2 == 1) {
        out("NO");
    }
    else {
        out("YES");
    }

    re0;
}

Measured memory_bytes: 256
def main():
    s = input()
    t = input()
    dp = [[0]*(len(s)+1) for _ in range((len(t)+1))]
    ans = ""
    for i in range(len(t)):
        for j in range(len(s)):
            tmp1 = dp[i+1][j]
            tmp2 = dp[i][j+1]
            tmp3 = dp[i][j]
            if t[i] == s[j]:
                tmp3 += 1
            dp[i+1][j+1] = max(tmp1,tmp2,tmp3)
    i = len(t)
    j = len(s)
    while i > 0 and j > 0:
        if dp[i-1][j-1]+1 == dp[i][j] and t[i-1] == s[j-1]:
            ans += t[i-1]
            i -= 1
            j -= 1
        elif dp[i-1][j] == dp[i][j]:
            i -= 1
        else:
            j -= 1
    print(ans[::-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 113372
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define fi(i,start,end) for(int i=start; i<end; ++i)
#define fd(i,end,start) for(int i=end-1; i>=start; --i)
#define pb push_back
#define mz(a) memset(a,0,sizeof(a))
#define nl cout<<endl;
#define ip(n) cin>>n;
#define op(n) cout<<n;
#define FT() int t; cin>>t; while(t--)
#define inparr fi(i,0,n) ip(a[i]);
#define dispar fi(i,0,n) op(a[i]); nl;
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

void solve()
{
	ll n;
	cin>>n;
	ll a[n][2];
	//ll a,b;
	for(int i=0;i<n; i++)
	{
		cin>>a[i][0]>>a[i][1];
	}
	bool f = 0;
	ll c = 0;
	for(int i=0; i<n; i++)
	{
		if(a[i][0]==a[i][1])
		{
			c++;
			if(c == 3)
			{
				f = 1;
				break;
			}
		}
		else
		{
			c = 0;
		}
	}

	if(f)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
}
int main()
{
	/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif*/
	
	//FT()
		solve();

	/*#ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
    #endif*/
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}

int n,k,p[200005],ans=1;
string str;
priority_queue<long long ,vector<long long> > que;
set<int> st;
bool a=0;
int main() {
	double ans;
	int n;
	cin>>n;
	int c=n/2;
	if(n%2==1)++c;
	ans=(double)c/n;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <algorithm>
#include <typeinfo>
#define _USE_MATH_DEFINES
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int n, q;
vector<int> A(2000);

int solve(int i, int v){
    if(v==0){
        return 1;
    }
    if(n==i){
        return 0;
    }
    int res;
    if(A[i]<=v){
        res = solve(i+1, v) || solve(i+1, v-A[i]);
    }else{
        res = solve(i+1, v);
    }
    return res;
}

int main(){

    cin >> n;

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

    cin >> q;
    for(int i=0; i<q; i++){
        int M;
        cin >> M;
        if(solve(0, M)){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }

    return 0;
}



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

int main(){
    int N,C,p,i;
    int cake_sum=0;

    cin>>N>>C;
    N+=1;

    for(i=0;i<C;i++){
        cin>>p;
        cake_sum+=p;
    }

    if(cake_sum%N==0){
        cout<<cake_sum/N<<endl;
    }else{
        cout<<cake_sum/N+1<<endl;
    }
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  constexpr auto ceil = [](auto a,auto b){return (a-1)/b+1;};

  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll x = ceil(a,d);
  ll y = ceil(c,b);
  cout<<(x>=y?"Yes":"No")<<endl;

}

Measured memory_bytes: 3632
def resolve():
    h, w = map(int, input().split())

    image = list()
    image_line = ""
    for i in range(h):
        image_line = input()
        image_line = "#" + image_line + "#"
        image.append(image_line)

    sharp_line = ""
    for i in range(w + 2):
        sharp_line += "#"
    
    image.insert(0, sharp_line)
    image.append(sharp_line)

    for i in range(h + 2):
        print(image[i])
resolve()

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int bubble_sort(int xs[], int n);
void print_array(const int xs[], int n);

int main(){
    int n;
    cin >> n;
    int xs[n];

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

    int cnt = bubble_sort(xs, n);
    print_array(xs, n);
    cout << cnt << '\n';
}

int bubble_sort(int xs[], int n){
    int cnt = 0;
    for(int i = 0; i < n; ++i){
        for(int j = n-1; j > i; --j){
            if(xs[j] < xs[j-1]){
                ++cnt;
                int tmp = xs[j];
                xs[j] = xs[j-1];
                xs[j-1] = tmp;
            }
        }
    }
    return cnt;
}

void print_array(const int xs[], int n){
    for(int i = 0; i < n-1; ++i){
        cout << xs[i] << ' ';
    }
    cout << xs[n-1] << '\n';
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
 #include <math.h>
 #include <string>
 using namespace std;
 
 int main(){
    int N;
    int i;
    int tmp = 1;
    int ans = 1;

    cin >> N;
    if (N == 1)
        ans = 1;
    else{
        while(1){
            tmp = ans * 2;
            if (tmp > N ){
                break;
                }
            ans = tmp;
            }
        }

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] ints = new int[n];
		for (int i=0; i<n; i++) {
			ints[i] = sc.nextInt();
		}
		
		for (int i=0; i<n; i++) {
			int v = ints[i];
			int j = i - 1;
			while (j>=0 && ints[j]>v) {
				ints[j+1] = ints[j];
				j--;
			}
			ints[j+1] = v;
			print(ints);
		}
	}
	
	static void print (int num[]) {
		for (int i=0; i<num.length; i++) {
			System.out.print(num[i]);
			if (i!=num.length-1) {System.out.print(" ");}
		}
		System.out.println();
	}
}				


Measured memory_bytes: 34188
# ABC088D - Grid Repainting
from collections import deque

def bfs() -> None:
    dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    q = deque([(0, 0)])
    while q:
        x, y = q.popleft()
        for dx, dy in dxy:
            nx, ny = x + dx, y + dy  # next x, y
            # find unsearched grids of S and keep them in the queue
            if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == "." and D[nx][ny] == 0:
                q.append((nx, ny))
                D[nx][ny] = D[x][y] + 1


def main():
    # shortest path needs to remain white, the rest can be black
    global H, W, S, D
    H, W, *S = open(0).read().split()
    H, W = int(H), int(W)
    D = [[0] * W for _ in range(H)]  # distance from (0, 0) to (x, y)
    D[0][0] = 1
    bfs()
    white, x = sum(s.count(".") for s in S), D[-1][-1]
    ans = white - x if x else -1  # x = 0 <-> can't make a path to goal
    print(ans)


if __name__ == "__main__":
    main()

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

ll solve() {
    ll N, M;
    cin >> N >> M;
    ll t = 1900 * M + 100 * (N-M);
    ll c = 1 << M;
    ll ans = t * c;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
  int k, x;
  scanf("%d %d", &k, &x);
  printf("%d", x - k + 1);
  for (int i = x - k + 2; i < x + k; ++i)
  {
    printf(" %d", i);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 128
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

int a[100000];
int main() {
    int i;
    int N,L;
    scanf("%d %d",&N,&L);
    for (i = 0; i < N; i++) scanf("%d",&a[i]);

    for (i = 1; i < N; i++) {
        if (a[i]+a[i-1] >= L) break;
    }
    if (i == N) printf("Impossible\n");
    else {
        int p = i;
        printf("Possible\n");
        for (i = 1; i < p; i++) printf("%d\n",i);
        for (i = N-1; i > p; i--) printf("%d\n",i);
        printf("%d\n",i);
    }

    return 0;
}



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

int main() {
  int N;
  cin >> N;
  bool check = false;
  for(int i=1; i<10; i++){
    if(N%i == 0 && N/i < 10){
      check = true;
      break;
    }
  }
  if(check){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}


Measured memory_bytes: 256
def D():
    N = int(input())
    numberlist = [0 for i in range(N + 1)]
    for i in range(1, N + 1):
        tmp = i
        for j in range(2, i + 1):
            while tmp % j == 0:
                numberlist[j] += 1
                tmp /= j
    anslist = []
    for p in range(N + 1):
        if numberlist[p] + 1 >= 75:
            anslist.append(pow(p, 74))
        for q in range(N + 1):
            if p != q and numberlist[p] + 1 >= 15 and numberlist[q] + 1 >= 5:
                anslist.append(pow(p, 14) * pow(q, 4))
            if p != q and numberlist[p] + 1 >= 25 and numberlist[q] + 1 >= 3:
                anslist.append(pow(p, 24) * pow(q, 2))
            for r in range(N + 1):
                if p != q and q != r and r != p and numberlist[p] + 1 >= 5 and numberlist[q] + 1 >= 5 and numberlist[r] + 1 >= 3:
                    anslist.append(pow(p, 4) * pow(q, 4) * pow(r, 2))
    ans = 1
    anslist.sort()
    for i in range(1, len(anslist)):
        if anslist[i] != anslist[i - 1]:
            ans += 1
    if len(anslist) == 0:
        ans = 0
    print(ans)
D()

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main() {

	int h, w;
	while (1) {
		cin >> h >> w;

		if (h == 0 && w == 0)break;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (i % 2==0) {
					if (j % 2 == 0) {
						cout << "#";
					}
					else {
						cout << ".";
					}
				}
				else {
					if (j % 2 == 0) {
						cout << ".";
					}
					else {
						cout << "#";
					}
				}
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;

}


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

int main() {
  int k,a,b;
  cin >> k  >> a >> b;

  int count=0;

  for(int i=a;i<=b;i++){
    if(i%k==0) count++;
    
  }

  if(count>0) cout << "OK" << endl;
  else cout << "NG" << endl;
}

Measured memory_bytes: 3568