akhauriyash/Code-Regression huggingface dataset:
object Main {
  def main(args: Array[String]): Unit = {
    val in = new java.util.Scanner(System.in)
    val W = in.nextInt()
    val H = in.nextInt()
    val x = in.nextInt()
    val y = in.nextInt()
    val r = in.nextInt()
    if(r <=x && r <= y && r <= W-x && r <= H-y){
      println("Yes")
    }else{
      println("No")
    }
  }
}

Measured memory_bytes: 45080
#include <iostream>
#include <string>
#include <map>
#include <math.h>
using namespace std;

#define ll long long

int main(){
    string S;
    cin >> S;
    int A[S.length()] = {};
    for(int i = 0;i < S.length();i++){
        if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T' && i > 0)A[i] = A[i-1] + 1;
        else if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T')A[i] = 1;
        else A[i] = 0;
    }
    for(int i = 0;i < S.length();i++){
        for(int j = i + 1;j < S.length();j++){
            if(A[i] < A[j]){
                A[i] ^= A[j];
                A[j] ^= A[i];
                A[i] ^= A[j];
            }
        }
    }
    cout << A[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Here your code !
    int A, B, C;
    
    scanf("%d %d %d", &A, &B, &C);
    
    if (A == B) {
        printf("%d\n", C);
    }
    if (B == C) {
        printf("%d\n", A);
    }
    if (C == A) {
        printf("%d\n", B);
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <set>

using namespace std;

string str;
int strlength;

bool check(int k){
	int count[256] = {0}, d = 0;
	count['a']++;
	count['z'+1]++;
	for(int i=0; i<strlength; i++){
		if( !count[ str[i] + ((k&(1<<i))?1:0) ]++ )
			d |= (1<<i);
	}
	return k == d;
}

int main(){
	while(cin >> str, str[0] != '#'){
		set<string> ans;
		set<string>::iterator it;
		strlength = str.length();
		for(int k=0; k<(1<<strlength); k++){
			if( check(k) ){
				string str2 = str;
				for(int l=0; l<strlength; l++){
					if( k & (1<<l) && str[l] != 'z' ){
						str2[l]++;
					}
				}
				ans.insert( str2 );
			}
		}
		// ??????
		cout << ans.size() << endl;
		if( ans.size() <= 10 ){
			for(it = ans.begin(); it != ans.end(); it++)
				cout << *it << endl;
		}else{
			int count = 0;
			for(it = ans.begin(); count < 5; it++, count++)
				cout << *it << endl;
			for(it = ans.end(); count > 0; it--, count--){}
			for(; count < 5; it++, count++)
				cout << *it << endl;
		}
	}
}

Measured memory_bytes: 3128
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
#include <vector>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int         long long
#define ll          long long
#define ld	    long double
#define pb          push_back
#define pp	    pop_back()
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),a.rend()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repj(j,a,b) for(ll j=a;j<b;j++)
#define lexistr(x,y)      lexicographical_compare(x.begin(),x.end(),y.begin(),y.end())
#define IOS	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//CONSTANTS----------------------------------
#define PI 	    3.141592653589793238462643
const ll hell=1000000007;
const ll mod=1000000007;
//function-----------------------------------
ll GCD(ll a , ll b)
{
    if(b==0)
        return a;
    else
        return GCD(b,a%b);
}
ll LCM(ll a, ll b)
{
    return a*(b/GCD(a,b));
}
bool isPrime(ll n) {

    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
}
ll fact(ll n)
{
    ll f=1;
    for(ll i=2;i<=n;i++)
	f=f*i;
    return f;
}
ll power(ll a,ll b)
{
  if(b==0)return 1;
  if(b==1)return a;
  ll t=power(a,b/2);
  t%=hell;
  t*=t;
  t%=hell;
  if(b%2)return (t*a)%hell;
  else
     return t;
}
//CODE------------------------------------------
ll solve()
{
    ll a=0,b=0,x;
    rep(i,0,3)
    {
        cin>>x;
        if(x==5) a++;
        if(x==7) b++;
    }
    if(a==2 && b==1)
        cout<<"YES";
    else cout<<"NO";
    return 0;
}
//MAIN------------------------------------------
signed main(){
    IOS
    #ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--) {
        solve();
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.text.*;

class Main{
public static void main(String[] args){
Scanner s = new Scanner(System.in);
	  double r = s.nextDouble();
	  double m = r*r*3.14159265359;
	  double n = 2*r*3.14159265359;
	  DecimalFormat fm = new DecimalFormat("#.######");
      System.out.println(fm.format(m)+" "+fm.format(n));
	 }
	}

Measured memory_bytes: 18460
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 10000000000005
#define MOD 1000000007
#define N 300005
#define M 15000005
#define LOG 1000000
#define KOK 650
#define EPS 0.00001
using namespace std;

int n,a[N],b[N];
bool dp[55][55];
vector<int>s; 
ll ans;

bool ok(int bit) {

	vector<int> cur;

	for(int i:s) cur.pb(i);

	for(int i=1;i<bit;i++) cur.pb(i);

	memset(dp,0,sizeof(dp));

	for(int i=0;i<=50;i++) {

		dp[i][i]=1;

		for(int j=0;j<=i;j++) {

			for(auto x:cur) {

				dp[i][j]|=dp[i%x][j];

			}

		}

	}

	for(int i=1;i<=n;i++) {

		if(!dp[a[i]][b[i]]) return false;

	}

	return true;

}

int main() {

//	freopen("input.txt","r",stdin);

//	freopen("ufakgcd.gir","r",stdin);
//	freopen("ufakgcd.cik","w",stdout);

	scanf("%d",&n);

	for(int i=1;i<=n;i++) {

		scanf("%d",a+i);

	}

	for(int i=1;i<=n;i++) {

		scanf("%d",b+i);

	}

	if(!ok(51)) {

		printf("-1");return 0;

	}

	for(int i=50;i>=1;i--) {

		if(!ok(i)) {

			s.pb(i);

			ans+=(1ll<<i);

		}

	}

	printf("%lld",ans);

}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  if ((a == 1 && b == 2) || (a == 2 && b == 1)) cout << "3" << endl;
  else if ((a == 3 && b == 2) || (a == 2 && b == 3)) cout << "1" << endl;
  else if ((a == 3 && b == 1) || (a == 1 && b == 3)) cout << "2" << endl;
}

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

using namespace std;

int main (void) {
    int N;
    cin >> N;
    map<int, int> A;
    int a;
    for ( int i=0; i<N; i++ ) {
        cin >> a;
        A[a]++;
    }

    int ans = 0;
    for ( pair<int, int> itr : A ) {
        if ( itr.second % 2 != 0 )
            ans ++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <queue>

using namespace std;

int main() {
    int n, m, i;
    priority_queue<long long> pque;
    cin >> n >> m;
    long long ans = 0;

    for (i = 0; i < n; i++) { 
        long long a;    cin >> a;
        pque.push(a);
    }

    while (m) {
        long long a = pque.top();
        pque.pop();
        a /= 2;
        pque.push(a);
        m--;
    }

    while (!pque.empty()) {
        ans += pque.top();
        pque.pop();
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
	string s; cin >> s;
	vector<int>ans(s.size());
	for (int rep = 0; rep < 2; rep++) {
		int cnt = 0;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == 'R')cnt++;
			else {
				ans[i] += cnt / 2;
				ans[i - 1] += (cnt + 1) / 2;
				cnt = 0;
			}
		}

		reverse(s.begin(), s.end());
		reverse(ans.begin(), ans.end());
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == 'R')s[i] = 'L';
			else s[i] = 'R';
		}
	}
	for (auto&& x : ans)cout << x << ' ';
	cout << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    mint dp[100][4][4][4];
    //A:0 C:1 G:2 T:3
    rep(i,n) rep(j,4) rep(k,4) rep(l,4) dp[i][j][k][l] = 0;
    rep(i,3) rep(j,4) rep(k,4) rep(l,4) {
        if(j == 0 && k == 2 && l == 1) continue; //AGC
        if(j == 0 && k == 1 && l == 2) continue; //ACG
        if(j == 2 && k == 0 && l == 1) continue; //GAC
        dp[i][j][k][l] = 1;
    }
    
    for(int i = 2; i < n-1; i++) rep(j,4) rep(k,4) rep(l,4) rep(m,4){
        if(k == 0 && l == 2 && m == 1) continue; //AGC
        if(k == 0 && l == 1 && m == 2) continue; //ACG
        if(k == 2 && l == 0 && m == 1) continue; //GAC
        if(j == 0 && k == 2 && l == 2 && m == 1) continue; //AGGC
        if(j == 0 && k == 2 && l == 3 && m == 1) continue; //AGTC
        if(j == 0 && k == 3 && l == 2 && m == 1) continue; //ATGC
        dp[i+1][k][l][m] += dp[i][j][k][l];
    }
    mint ans = 0;
    rep(j,4) rep(k,4) rep(l,4) ans += dp[n-1][j][k][l];
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

const int mod = 1000000007;

struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

auto g = make_vec<int>(0, 0);
auto dp = make_vec<int>(0, 0);

int dfs(int v, int p=-1, int c=0) {
    if (dp[v][c] != -1) return dp[v][c];
    if (c == 0) {
        mint white = 1;
        mint black = 1;
        for (int u : g[v]) {
            if (u == p) continue;
            white *= dfs(u, v, 0);
            black *= dfs(u, v, 1);
        }
        mint res = white + black;
        return dp[v][c] = res.x;
    } else {
        mint res = 1;
        for (int u : g[v]) {
            if (u == p) continue;
            res *= dfs(u, v, 0);
        }
        return dp[v][c] = res.x;
    }
}

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

    int n;
    cin >> n;
    g.resize(n);
    rep(i, n-1) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dp = make_vec<int>(n, 2);
    fill_v<int>(dp, -1);
    cout << dfs(0) << endl;
}


Measured memory_bytes: 22304
#include <stdio.h>
int main()
{
    int a[3];
    while(~scanf("%d%d%d",&a[0],&a[1],&a[2]))
    {
        int max,min,i;
        max=min=a[0];
       if(a[1]==a[0]&&a[1]==a[2])
       {
           printf("0\n");
       }
       else
       {
           for(i=1;i<3;i++)
           {
               if(max<a[i])
                max=a[i];
                if(min>a[i])
                min=a[i];

           }
           printf("%d\n",max-min);
       }
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#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


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

    if (A >= 13) print(B);
    else if (A <= 12 && A >= 6)  print(B/2);
    else print(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(){
    int a,b,c,d; cin>>a>>b>>c>>d;
    string ans="";
    rep(i,c-a)ans+='R';
    rep(i,d-b)ans+='U';
    rep(i,c-a)ans+='L';
    rep(i,d-b+1)ans+='D';
    rep(i,c-a+1)ans+='R';
    rep(i,d-b+1)ans+='U';
    ans+="LU";
    rep(i,c-a+1)ans+='L';
    rep(i,d-b+1)ans+='D';
    cout<<ans<<'R'<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;

typedef pair<ll, int> P;
ll a[200005];
int n;
vector<int> g[200005];
stack<P> s;
ll ans[200005];
const ll INF = 1e12;

vector<ll> lcs(200005, INF);
int pos;

void dfs(int v, int prev)
{
    bool change = false;
    int f = lower_bound(lcs.begin(), lcs.end(), a[v]) - lcs.begin();
    if (f >= pos)
    {
        lcs[f] = a[v];
        pos++;
    }
    else
    {
        change = true;
        s.push(P(lcs[f], f));
        lcs[f] = a[v];
    }

    /* cout << "v = " << v << "   pos = " << pos << "f = " << f << endl;
    for (int i = 0; i < 3; i++)
        cout << "lcs[" << i << "] = " << lcs[i] << endl;
*/
    for (int i = 0; i < g[v].size(); i++)
    {
        int u = g[v][i];
        if (u == prev)
            continue;
        dfs(u, v);
    }
    ans[v] = pos;
    if (change)
    {
        P e = s.top();
        s.pop();
        lcs[e.second] = e.first;
    }
    else
    {
        pos--;
        lcs[pos] = INF;
    }
    return;
}

int main()
{

    cin >> n;

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

    for (int i = 0; i < n - 1; i++)
    {
        int u, v;
        cin >> u >> v;

        u--;
        v--;

        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(0, -1);

    for (int i = 0; i < n; i++)
        cout << ans[i] << endl;
}

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

struct ank
{
    string city;
    int id, points;
};

vector<ank> v;

bool cmp( ank a, ank b)
{
    if(a.city == b.city) return a.points > b.points;
    else return a.city < b.city;
}

int main()
{
    ank input;
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        string s;
        int p;
        cin >> s >> p;
        input.city = s;
        input.id = i;
        input.points = p;
        v.push_back(input);
    }
    sort(v.begin(), v.end(), cmp);
    for(auto x: v)
    {
        cout << x.id << "\n";
        //<<x.city << " "<<x.points<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 105
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
struct node {
    int to,next;
    int64 cap;
}E[MAXN * MAXN * 2];
int sumE = 1,head[MAXN],S,T;
int64 a[MAXN];
void add(int u,int v,int64 c) {
    E[++sumE].to = v;
    E[sumE].next = head[u];
    E[sumE].cap = c;
    head[u] = sumE;
}
void addtwo(int u,int v,int64 c) {
    add(u,v,c);add(v,u,0);
}
int gap[MAXN],dis[MAXN],last[MAXN];
int64 sap(int u,int64 aug) {
    if(u == T) return aug;
    int64 flow = 0;
    for(int i = last[u] ; i ; i = E[i].next) {
	int v = E[i].to;
	if(E[i].cap > 0) {
	    if(dis[v] + 1 == dis[u]) {
		int64 t = sap(v,min(E[i].cap,aug - flow));
		E[i].cap -= t;E[i ^ 1].cap += t;
		flow += t;
		if(flow == aug) return flow;
		if(dis[S] >= T) return flow;
	    }
	}
    }
    if(--gap[dis[u]++] == 0) dis[S] = T;
    ++gap[dis[u]];
    last[u] = head[u];
    return flow;
}
void Solve() {
    read(N);
    int64 ans = 0,tmp = 0;
    for(int i = 1 ; i <= N ; ++i) {
	read(a[i]);
	ans += a[i];
    }
    S = N + 1,T = N + 2;
    for(int i = 1 ; i <= N ; ++i) {
	if(a[i] > 0) addtwo(i,T,a[i]);
	else if(a[i] < 0) {
	    addtwo(S,i,-a[i]);
	    tmp -= a[i];
	}
    }
    for(int i = 1 ; i <= N ; ++i) {
	int t = 2 * i;
	while(t <= N) {
	    addtwo(i,t,2e9);
	    t += i;
	}
    }
    for(int i = 1 ; i <= N + 2 ; ++i) last[i] = head[i];
    while(dis[S] < T) tmp -= sap(S,1e18);
    ans += tmp;
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <memory.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <queue>
#pragma comment(linker, "/STACK:1000000000")
using namespace std;
typedef long long LL;
typedef double D;

int c[100][100];

int main()
{
	ios::sync_with_stdio(0);
	bool d = 1;
	int H, W, n, a, x = 0, y = 0;
	cin >> H >> W >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a;
		while (a)
		{
			c[y][x] = i + 1;
			if (d)
				y++;
			else
				y--;
			if ((d && y == H) || (!d && y == -1))
			{
				if (d)
					y = H - 1;
				else
					y = 0;
				d ^= 1;
				x++;
			}
			a--;
		}
	}
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
			cout << c[i][j] << ' ';
		cout << '\n';
	}
}

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

int main() {
  ll n;
  cin >> n;
  string s;
  ll ac=0;
  ll wa=0;
  ll tle=0;
  ll re=0;
  for (ll i=0;i<n;i++) {
    cin >> s;
    if (s=="AC") {
      ac+=1;
    } else if (s=="WA") {
      wa+=1;
    } else if (s=="TLE") {
      tle+=1;
    } else if (s=="RE") {
      re+=1;
    }
  }
  
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\Users\Joeon\Desktop\IN.txt", "r", stdin);
//		freopen("C:\Users\Joeon\Desktop\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n = next<int>(), cnt = 0, p = 100;
	while(p < n) p *= 1.01, cnt++;
	cout<<cnt<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}


Measured memory_bytes: 3608
from fractions import gcd
N = int(input())
array = list(map(int,input().split()))
all_gcd = [0]*N
#calc from start to end
gcd_L = [array[0]]
for i in range(N-1):
  gcd_L.append(gcd(gcd_L[-1],array[i+1]))
  
#calc from end to start
gcd_R = [array[-1]]
for j in range(N-1,0,-1):
  gcd_R.append(gcd(gcd_R[-1],array[j-1]))
  
gcd_arr = []
  
for idx in range(N):
  if idx==0:
    gcd_arr.append(gcd_R[-2])
  elif idx==N-1:
    gcd_arr.append(gcd_L[-2])
  else:
    gcd_arr.append(gcd(gcd_L[idx-1],gcd_R[N-1-idx-1]))
print(max(gcd_arr))



Measured memory_bytes: 16124
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
	Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	if(n>=400&&n<=599) {
		System.out.println("8");
	}else if(n>=600&&n<=799) {
		System.out.println("7");
	}else if(n>=800&&n<=999) {
		System.out.println("6");
	}else if(n>=1000&&n<=1199) {
		System.out.println("5");
	}else if(n>=1200&&n<=1399) {
		System.out.println("4");
	}else if(n>=1400&&n<=1599) {
		System.out.println("3");
	}else if(n>=1600&&n<=1799) {
		System.out.println("2");
	}else if(n>=1800&&n<=1999) {
		System.out.println("1");}
}
}


Measured memory_bytes: 35724
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int N;
    cin >> N;
    vector<vector<int>> A(2, vector<int>(N, 0));
    REP (i, 2) REP (j, N) cin >> A[i][j];
    REP (j, N - 1) {
        A[0][j + 1] += A[0][j];
        A[1][N - j - 2] += A[1][N - j - 1];
    }
    int ans = 0;
    REP (i, N) ans = max(ans, A[0][i] + A[1][i]);
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<tuple<string, int, int>> a;
    for(int i = 1; i <= n; i++){
        string s;
        int p;
        cin >> s >> p;
        p = -p;
        a.push_back(tie(s,p,i));
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < n; i++){
        cout << get<2>(a[i]) << endl;
    }
}
  


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

int main(){
  int N;
  cin >> N;
  vector<float> A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  float value = A[0];
  for(int j=1;j<N;j++){
    value = (value+A[j])/2.0;
  }
   printf("%.6f\n",value);
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cmath>
#define int long long

using namespace std;

int k;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;}

int quick_mul(int a,int b,int mod)
{
    int res=0;
    while(b)
    {
        if(b&1) res=(res+a)%mod;
        a=(a+a)%mod;
        b>>=1;
    }
    return res;
}

int quick_pow(int a,int b,int mod)
{
    int res=1;
    while(b)
    {
        if(b&1) res=quick_mul(res,a,mod);
        a=quick_mul(a,a,mod);
        b>>=1;
    }
    return res;
}

int ge(int x){
	int y=x;
	for(int i=2;i<=x/i;++i){
		if(x%i==0){
			while(x%i==0)
				x/=i;
			y=y/i*(i-1);
		}
	}
	if(x>1) y=y/x*(x-1);
	return y;
}

signed main(){
	cin>>k;
	int c=k/gcd(k,7)*9;
	int r=1e10;
	if(gcd(10,c)!=1) r=0;
	else{
		int pc=ge(c);
		for(int i=1;i<=pc/i;++i)
			if(pc%i==0){
				if(quick_pow(10,i,c)==1)
					r=min(r,i);
				if(quick_pow(10,pc/i,c)==1)
					r=min(r,pc/i);
			}
	}
	if(r==0)
		cout<<-1<<endl;
	else
		cout<<r<<endl;
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b; cin >> a >> b;
    if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    if n == 0:
        print(0)
    else:
        ans = []
        while n:
            if n % -2 == 0:
                ans.append("0")
                n //= -2
            else:
                ans.append("1")
                n //= -2
                n += 1
        ans.reverse()
        print("".join(ans))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include<iomanip>
using namespace std;

int main()
{
    int N;
    cin >> N;
    double num;
    int a;
    int counter=0;
    for (int i = 1; i < N+1; i++)
    {
        num = log10(i);
        a = num;
        if(a%2==0)counter++;
    }
    cout << counter << endl;
}

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

using namespace std;

int main()

{

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

    sort(arr, arr+3);
    if(arr[0] == 5 && arr[1] == 5 && arr[2] == 7)
        cout << "YES";
    else
        cout <<"NO";

}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			String[] s = str.split(" ",0);
			int x = Integer.parseInt(s[0]);
			int t = Integer.parseInt(s[1]);
			int ans;
			if(x - t >= 0) {
				ans = x -t;
			}else {
				ans = 0;
			}
			System.out.println(ans);

//			long max  = 1000000007;
		}catch (Exception e) {
			System.exit(0);
		}
	}

}


Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <complex>
#include <vector>
#include <algorithm>
using namespace std;

typedef complex<double> P; /* ツ点 */

int main(){
	int n;
	cin>>n;
	double x1, y1, x2, y2, x3, y3;
	while(cin>>x1>>y1>>x2>>y2>>x3>>y3){
		double a1 = 2*(x2-x1);
		double b1 = 2*(y2-y1);
		double c1 = x1*x1-x2*x2+y1*y1-y2*y2;
		double a2 = 2*(x3-x1);
		double b2 = 2*(y3-y1);
		double c2 = x1*x1-x3*x3+y1*y1-y3*y3;
		double cx = (b1*c2-b2*c1)/(a1*b2-a2*b1);
		double cy = (c1*a2-c2*a1)/(a1*b2-a2*b1);
		P cen2 = P(cx, cy);
		double r2 = abs(P(x1,y1)-cen2);

		printf("%.3f %.3f %.3f\n", real(cen2), imag(cen2), r2);
	}
	return 0;
}

Measured memory_bytes: 0
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

N = int(input())
lst = [int(input()) for i in range(N)]

for l in lst:
    for i in range(3):
        if a[i] == l:
            a[i] = "〇"
        if b[i] == l:
            b[i] = "〇"
        if c[i] == l:
            c[i] = "〇"
            
if a[0] == a[1] == a[2]:
    print("Yes")
elif b[0] == b[1] == b[2]:
    print("Yes")
elif c[0] == c[1] == c[2]:
    print("Yes")
elif a[0] == b[0] == c[0]:
    print("Yes")
elif a[1] == b[1] == c[1]:
    print("Yes")
elif a[2] == b[2] == c[2]:
    print("Yes")
elif a[0] == b[1] == c[2]:
    print("Yes")
elif a[2] == b[1] == c[0]:
    print("Yes")
else:
    print("No")

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

#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second

typedef long long ll;
const int dx[] = {0,1,0,-1};
const int dy[] = {1,0,-1,0};

int main(){
//    ifstream in("cin.txt");
//    cin.rdbuf(in.rdbuf());
    int h,w,c;
    while(cin >> h >> w >> c,h){
        int ma = 0;
        int p[10][10] = {};
        rep(y,h)rep(x,w) cin >> p[y][x];
        int a[6] = {};
        rep(bit,pow(6,4)){
            int tmp_bit = bit;
            rep(i,4){
                a[i] = tmp_bit%6;
                tmp_bit/=6;
                a[i]+=1;
                if(a>0 && a[i-1] == a[i]) a[0] = -1;
//                cout << a[i] << " ";
            }
            if(a[0] == -1 || a[3] == c) continue;
//            cout << endl;
            a[4] = c;
//            rep(i,c) cout << a[i] << " ";
//            cout << endl;
            int t[10][10];
            rep(y,h)rep(x,w) t[y][x] = p[y][x];

            rep(i,5){

                queue<pii> que;
                que.push(pii(0,0));
                int now_color = t[0][0];
                bool u[10][10] = {};
                while(!que.empty()){
                    int x,y;
                    tie(x,y) = que.front();
                    que.pop();
                    if(u[y][x]) continue;
                    u[y][x] = true;
                    t[y][x] = a[i];
                    rep(d,4){
                        int nx = x + dx[d];
                        int ny = y + dy[d];
                        if(nx < 0 || w <= nx ||
                                ny < 0 || h <= ny) continue;
                        if(u[ny][nx] || t[ny][nx] != now_color) continue;
                        que.push(pii(nx,ny));
                    }
                }
            }
            int cnt = 0;
            queue<pii> qe;
            qe.push(pii(0,0));
            bool uu[10][10] = {};

            while(!qe.empty()) {
                int xp, yp;

                tie(xp, yp) = qe.front();
                qe.pop();
                if(uu[yp][xp]) continue;
                cnt += 1;
                uu[yp][xp] = true;
                rep(d, 4) {
                    int nx = xp + dx[d];
                    int ny = yp + dy[d];
                    if (nx < 0 || w <= nx ||
                        ny < 0 || h <= ny)
                        continue;
                    if(uu[ny][nx]) continue;
                    if(t[ny][nx] != c) continue;
                    qe.push(pii(nx, ny));
                }
            }
            ma = max(ma,cnt);
        };
        cout << ma << endl;

    }
    return 0;
}


Measured memory_bytes: 3060
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <functional>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define MAX_DWORD				(0xFFFFFFFF)
#define	MAX_SDWORD				((SDWORD)0x7FFFFFFF)
#define	MIN_SDWORD				((SDWORD)0x80000000)
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define	MIN_QWORD				((QWORD)0x0000000000000000)
#define	MAX_SQWORD				((SQWORD)0x7FFFFFFFFFFFFFFF)
#define	MIN_SQWORD				((SQWORD)0x8000000000000000)
#define M_PI					3.14159265358979323846

typedef long					SDWORD;
typedef long long				SQWORD;
typedef unsigned long			DWORD;
typedef unsigned long long int	QWORD;
typedef pair<int, int>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
#define N_MAX	(200 * 1000)
#define K_MAX	(10)
#define M_MAX	(10)
#define H_MAX	(1000)
#define W_MAX	(1000)

int main()
{
	int N;
	const int A = 0;
	const int G = 1;
	const int C = 2;
	const int T = 3;

	cin >> N;
	static int dp[101][4][4][4];
	dp[0][0][0][0] = 1;	// [0文字][3文字前][2文字前][1文字前]
	REP(k, 4) {
		REP(l, 4) {
			REP(m, 4) {
				if ((k == A) && (l == G) && (m == C) ||
					(k == A) && (l == C) && (m == G) ||
					(k == G) && (l == A) && (m == C)) {
					continue;
				}
				dp[2][k][l][m] = 1;
			}
		}
	}

	for (int i = 2; i < N - 1; i++) {
		REP(j, 4) {
			REP(k, 4) {
				REP(l, 4) {
					REP(m, 4) {
						// jklm	
						// 3210  jklm  jklm  jklm  jklm
						// ?AGC, ?ACG, ?GAC, A?GC, AG?C
						if ((k == A) && (l == G) && (m == C) ||
							(k == A) && (l == C) && (m == G) ||
							(k == G) && (l == A) && (m == C) ||
							(j == A) && (l == G) && (m == C) ||
							(j == A) && (k == G) && (m == C)) {
							continue;
						}
						// i+1桁目[] += i桁目の一桁ずれた値
						dp[i + 1][k][l][m] += dp[i][j][k][l];
						dp[i + 1][k][l][m] %= MOD;
					}
				}
			}
		}
	}

	int ans = 0;
	REP(i, 4) {
		REP(j, 4) {
			REP(k, 4) {
				ans += dp[N - 1][i][j][k];
				ans %= MOD;
			}
		}
	}

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



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,m;
set<int> po[252521];

int main(){
  scanf("%d%d",&n,&m);
  REP(i,m){
    int a,b;
    scanf("%d%d",&a,&b);
    --a;--b;
    po[a].insert(b);
    po[b].insert(a);
  }
  for(int to : po[0]){
    if(po[n-1].count(to)){
      puts("POSSIBLE");
      return 0;
    }
  }
  puts("IMPOSSIBLE");
  return 0;
  return 0;
}


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

using namespace std;

#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 sq(x) ((x) * (x))
#define bit(x) bitset<8>(x)
#define vsort(v)  sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<int>())
#define debug(x) cout << #x << " " << (x) << endl
#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1e9+7

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


template<typename Tn> Tn __lcm(Tn a, Tn b)
{
    return a / __gcd(a, b) * b;
}


int main()
{
    int n, k;
    int h;
    ci >> n >> k;

    int cnt = 0;
    
    rep(i, 0, n) {
	ci >> h;
	if(h >= k) cnt++;
    }

    co << cnt << en;
      
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[100],b[100];
long long i,ii,s=0;
int main()
{
cin>>a>>b;
ii=strlen(a);
for(i=0;i<strlen(a);i++,ii++)
{
	a[ii]=b[i];
}
for(i=0;i<strlen(a);i++)
{
s=s+a[i]-48;
if (i+1<strlen(a)) s*=10;
}
if (sqrt(s)==int(sqrt(s))) cout<<"Yes";
else cout<<"No";
cout<<endl;
return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

void conv(int t)
{
	char tbl[] = "01235789";
	bool flag = false;
	
	for (int i = 30; i >= 0; i -= 3){
		if (flag == true || (t >> i) & 7){
			flag = true;
			printf("%c", tbl[(t >> i) & 7]);
		}
	}
	
	printf("\n");
}

int main()
{
	int n;
	
	while (scanf("%d", &n) && n){
		conv(n);
	}
	
	return (0);
}

Measured memory_bytes: 1000
private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }

fun eratosthenes(bound: Int): Array<Boolean> {
    val primeList = Array(bound + 2) { true }
    val sieveBound = Math.ceil(Math.sqrt(bound.toDouble())).toInt()
    primeList[0] = false
    primeList[1] = false
    for (i in 2 .. sieveBound) {
        if (!primeList[i]) continue
        for (j in (2 * i .. bound).step(i)) {
            primeList[j] = false
        }
    }
    return primeList
}

fun Array<Boolean>.toPrimes() = mapIndexedNotNull { index, isPrime -> if (isPrime) index else null }

fun main(args: Array<String>) {
    val N = readInts()[0]
    val answer = eratosthenes(55555).toPrimes().filter { it % 5 == 1 }.take(N)
    println(answer.joinToString(" "))
}

Measured memory_bytes: 38004
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{ 
    static void Main(string[] args)
    {
        var num = Input.num;
        var dic = Calculation.Factorize(num);
        WriteLine($"{num}: {string.Join(" ", dic.Select(pair => string.Join(" ", Enumerable.Repeat(pair.Key, pair.Value))))}");
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const double eps = 1e-11;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

public class Calculation
{
    public static int LCM(int num1, int num2)
    {
        return num1 / GCD(num1, num2) * num2;
    }

    public static long LCM(long num1, long num2)
    {
        return num1 / GCD(num1, num2) * num2;
    }

    public static int GCD(int num1, int num2)
    {
        return num1 < num2 ? GCD(num2, num1) :
            num2 > 0 ? GCD(num2, num1 % num2) : num1;
    }

    public static long GCD(long num1, long num2)
    {
        return num1 < num2 ? GCD(num2, num1) :
            num2 > 0 ? GCD(num2, num1 % num2) : num1;
    }

    public static List<int> GetPrime(long num)
    {
        if (num < 2) return new List<int>();
        var prime = new List<int> { 2 };
        var bo = new bool[num + 1];
        for (var i = 3; i <= num; i += 2)
            if (!bo[i])
            {
                prime.Add(i);
                for (var j = 3 * i; j <= num; j += 2 * i)
                    bo[j] = true;
            }
        return prime;
    }

    public static Dictionary<long,int> Factorize(long num)
    {
        var dic = new Dictionary<long, int>();
        for(var i = 2; i * i <= num; i++)
        {
            var ct = 0;
            while (num % i == 0)
            {
                ct++;
                num /= i;
            }
            if (ct != 0) dic[i] = ct;
        }
        if (num != 1) dic[num] = 1;
        return dic;
    }
}



Measured memory_bytes: 20588
import numpy as np

num = np.array(list(map(int, input().split())))
surplus = num % 2

sum_sur = sum(surplus)

count = 1
if sum_sur == 1:
    index = np.argmax(surplus)
    num += 1
    num[index] -= 1
    
elif sum_sur == 2:
    index = np.argmin(surplus)
    num += 1
    num[index] -= 1
else:
    count = 0

max_num = max(num)
max_index = np.argmax(num)

num = max_num - num
count += sum(num // 2)

print(count)


Measured memory_bytes: 12504
#include<stdio.h>

int main(void){
    int ng,rg,pg;
    scanf("%d %d %d",&ng,&rg,&pg);
    if((ng+rg)>=pg)	printf("%d\n",rg+pg);
    else		printf("%d\n",ng+2*rg+1);

    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
		int a,s,d;
		scanf("%d %d %d",&a,&s,&d);
		if(a==1&&s==0&&d==0||a==0&&s==1&&d==0||a==0&&s==0&&d==0){
				printf("Close\n");
				}
		else{
			printf("Open\n");
			}
	return 0;
}

Measured memory_bytes: 1012
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	long long n;
	int m,i,x,j,y;
	cin>>n;
	m=sqrt(n);
	for(i=m;i>=1;i--)if(n%i==0){x=i;break;}
	y=n/i;
	for(i=0;x!=0;i++)x=x/10;
	for(j=0;y!=0;j++)y=y/10;
	cout<<max(i,j)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CK(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second
#define ll long long;

const int INF = 1e9;
const long long  LLINF = 1e15;

using namespace std;

int n;
int a[200010];

int main() {
  cin>>n;
  REP(i,0,n) cin>>a[i];

  int l=-1, r=1;
  vector<pair<int,int> > b;
  REP(i,0,n){
    if(i%2==0){
      b.push_back(make_pair(l,a[i]));
      l--;
      //b = a[i] + b;
    }else{
      b.push_back(make_pair(r,a[i]));
      r++;
      //b += a[i];
    }
  }
  sort(b.begin(),b.end());

  if(n%2==0) {
    RREP(i,0,b.size()) cout<<b[i].S<<" ";
  }else{
    REP(i,0,b.size()) cout<<b[i].S<<" ";
  }
  cout<<endl;

  return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int h, w, n;

char c[1001][1001];
int d[1001][1001];
int sx, sy;
int ans = 0;

void bfs()
{

    for (int i = 1; i <= n; i++)
    {
        rep(s, h) rep(t, w) d[s][t] = 0;
        queue<pii> q;
        q.push(pii(sx, sy));
        while (!q.empty())
        {
            pii p = q.front();
            q.pop();

            if (c[p.first][p.second] == (char)(i + '0'))
            {
                sx = p.first, sy = p.second;
                ans += d[sx][sy];
                break;
            }
            rep(j, 4)
            {
                int nx = p.first + dx[j], ny = p.second + dy[j];

                if (!(0 <= nx && nx < h && 0 <= ny && ny < w) || d[nx][ny] > 0)
                    continue;

                if (c[nx][ny] == 'X')
                    continue;

                q.push(pii(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
}

int main()
{
    cin >> h >> w >> n;
    rep(i, h)
    {
        rep(j, w)
        {
            cin >> c[i][j];
            if (c[i][j] == 'S')
                sx = i, sy = j;
        }
    }
    bfs();
    OP(ans);

    return 0;
}


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


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

    ll sum = 0;
    ll max_height = A[0];
    for(int i = 1; i < N; i++){
        if(A[i] < max_height){
            sum += max_height - A[i];
        }
        else{
            max_height = A[i];
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 4832
#include<stdio.h>
int main(){
 int a,b,c;
 int yakusu,i;
 
 scanf("%d %d %d\n",&a,&b,&c);
 yakusu=0;

 for(i=a;i<=b;i++){
  if(c%i==0){
   yakusu+=1;
  }
 }

 printf("%d\n",yakusu);

return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef vector <ll> vi;                 // Vector of long long
typedef vector <vi> vvi;                // Vector of vi
typedef vector <pair<ll,ll>> ii;        // Vector of pairs
#define ff first                        // For pairs
#define ss second                       // For pairs
#define sz(a) int((a).size())           // Function to determine size of any container
#define pb push_back                    // Pushback to vector
#define mp make_pair                    // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()   // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
#define MAX (ll)(1e6 + 5)

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

    ll arr[MAX] = {};
    for (ll i = 2; i < MAX; i++)
    {
        if (arr[i] == 0)
        {
            for (ll j = i * i; j < MAX; j += i)
                arr[j] = 1;
        }
    }

    ll x;
    cin >> x;

    for (int i = x; i < MAX; i++)
    {
        if (arr[i] == 0)
        {
            cout << i << "\n";
            return 0;
        }
    }
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
#include <iostream>
//#include <vector>
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll maxn = 1000000000;

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

}

Measured memory_bytes: 256