akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
#define P(a,b) make_pair(a,b);
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];
  bool flag = 1;
  rep(i,N){
    if(A[i] % 2 == 0){
      if(A[i] % 3 != 0 && A[i] % 5 != 0) flag = 0;
    }
  }
  if(flag){
    cout  << "APPROVED" << endl;
  }else{
    cout << "DENIED" << endl;
  }
}


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

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

  int N;
  cin >> N;
  int A[N];
  rep(i, N){
    cin >> A[i];
  }
  int j = 0;
  bool ans= false;
  int ans1;
  rep(i, N*10){
    j = A[j] - 1;
    if(j == 1){
      ans = true;
      ans1 = i+1;
      break;
    }
  }
  if(ans) cout << ans1 << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(int argc, char const *argv[])
{
    int n,a,b;

    scanf("%d",&n);
    if(n==1){
        printf("Hello World\n");
    }else if(n==2){
        scanf("%d",&a);
        scanf("%d",&b);
        int result = a+b;
        printf("%d\n",result);
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(void){
    // Your code here!
    int n,l;
    string s[110];
    cin  >> n >>l ;
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    sort(s,s+n);
    for(int i=0;i<n;i++){
        cout << s[i];
    }
    cout <<endl;
}

Measured memory_bytes: 256
#python3
from math import factorial
MOD = int(1e9+7)
INF = int(1e9)

def comb(n, m, mod):
    comb_a = 1
    for i in range(m):  
        comb_a *= (n-i)
        comb_a %= mod
    comb_b = factorial(m)%mod
    comb_b = pow(comb_b, mod-2, mod)
    return (comb_a * comb_b) % mod
    
def main():
    n, a, b = map(int, input().split())
    print((pow(2, n, MOD)-1-comb(n, a, MOD)-comb(n, b, MOD))%MOD)
main()

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

void we_r_done(){cout<<"NO"; exit(0);}

void debug(string mssg){cout<<mssg; exit(0);}


int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;

    int n;
    scn(n);
    int a[n+1] , res[n+1];

    for(int i=1; i<=n; i++)scn(a[i]);

    for(int lo=1,hi=n , now = n ; lo<=hi; lo++, hi--){

        res[lo] = a[now];
        if(lo < hi) res[hi] = a[now-1];
        now -= 2;
    }
    for(int i=1; i<=n; i++)printf("%d ",res[i]);
    return 0;
    ///return main();
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///priority_queue< int, vector< int >, greater< int > > minHeap;
///using bs = bitset<MX>; // how many distinct number can be form?


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    vector<ll> C(N);
    REP(i,N){
        cin >> A[i];
        B[i] = -A[i]+i;
        C[i] = -A[i]-i;
    }
    sort(ALL(B));
    sort(ALL(C));
    ll count = 0;
    REP(i,N){
        count+=upper_bound(ALL(B),A[i]+i) - lower_bound(ALL(B),A[i]+i);
    }
    cout << count << "\n";
}


Measured memory_bytes: 7952
#include <iostream>
#include <cmath>
using namespace std;
#define EPS 1e-9

double get_distance( double x1, double y1, double x2, double y2 )
{
	return sqrt( ( x2 - x1 ) * ( x2 - x1 ) + ( y2 - y1 ) * ( y2 - y1 ) );
}

double get_sum( double x1, double y1, double x2, double y2, double x3, double y3 )
{
	double a = get_distance( x1, y1, x2, y2 );
	double b = get_distance( x2, y2, x3, y3 );
	double c = get_distance( x3, y3, x1, y1 );
	double s = ( a + b + c ) / 2;
	return sqrt( s * ( s - a ) * ( s - b ) * ( s - c ) );
}

int main( void )
{
	double x1, y1, x2, y2, x3, y3, xp, yp;
	while ( cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp )
	{
		double s = get_sum( x1, y1, x2, y2, x3, y3 );
		double s1 = get_sum( x1, y1, xp, yp, x2, y2 );
		double s2 = get_sum( x2, y2, xp, yp, x3, y3 );
		double s3 = get_sum( x3, y3, xp, yp, x1, y1 );

		if ( fabs( s - ( s1 + s2 + s3 ) ) <= EPS ) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

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

using namespace std;

int main(){
  long long int X,Y;
  scanf("%lld %lld",&X,&Y);
  int n=0;
  while(1){
    if(X>Y) break;
    else{
      X=X*2;
      n+=1;
    }
  }
  printf("%d",n);
  return 0;
}


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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[]s = br.readLine().split(" ");
        int h = Integer.parseInt(s[0]);
        int w = Integer.parseInt(s[1]);
        int k = Integer.parseInt(s[2]);

        char[][] mat = new char[h][w];

        for(int i=0;i<h;i++){
            String s2 = br.readLine();
            for (int j = 0; j < w; j++) {
                mat[i][j] = s2.charAt(j);
            }
        }
        int ans = 0;
        for (int maskR = 0; maskR < (1 << h) - 1; maskR++) {
            for (int maskC = 0; maskC < (1 << w) - 1; maskC++) {
                int black = 0;
                for (int i = 0; i < h; i++) {
                    for (int j = 0; j < w; j++) {
                        if ( (((maskR >> i) & 1) == 0) && (((maskC >> j) & 1) == 0) && mat[i][j] == '#'){
                            black += 1;
                        }
                    }
                }
                if (black==k) ans+=1;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 32752
#include<bits/stdc++.h>
using namespace std;
void fast(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
}

int main(){
	fast();	
	int h , a;
	cin >> h >> a;
	cout << ceil((double)h/a) << "\n";

	return 0;
}


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

int main() {
  ll n, k;
  string s;
  cin >> n >> k >> s;

  vector<pair<char, int>> vec(1, P(s[0], 0));
  rep(i, n) {
    if (vec.back().first == s[i]) {
      vec.back().second++;
    } else {
      vec.emplace_back(s[i], 1);
    }
  }

  int m = vec.size();
  vector<ll> d(m + 1, 0);
  rep(i, m) d[i + 1] = d[i] + vec[i].second;

  ll ans = 0;
  rep(i, m) {
    int j = i + 2 * k;
    if (vec[i].first == '1') j++;
    j = min(j, m);
    ll tmp = d[j] - d[i];
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4920
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        class Man
        {
            public readonly int honest;
            public readonly int unkind;
            public Man(int[][] pairs)
            {
                foreach (int[] pair in pairs)
                {
                    switch (pair[1])
                    {
                    case 0: unkind |= 1 << (pair[0] - 1); break;
                    case 1: honest |= 1 << (pair[0] - 1); break;
                    }
                }
            }
        }

        static int CountBits(int n)
        {
            int cnt = 0;
            while (n > 0)
            {
                if ((n & 1) != 0) { ++cnt; }
                n >>= 1;
            }
            return cnt;
        }

        static bool Conceivable(int N, int bits, Man[] men)
        {
            for (int i = 0; i < N; ++i)
            {
                if ((bits & (1 << i)) != 0)
                {
                    if ((men[i].honest & ~bits) != 0) { return false; }
                    if ((men[i].unkind & bits) != 0) { return false; }
                }
            }
            return true;
        }

        static int Solve(int N, Man[] men)
        {
            int max = 0;
            for (int bits = 0; bits < 1 << N; ++bits)
            {
                if (Conceivable(N, bits, men)) { max = Math.Max(CountBits(bits), max); }
            }
            return max;
        }

        static void Main(string[] args)
        {
            int N = ReadInt();
            var men = new Man[N];
            for (int i = 0; i < N; ++i)
            {
                int A = ReadInt();
                var pairs = new int[A][];
                for (int j = 0; j < A; ++j) { pairs[j] = ReadInts(); }
                men[i] = new Man(pairs);
            }
            Console.WriteLine(Solve(N, men));
        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>

int main(){
	int x,a,b;
	int xa;
	int xb;
	scanf("%d %d %d", &x,&a,&b);
	if(x>a){
		xa= x-a;
	}else{
		xa= (x-a)*-1;
	}
	 if(x>b){
		xb=x-b;
	} else{
		xb=(x-b)*-1;
	}
	 if(xa<xb){
	 	printf("A");
	 }else{
	 	printf("B");
	 }
	
	
	
	return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

struct topological_sort{
    vector<vector<int>> G;
    vector<int> indegree;
    int V;

    topological_sort(int V) : V(V) {G.resize(V); indegree.resize(V);}
    void add_edge(int a, int b) {
        G[a].push_back(b);
        indegree[b]++;
    }
    vector<int> sort() {
        queue<int> q;
        vector<int> sorted;
        for (int i = 0; i < V; i++) if (indegree[i] == 0) q.push(i);
        while (!q.empty()) {
            int v = q.front(); q.pop();
            for (int i = 0; i < G[v].size(); i++) {
                int u = G[v][i];
                indegree[u]--;
                if (indegree[u] == 0) q.push(u);
            }
            sorted.push_back(v);
        }
        return sorted;
    }
};

P change(P x) {
    if (x.first > x.second) swap(x.first,x.second);
    return x;
}

int to_id(P x, vvint &to) {
    return to[x.first][x.second];
}

int main() {
    int n; cin >> n;
    topological_sort ts(n*(n-1)/2);
    vvint to(n,vint(n));
    vector<P> from(n*(n-1)/2);
    int num = 0;
    rep(i,n)rep(j,i) {
        to[j][i] = num;
        from[num] = P(j,i);
        num++;
    }
    vvint data(n,vint(n-1));
    rep(i,n)rep(j,n-1) {
        int x; cin >> x;
        x--;
        data[i][j] = x;
    }
    vvint back(n*(n-1)/2);
    rep(i,n)rep(j,n-2) {
        P p1 = P(i,data[i][j]);
        P p2 = P(i,data[i][j+1]);
        p1 = change(p1);
        p2 = change(p2);
        ts.add_edge(to_id(p1,to),to_id(p2,to));
        back[to_id(p2,to)].push_back(to_id(p1,to));
    }
    vint res = ts.sort();
    if (res.size() != n*(n-1)/2) {cout << -1 << endl; return 0;}
    vint dp(n*(n-1)/2,1);
    rep(i,n*(n-1)/2) {
        P p = from[res[i]];
        rep(j,back[to_id(p,to)].size()) {
            chmax(dp[to_id(p,to)],dp[back[to_id(p,to)][j]]+1);
        }
    }
    cout << dp[res.back()] << endl;
}


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

int main(){
  int N,M;

  cin >>N>>M;
  int LMAX = -1;
  int RMIN = 1000000; 

  for(int i = 0; i< M;i++){
      int L,R;
      cin >>L>>R;

      if((RMIN < L)||(LMAX > R)){
          cout <<0<<endl;
          return 0;

      }

      if(LMAX < L)LMAX = L;
      if(RMIN > R)RMIN = R;


  }
  cout <<(RMIN-LMAX+1)<<endl;
  return 0;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

ll K;
vec<ll> ans;

void dfs(string l) {
    if(l.size()>=11) return;
    if (l != "") ans.push_back(stol(l));
    
    int b = l.back() - '0';
    if (b != 0) dfs(l + to_string(b - 1));
    dfs(l + to_string(b));
    if (b != 9) dfs(l + to_string(b + 1));
}

int main() {
    cin >> K;
    for (int i = 1; i <= 9; ++i) {
        dfs(to_string(i));
    }
    sort(all(ans));
    cout << ans[K-1] << endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc162/abc162_c.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

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

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  ll ans = 0;
  rep(i, N) rep(j, N) rep(k, N) { ans += _gcd(_gcd(i+1, j+1), k+1); }

  cout << ans << endl;
}

Measured memory_bytes: 3648
#include<stdio.h>



int main(void){
    int a,b,c,d,e;
    int hun[5],u[5];
    int max=0;
    scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
    for(int i=0;i<14;i++){
        if(a>10*i && a<=10*(i+1)){
            hun[0]=10*(i+1);
            u[0]=hun[0]-a;
            break;
        }
    }
    for(int i=0;i<14;i++){
        if(b>10*i && b<=10*(i+1)){
            hun[1]=10*(i+1);
            u[1]=hun[1]-b;
            break;
        }
    }
    for(int i=0;i<14;i++){
        if(c>10*i && c<=10*(i+1)){
            hun[2]=10*(i+1);
            u[2]=hun[2]-c;
            break;
        }
    }
    for(int i=0;i<14;i++){
        if(d>10*i && d<=10*(i+1)){
            hun[3]=10*(i+1);
            u[3]=hun[3]-d;
            break;
        }
    }
    for(int i=0;i<14;i++){
        if(e>10*i && e<=10*(i+1)){
            hun[4]=10*(i+1);
            u[4]=hun[4]-e;
            break;
        }
    }
    for(int i=0;i<5;i++){
        if(u[i]>max){
            max=u[i];
        }
    }

    int sum=hun[0]+hun[1]+hun[2]+hun[3]+hun[4];
    printf("%d",sum-max);

    return 0;
}

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

int main() {
  int n;
  cin>>n;
  int i=1;
  while(1) {
    i*=2;
    if(i>n) {
      cout<<i/2<<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3592
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-9
#define M_PI 3.141592653589793
#define bsize 300

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 300031;

int n,a,b,c;
long long fact[N],invf[N];

long long pw(long long a,long long b){
	if (b==0)
		return 1;
	if (b%2)
		return a*pw(a,b-1)%bs;
	return pw(a*a%bs,b/2);
}

long long inv(long long x){
	return pw(x,bs-2);
}

long long C(long long n,long long m)
{
	if (n<m)
		return 0;
	long long res=fact[n];
	res*=invf[n-m];
	res%=bs;
	res*=invf[m];
	return res%bs;
}

long long ans;

long long solver(long long p1,long long p2,long long A,long long B){
	long long pp1=p1*inv(p1+p2)%bs;
	long long pp2=p2*inv(p1+p2)%bs;
	//cout<<pp1<<"@"<<pp2<<endl;
//	pp1=pp1*inv(p1+p2);
	long long prob=pw(pp1,A-1)*pw(pp2,B)%bs;
	prob*=C(A+B-1,A-1);
	prob%=bs;
	prob*=pp1;
	prob%=bs;
	prob=prob*(A+B)%bs;
	//cout<<prob<<endl;
	prob=prob*100%bs*inv(p1+p2)%bs;
	return prob;
}

int main(){
//    freopen("apache.in","r",stdin);
//    freopen("apache.out","w",stdout);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);

	cin>>n>>a>>b>>c;

	fact[0]=1;
	for (int i=1;i<N;i++){
		fact[i]=fact[i-1]*i%bs;
	}

	for (int i=0;i<N;i++){
		invf[i]=inv(fact[i]);
	}

	for (int i=0;i<n;i++){
		if (a==0)
			continue;
		ans+=solver(a,b,n,i);
		ans%=bs;
	}
	for (int i=0;i<n;i++){
		if (b==0)
		continue;
		ans+=solver(b,a,n,i);
		ans%=bs;
	}

	cout<<ans<<endl;

//    cin.get(); cin.get();
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
    int H,W;
    cin>>H>>W;
    vector<vector<int>> c(10,vector<int>(10,0));
    for (int i = 0; i < 10; ++i) {
        for (int j = 0; j < 10; ++j) {
            cin>>c[i][j];
        }
    }
    vector<int> shortest(10,0);
    for (int i = 0; i < 10; ++i) {
        if(i==1) continue;
        bool det[10]={0};
        vector<int> dist(10,(int)1e9);
        priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>> pq;
        dist[i]=0;
        pq.push({0,i});
        
        while(!pq.empty()){
            int node=pq.top().second,d=pq.top().first;
            pq.pop();
            if(det[node]) continue;
            det[node]=true;
            for (int j = 0; j < 10; ++j) {
                if(det[j]) continue;
                dist[j]=min(dist[j],dist[node]+c[node][j]);
                pq.push({dist[j],j});
            }
        }
        
        shortest[i]=dist[1];

    }
    int nums[10]={0};
    int a;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin>>a;
            if(a!=-1) nums[a]++;
        }
    }
    ll ans=0LL;
    for(int i=0;i<10;i++){
        //cout<<shortest[i];
        ans+=(ll)nums[i]*shortest[i];
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

swap_count = 0
for i in range(n):
    flag = False
    minj = i
    for j in range(i, n):
        if a[j] < a[minj]:
            minj = j
            flag = True
    if flag:
        a[i], a[minj] = a[minj], a[i]
        swap_count += 1

print(' '.join(map(str, a)))
print(swap_count)



Measured memory_bytes: 5600
#include <stdio.h>
#include <algorithm>

using namespace std;

int A[100005];

int main() {
	int N;

	scanf("%d", &N);
	for(int i = 0; i < N; i++) scanf("%d", A + i);

	sort(A, A + N);
	
	if(N % 3) {
		if(A[N - 1] == 0) printf("Yes");
		else printf("No");
	}
	else {
		//printf("%d, %d, %d\n%d %d\n", A[0], A[1], A[2], 1 ^ 2 ^ 3, A[0] ^ A[N / 2] ^ A[N - 1]);
		if(A[0] != A[N / 3 - 1] || A[N / 3] != A[N / 3 * 2 - 1] || A[N / 3 * 2] != A[N - 1] || (A[0] ^ A[N / 3] ^ A[N - 1]) != 0)
			printf("No");
		else printf("Yes");
	}
	return 0;
}


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

int main() {
  string n;
  cin >> n;
  if (n[0] == '9' || n[1] == '9') cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

int INF = 1e9 + 7;

typedef long long ll;
typedef pair<int, int> P;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> d = { 1, -1 };
	vector<ll> x(n), y(n), z(n), sum(n);
	for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i];

	ll MAX = 0;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k < 2; k++) {

				ll ans = 0;
				for (int l = 0; l < n; l++) {
					sum[l] = d[i] * x[l] + d[j] * y[l] + d[k] * z[l];
				}

				sort(sum.begin(), sum.end(), greater<>());

				for (int l = 0; l < m; l++) ans += sum[l];

				MAX = max(MAX, ans);
			}
		}
	}
	cout << MAX << endl;
}

Measured memory_bytes: 256
t=[0]
x=[0]
y=[0]
(N=gets.to_i).times do
	a,b,c=gets.split.map(&:to_i)
	t.push(a)
	x.push(b)
	y.push(c)
end

ans = "Yes"
for i in 1..N do
	dx = (x[i]-x[i-1]).abs + (y[i]-y[i-1]).abs
	dt = t[i]-t[i-1]
	if dx>dt || (dx+dt).odd?
		ans = "No"
		break
	end
end
puts ans


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  int min = a[0], max = a[0];
  for(int i = 0; i < n; i++){
    if(min > a[i]){
      min = a[i];
    }
    if(max < a[i]){
      max = a[i];
    }
  }
  cout << max - min << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define all(v) v.begin() , v.end()
#define w(x) cout << (#x) << " is " << x << "\n" ;
#define fast ios_base::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)

#define n 10000001
bool markd[n] ;
vector<ll>v ;
void sieve()
{
    ll i , j ;
    for(i = 3 ; i * i < n ; i+=2)
    {
        if(markd[i] != 1)
        {
            for(j = i * i ; j < n ; j = j + i + i)
                markd[j] = 1 ;
        }
    }
    v.pb(2);
    for(i = 3 ; i < n ; i+=2)
    {
        if(markd[i] != 1)
            v.pb(i) ;
    }
}

int main()
{
    fast;
    sieve() ;
    ll s ;
    cin >> s ;
    auto it = lower_bound(all(v) , s) ;
    if(it != v.end())
        cout << *it << "\n" ;
    return 0;
}

Measured memory_bytes: 21328
#include <stdio.h>

	int main(void){
    int a,b,c,i,num=0;
     
    scanf("%d %d %d", &a, &b, &c);
     
    for(i=a;i<=b;i++){
        if(c%i==0) num+=1;
        else num+=0;
    }
    printf("%d\n", num);
	return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
int main(void){
    int K;
    scanf("%d",&K);
    int c[32] = {1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
    printf("%d\n",c[K-1]);
    return 0;
}

Measured memory_bytes: 128
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
	auto N = readln.split[0].to!int;
	auto H = readln.split.to!(int[]);
	
	int ans;
	foreach (i, height; H) {
		bool flag = true;
		foreach (h; H[0..i]) if (h > height) flag = false;
		if (flag) ++ans;
	}
	writeln(ans);
}



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

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

    for(int i=1; i<=3; i++) {
        if (i == A || i == B) continue;
        else {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp(a, b) make_pair(a, b)
#define pb push_back

const long long MOD = 1000000007;


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

    priority_queue<ll> q;
    rep(i, n){
        cin >> a;
        q.push(a);
    }
    rep(i, m){
        ll b = q.top();
        q.pop();
        q.push(b/2);
    }

    ll sum = 0;
    while(!q.empty()){
        sum += q.top();
        q.pop();
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 1400
/*カンニング*/
#include<stdio.h>

int main(void) {
	int n, i, j;
	scanf("%d", &n);
	int a[100000], A[100000];
	for (i = 0; i<n; i++) {
		scanf("%d", &a[i]);
      	}
  
	for (i=0;i<n;i++){
      A[a[i]-1]=i+1;
    }
  
    for (i = 0; i<n; i++) {
		printf("%d\t", A[i]);
	}
	return 0;
}

Measured memory_bytes: 1536
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
  int s,w;
  cin>>s>>w;

  if(w>=s){
    cout<<"unsafe"<<endl;
  }else{
    cout<<"safe"<<endl;
  }
}


Measured memory_bytes: 3648
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n, x, t; cin >>n>>x>>t;
  if(n%x==0){
    cout <<n/x*t<<endl;
  }else{
    cout <<(n/x+1)*t<<endl;
  }
}

Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
  int N, X; cin >> N >> X;
  vector<int> m(N);
  for(int i = 0; i < N; ++i)cin >> m[i];
  int gram = 0;
  for(int i = 0; i < N; ++i){
    X -= m[i];
    ++gram;
  }
  int min = *min_element(m.begin(), m.end());
  int num = 0;
  num = X / min;
  gram += num;
  cout << gram << endl;
}

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

int main(void){
    int N, Q;
    string S;
    cin >> N >> Q;
    cin >> S;
    int L[Q], R[Q];
    for (int i=0; i<Q; i++)
    {
        cin >> L[i] >> R[i];
    }
    int cnt = 0;
    int T[N];
    T[0] = 0;
    for (int i = 0; i < N-1; i++)
    {
        if(S[i] == 'A' && S[i+1] == 'C') 
        {
            cnt++;
        }
        T[i+1] = cnt;
    }
    for (int i = 0; i < Q; i++)
    {
        cout << T[R[i]-1] - T[L[i]-1] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 2176
s = gets.chomp

n = s.length
one = s.split('') == s.split('').reverse
two = s.split('')[0..(n-1)/2-1] == s.split('')[0..(n-1)/2-1].reverse
three = s.split('')[(n+3)/2-1..n-1] == s.split('')[(n+3)/2-1..n-1].reverse

puts one && two && three ? "Yes" : "No"


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

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

  ll n, k;
  cin >> n >> k;

  ll cnt[n + 5];
  memset(cnt, 0, sizeof(cnt));

  for (ll i = 1; i <= k; i++) {
    ll x;
    cin >> x;
    for (ll j = 1; j <= x; j++) {
      ll y;
      cin >> y;
      cnt[y]++;
    }
  }

  ll res = 0;
  for (ll i = 1; i <= n; i++) {
    if (cnt[i] == 0)
      res++;
  }
  cout << res << en;
  return 0;
}


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

#define fi first
#define se second

char asd[1005][1005];
int vis[1000][1000];

queue <pair<int,int> > que;

int ar[5]={1,-1,0,0};
int arr[5]={0,0,1,-1};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	
	int z,x,c;
	cin>>z>>x>>c;
	int st1,st2;
	for(int q=1;q<=z;q++)
	{
		for(int w=1;w<=x;w++)
		{
			cin>>asd[q][w];
			if(asd[q][w]=='S')st1=q,st2=w;
		}
	}
	
	for(int q=1;q<=z;q++)
	{
		for(int w=1;w<=x;w++)vis[q][w]=INT_MAX;
	}
	
	que.push(make_pair(st1,st2));
	vis[st1][st2]=0;
	
	while(!que.empty())
	{
		pair <int,int> temp;
		temp=que.front();
		
		for(int q=0;q<4;q++)
		{
			
			if(temp.fi+ar[q]>=1 && temp.fi+ar[q]<=z && temp.se+arr[q]>=1 && temp.se+arr[q]<=x && asd[temp.fi+ar[q]][temp.se+arr[q]]=='.')
			{
				if(vis[temp.fi][temp.se]+1<=c && vis[temp.fi+ar[q]][temp.se+arr[q]]==INT_MAX)
				{
					vis[temp.fi+ar[q]][temp.se+arr[q]]=vis[temp.fi][temp.se]+1;
					que.push(make_pair(temp.fi+ar[q],temp.se+arr[q]));
				}
			}
		}
		que.pop();
	}
	int ans=INT_MAX;
	for(int q=1;q<=z;q++)
	{
		for(int w=1;w<=x;w++)
		{
			if(vis[q][w]<=c)
			{
				int mins=min(q-1,min(w-1,min(z-q,x-w)));
				int temp=mins/c;
//				cout<<"yo  "<<q<<" "<<w<<" "<<vis[q][w]<<" "<<mins<<endl;
				if(mins%c!=0)temp++;
				ans=min(ans,temp+1);
			}
		}
	}
	cout<<ans<<endl;
}

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

int main() {
  
  int N, A, B, C;
  cin >> N >> A >> B;
  C = N * A;
  
  if (B < C) {
    cout << B << endl;
  }
  
  else {
    cout << C << endl;
  }
}
    
  

Measured memory_bytes: 3644
def he(cc):
    aa = 1
    while(cc>aa*aa) :
        aa += 1
    if(cc==aa*aa) :
        return True
    else :
        return False


n,d = map(int,input().split())
a = []
b = []
cnt = 0 
for z in range(n) :
    a.append([int(x) for x in input().split(' ')])


for i in range(n-1) :
    for j in range(i+1,n) :
        c = map(lambda x,y: abs(x-y) * abs(x-y), a[i], a[j])
        # print(str(i) + ' ' + str(j) + ' ' + str(sum(c)))
        if(he(sum(c))) :
            cnt += 1

print(cnt)

Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(z, x);
    cout << x << ' ' << y << ' ' << z << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < 4; i++) {
    if (s[i] == '+') {
      ans++;
    } else {
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/*-In the name of God-
 
Author : Syed Mujtaba
Seek knowledge from the Cradle to the Grave !!
https://www.linkedin.com/in/syed-mujtaba
*/

#include <bits/stdc++.h>
using namespace std;
#define int             long long
#define ld              long double
#define ll              long long
#define pb              push_back
#define fi              first
#define se              second
#define MAXN            200064
#define mod             1000000007  //998244353 // 1e9 + 7
#define MAX             8000000000000000064LL
#define MIN            -8000000000000000064LL
#define mt              make_tuple
#define eps             1e-6
#define endl            '\n'
#define test            int T_T; cin>>T_T; while(T_T--)
#define fast_io         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

signed main()
{
   int n, m;
   cin >> n >> m;
   vector < int > adj[n + 4];
   int u, v;
   for(int i = 0; i < m; i++)
   {
      cin >> u >> v;
      adj[u].pb(v);
      adj[v].pb(u);
   }
   bool vis[n + 4];
   int par[n + 4];
   memset(vis, false, sizeof(vis));
   vis[1] = true;
   queue < pair < int, int > > q;
   q.push({1, 0});
   while(!q.empty())
   {
      int x, y;
      tie(x, y) = q.front();
      q.pop();
      par[x] = y;
      for(auto z : adj[x]){
         if(!vis[z]){
            vis[z] = true;
            q.push({z, x});
         }
      }
   }
   bool floofs = true;
   for(int i = 1; i <= n; i++)
   {
      if(!vis[i]){
         floofs = false;
         break;
      }
   }
   if(floofs){
      cout << "Yes\n";
      for(int i = 2; i <= n; i++){
         cout << par[i] << endl;
      }
   }
   else{
      cout << "No\n";
   }
}

Measured memory_bytes: 13896
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        while (in.hasNext()){
            int day = in.nextInt();
            System.out.print("Christmas");
            int n = 25 - day;
            for (int i = 0; i < n; i++) {
                System.out.print(" Eve");
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 21716
n,y=map(int,input().split())
for i in range(0,n+1):
    for j in range(0,n-i+1):
        if i*10000+j*5000+(n-i-j)*1000==y:
            print(i,j,n-i-j)
            break
    else:
        continue
    break
else:
    print("-1 -1 -1")

Measured memory_bytes: 3060
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    int n;cin>>n;
    int F[50];
    F[0]=F[1]=1;
    for(int i=2;i<=n;i++)F[i]=F[i-1]+F[i-2];
        cout<<F[n]<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------















































Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
signed main() {
  int n;
  int a[5] = {};
  string s[5] = {"AC", "WA", "TLE", "RE"};
  string t;
  
  cin >> n;
  
  for (int i = 0; i < n; i++){
    cin >> t;
    if (t == s[0]) {
      a[0]++;
    }else if (t == s[1]) {
      a[1]++;
    }else if (t == s[2]) {
      a[2]++;
    }else if (t == s[3]) {
      a[3]++;
    }
  }
  
  for (int i = 0; i < 4; i++) {
    cout << s[i] << " x " << a[i] << "\n";
  }
  
  return 0; 
}

Measured memory_bytes: 3600
#include <iostream>
#include <queue>
using namespace std;
int main(){
  string s;
  while(cin>>s,s[0]!='-'){
    int n,i,b;
    queue<char>a;
    for(i=0;i<s.size();i++)a.push(s[i]);
    cin>>n;
    while(n--){
      cin>>b;
      while(b--){
	a.push(a.front());
	a.pop();
      }
    }
    while(!a.empty()){
      cout<<a.front();
      a.pop();
    }
    cout<<endl;
  }
}

Measured memory_bytes: 3196
import bisect

n,m,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

sumA = [0]
s = 0
for a in A:
    s += a
    sumA.append(s)

s = 0
sumB = []
for b in B:
    s += b
    sumB.append(s)
# print(sumA,sumB)
ans = 0
for i in range(len(sumA)):
    if sumA[i] <= k:
        diff = k - sumA[i]
        j = bisect.bisect_right(sumB,diff)
        # print(sumA[i],diff,j)
        ans = max(i+j,ans)

print(ans)


Measured memory_bytes: 47476
#include <iostream>
#include <fstream>
#include <sstream>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

#define pb push_back
#define pbk pop_back
#define mp make_pair
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define foreach(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define len(a) ((int) (a).size())

#ifdef CUTEBMAING
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

using namespace std;

typedef long long int64;
typedef long double ld;
typedef unsigned long long lint;

const int inf = (1 << 30) - 1;
const int64 linf = (1ll << 62) - 1;

int main() {
#ifdef XCODE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    string s; cin >> s;
    cout << s.substr(0, 4) + " " + s.substr(4) << endl;
    return 0;
}


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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using namespace std;

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

    int h, w; cin >> h >> w;

    REPI(i, w + 2) cout << '#';
    cout << '\n';

    REPI(i, h){
        cout << '#';
        REPJ(j, w){
            char c; cin >> c;
            cout << c;
        }cout << '#' << '\n';
    }
    REPI(i, w + 2) cout << '#';
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		System.out.println(shorten(in.readLine()));
	}

	static String shorten(String src) {
		final Pattern p = Pattern.compile("AtCoder ([A-Z])[a-z]{0,99} Contest");
		final Matcher m = p.matcher(src);
		if (m.find()) {
			return m.replaceAll("A$1C");
		}
		throw new IllegalArgumentException();
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef long long ll;
//No change above here

const ll maxi = (2 * 1e5 + 3);
ll mod = (1e9 + 7);

//function for power
ll power(ll x, ll n) {
	ll res = 1;
	x %= mod;
	while (n) {
		if (n & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

ll dir[4][2] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll p, q;
bool valid(ll i, ll j) { return i >= 1 && i <= p && j >= 1 && j <= q; }

//declare needed things here

int main()
{
	IOS;
	char a;
	cin >> a;
	if (a >= 'a' && a <= 'z')
		cout << "a" << endl;
	else
		cout << "A" << endl;
	return 0;
}

Measured memory_bytes: 3648
//#include<bits/stdc++.h>
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<cstring>
#include<utility>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
using namespace std;

typedef long long ll;
typedef long double ld;

#define pa pair<int,int>
#define sc(n) scanf("%d",&n)
#define ss(s) scanf("%s",s)
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define of(i,a,b) for(int i=a;i>=b;i--)
#define mem(a,b) memset(a,b,sizeof a)
#define uint unsigned int

const  int N = 2e5 + 10;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;

int n;
int a[N];
int q;
vector<int> mp[N];
int ans[N];
void dfs(int num,int val)
{
	int len = mp[num].size();
	fo(i, 0, len - 1)
	{
		ans[mp[num][i]] = val + a[mp[num][i]];
		dfs(mp[num][i], val + a[mp[num][i]]);
	}
}

int main()
{
	/*ios::sync_with_stdio(false);*/
	cin >> n >> q;
	fo(i, 1, n-1)
	{
		int x, y;
		sc(x);
		sc(y);
		mp[x].push_back(y);
	}
	fo(i, 1, q)
	{
		int x, y;
		sc(x);
		sc(y);
		a[x] += y;
	}
	ans[1] = a[1];
	dfs(1, ans[1]);
	fo(i, 1, n)
		cout << ans[i] << ' ';
	return 0;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll x;
    cin >> x;
    ll money = 100;
    ll ans = 0;
    while (money < x) {
        money *= 1.01;
        ans++;
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll max = *max_element(a.begin(), a.end());
    ll min = *min_element(a.begin(), a.end());

    cout << abs(max - min) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MN 700
int n,g[MN+5][MN+5],u[MN+5],s,s1,s2,f[MN+5][MN+5];
void dfs(int x)
{
	u[x]<2?++s1:++s2;
	for(int i=1;i<=n;++i)if(i!=x&&!g[i][x])
	{
		if(u[i]==u[x])exit(0*puts("-1"));
		if(!u[i])u[i]=3-u[x],dfs(i);
	}
}
int main()
{
	int m,i,x,y;
	scanf("%d%d",&n,&m);
	while(m--)
	{
		scanf("%d%d",&x,&y);
		g[x][y]=g[y][x]=1;
	}
	f[0][0]=1;
	for(i=1;i<=n;++i)if(!u[i])
	{
		s1=s2=0;u[i]=1;dfs(i);
		for(x=0;x<=s;++x)f[x+s1][s-x+s2]|=f[x][s-x],f[x+s2][s-x+s1]|=f[x][s-x];
		s+=s1+s2;
	}
	for(x=1e9,i=0;i<=n;++i)if(f[i][n-i])x=min(x,i*(i-1)/2+(n-i)*(n-i-1)/2);
	printf("%d",x);
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<int> vei;
typedef vector<vector<int>> ve_vei;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

    ld N, T, A; cin >> N >> T >> A;

    ld temp = INF;
    int ans;
    rep(i,N) {
        ld h; cin >> h;
        if(abs(T - h * 0.006 - A) < abs(temp)){
            temp = T - h * 0.006 - A;
            ans = i+1;
        }
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
import bisect
n, m = list(map(int, input().split(' ')))
aaa = list(map(int, input().split(' ')))
aaa = sorted([-a for a in aaa])[::-1]
len_aaa = len(aaa)

cccbbb = []
for i in range(m):
    b, c = list(map(int, input().split(' ')))
    cccbbb.append((-c, b))
cccbbb = sorted(cccbbb)
ccc = []
for c, b in cccbbb:
    ccc += [c] * b
    if len(ccc) > len_aaa:
        break
ans = 0
for i in range(len_aaa):
    c = ccc[i] if i < len(ccc) else 0
    ans += min(aaa[i], c)
print(abs(ans))

Measured memory_bytes: 24084
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#define ll long long
#define INF 1e+7
#define MOD 1000000007
using namespace std;


int main(){
    int N,M;
    cin >> N >> M;
    
    int ans=1;
    for(int i=1; i*i<=M; i++){
        int g1,g2;
        if(M%i==0){
            g1=i;
            g2=M/i;
        }
        
        if(M/g1 >= N){
            ans=max(ans,g1);
        }
        
        if(M/g2 >= N){
            ans=max(ans,g2);
        }
        
    }
    
    cout<<ans<<endl;

    return 0;
}


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

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

int main() {
    int n;
    cin >> n;
    vector<int> R(n);
    REP(i, n) {
        cin >> R[i];
    }
    
    int a = R[0];
    int b = R[1] - R[0];
    REP(j, n - 1) {
        b = max(R[j + 1] - a, b);
        a = min(R[j + 1], a);
    }
    
    cout << b << endl;
}


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

using namespace std;


int main()
{
   int n,i,ar[2000000],j,c=0,max=-2590;

   cin>>n;

   for (i=0;i<n;++i){

        cin>>ar[i];

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

        if(ar[i]<=ar[i-1])++c;
        else{

            if(c>max)max=c;
            c=0;

        }
   }
   if(c>max)max=c;
   cout<<max<<endl;

   return 0;

}


Measured memory_bytes: 2432