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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int, int> PII;
typedef map<int, int> MII;
typedef priority_queue<int> P_QI;
typedef priority_queue<string> P_QS;
typedef vector<int> VI;
typedef vector<long long> VLL;
typedef vector< int > :: iterator $$;

#define SET(arr) memset(arr, -1, sizeof(arr))
#define CLR(arr) memset(arr, 0, sizeof(arr))

#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

#define $ vector< int > :: iterator
#define m_p make_pair
#define p_b push_back
#define rep(i, n) for(int i=0; i<(n); i++)
#define forn(i, n) for (int i = 1; i <=(int)(n); ++i)
#define forab(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define forba(i, b, a) for (int i = (int)(b); i >= (int)(a); --i)

#define forv(i,v) rep(i,SZ(v))
#define forit(i,s) for(auto i=(s).begin();i!=(s).end();++i)

#define Boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define _ <<" "<<
#define CS(i) cout<<"Case "<<(int)(i)<<": "

const int MOD = 1e9+7;
const int inf = 1e9+9;
const long long INF = 1e18+3;
const ld eps = 1e-9;
const ld PI=acos(-1.0);
const ld E=2.71828182845904523536;

int main() {
Boost;
//READ("in.txt");
//WRITE("out.txt");
    ll s;
    cin>>s;

    ll x=sqrt(s);
    if(x*x!=s) x++;
    ll def=x*x-s;

    cout<<"0 0 "<<x<<" "<<"1 "<<def<<" "<<x<<endl;

return 0;
}


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

int main() {
  int n;
  cin>>n;
  int R[n];
  for (int t=0; t<n; t++) {
    cin>>R[t];
  }
  int maxv=R[1]-R[0];
  int minv=R[0];
  for (int t=1; t<n; t++) {
    maxv=max(maxv,R[t]-minv);
    minv=min(minv,R[t]);
  }
  cout<<maxv<<endl;
  return 0;
}



Measured memory_bytes: 3864
import java.util.Scanner;

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

    while (true) {
      a = scanner.nextInt();
      b = scanner.nextInt();
      if (a == 0 && b == 0) break;
      for (int i = 0; i < a; ++i) {
        for (int j = 0; j < b; ++j) System.out.printf("#");
        System.out.println();
      }
      System.out.println();
    }
  }
}


Measured memory_bytes: 58644
use proconio::{fastout, input};
use std::collections::HashMap;

#[fastout]
fn main() {
    input! {
        n: u32,
        m: u32,
        h: [u32;n],
        com: [[u32;2];m]
    }

    let mut bad_peaks = vec![true; n as usize];

    for i in 0..com.len() {
        // println!("{}", h[com[i][0] as usize - 1]);
        // println!("{}", h[com[i][1] as usize - 1]);
        if h[com[i][0] as usize - 1] > h[com[i][1] as usize - 1] {
            bad_peaks[com[i][1] as usize - 1] = false;
        } else if h[com[i][0] as usize - 1] == h[com[i][1] as usize - 1] {
            bad_peaks[com[i][1] as usize - 1] = false;
            bad_peaks[com[i][0] as usize - 1] = false;
        } else {
            bad_peaks[com[i][0] as usize - 1] = false;
        }
    }

    // println!("{:?}", bad_peaks);

    println!("{}", bad_peaks.iter().filter(|x| x == &&true).count());
}


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=305;
int N;
double dp[MAX][MAX][MAX];

double value(int a,int b,int c){
    if(dp[a][b][c]>=0) return dp[a][b][c];
    double ans=1.0;
    if(a!=0) ans+=value(a-1,b,c)*double(a)/double(N);
    if(b!=0) ans+=value(a+1,b-1,c)*double(b)/double(N);
    if(c!=0) ans+=value(a,b+1,c-1)*double(c)/double(N);
    ans=ans/((1.0-double(N-a-b-c)/double(N)));
    return dp[a][b][c]=ans;
}

int main(){
  
    cin>>N;
    int a=0,b=0,c=0;
    for(int i=0;i<N;i++){
        int d;cin>>d;
        if(d==1) a++;
        if(d==2) b++;
        if(d==3) c++;
    }
    for(int i=0;i<N+1;i++){
        for(int j=0;j<N+1;j++){
            for(int k=0;k<N+1;k++){
                dp[i][j][k]=-1;
            }
        }
    }
    dp[0][0][0]=0;
    
    cout<<setprecision(15)<<value(a,b,c)<<endl;
}


Measured memory_bytes: 219520
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
int main() {
  int N, M;
  while(cin >> N >> M && (N|M)) {
    vector<int> y(N+1), x(M+1);
    for(int i=0; i<N; i++) { cin >> y[i+1]; y[i+1] += y[i]; }
    for(int i=0; i<M; i++) { cin >> x[i+1]; x[i+1] += x[i]; }
    N++, M++;
    unordered_map<int, int> mp;
    for(int i=0; i<N; i++)
      for(int j=0; j<M; j++)
        mp[y[i]-x[j]]++;
    // 斜め45度線
    int ans = 0;
    for(auto e : mp)
      if(e.second >= 2)
        ans += e.second*(e.second-1)/2;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 29708
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,m;
	cin >> n >> m;
	ll x;
	priority_queue<ll> pq;
	rep(i,0,n){
		cin >> x;
		pq.push(x);
	}
	while(m){
		ll z=pq.top();
		pq.pop();
		z/=2;
		pq.push(z);
		m--;
	}
	//trace1(1);
	ll ans=0;
	while(1){
		ans+=pq.top();
		pq.pop();
		if(pq.empty()) break;
	}
	cout << ans;
	return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


Measured memory_bytes: 1400
#include <stdio.h>

int main(){
  int A,B;
  scanf("%d%d",&A,&B);
  if(B<0){
    if(A*B<A-B) printf("%d",A-B);
    else printf("%d",A*B);
  }
  else{
     if(A*B<A+B) printf("%d",A+B);
    else printf("%d",A*B);
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int N = 2e5 + 5;
int n;
int arr[N];
long long ans;
long long tot;
long long sum;
int main(){
	scanf("%d" , &n);
	for(int i = 1 ; i <= n ; ++i){
		scanf("%d" , arr + i);
		tot += arr[i];
	}
	ans = 1LL << 60;
	for(int i = 1 ; i < n ; ++i){
		sum += arr[i];
		ans = min(ans , abs(tot - 2 * sum));
	}
	printf("%lld\n" , ans);
}

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

vector<P>E[20], G[20];
bool used[20];
int cnt[20], pr[20];

void C(int u) {
	used[u] = true;
	for (P v : E[u]) {
		if (!used[v.second]) {
			G[u].push_back(v);
			cnt[u]++; pr[v.second] = u; C(v.second);
		}
	}
}
int dfs(int u) {
	int sum = 0;
	for (P v : G[u]) {
		if (0 < G[v.second].size())
			sum += dfs(v.second) + v.first * 2;
	}
	return sum;
}
int dfs2(int u) {
	int Max = 0;
	for (P v : G[u]) {
		if (0 < G[v.second].size())
			Max = max(Max, dfs2(v.second) + v.first);
	}
	return Max;
}
int main() {
	int n;
	while (scanf("%d", &n), n) {
		rep(i, n) {
			E[i].clear();
			G[i].clear();
		}
		rep(i, n - 1) {
			int a, b, t; scanf("%d%d%d", &a, &b, &t); a--; b--;
			E[a].push_back(P(t, b)); E[b].push_back(P(t, a));
		}
		memset(used, 0, sizeof(used)); C(0);
		printf("%d\n", dfs(0) - dfs2(0));
	}
}

Measured memory_bytes: 3204
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <sstream>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <deque>
#include <cmath>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define dow(i, a, b) for(int i = a; i >= b; --i)
#define mem(a) memset(a, 0, sizeof(a))
#define mst(a, b) memset(a, b, sizeof(a))
#define sfi(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define sfd(a) scanf("%lf", &a)
#define sfs(a) scanf("%s", a)
#define pb(a) push_back(a)
#define sync ios::sync_with_stdio(0); cin.tie(0);

const int MAX = 1e2 + 5;
const int L = 2;
const LL MOD = 10000;
const int dir[MAX][MAX] = {{0,1},{0,-1},{1,0},{-1,0},{-1,-1},{-1,1},{1,1},{1,-1}};

const double EPS = 1e-8;
const double PI = acos(-1.0);

typedef struct Point Point;
typedef struct Line Line;

int cmp(double x);
double sqr(double x);
double det(Point a, Point b);
double dot(Point a, Point b);
double dist(Point a, Point b);
Point rotate_point(Point p, double A);
bool parallel(Line a, Line b);
bool orthogonal(Line a, Line b);

struct Point
{
	double x, y;
	Point() {}
	Point(double a, double b): x(a), y(b) {}

	friend Point operator -(Point a, Point b)
	{
		return Point(a.x-b.x,a.y-b.y);
	}
	friend Point operator +(Point a, Point b)
	{
		return Point(a.x+b.x,a.y+b.y);
	}
	friend bool operator ==(Point a, Point b)
	{
		return cmp(a.x-b.x)==0 && cmp(a.y-b.y)==0;
	}
	friend Point operator *(Point a, double b)
	{
		return Point(a.x*b,a.y*b);
	}
	friend Point operator *(double a, Point b)
	{
		return Point(a*b.x,a*b.y);
	}
	friend Point operator /(Point a, double b)
	{
		return Point(a.x/b,a.y/b);
	}
	double norm()
	{
		return sqrt(sqr(x)+sqr(y));
	}
};

struct Line
{
	Point a, b;
	Line() {}
	Line(Point x, Point y): a(x), b(y) {}
};

bool parallel(Line a, Line b)
{
	return !cmp(det(a.a-a.b,b.a-b.b));
}
	
bool orthogonal(Line a, Line b)
{
	return !cmp(dot(a.a - a.b, b.a - b.b));
}

int cmp(double x)
{
	if(abs(x) < EPS)
		return 0;
	if(x > 0)
		return 1;
	return -1;
}

double sqr(double x)
{
	return x * x;
}

double det(Point a, Point b)
{
	return a.x*b.y-a.y*b.x;
}

double dot(Point a, Point b)
{
	return a.x*b.x+a.y*b.y;
}
double dist(Point a, Point b)
{
	return (a-b).norm();
}

Point rotate_point(Point p, double A)
{
	double tx = p.x, ty = p.y;
	return Point(tx*cos(A)-ty*sin(A),tx*sin(A)+ty*cos(A));
}

int main()
{	
#ifdef LOCAL
	//~ freopen("in.txt", "r", stdin);
#endif

	int T;
	sfi(T);
	while(T--)
	{
		Line a, b;
		scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &a.a.x, &a.a.y, &a.b.x, &a.b.y, &b.a.x, &b.a.y, &b.b.x, &b.b.y);
		if(parallel(a, b))
			puts("2");
		else if(orthogonal(a, b))
			puts("1");
		else
			puts("0");
		
	}
	return 0;
}



Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A[3];
    int B[3];
    rep(i, 3) cin >> A[i];
    rep(i, 3) {
        if (A[i] % 2 == 1) {
            cout << "0" << endl;
            return 0;
        }
    }
    if (A[0] == A[1] && A[0] == A[2]) {
        cout << "-1" << endl;
        return 0;
    } 
    rep(i, 1000000) {
        rep(j, 3) A[j] /= 2;
        rep(j, 3) B[j] = A[(j+1)%3] + A[(j+2)%3];
        rep(j, 3) {
            if (B[j] % 2 == 1) {
                cout << i+1 << endl;
                return 0;
            }
        }
        rep(i, 3) A[i] = B[i];
    }

    cout << "-1" << endl;
    return 0;
}


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

int main(){
  long long n,now,be;
  long long big[2]={};
  std::cin >> n;
  std::cin >> big[0];
  be=big[0];

  bool fl=true;
  for (int i = 1; i < n; i++) {
    std::cin >> now;
    if(now==big[0])continue;
    else if(now>=big[0]+1){
      big[0]=now-1;big[1]=i;
    }
    else if(now<big[0])fl=false;

  }

  if(fl==true)std::cout << "Yes" << '\n';
  else std::cout << "No" << '\n';



  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)

	for i := a; i <= min(b, a+k-1); i++ {
		fmt.Println(i)
	}
	for i := max(b-k+1, a+k); i <= b; i++ {
		fmt.Println(i)
	}
}


Measured memory_bytes: 512
N = int(input())
dp = [{ "A": 0, "B": 0, "C": 0 }]
for i in range(N):
  a, b, c = map(int, input().split())
  d = dp[i]
  d2 = {}
  d2["A"] = a+max(d["B"], d["C"])
  d2["B"] = b+max(d["C"], d["A"])
  d2["C"] = c+max(d["A"], d["B"])
  dp.append(d2)
r = max(dp[N].values())
print(r)


Measured memory_bytes: 85848
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

fn main() {
    input! {
        N: i64,
        R: i64,
    }

    let ans = if N >= 10 { R } else { R + 100 * (10 - N) };

    println!("{}", ans);
}


Measured memory_bytes: 2088
#include<bits/stdc++.h>
using namespace std; 
void lcs( string X, string Y, int m, int n ) 
{ 
int L[m+1][n+1]; 
for (int i=0; i<=m; i++) 
{ 
	for (int j=0; j<=n; j++) 
	{ 
	if (i == 0 || j == 0) 
		L[i][j] = 0; 
	else if (X[i-1] == Y[j-1]) 
		L[i][j] = L[i-1][j-1] + 1; 
	else
		L[i][j] = max(L[i-1][j], L[i][j-1]); 
	} 
}
int index = L[m][n]; 
char lcs[index+1]; 
lcs[index] = '\0';
int i = m, j = n; 
while (i > 0 && j > 0) 
{  
	if (X[i-1] == Y[j-1]) 
	{ 
		lcs[index-1] = X[i-1]; 
		i--; j--; index--;	  
	}  
	else if (L[i-1][j] > L[i][j-1]) 
		i--; 
	else
		j--; 
} 
cout << lcs; 
} 
int main() 
{ 
string s, t;
cin >> s >> t; 
int m = s.size(); 
int n = t.size(); 
lcs(s, t, m, n); 
return 0; 
} 


Measured memory_bytes: 35456
import itertools
import numpy as np

N, W, K = map(int, input().split())
g_all = np.array([list(input()) for i in range(N)])

K_all = np.count_nonzero(g_all == '#')
count = 0

def dfs(i, g):
    if (i < N):
        g[i, :] = ['r'] * W
    else:
        g[:, i - N] = ['r'] * N
    return g

g = g_all

for L in range(2 ** (N + W)):
    g = g_all.copy()
    for i in range(N + W):
        if (i < N):
            if ((L >> i) & 1):
                g[i, :] = ['r'] * W
        else:
            if ((L >> i) & 1):
                g[:, i - N] = ['r'] * N
    if np.count_nonzero(g == '#') == K:
        count += 1
print(count)

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

int main(){
    int n,x; cin >> n >> x;
    int sum = 0,l = 1001;
    for(int i=0;i<n;i++){
        int m; cin >> m;
        sum += m;
        l = min(l,m);
    }
    cout << n + (x - sum) / l << endl;
}


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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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


bool my_cp(pair<int, int> a, pair<int, int> b){
  return (double)b.first / (double)(b.second+1) < (double)a.first / (double)(a.second+1);
}

ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}

int N;

void dfs(string s, char m, int N){

  if(s.length() == N){
    cout << s << endl;
  }else{
    for(char c = 'a'; c <= m; c++){
      dfs(s + c, ((c == m)? (m + 1) : m), N);
    }
  }
}





// substr(start, len)

int main(){
  int H, W, K;

  cin >> H >> W >> K;
  
  vector<string> s(H);
  rep(i, 0, H){
    cin >> s[i];
  }

  int ret = 1e9;

  rep(h, 0, 1 << (H-1)){
    int h_sec = 1 + __builtin_popcount(h);
    vector<int> cnt(h_sec);
    int tmp = __builtin_popcount(h);

    bool suc = false;

    rep(j, 0, W){
      int now = 0;
      rep(i, 0, H){
        if(s[i][j] == '1') cnt[now]++; // ホワイトチョコなら現在のh_secのカウンタを増加
        if((h >> i) & 1) now++; // 横の分割を超えたらh_secを1つ移動する
      }

      if(*max_element(all(cnt)) > K){
        // ここまでの探索で，それぞれのh_secのホワイトチョコの数がKを超えたら縦の分割を入れる
        if(suc){
          // 現在の縦列だけでホワイトチョコの数がKを超えたらこのhでの探索を実質終了
          tmp = 1e9;
          break;
        }
        tmp++;
        for(auto &x : cnt) x = 0; // カウンタのクリア
        j--; // カウンタがKを超えているので横方向に1つ戻る
        suc = true; // 一度Kを超えたことを保存する
        continue;
      }
      suc = false; // この縦列の探索ではカウンタがKを超えなかった
    }
    chmin(ret, tmp); // 今回のhの分割数について比較，更新
  }
  cout << ret << endl;




  // cout << setprecision(8) << ans << endl;  // For double
// CHECK if it's possible to overflow!!
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,M;
	cin >> N;
	vector<int> a(N);
	rep(i,N)cin >> a[i];
	cin >> M;
	vector<int> b(M);
	rep(i,M)cin >> b[i];
	sort(ALL(a));
	sort(ALL(b));
	int cnt = 0;
	for(int i=0;i<N;i++){
		if(a[i]==b[cnt]&&cnt<M)cnt++;
	}
	if(cnt==M)cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second
#define all(a) a.begin(),a.end()
int dx[]={0,0,-1,1};
int dy[]={1,-1,0,0};
signed main(){
	int h,w;
	cin>>h>>w;
	string s[h];
	r(i,h)cin>>s[i];
	r(i,h)r(j,w)if(s[i][j]=='#'){
		int sum=0;
		r(k,4){
			int y=i+dy[k];
			int x=j+dx[k];
			if(y<0||x<0||y>=h||x>=w)continue;
			if(s[y][x]=='#')sum++;
		}
		if(!sum){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}

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

string s;
int arr[5];
int n;

main () {
	for (int j = 1; j <=5; j ++) {
		arr[j] = 0;
	}
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> s;
		if (s == "AC") {
			arr[1] ++;
		}
		else if (s == "WA") {
			arr[2] ++;
		}
		else if (s == "TLE") {
			arr[3] ++;
		}
		else if (s == "RE") {
			arr[4] ++;
		}
	}
	cout << "AC x " << arr[1] <<endl;
	cout << "WA x " << arr[2]<<endl;
	cout << "TLE x " << arr[3]<<endl;
	cout << "RE x " << arr[4]<<endl;
}

Measured memory_bytes: 3624
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  solve <$> getc (map toInt) >>= mapM_ print

solve :: [Int] -> [Int]
solve = map f
  where
    f n
      | n == 1 = 0
      | n == 2 = 0
      | n == 3 = 1
      | even n = if isPn (n-1) then 2 else 0
      | otherwise = sum $ zipWith (\a b -> if isPn a && isPn b then 1 else 0) ls (reverse ls)
      where
        ls = [1,3..n]

toInt :: String -> Int
toInt = read

getc :: ([String] -> a) -> IO a
getc f = f . lines <$> getContents

pns :: [Int]
pns = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101]

isPn :: Int -> Bool
isPn 1 = False
isPn x = all ((/= 0) . mod x) $ takeWhile ((<= x) . (^2)) pns

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

int N;
double A, B;
double C;
int D[101];

int main() {
  cin >> N;
  cin >> A >> B;
  cin >> C;
  for(int i = 0; i < N; ++i) {
    cin >> D[i];
  }

  int T[101];
  fill(T,T+101,0);
  for(int j = 0; j < N; ++j) {
    for(int i = N; i >= 1; --i) {
      T[i] = max(T[i], T[i-1]+D[j]);
    }
  }
  double maxi = C / A;
  for(int i = 1; i <= N; ++i) {
    maxi = max(maxi, (C+T[i])/(A+i*B));
  }
  cout << (int)maxi << endl;
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, a) for(auto &&i:(a))
#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(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main() {
  INIT;
	VAR(string,s);
  vector<int> c(26,0);
  REP(i,s.size()){
    ++c[s[i]-97];
  }

  REP(i,26){
    if(c[i]==0) {
      OUT((char)(97+i))BR;
      return 0;
    }
  }
  OUT("None")BR;
  
  return 0;
}


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

char card[100000],card2[100000];

void merge(int a[],int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  int L[n1+1],R[n2+1];
  char LL[n1+1],RR[n1+1];
  for(int i=0;i<n1;i++){
    L[i]=a[left+i];
    LL[i]=card2[left+i];
  }
  for(int i=0;i<n2;i++){
    R[i]=a[mid+i];
    RR[i]=card2[mid+i];
  }
  L[n1]=R[n2]=100000001;
  int i=0,j=0;
  for(int k=left;k<right;k++){
    if(L[i]<=R[j]){
      a[k]=L[i];
      card2[k]=LL[i];
      i++;
    }else{
      a[k]=R[j];
      card2[k]=RR[j];
      j++;
    }
  }
}

void mergeSort(int A[],int left,int right){
  if(left+1<right){
    int mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

int partition(int A[],int p,int r){
  int x=A[r];
  int i=p-1;
  for(int j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      swap(A[i],A[j]);
      swap(card[i],card[j]);
    }
  }
  swap(A[i+1],A[r]);
  swap(card[i+1],card[r]);
  return i+1;
}

void quicksort(int A[],int p,int r){
  int q;
  if(p<r){
    q=partition(A,p,r);
    quicksort(A,p,q-1);
    quicksort(A,q+1,r);
  }
}

int main(){
  int n;
  int A[100000],a[100000];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>card[i]>>A[i];
    card2[i]=card[i];
    a[i]=A[i];
  }
  quicksort(A,0,n-1);
  mergeSort(a,0,n);
  for(int i=0;i<n;i++){
    if(card[i]!=card2[i]){
      cout<<"Not stable"<<endl;
      break;
    }
    else if(i==n-1) cout<<"Stable"<<endl;
  }
  for(int i=0;i<n;i++){
    cout<<card[i]<<" "<<A[i]<<endl;
  }
  return 0;
}



Measured memory_bytes: 4552
#include <iostream>
#include <vector>
#include <cassert>

using namespace std;

int main() {
  int q;
  cin >> q;
  vector<int> a;
  while(q--) {
    int t;
    cin >> t;
    if(t == 0) {
      int x;
      cin >> x;
      a.push_back(x);
    } else if(t == 1) {
      int p;
      cin >> p;
      cout << a.at(p) << endl;
    } else if(t == 2) {
      a.pop_back();
    } else {
      assert(false);
    }
  }
  return 0;
}



Measured memory_bytes: 3768
#include <stdio.h>

int main()
{
  int n, x, min, max;
  long sum;
  scanf("%d\n", &n);
  scanf("%d", &x);
  min = max = sum = x;
  for (int i=1; i<n; i++) {
    scanf("%d", &x);
    if (x<min) min=x;
    if (x>max) max=x;
    sum += x;
  }
  printf("%d %d %ld\n", min, max, sum);
  return 0;
}


Measured memory_bytes: 2124
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
ll n;
while(1){
  cin>>n;
  if(n==0)return 0;
  V<V<int>> a(205,V<int>(205,0));
  int h,w;
  cin>>w>>h;
  V<P> dat(n);
  for(int i=0;i<n;i++){
	  cin>>dat[i].fi>>dat[i].se;
	  dat[i].fi--;dat[i].se--;
  }
  int wid,hei;
  cin>>wid>>hei;
  for(int i=0;i<n;i++){
	  int y=dat[i].fi,x=dat[i].se;
	  a[x][y]++;
	  a[x+hei][y]--;
	  a[x][y+wid]--;
	 a[x+hei][y+wid]++;
  }
  for(int i=0;i<h;i++)for(int j=0;j<w;j++)a[i][j+1]+=a[i][j];
   for(int i=0;i<w;i++)for(int j=0;j<h;j++)a[j+1][i]+=a[j][i];
   int ans=0;
   for(int i=hei-1;i<h;i++){
	   for(int j=wid-1;j<w;j++){
		   chmax(ans,a[i][j]);
	   }
   }
  cout<<ans<<endl;
}
}



Measured memory_bytes: 3148
import collections

n=int(input())
a=list(map(int,input().split()))
q=int(input())
s=sum(a)
cc=collections.Counter(a)


for i in range(q):
    b,c=map(int,input().split())
    tmp=cc[b]
    cc[b]=0
    s=s-b*tmp+c*tmp
    cc[c]+=tmp
    print(s)

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

int main()
{
int n,i,a=1,c=1,t=0,s;

cin>>n;
s=n;
while(a!=0)
{
a=s%10;
s=s/10;
if(a==7)
{
	t++;
    break;	
}
}

if(t==1)
cout<<"Yes";
else
cout<<"No";

}


Measured memory_bytes: 3620
N = int(input())
A = list(map(int, input().split()))

Q = int(input())

counter = [0 for _ in range(10**5+1)]
ans = 0

for i in range(N):
    counter[A[i]] += 1
    ans += A[i]

B = []
C = []
for i in range(Q):
    Bi, Ci = list(map(int, input().split()))
    B.append(Bi)
    C.append(Ci)

for i in range(Q):
    Bi = B[i]
    Ci = C[i]
    ans += Ci*counter[Bi] - Bi*counter[Bi]
    print(ans)
    counter[Ci] += counter[Bi]
    counter[Bi] = 0


Measured memory_bytes: 22832
/**
*   Author : Krishna Purohit
*/

#include "bits/stdc++.h"
#define sync ios_base::sync_with_stdio(false)
#define ll long long
#define ld long double
#define all(x) x.begin(), x.end()
#define mod 10000000007
using namespace std;

ll t, n;

int main() {
    sync;
    vector<string> s {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string t;
    cin >> t;
    for(int i = 0; i < 7; i++) {
        if(s[i] == t) {
            cout << 7 - i << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
using namespace std;
template <class data_t>

class dice{
public:
  vector<data_t> field;
  dice(vector<data_t> v);
  void roll(char ch);
  data_t top(){
    return field[0];
  }
};

template <class data_t>
dice<data_t>::dice(vector<data_t> v){
  typename vector<data_t>::iterator vi = v.begin();
  while(vi!=v.end()){
    field.push_back(*vi);
    vi++;
  }
}

template <class data_t>
void dice<data_t>::roll(char ch){
  data_t tmp;
  switch(ch){
  case 'E':
    tmp = field[0];
    field[0] = field[3];
    field[3] = field[5];
    field[5] = field[2];
    field[2] = tmp;
    break;
  case 'N':
    tmp = field[0];
    field[0] = field[1];
    field[1] = field[5];
    field[5] = field[4];
    field[4] = tmp;
    break;
  case 'S':
    tmp = field[0];
    field[0] = field[4];
    field[4] = field[5];
    field[5] = field[1];
    field[1] = tmp;
    break;
  case 'W':
    tmp = field[0];
    field[0] = field[2];
    field[2] = field[5];
    field[5] = field[3];
    field[3] = tmp;
    break;
  }
  return;
}
template <class data_t>
void spin(dice<data_t> &d){
  data_t tmp;
  tmp = d.field[1];
  d.field[1] = d.field[3];
  d.field[3] = d.field[4];
  d.field[4] = d.field[2];
  d.field[2] = tmp;
  return;
}

int main(void) {
  vector<int> v(6);
  int q_num, num1, num2, i;
  cin >> v[0] >> v[1] >> v[2] >> v[3] >> v[4]>> v[5];
  dice<int> d(v);
  cin >> q_num;
  while(q_num--){
    cin >> num1 >> num2;
    if(d.field[0] != num1){
      for(i=0;i<3;i++){
        d.roll('N');
        if(d.field[0] == num1)
          break;
      }
      if(d.field[0] != num1){
        for(i=0;i<3;i++){
          d.roll('E');
          if(d.field[0] == num1)
            break;
        }
      }
    }
    if(d.field[1] != num2){
      while(true){
        spin(d);
        if(d.field[1] == num2){
          break;
        }
      }
    }
    cout << d.field[2] << endl;
  }
  return 0;
}

Measured memory_bytes: 3136
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Program
{
    public static Scanner cin;
    static void Main()
    {
        cin = new Scanner();
        int n = cin.nextInt();
        int[] height = cin.ArrayInt(n);
        int count = 1;
        int max = height[0];
        for (int a = 1; a < n; a++)
        {
            if (max <= height[a])
            {
                count++;
                max = height[a];
            }
        }


        WriteLine(count);
        Console.ReadLine();

    }
    static bool search(int[] array,int len,int key)
    {
        for (int a = 0; a < len; a++)
        {
            if (array[a]==key) return true;
        }
        return false;
    }
}





class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

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

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(n);
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i]>>c[i];
	}
	vector<vector<int> > dp(n,vector<int>(3));
	dp[0]={a[0],b[0],c[0]};
	for(int i=1;i<n;i++){
		dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define N 200100
#define mod 1000000007
#define MOD 998244353
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define INF 100000000000000000
#define pii pair<int,int>
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int a[N];


signed main()
{
    
    speed
    string s,t;cin>>s>>t;
    vector <string> v;
    rep(i,1,26){
        string k=s;
        k+=(char)('a'+i-1);
        v.pb(k);
    }
    for(auto it:v){
        if(it==t){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;






    return 0;
}

Measured memory_bytes: 3648
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String[] s = saori.nextHayami().split("");
		long ans = 0;
		long count = 0;
		for(int i = 0;i < s.length;i++){
			if(s[i].equals("W")){
				ans += i-count;
				count++;
			}
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 48876
#include <bits/stdc++.h>
#define dump(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1000000007;
/* テンプレートここまで */

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

  map<ll, int> mp; 

  REP(i, N){
    ll a;
    cin >> a;
    mp[a] += 1; 
  }

  REP(i, M){
    ll b, c;
    cin >> b >> c;
    mp[c] += b;
  }

  ll ans = 0;

  for(auto it = mp.rbegin(); it != mp.rend() ; it++){
    if(it -> second >= N){
      ans += it->first * N;
      break;
    }else{
      ans += it->first * it->second;
      N -= it->second;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 12800
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	A, B, C, D := sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()
	mi := min(A, B)
	mi2 := min(C, D)

	fmt.Fprintln(wtr, mi+mi2)
	wtr.Flush()
}


Measured memory_bytes: 640
//GCD FREQUENCY COUNTER WITH INC-EXC BY ADANCITO

//WHAT DOES THIS ALGORITHM DO?
/*
 
 imagine that for every ordered pair (i, j), 0 <= i, j <= maxN, we did
 res[gcd(i, j)] += one[i] * two[j]
 
 this algorithm calculates the final value of res in O(nlgn)
 
 remember to call precalculations() at the beginning of the program
 
 */

#include <iostream>
#include <string.h>
#include <ctime>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <set>
#include <map>
#include <vector>

using namespace std;
const int maxN = 404, MOD = 1e9 + 7;

typedef long long ll;
typedef pair<ll, ll> ii;

string mys[maxN];

set<string> s;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    
    int n;
    mys[0] = "0";
    cin >> n;
    
    for(int i = 1; i <= n; i++){
        cin >> mys[i];
        if(i > 1 &&  (mys[i][0] != mys[i - 1].back() || s.find(mys[i]) != s.end())){
            cout << "No\n";
            return 0;
        }
        s.insert(mys[i]);
    }
    cout << "Yes\n";
    
}


Measured memory_bytes: 256
#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()
{
    int d, t, s;
    cin >> d >> t >> s;
    if ((d + s - 1) / s <= t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)


int main(){
    ll s;
    cin >> s;
    ll a = 1;
    if(s==1){
        cout << 0 << " " << 0 << " " << 1 << " " << 0 << " " << 0 << " " << 1 << endl;
        return 0;
    }
    for(int i=0;i<10;i++){
        if(a>=s){
            break;
        }else{
            a*=10;
        }
    }
    a/=10;
    ll b = (s+a-1)/a;
    ll p = a*b-s;
    ll q = 1;
    cout << 0 << " " << 0 << " " << a << " " << p << " " << q << " " << b << endl;
    //cerr << a*b-p*q << endl;
    return 0;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
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; }
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000
#define MAX_N 200010

int par[MAX_N]; // 親
int depth[MAX_N]; // 木の深さ

struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    // 木の根を求める
    int root(int x) {
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    // xとyの属する集合を併合
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return;

        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;

    }

    // xとyが同じ集合に属するか否か
    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return -par[root(x)];
    }
};

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

  int n, k, l;
  cin >> n >> k >> l;
  UnionFind road(n), rail(n);
  rep(i, 0, k) {
    int p, q;
    cin >> p >> q;
    road.unite(--p, --q);
  }
  rep(i, 0, l) {
    int r, s;
    cin >> r >> s;
    rail.unite(--r, --s);
  }
  map<pair<int, int>, int> rsl;
  rep(i, 0, n) rsl[make_pair(road.root(i), rail.root(i))]++;
  rep(i, 0, n) {
    cout << rsl[make_pair(road.root(i), rail.root(i))];
    if(i == n - 1) {
      cout << endl;
      return 0;
    }
    cout << " ";
  }
}



Measured memory_bytes: 13568
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <climits>
#include <ctime>
#include <random>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-9
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;

int main() {
	speed;
	int x, y;
	cin >> x >> y;
	cout << x + y / 2;
}

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

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i = 0; i < N; ++i) {
        cin >> S[i];
    }
    sort(S.begin(), S.end());
    int C=1;
    for(int i=1; i<N; ++i) {
        if(S[i] != S[i-1]) {
            ++C;
        }
    }
    cout << C << endl;
}

Measured memory_bytes: 9540
#include <cstdio>
#include <algorithm>
typedef long long ll;
const int N = 2e3 + 5;
const int Mod = 924844033;
int n, K;
int g[N][N][4], w[2][N], fac[N], ans;
int main() {
	scanf("%d%d", &n, &K);
	g[0][0][2] = 1;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j <= i; ++j) 
			for (int opt = 0; opt < 4; ++opt) 
				if (g[i][j][opt]) {
					(g[i + 1][j][(opt & 1) << 1] += g[i][j][opt]) %= Mod;
					(g[i + 1][j + 1][((opt & 1) << 1) | 1] += g[i][j][opt]) %= Mod;
					if (!(opt >> 1)) (g[i + 1][j + 1][(opt & 1) << 1] += g[i][j][opt]) %= Mod;
				}
	
	int x = 0, y = 1; w[0][0] = 1;
	for (int c = 0, pre = 0; c < K; ++c, std :: swap(x, y)) {
		int m = n / K + (c ? c <= (n % K) : 0); pre += m;
		for (int i = 0; i <= pre; ++i) w[y][i] = 0;
		for (int v = 0; v <= m; ++v) {
			int t = (g[m][v][0] + g[m][v][2]) % Mod;
			for (int i = v; i <= pre; ++i)
				(w[y][i] += (ll)w[x][i - v] * t % Mod) %= Mod; 
		}
	}
	
	fac[0] = 1;
	for (int i = 1; i <= n; ++i) fac[i] = (ll)fac[i - 1] * i % Mod;
	
	for (int i = 0; i <= n; ++i) 
		if (i & 1) (ans -= (ll)fac[n - i] * w[x][i] % Mod) %= Mod;
		else (ans += (ll)fac[n - i] * w[x][i] % Mod) %= Mod;
		
	if (ans < 0) ans += Mod;
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 61184
#include<stdio.h>
#define a 10000
#define b 500

int main(){
  int i,j,n,q,S[a],T[b],c=0;
  scanf("%d",&n);  
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);  
  scanf("%d",&q);  
  for(i=0;i<q;i++)
    scanf("%d",&T[i]);  
  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(S[j]==T[i]){
	c++;
	break;
      }
    }
  }
  printf("%d\n",c);  
  return 0;
}



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

int main() {
  string S;
  cin >> S;
  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
  cout << "Yes" << endl;
  }
  else {
  cout << "No" << endl;   
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
const int maxn=1010;
int n,x[maxn],y[maxn],f[2],a[100],m;
int main(){
    scanf("%d",&n);
    rep(i,1,n) scanf("%d%d",&x[i],&y[i]),f[(x[i]+y[i])&1]++;
    if(f[0]&&f[1]) return puts("-1"),0;
    if(f[0]) m=1,a[1]=1;
    rep(i,0,30) a[++m]=1<<i;
    printf("%d\n",m);
    per(i,m,1) printf("%d ",a[i]);puts("");
    rep(i,1,n){
        if(f[0]) ++x[i];
        per(j,30,0)
            if(abs(x[i])>abs(y[i]))
                putchar(x[i]>0?'R':'L'),x[i]>0?(x[i]-=1<<j):(x[i]+=1<<j);
            else 
                putchar(y[i]>0?'U':'D'),y[i]>0?(y[i]-=1<<j):(y[i]+=1<<j);
        if(f[0]) putchar('L');
        puts("");
    }
    return 0;
}

Measured memory_bytes: 256
//abc133_b.cpp
//Sun Jul  7 20:47:39 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	map<int,int> mp;
	for (int i=1;i<130;i++){
		mp[i*i]=1;
	}
	int n,d;
	cin >> n >> d;

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

	int ans = 0;
	for (int i=0;i<n-1;i++){
		for (int j=i+1;j<n;j++){
			int temp = 0;
			for (int k=0;k<d;k++){
				temp += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			}
			auto itr = mp.find(temp);
			if (itr != mp.end()){
				ans++;
			}
		}
	}


	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

alias rsort = sort!("a > b", SwapStrategy.unstable, long[]);

void main()
{
    auto xyzk = readln.split.to!(int[]);
    auto X = xyzk[0];
    auto Y = xyzk[1];
    auto Z = xyzk[2];
    auto K = xyzk[3];
    auto AS = readln.split.to!(long[]);
    rsort(AS);
    auto BS = readln.split.to!(long[]);
    rsort(BS);
    auto CS = readln.split.to!(long[]);
    rsort(CS);

    long[] R;
    R.length = X * Y;
    int i;
    foreach (a; AS) {
        foreach (b; BS) {
            R[i++] = a + b;
        }
    }
    rsort(R);
    R = R[0..min($, 3000)];
    long[] S;
    S.length = Z * R.length;
    i = 0;
    foreach (r; R) {
        foreach (c; CS) {
            S[i++] = r + c;
        }
    }
    rsort(S);
    foreach (s; S[0..K]) writeln(s);
}

Measured memory_bytes: 36604