akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std ;

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 998244353, INF = 1E9 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

int arr[100005], dp[100005] ;
int n, k = 2 ;

int check(int pos)
{
    if (dp[pos] != INF) {
        return dp[pos] ;
    }
    else {
        for (int i = 1; i <= k; i++) {
            if (pos - i < 0)    continue ;
            dp[pos] = min(dp[pos], check(pos - i) + abs(arr[pos] - arr[pos - i]) ) ;
        }
        return dp[pos] ;
    }
}

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

    for (int i = 0; i < n; i++) {
        cin >> arr[i] ;
        dp[i] = INF ;
    }
    dp[0] = 0 ;
    ans = check(n - 1) ;
    cout << ans ;

    return 0 ;
}


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

int main() {
    int N; cin >> N;
    map<int, int> hoge;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        if (hoge[a] != 0) {
            cout << "NO" << endl;
            return 0;
        } else {
            hoge[a]++;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m;i>n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C=0,D=0,E=0,F=INF,G=INF,H=0,N,M,K,sum=0;
  cin >> N;
  Out(N*N*N);
}

Measured memory_bytes: 256
a=[]
for _ in range(3):
    a.append(list(map(int,input().split())))
n=int(input())
b=[]
for _ in range(n):
    b.append(int(input()))
for k in range(n):
    for i in range(3):
        for j in range(3):
            if a[i][j]==b[k]:
                a[i][j]=0
for i in range(3):
    if sum(a[i])==0:
        print('Yes')
        exit()
    elif a[0][i]+a[1][i]+a[2][i]==0:
        print('Yes')
        exit()
if a[0][0]+a[1][1]+a[2][2]==0 or a[0][2]+a[1][1]+a[2][0]==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9252
<?php
  
while ($line = fgets(STDIN)) {
   $stdin[] = trim($line);
}
#$v2 = str_split($stdin[0]);
#$v2 = explode(" ", $stdin[0]);

$v = explode(" ", $stdin[1]);

$count = 0;

$res = array();
$res[] = 0;


for($i = 0; $i < $stdin[0] - 1; $i++){
  if($v[$i] >= $v[$i + 1]){
    $count++;
    $res[] = $count;
  }else{
    $count = 0;
  }
  

}

echo max($res) . PHP_EOL;




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

int n, k, num=1;

int main()
{
    cin >> n >> k;
    while(n--) {
        int temp1 = num*2, temp2 = num+k;
        if(temp1<=temp2) num = temp1;
        else num = temp2;
    }
    cout << num << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int lcm(int x, int y){
	int g = gcd(x,y);
	return x/g*y;
}

int facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum = (sum%MOD*i%MOD)%MOD;
    }
    return sum;
}

int main(){
	int n; cin >> n;
	int li[9] = {};
	rep(i,n){
		int a; cin>>a;
		bool found = false;
		for(int j = 1; j <= 8; j++){
			if (a < 400*j){
				li[j-1]++;
				found = true;
				break;
			}
		}
		if (!found){
			li[8]++;
		}
	}
	int ans = 0;
	rep(i,8){
		if (li[i]) ans++;
	}
	if (ans){
		cout << ans << " " << ans + li[8] << endl;
	}else{
		cout << 1 << " " << li[8] << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
  int a,b;
  int s[10],t[10];
  int i;

  scanf("%d %d", &a, &b);

  for(i = 0;i < a;i++){
    s[i] = b;
  }

  for(i = 0;i < b;i++){
    t[i] = a;
  }

  if(a == b){
    for(i = 0;i < a;i++) printf("%d", s[i]);
  }

  else{
    if(s[0] > t[0]){
      for(i = 0;i < b;i++) printf("%d", t[i]);
    }

    else{
      for(i = 0;i < a;i++) printf("%d", s[i]);
    }
  }

  printf("\n");

  return 0;
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    string s;
    int k;
    cin>>s>>k;
    int n=s.size();

    Vi a(n);
    REP(i,0,n){
        a[i]=s[i]-'a';
        if(a[i]!=0) a[i]=26-a[i];
    }
    REP(i,0,n){
        if(k>=a[i]){
            k-=a[i];
            s[i]='a';
        }
        if(i==n-1 && s[i]!='a'){
            s[i] += k%26;
            k=0;
        }
//        cout<<s<<" "<<k<<endl;
    }
    if(k!=0){
        k%=26;
        REP(i,0,k){
            if(s[n-1]=='z') s[n-1]='a';
            else s[n-1]++;
        }
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 1360
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////
int n,p[30],ans;
signed main(){
  cin>>n;rep(i,n)cin>>p[i];
  repd(i,1,n-1){
    if(p[i-1] < p[i] && p[i] < p[i+1])ans++;
    if(p[i-1] > p[i] && p[i] > p[i+1])ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(x) x.begin(), x.end()
#define fi first
#define se second


int main(){
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int z = max(x, y);
	int ans = 10000000000;
	for(int i = 0; i <= z; i++){
		int pay = a * max(0, (x-i)) + b * max(0, (y-i)) + c * 2 * i; 
		ans = min(ans, pay);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(int argc, const char * argv[]){
  int a,b,c,tmp;
  
  scanf("%d %d %d",&a,&b,&c);
  
  if (a>b) {
    tmp=a;
    a=b;
    b=tmp;
  }
  
  if (b>c) {
    tmp=b;
    b=c;
    c=tmp;
  }
  
  if (a>b) {
    tmp=a;
    a=b;
    b=tmp;
  }
  
  printf("%d %d %d\n",a,b,c);
  return 0;
}


Measured memory_bytes: 2148
#include <stdio.h>
#include <queue>
#include <algorithm>
using namespace std;

typedef struct point {
  int x, y;
} POINT;

int W, H;
char str[20][21];
queue<POINT> que;

bool input() {
  int i;

  scanf("%d %d", &W, &H);
  if (!W && !H) return false;

  for (i = 0; i < H; i++) {
    scanf("%s", str[i]);
  }

  return true;
}

int main() {
  int i, j, cnt;
  POINT p, q;

  while (input()) {

    while (!que.empty()) que.pop();
    for (i = 0; i < H; i++) {
      for (j = 0; j < W; j++) {
        if (str[i][j] == '@') {
          p.x = j;
          p.y = i;
          que.push(p);
          i = H;
          j = W;
        }
      }
    }

    cnt = 0;
    while (!que.empty()) {
      p = que.front();
      que.pop();
      if (p.x < 0 || W <= p.x || p.y < 0 || H <= p.y) continue;
      if (str[p.y][p.x] == '#') continue;
      cnt++;
      str[p.y][p.x] = '#';
      q.x = p.x;
      q.y = p.y+1;
      que.push(q);
      q.x = p.x+1;
      q.y = p.y;
      que.push(q);
      q.x = p.x-1;
      q.y = p.y;
      que.push(q);
      q.x = p.x;
      q.y = p.y-1;
      que.push(q);
    }

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

  }

  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
int main (){
	char a[101];
	char b;
	int i;
	int n;
	scanf("%s",a);
	n=strlen(a);
	int num=0;
	for(b='a';b<='z';b++){
		for(i=0;i<n;i++){
			if(a[i]==b){
				num++;
			}
		}
		if(num%2!=0){
			printf("No\n");
			return 0;
		} 
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
using System;

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var s = getString(n);
        for (int i = 0; i < 200000; i++)
            if (s.IndexOf(i.ToString()) < 0) { Console.WriteLine(i); break; }
    }
    public static string getString (int n)
    {
        var ret = "";
        while (true)
        {
            var s = Console.ReadLine().Trim();
            ret += s.Replace(" ", "");
            if (ret.Length == n) break;
        }
        return ret;
    }
}


Measured memory_bytes: 8428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const int N=100000;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,ans;
	cin >> n,ans=sqrt(n);
	while(ans*ans>n){
		ans--;
	}
	cout << ans*ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[4];
int main()
{
	int d;
	scanf("%d %d %d %d",&a[0],&a[1],&a[2],&d);
	if(abs(a[2]-a[0])<=d)
	    printf("Yes");
	else
	{
		sort(a,a+3);
		if(a[1]-a[0]<=d&&a[2]-a[1]<=d)
		      printf("Yes");
		else
		      printf("No");   
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
  char A[100],B[100];
  int i;
  
  scanf("%s %s",A,B);
  
  if(strlen(A)>strlen(B)) printf("GREATER");
  else if(strlen(A)<strlen(B)) printf("LESS");
  else {
    for(i=0;i<strlen(A);i++){
      if(A[i]>B[i]){
        printf("GREATER");
        break;
      }
      else if(A[i]<B[i]){
        printf("LESS");
        break;
      }
    }
    if(i==strlen(A)) printf("EQUAL");
  }
  
  return 0;
}

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

int main() {
	int A,B,C,D,E,F,x=1,y=1;
	cin>>A>>B>>C>>D>>E>>F;
	for(int i=0;i<=F/(A*100);i++){
		int a=i*100*A;
		if(a>F) break;
		for(int j=0;j<=F/(B*100);j++){
			int b=j*100*B;
			if((a+b)>F) break;
			for(int k=0;k<=F/C;k++){
				int c=k*C;
				if(a+b+c>F) break;
				for(int l=0;l<=F/D;l++){
					int d=l*D;
					if(a+b+c+d>F||(c+d)>(a+b)/100*E) break;
					int n=a+b;
					int m=c+d;
					if(x*(n+m)<=m*(x+y)){
						x=m;
						y=n;
					}
				}
			}
		}
	} 
	cout<<x+y<<" "<<x;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int n,m;
  cin >> n >> m;
  vector<int> x(m);
  rep(i,0,m) cin >> x[i];
  sort(ALL(x));
  priority_queue<int> d;
  rep(i,0,m-1) d.push( abs(x[i]-x[i+1]) );
  rep(i,0,n-1) if(!d.empty()) d.pop();
  
  int ans = 0;
  while (!d.empty()) {
    ans += d.top();
    d.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 2168
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#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++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



ll mod(ll i, ll j)
{
    return (i % j) < 0 ? (i % j) + 0 + (j < 0 ? -j : j) : (i % j + 0);
    //return (a - (a / b + a % b) * b);
}

int main() {
    int N;
    cin >> N;
    vll A(N);
    rep(i, N) cin >> A[i];

    v2ll dp(N + 1, vll(300 * 300 + 1, 0));
    ll p = 998244353;
    dp[1][0] = 2;
    dp[1][A[0]] = 1;
    REP(i, 1, N) {
        rep(j,  300 * 300 + 1) {
            if (dp[i][j] > 0) {
                dp[i + 1][j] += dp[i][j] * 2;
                dp[i + 1][j] %= p;
                dp[i + 1][j + A[i]] += dp[i][j];
                dp[i + 1][j + A[i]] %= p;
            }
        }
    }

    ll minus = 0;
    ll S = accumulate(A.begin(), A.end(), 0);
    REP(i, (S / 2) + (S % 2), 300 * 300 + 1) {
        minus += dp[N][i];
    }


    v2ll dp2(N + 1, vll(300 * 300 + 1, 0));
    dp2[1][0] = 1;
    dp2[1][A[0]] = 1;
    REP(i, 1, N) {
        rep(j,  300 * 300 + 1) {
            if (dp2[i][j] > 0) {
                dp2[i + 1][j] += dp2[i][j];
                dp2[i + 1][j] %= p;
                dp2[i + 1][j + A[i]] += dp2[i][j];
                dp2[i + 1][j + A[i]] %= p;
            }
        }
    }
    ll add = 0;
    if (S % 2 == 0)
        add = dp2[N][S / 2];
    ll ans = 1;
    rep(i, N) {
        ans *= 3;
        ans %= p;
    }
    ans = (mod(ans - 3 * minus, p) + 3 * add) % p;
    cout << ans << endl;;

    return 0;
}

Measured memory_bytes: 424512
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);
    d=a/b;
    r=a%b;
    f=1.0*a/b;
    printf("%d %d %.8lf\n",d,r,f);
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int vacation = scanner.nextInt();
		int homeworkNumber = scanner.nextInt();
		int[] daysSpentInHomework = new int[homeworkNumber];
		int studyDay = 0;

		for (int i = 0; i < homeworkNumber; i++) {
			daysSpentInHomework[i] = scanner.nextInt();
		}

		for (int j = 0; j < homeworkNumber; j++) {
			studyDay = studyDay + daysSpentInHomework[j];
		}

		int playable;

		if (vacation - studyDay >= 0) {
			playable = vacation - studyDay;
			System.out.println(playable);
		} else {
			System.out.println("-1");
		}

		scanner.close();

	}

}


Measured memory_bytes: 46280
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <climits>

using namespace std;


int main(){
	int n;
	cin >> n;
	vector<char> arr(n);

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

	int count = 0;
	for (int i = 0; i < n - 2; i++) {
		if (arr[i] == 'A') {
			if (arr[i + 1] == 'B') {
				if (arr[i + 2] == 'C')
					count++;
			}
		}
	}

	cout << count << endl;

	return 0;
}

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

using namespace std;
using ll = long long;

ll p5(ll a){
    return a*a*a*a*a;
}

int main(){
    ll x, a, b;
    int ans = 0;
    cin >> x;
    bool end = false;
    for(a=0; a<200; a++){
        for(b=-200; b<200; b++){
            if(p5(a)-p5(b)==x){
                cout << a << " " << b << endl;
                end = true;
                break;
            }
        }
        if(end){
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  int p[a],q[b],r[c];
  priority_queue<pair<int,char> > pq;
  rep(i,a){
    cin>>p[i];
    pq.push(make_pair(p[i],'r'));
  }
  rep(i,b){
    cin>>q[i];
    pq.push(make_pair(q[i],'g'));
  }
  rep(i,c){
    cin>>r[i];
    pq.push(make_pair(r[i],'!'));
  }
  int gc=0,rc=0;
  int ans=0;
  int cnt=0;
  while(cnt<(x+y)){
    pair<int,char> P=pq.top();
    pq.pop();
    //cout<<P.F<<" "<<P.S<<endl;
    if(P.S=='g' && gc<y){
      cnt++;
      ans+=P.F;
      gc++;
    }else if(P.S=='r' && rc<x){
      cnt++;
      ans+=P.F;
      rc++;
    }else if(P.S=='!'){
      cnt++;
      ans+=P.F;
    }
    // cout<<ans<<endl;
    //pq.pop();
  }
    
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 12268
#include <iostream>
#include <climits>
#include <stdio.h>
using namespace std;

struct Card
{
  char suit;
  char value;
};

void bubbleSort(Card C[], int N)
{
  for (int i = 0; i <= N - 1; i++)
  {
    for (int j = N - 1; j >= i + 1; j--)
    {
      if (C[j].value < C[j - 1].value)
      {
        std::swap(C[j], C[j - 1]);
      }
    }
  }
}

void selectionSort(Card C[], int N)
{
  for (int i = 0; i <= N - 1; i++)
  {
    int mini = i;
    for (int j = i; j <= N - 1; j++)
    {
      if (C[j].value < C[mini].value)
      {
        mini = j;
      }
    }
    std::swap(C[i], C[mini]);
  }
}

void print(Card C[], int N)
{
  for (int i = 0; i < N; i++)
  {
    if (i > 0)
      cout << " ";
    cout << C[i].suit << C[i].value;
  }
  cout << endl;
}

bool isStable(Card C1[], Card C2[], int N)
{
  for (int i = 0; i < N; i++)
  {
    if (C1[i].suit != C2[i].suit)
      return false;
  }
  return true;
}

int main(int argc, char *argv[])
{
  Card C1[100], C2[100];
  int N;
  char ch;

  cin >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> C1[i].suit >> C1[i].value;
  }

  for (int i = 0; i < N; i++)
  {
    C2[i] = C1[i];
  }

  bubbleSort(C1, N);
  selectionSort(C2, N);
  print(C1, N);
  cout << "Stable" << endl;
  print(C2, N);
  if (isStable(C1, C2, N))
  {
    cout << "Stable" << endl;
  }
  else
  {
    cout << "Not stable" << endl;
  }

  return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	int r,g,b,n;
	cin >> r >> g >> b >> n;
	int ans = 0;
	rep(i, n + 1) rep(j, n + 1){
		const int rest = n - r * i - g * j;
		if(rest < 0) continue;
		if(rest % b) continue;
		ans++;
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int K,S;
  cin>>K>>S;
  
  int ans=0;
  
  
  for(int x=0;x<=K;x++){
    for(int y=0;y<=K;y++){
      if(0<=S-x-y&&S-x-y<=K){
        ans++;
      }
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
template <class T1, class T2> void vadd(vector<T1> &v, T2 x);

#define int long long int
int dp[1005] = {};
signed main() {
  int n, k;
  cin >> n >> k;
  rep(i, k) {
    int d;
    cin >> d;
    set<int> s;
    rep(j, d) {
      int l;
      cin >> l;
      dp[l - 1] = true;
    }
  }
  int ret = 0;
  rep(i, n + 1) if (dp[i]) ret++;
  cout << n - ret << endl;
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 3644
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

ll n, A, B, C;
ll ans = INF;
vector<ll> l(10);

void bfs(int a, int b, int c, int i, int m)
{
    if (i == n)
    {
        if (!a || !b || !c)
        {
            return;
        }

        ans = min(ans, abs(A - a) + abs(B - b) + abs(C - c) + m);

        return;
    }

    bfs(a + l[i], b, c, i + 1, a ? m + 10 : m);
    bfs(a, b + l[i], c, i + 1, b ? m + 10 : m);
    bfs(a, b, c + l[i], i + 1, c ? m + 10 : m);
    bfs(a, b, c, i + 1, m);
}

int main(void)
{
    cin >> n >> A >> B >> C;

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

    bfs(0, 0, 0, 0, 0);

    cout << ans << endl;
}


Measured memory_bytes: 256
<?php
  
$ab = explode(' ',trim(fgets(STDIN)));
$a = $ab[0];
$b = $ab[1];
$s = trim(fgets(STDIN));

$pattern = '/^[0-9]{'.preg_quote($a).'}-[0-9]{'.preg_quote($b).'}$/';
echo preg_match($pattern,$s) ? 'Yes' : 'No';

?>

Measured memory_bytes: 4856
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

vector<vector<int>> con;

int dfs(int n,set<int> &st){
	if(sz(st)==0) return 1;
	int ans=0;
	for(auto &i:con[n]){
		if(st.count(i)){
			st.erase(i);
			ans+=dfs(i,st);
			st.insert(i);
		}
	}
	return ans;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,e; cin>>n>>e;
	con.resize(n);
	int s,t;
	For(i,0,e-1){
		cin>>s>>t;
		s--; t--;
		con[s].emplace_back(t);
		con[t].emplace_back(s);
	}
	set<int> st;
	For(i,1,n-1) st.insert(i);
	cout<<dfs(0,st)<<"\n";
	return 0;
}





























Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

bool red[100005];
int cnt[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    red[1] = true;
    rep(i,m){
        int x, y;
        cin >> x >> y;
        --cnt[x];
        ++cnt[y];
        red[y] |= red[x];
        if(cnt[x] < 0) red[x] = false;
    }
    int ans = 0;
    rep(i,n+1){
        if(red[i]) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4048
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long 
const int maxn = 1e5+10;
vector <int> vec[maxn];
int n,m;
int vis[maxn];
int ans[2],sta[2][maxn];
void dfs(int u,int cur)
{
	vis[u]=1;
	ans[cur]++;
	sta[cur][ans[cur]]=u;
	for(auto v:vec[u])
	{
		if(vis[v]) continue;
		dfs(v,cur);
		break;
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	int u,v;
	int st;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		vec[u].push_back(v);
		vec[v].push_back(u);
	    st=u;
	}
	vis[st]=1;
	dfs(vec[st][0],0);
	for(int i=1;i<vec[st].size();i++)
	{
		int v=vec[st][i];
		if(vis[v]) continue;
		dfs(v,1);
		break;
	}
	printf("%d\n",ans[0]+ans[1]+1);
	for(int i=ans[0];i;i--) printf("%d ",sta[0][i]);
	printf("%d ",st);
	for(int i=1;i<=ans[1];i++) printf("%d ",sta[1][i]);
	return 0;
}

Measured memory_bytes: 7040
import java.util.Scanner;

public class Main {

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

        int N = sc.nextInt();
        String S = sc.next();

        if (N % 2 == 1) {
            System.out.println("No");
            return;
        }

        if (S.substring(0, N / 2).equals(S.substring(N / 2, N)))
            System.out.println("Yes");
        else
            System.out.println("No");

    }
}

Measured memory_bytes: 21844
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define mod (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int gcd(int A,int B) {if(!B)return A;return gcd(B,A%B);}
int main()
{
	ll n;
    cin>>n;
    map<string,int>cnt;
    for(int i=0;i<n;i++){
		string s;
		cin>>s;
		cnt[s]++;
	}
	int ans = 0;
	vector<string>a;
	for(auto x:cnt){
		ans = max(ans,x.se);
	}
	for(auto x:cnt){
		if(x.se == ans)a.pb(x.fi);
	}
	sort(a.begin(),a.end());
	for(auto x:a)cout<<x<<endl;
}

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

int main()
{
  string S;
  cin >> S;
  char c = S[0];
  int ans = 0;
  for(int i = 1; i < S.size(); i++){
    if(S[i] == c) continue;
    c = S[i];
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
    int n;
    string s;
    cin >> n >> s;
    rep(i,s.size()) cout << alpha[((s[i]-'A')+n)%26];
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  int y,m,d;
  char a,b;

  cin >> y >> a >> m >> b >> d;

  if(y <= 2018){
    cout << "Heisei" << endl;
    return 0;
  } else {
    if(m <= 4){
      cout << "Heisei" << endl;
      return 0;
    } else{
      cout << "TBD" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;

const int DATA = 200;

int main() {
  int i=0;
  //float[DATA][2] result;// = new float[DATA][2];
  while(true) {
    //ax + by = c   dx + ey = f
    //0    1    2   3    4    5
    string[] input = (chomp(readln)).split(" ");
    if(stdin.eof()) break;
    
    // |a b|
    // |d e|
    float[][] lmat = [[to!(float)(input[0]), to!(float)(input[1])], [to!(float)(input[3]), to!(float)(input[4])]];
    float[] rmat = [to!(float)(input[2]), to!(float)(input[5])];
    float[][] revmat = [[to!(float)(input[4]), -to!(float)(input[1])], [-to!(float)(input[3]), to!(float)(input[0])]];
    float ad_bc = lmat[0][0]*lmat[1][1] - lmat[0][1]*lmat[1][0];

    float x = (revmat[0][0]*rmat[0]+revmat[0][1]*rmat[1]) / ad_bc + 0.0;
    float y = (revmat[1][0]*rmat[0]+revmat[1][1]*rmat[1]) / ad_bc + 0.0;
    writef("%.3f %.3f\n",x, y);
      //i++;
  }
// 
//  for(int j=0; j<i; j++) {
//    writef("%.3f %.3f\n",result[j][0], result[j][1]);
//  }

  return 0;
}

Measured memory_bytes: 1140
#include<bits/stdc++.h>
using namespace std;
const int nax=100001;
int dist[nax]={0};
int in_deg[nax]={0};
int vis[nax]={0};
vector<int> adj[nax];
void dfs(int i) {
    vis[i]=1;
    vector<int>:: iterator j;
    for(j=adj[i].begin();j!=adj[i].end();j++) {
        dist[*j]=max(dist[*j],dist[i]+1);
        in_deg[*j]--;
        if(in_deg[*j]==0)
            dfs(*j);
    }
}
int main() {
    int n,m;
    cin>>n>>m;
    int ans=0;
    for(int i=0;i<m;i++) {
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        in_deg[y]++;
    }
    for(int i=1;i<=n;i++) {
        if(!vis[i] && in_deg[i]==0) {
            dfs(i);
        }
    }
    for(int i=1;i<=n;i++)
        ans=max(ans,dist[i]);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 10112
N,W = map(int,input().split())
wv_list = [tuple(map(int,input().split())) for _ in range(N)]

v_max = 10**3 * 10**2
memo = [float("inf") for _ in range(v_max+1)]
memo[0] = 0

for weight,value in wv_list:
    for v in range(v_max+1-value)[::-1]:
#         if memo[v]:
        memo[v+value] = min(memo[v]+weight, memo[v+value])

ans = 0

for i,m in enumerate(memo):
    if m <= W:
        ans = i

print(ans)

Measured memory_bytes: 94844
#include<stdio.h>

const int mod = 1e9 + 7;

void swap(long long* a, long long* b){
  *a ^= *b;
  *b ^= *a;
  *a ^= *b;
}

long long inv(long long x){
  long long m = mod, u = 1, v = 0;
  while(m){
    long long t = x / m;
    x -= t * m; swap(&x, &m);
    u -= t * v; swap(&u, &v);
  }
  u %= mod;
  if(u < 0) u += mod;
  return u;
}

int main(){
  int N, M;
  scanf("%d%d", &N, &M);
  int K;
  scanf("%d", &K);
  
  long long fact[N * M + 1];
  fact[0] = 1;
  for(int i = 1; i <= N * M; i++){
    fact[i] = fact[i - 1] * i % mod;
  }
  
  long long all_costs = 0;
  
  for(long long dy = 1; dy < N; dy++){
    long long cost = dy * M * M * (N - dy) % mod * (fact[N * M - 2] * inv(fact[K - 2] * fact[N * M - K] % mod) % mod) % mod;
    all_costs += cost;
    all_costs %= mod;
  }
  
  for(long long dx = 1; dx < M; dx++){
    long long cost = dx * N * N * (M - dx) % mod * (fact[N * M - 2] * inv(fact[K - 2] * fact[N * M - K] % mod) % mod) % mod;
    all_costs += cost;
    all_costs %= mod;
  }
  
  printf("%lld\n", all_costs);
  
  return 0;
}

Measured memory_bytes: 1664
num,food_num = map(int,input().split())

food_dict = {}

for i in range(num):
    l = list(map(int,input().split()))
    for j in range(1,l[0]+1):
            food_dict.setdefault(l[j],0)
            food_dict[l[j]] += 1

ans = 0

for name, likes in food_dict.items():
    if likes == num:
        ans += 1

print(ans)

Measured memory_bytes: 9048
import math
a,b,h,m=map(int,input().split())
bb=6*m
aa=0.5*m+30*h
if aa<bb:
    cc=aa
    aa=bb
    bb=cc
sum_=aa-bb
if 180<=sum_:
    sum_=360-sum_
si=math.radians(sum_)
ans=math.sqrt(a**2+b**2-2*a*b*math.cos(si))
print(ans)

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

N = int(input())
S = ''
list_chr = [chr(i) for i in range(ord('a'), ord('z')+1)]

while True:
  N -= 1
  S = list_chr[N%26] + S
  N = N//26
  if N==0:
    break

print(S)

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

using namespace std;

typedef complex<double> P;

#define EPS 1e-12

double dot(P& p1, P& p2) {
	return p1.real()*p2.real() + p1.imag()*p2.imag();
}
int main() {
	int x0, y0, x1, y1; cin >> x0 >> y0 >> x1 >> y1;

	P p0 = P(x0, y0), p1 = P(x1, y1);
	P a = p1 - p0;
	a /= abs(a);

	int Q; cin >> Q;
	for (int q = 0; q < Q; ++q) {
		int x, y; cin >> x >> y;
		P p2 = P(x, y);
		P b = p2 - p0;
		P t = a * dot(a, b);
		t += p0;

		printf("%.10f %.10f\n", t.real(), t.imag());
	}
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 33003;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;
using namespace std;

int main(){
ll w,h,x,y;
cin>>w>>h>>x>>y;
cout<<setprecision(10)<<w*h/(2.0)<<" ";
cout<<(x*2==w&&y*2==h) ? 1:0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int  main(){
int h,w;
cin >> h >> w;
int dx[8] ={1,1,1,0,0,-1,-1,-1};
int dy[8]={1,0,-1,1,-1,1,0,-1};
char z[h][w];
for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        cin >> z[i][j];
    }
}
for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        int ans=0;            
        if(z[i][j]=='#'){
                cout<<'#';
                continue;
            }
        for(int k=0;k<8;k++){

            int x = dx[k],y=dy[k];
            x+=j;
            y+=i;
            if(0>x||x>=w||0>y||y>=h)continue;
            if(z[y][x]=='#')ans++;
        }
        cout<< ans;
    }
    cout<<endl;
}
}







Measured memory_bytes: 256
# ARC077C - pushpush (ABC066C)
from collections import deque


def main():
    n = int(input())
    lst = list(map(int, input().rstrip().split()))
    b = deque()
    parity = n % 2
    for i, j in enumerate(lst, start=1):
        if i % 2 == parity:
            b.appendleft(j)
        else:
            b.append(j)
    print(*b)


if __name__ == "__main__":
    main()

Measured memory_bytes: 25536
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }


int main() {
  string s;
  cin >> s;
  cout << s.substr(0, 3) << endl;
}


Measured memory_bytes: 3592
import java.io.*
import java.util.*

val pw = PrintWriter(System.out)
fun solve(N: Long, A: Long){
    println(N*N-A)
    pw.flush()
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toLong()
    val A = sc.next().toLong()
    solve(N, A)
}



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

int main() {
  int n;
  cin >> n;
  vector<double>x(n);
  vector<double>y(n);
  vector<double>d(n);
  double max = 0,sum = 0,dsum = 0,csum = 0;
  for(int i = 0;i < n;i++) cin >> x[i];
  for(int i = 0;i < n;i++) cin >> y[i];
  for(int i = 0;i < n;i++){
    d[i] = abs(x[i]-y[i]);
    sum += d[i];
    dsum += d[i]*d[i];
    csum += d[i]*d[i]*d[i];
    if(max < d[i]) max = d[i];
  }
  std::cout << std::fixed;
  std::cout << std::setprecision(6) << sum << endl;
  std::cout << std::setprecision(6) << sqrt(dsum) << endl;
  std::cout << std::setprecision(6) << cbrt(csum) << endl;
  std::cout << std::setprecision(6) << max << endl;
}



Measured memory_bytes: 3436
while True:
    H,W = map(int,input().split())



    if H == 0 and W == 0:
        break

    else:
        for tate in range(1,H+1):
            for yoko in range(1,W+1):
                if (tate == 1 or tate == H
                    or yoko == 1 or yoko == W):
                    print("#",end="")

                else:
                    print(".",end="")
            print()
        print()


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int h, w;
vector<string> G(20, "");
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int bfs(int sx, int sy) {
    vector<vector<int>> dist(h, vector<int>(w, -1));
    vector<vector<bool>> vis(h, vector<bool>(w, false));
    queue<pair<int, int>> que;
    que.push({sx, sy});
    dist[sx][sy] = 0;
    vis[sx][sy]  = true;

    while (not(que.empty())) {
        int cx, cy;
        tie(cx, cy) = que.front();
        que.pop();

        for (int i = 0; i < 4; i++) {
            int nx = cx + dx[i], ny = cy + dy[i];
            if (0 <= nx and nx < h and 0 <= ny and ny < w) {
                if (G[nx][ny] != '#' and not(vis[nx][ny])) {
                    que.push({nx, ny});
                    dist[nx][ny] = dist[cx][cy] + 1;
                    vis[nx][ny]  = true;
                }
            }
        }
    }
    int ma = -1;
    rep(x, h) rep(y, w) { ma = max(ma, dist[x][y]); }
    return ma;
}

int main() {
    cin >> h >> w;
    rep(i, h) cin >> G[i];

    int ma = -1;
    for (int sx = 0; sx < h; sx++) {
        for (int sy = 0; sy < w; sy++) {
            if (G[sx][sy] == '#') {
                continue;
            } else {
                int mma = bfs(sx, sy);
                ma      = max(ma, mma);
            }
        }
    }
    cout << ma << endl;
    return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int n;
    cin>>n;
    int *m = new int[n+1];
    for(int i = 0 ; i < n + 1 ; i++){
        cin>>m[i];
    }
    int *h = new int[n];
    for(int i = 0 ; i< n  ; i++){
        cin>>h[i];
    }
    int last = 0;
    int sum = 0;
    for(int i = 0 ; i < n ; i++){
        if(m[i] > last + h[i]){
            sum +=  last + h[i];
            last = 0;
        }else {
            if(last >= m[i]){
                sum += m[i];
                last = h[i];
            }else {
                sum += m[i];
                last = last + h[i] - m[i];
            }
        }
    }
    sum += min(last , m[n]);
    cout<<sum<<endl;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < n ; i++)

int n,H,W;
int memo[65536];
int visi[65536];
int Q[65537];
int head = 0 , size = 0;
vector< pair<int,int> > mask;

vector< vector<char> > goal(4,vector<char>(4));

int w[20],h[20];

inline void gen(int s,int x,int y){
	rep(k,3){
		int a=0,b=0;
		rep(i,h[s]){
			rep(j,w[s]){
				int tx = x + j;
				int ty = y + i;
				if(tx >= 0 && tx < 4 && ty < 4 && ty >= 0){
						a |= 1<<(ty*4+tx);
						b |= (goal[ty][tx] == k)<<(ty*4+tx);
				}
			}
		}
		if(b)mask.push_back(make_pair(a,b));
	}
}
int f(int init){
	Q[size++] = init;
	memo[init] = 0;
	int good = (1<<16)-1;
	while(head < size){
		int q = Q[head++];
		int cost = memo[q];
		if(good == q) return cost;
		
		rep(i,mask.size()){
			int bit = (q & ~mask[i].first) | mask[i].second;
			if(!visi[bit]){
				visi[bit] = 1;
				memo[bit] = cost + 1;
				Q[size++] = bit;
			}
		}
	}
	

}

int main(){
	cin >> n;
	rep(i,n) cin >> h[i] >> w[i];
	rep(i,4)rep(j,4){
		char c;cin >> c;
		if(c=='R')c = 0;
		if(c=='G')c = 1;
		if(c=='B')c = 2;
		goal[i][j] = c;
	}
	rep(k,n){
		rep(i,7)rep(j,7){
			gen(k,i-3,j-3);
		}
	}
	sort(mask.begin(),mask.end());
	mask.erase(unique(mask.begin(),mask.end()),mask.end());
	
	cout << f(0) << endl;
	
	
}

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

using namespace std;

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

    vector<int> A(N);
    int highest = 0, highestCount = 0, second = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        if (A[i] == highest){
            ++highestCount;
        }else if(A[i] > highest){
            second = highest;
            highest = A[i];
            highestCount = 1;
        }else{
            second = max(second, A[i]);
        }
    }

    for (auto Ai : A) {
        if (highestCount == 1 && Ai == highest) {
            cout << second << "\n";
        } else {
            cout << highest << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 2432
#if 1
  #include <bits/stdc++.h>
#else
  #include "../../../../bits/stdc++.h"
#endif

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

using namespace std;

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

#define pb push_back
#define mp make_pair
#define ft first
#define sd second

char c[4];

int main(){
  cin.tie(0);
  
  cin>>c;

  if(c[0]==c[2])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
package main

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

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f+"\n", a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func ints(cnt int, a ...interface{}) {
	format := strings.Repeat("%d"+" ", cnt)
	format = strings.TrimRight(format, " ") + "\n"
	scanf(format, a...)
}

func intSlice(cnt int) []int {
	a := make([]int, cnt)
	for i := 0; i < cnt; i++ {
		scanf("%d", &a[i])
	}
	return a
}

func strs(cnt int, a ...interface{}) {
	format := strings.Repeat("%s"+" ", cnt)
	format = strings.TrimRight(format, " ") + "\n"
	scanf(format, a...)
}

type intsDesc []int

func (v intsDesc) Len() int           { return len(v) }
func (v intsDesc) Swap(i, j int)      { v[i], v[j] = v[j], v[i] }
func (v intsDesc) Less(i, j int) bool { return v[i] > v[j] }

func main() {
	defer writer.Flush()

	var N int
	ints(1, &N)
	if N > 999 {
		printf("ABD")
	} else {
		printf("ABC")
	}
}


Measured memory_bytes: 640