akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
#define MAX 100000

int parent(int i) {return i/2;}
int left(int i) {return 2*i;}
int right(int i) {return 2*i+1;}

int main(){
	int H,i,A[MAX+1];

	cin >> H;
	for(i=1;i<=H;i++) cin >> A[i];

	for(i=1;i<=H;i++){
		cout << "node " << i << ": key = " << A[i] << ", ";
		if(parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
		if(left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
		if(right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3064
h = [0] * 2019
h[0] = p10 = 1
cur = 0

gets.to_s.chomp.bytes.reverse_each do |c|
  cur = ( cur + ( c - 48 ) * p10 ) % 2019 # p '0'.ord 48
  h[cur] += 1
  p10 = p10 * 10 % 2019
end

ans = h.map{|i| i * (i-1) / 2 }.sum

puts ans

Measured memory_bytes: 16216
#include <stdio.h>

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    long long a[200001];
    for(int i=0; i<n; i++) {
        scanf("%lld", &a[i]);
    }
    long long sum = 1;
    for(int i=0; i<k; i++) {
        sum *= a[i];
    }
    long long tmp = a[0];
    for(int i=1; i<=n-k; i++) {
        if(a[i+k-1] > tmp) {
            printf("Yes\n");
        }
        else {
            printf("No\n");
        }
        tmp = a[i];
    }
    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, ans;
bool dp[MAXN];

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n;
	dp[0]=dp[100]=dp[101]=dp[102]=dp[103]=dp[104]=dp[105]=1;
	for (int i=106; i<=n; i++) dp[i]=dp[i-100]|dp[i-101]|dp[i-102]|dp[i-103]|dp[i-104]|dp[i-105];
	cout<<dp[n]<<'\n';
	
	return 0;
}


Measured memory_bytes: 384
use proconio::{fastout, input, marker::*};

fn gcd(a: usize, b: usize) -> usize {
    let mut x = a;
    let mut y = b;

    loop {
        if x < y {
            let tmp = x;
            x = y;
            y = tmp;
        }

        let z = x % y;
        if z == 0 {
            break;
        }
        x = y;
        y = z;
    }
    return y;
}

fn tri_gcd(a:usize, b:usize, c:usize) -> usize {
    return gcd(gcd(a,b), c);
}

#[fastout]
fn main() {
    input! {
        k: usize,
    }

    let mut ans = 0;
    for a in 1..k+1 {
        for b in 1..k+1 {
            for c in 1..k+1 {
                ans += tri_gcd(a, b, c);
            }
        }
    }

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


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
ll H,W,K;
vector<string> c;
ll ans;

void dfs(int h,int w,set<int> &hs,set<int> &ws){
    if(h==H &&w ==W){
        //validate
        ll temp =0;
        for(int i=0;i<H;i++)for(int j=0;j<W;j++){
            if(hs.find(i) != hs.end()){
                continue;
            }
            if(ws.find(j) != ws.end()){
                continue;
            }
            if(c[i][j] =='#'){
                temp++;
            }
        }
        if(temp ==K){
            ans++;
        }
        return;
    }
    //まず縦方向
    if(h<H){
        hs.insert(h);
        dfs(h+1,w,hs,ws);
        hs.erase(h);
        dfs(h+1,w,hs,ws);
        return;
    }
    ws.insert(w);
    dfs(h,w+1,hs,ws);
    ws.erase(w);
    dfs(h,w+1,hs,ws);
}





// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    cin >> H >>W >> K;
    c.resize(H);
    for(int i=0;i<H;i++){
        cin >> c[i];
    }
    set<int> hs,ws;
    dfs(0,0,hs,ws);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll sx;
    cin >> sx;
    ll sy;
    cin >> sy;
    ll tx;
    cin >> tx;
    ll ty;
    cin >> ty;
    ll A=tx-sx;
    ll B=ty-sy;
    deque<char> ans;
    for(ll i=0;i<B;++i)ans.emplace_back('U');
    for(ll i=0;i<A;++i)ans.emplace_back('R');
    ans.emplace_back('U');
    for(ll i=0;i<A+1;++i)ans.emplace_back('L');
    for(ll i=0;i<B+1;++i)ans.emplace_back('D');
    ans.emplace_back('R');
    ans.emplace_back('D');
    for(ll i=0;i<A+1;++i)ans.emplace_back('R');
    for(ll i=0;i<B+1;++i)ans.emplace_back('U');
    ans.emplace_back('L');
    for(ll i=0;i<B;++i)ans.emplace_back('D');
    for(ll i=0;i<A;++i)ans.emplace_back('L');
    for(ll i=0;i<ans.size();++i)cout<<ans[i];
    cout<<endl;


    return 0;
}


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

#define rep(i,n) for(ll i=0;i<n;i++)
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define YesNo(a) (a)?cout<<"Yes"<<endl:cout<<"No"<<endl
#define YESNO(a) (a)?cout<<"YES"<<endl:cout<<"NO"<<endl
#define INF (2e9)
#define PI (acos(-1))

int main(void){
    int n; cin >> n;
    vector<int> p(n); rep(i,n) cin >> p[i];
    
    int min_n = n;
    int ans = 0;
    rep(i,n){
        if(min_n >= p[i]) ans++;
        min_n = min(min_n, p[i]);
    }
    
    cout << ans << endl;
}


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

int gcd(int p, int q) {
    if (p % q == 0) return q;
    return gcd(q, p % q);
}

int main() {
    int K;
    cin >> K;

    int ans = 0;
    for (int i = 1; i<= K; i++){
        for (int j = 1; j <= K; j++) {
            for (int k = 1; k <= K; k++) {
                ans += gcd(gcd(i, j), k);
            }
        }
    }

    cout << ans << endl;

}

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

int main(){
	int H,W;

	while(1){
		cin >>H>>W;
		if (W==0 && H==0) break;
		for (int i=1; i<=H; i++){
			for (int k=1; k<=W; k++)cout << "#";
			cout <<"\n";
		}
		cout << "\n";
	}
	
	return 0;
}

Measured memory_bytes: 1124
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
char C[2];
int K, N, X, Y, b[2100][2100], sumb[4100][4100], sumw[4100][4100], w[2100][2100];
int main(){
  int i, j, opt, tmp;
  rd(N);
  rd(K);
  for(i=0;i<N;i++){
    rd(X);
    rd(Y);
    rd(C);
    X %= 2*K;
    Y %= 2*K;
    if(C[0]=='B'){
      b[X][Y]++;
    }
    else{
      w[X][Y]++;
    }
  }
  for(i=0;i<4*K;i++){
    for(j=0;j<4*K;j++){
      sumb[i+1][j+1] = b[i%(2*K)][j%(2*K)] + sumb[i][j+1] + sumb[i+1][j] - sumb[i][j];
    }
  }
  for(i=0;i<4*K;i++){
    for(j=0;j<4*K;j++){
      sumw[i+1][j+1] = w[i%(2*K)][j%(2*K)] + sumw[i][j+1] + sumw[i+1][j] - sumw[i][j];
    }
  }
  opt = 0;
  for(i=0;i<2*K;i++){
    for(j=0;j<2*K;j++){
      tmp  = sumb[i+K][j+K] - sumb[i][j+K] - sumb[i+K][j] + sumb[i][j];
      tmp += sumb[i+2*K][j+2*K] - sumb[i+K][j+2*K] - sumb[i+2*K][j+K] + sumb[i+K][j+K];
      tmp += sumw[i+2*K][j+K] - sumw[i+K][j+K] - sumw[i+2*K][j] + sumw[i+K][j];
      tmp += sumw[i+K][j+2*K] - sumw[i][j+2*K] - sumw[i+K][j+K] + sumw[i][j+K];
      chmax(opt, tmp);
    }
  }
  wt_L(opt);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20180108-2

// --- original code ---
// int N, K, X, Y;
// char C[2];
// 
// int b[2100][2100], sumb[4100][4100];
// int w[2100][2100], sumw[4100][4100];
// 
// {
//   int i, j;
//   int opt, tmp;
//   
//   rd(N,K);
//   rep(i,N){
//     rd(X,Y,C);
//     X %= 2K;
//     Y %= 2K;
// 
//     if(C[0]=='B') b[X][Y]++;
//     else          w[X][Y]++;
//   }
// 
//   rep(i,4K) rep(j,4K) sumb[i+1][j+1] = b[i%(2K)][j%(2K)] + sumb[i][j+1] + sumb[i+1][j] - sumb[i][j];
//   rep(i,4K) rep(j,4K) sumw[i+1][j+1] = w[i%(2K)][j%(2K)] + sumw[i][j+1] + sumw[i+1][j] - sumw[i][j];
// 
//   opt = 0;
//   rep(i,2K) rep(j,2K){
//     tmp  = sumb[i+K][j+K] - sumb[i][j+K] - sumb[i+K][j] + sumb[i][j];
//     tmp += sumb[i+2K][j+2K] - sumb[i+K][j+2K] - sumb[i+2K][j+K] + sumb[i+K][j+K];
//     tmp += sumw[i+2K][j+K] - sumw[i+K][j+K] - sumw[i+2K][j] + sumw[i+K][j];
//     tmp += sumw[i+K][j+2K] - sumw[i][j+2K] - sumw[i+K][j+K] + sumw[i][j+K];
//     opt >?= tmp;
//   }
// 
//   wt(opt);
// }


Measured memory_bytes: 165248
#include <stdio.h>
#include <vector>
#include <map>
#include <set>
using namespace std;
map<char, int> mp;
char inp[5];
int main(void) {
	scanf("%s", inp);
	for (int i = 0; i < 4; i++) {
		mp[inp[i]]++;
	}
	if (mp.size() != 2) {
		return !printf("No\n");
	}
	for (auto e : mp) {
		if (e.second != 2) return !printf("No\n");
	}
	return !printf("Yes\n");
}

Measured memory_bytes: 256
/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog ender-zzm.enbar.cn
*/
#include <bits/stdc++.h>
using namespace std;

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
inline int readint(){
    register int x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}

inline long long readlong() {
	register long long x = 0, flag = 1;
	register char ch;
	while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}
template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define For(i, x, y) for (int i = (x); i <= (y); i++) 
#define Rep(i, x, y) for (int i = (x); i >= (y); i--) 
#define ri readint
#define rl readlong

#define int long long
signed main() {
	int n, a, b;
	cin >> n >> a >> b;
	int op = (n / (a + b));
	int ans = op * a;
	int yu = n % (a + b);
	if (yu <= a) ans += yu;
	else ans += a;
	cout << ans;
	return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;

int main(){
    int n,m; cin >> n >> m;
    vector<int> a(n,0);
    rep(i,n) cin >> a.at(i);
    sort(a.begin(),a.end());
    vector<pair<int,int>> cb(m,make_pair(0,0));
    rep(i,m) cin >> cb.at(i).second >> cb.at(i).first;
    sort(cb.rbegin(),cb.rend());
    int scope = 0;
    ll ans = 0;
    rep(i,m){
        int amt = cb.at(i).second;
        int value = cb.at(i).first;
        auto it = lower_bound(a.begin(),a.end(),value);
        int x = it - a.begin();
        int change_amount = min(amt,max(0,x-scope));
        //cout << i <<" " << change_amount << endl;
        rep(j,change_amount){
            ans += value;
            scope++;
            if(scope == n) goto aaaa;
        }
    }
    aaaa:;
    for(int i=scope;i<n;i++){
		ans+=a.at(i);
    }
    cout << ans << endl;
}


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

using namespace std; 

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mmp make_pair
#define st first
#define nd second
#define rd third
#define ll long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define itr pair <int, pii>
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define Rep(i, n) for (int (i) = 0; (i) <= (int)(n); i++)
#define For(i, a, n) for (int (i) = (a); (i) <= (int)(n); i++)
#define Forn(i, a, n) for (int (i) = (a); (i) >= (int)(n); i--)
#define rep(i, n) for (int (i) = 1; (i) <= (int)(n); i++)
#define EACH(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define DEBUG(x) cout << #x << " = " << (x) << endl; 
#define PR(a, n) {cout << #a << " = "; FOR(_, 1, n) cout << a[_] << ' '; puts(""); }
#define PRO(a, n) { cout << #a << " = "; REP(_, n) cout << a[_] << ' '; puts(""); }
#define pi 3.1415926535897932384626433832795028841971
//#define LOCAL

const int INF = 1e9; 
const int Maxn = 1005; 
const int dx[] = {-1, 0, 1, 0}; 
const int dy[] = {0, 1, 0, -1}; 

struct pos { int first, second, third; }; 

int n, m; 
queue <int> Q; 
vector <int> Deg, D; 
vector <vector <int> > E; 

int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin); 
		freopen("output.txt", "w", stdout); 
	#endif
	
	scanf("%d%d", &n, &m); 
	Deg.resize(n + 1); 
	D.resize(n + 1); 
	E.resize(n + 1); 
	
	REP(i, m)
	{
		int x, y; 
		scanf("%d%d", &x, &y); 
		E[x].pb(y); 
		Deg[y]++; 
	}
	
	rep(i, n) if (!Deg[i]) Q.push(i); 
	int res = 0; 
	while (!Q.empty())
	{
		int x = Q.front(); 
		Q.pop(); 
		
		res = max(res, D[x]); 
		//printf("D[%d] = %d\n", x, D[x]); 
		REP(i, E[x].size())
		{
			int y = E[x][i]; 
			Deg[y]--; 
			D[y] = max(D[y], D[x] + 1); 
			if (!Deg[y]) Q.push(y); 
		}
	}
	
	printf("%d\n", res); 
	
	return 0; 
}

Measured memory_bytes: 6528
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = null;
		try {
			sc = new Scanner(System.in);
			while (sc.hasNextInt()) {
				int d = sc.nextInt();
				int areaCulcCount = 600 / d;
				long sum = 0L;

				for (int i = 1; i < areaCulcCount; i++) {
					int x = i * d;
					int y = x * x;
					sum += y * d;
				}
				System.out.println(sum);
			}
		} finally {
			sc.close();
		}
	}
}

Measured memory_bytes: 26076
import sys
input = sys.stdin.readline


def main():
    A = [list(map(int, input().split())) for _ in range(3)]
    a = [[False] * 3 for _ in range(3)]
    n = int(input())
    for _ in range(n):
        b = int(input())
        for i in range(3):
            for j in range(3):
                if A[i][j] == b:
                    a[i][j] = True
    for i in range(3):
        if all(a[i]):
            print("Yes")
            return
    for j in range(3):
        if all([a[0][j], a[1][j], a[2][j]]):
            print("Yes")
            return
    if a[0][0] and a[1][1] and a[2][2]:
        print("Yes")
        return
    if a[0][2] and a[1][1] and a[2][0]:
        print("Yes")
        return
    print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
def fact(n):
    tmp = n
    ret = []
    while(True):
        if tmp == 1:
            break
        for i in range(2, n + 1):
            if tmp % i == 0:
                tmp = tmp / i
                ret.append(i)
                break
    return ret

n = int(input())

lis = fact(n)

bina = [0 for i in range(len(lis))]
ret = False
for i in range(2 ** len(lis)):

    A = 1
    B = 1
    for j in range(len(bina)):
        if bina[j] == 0:
            A *= lis[j]
        else:
            B *= lis[j]
    
    #print(A, B)
    if A < 10 and B < 10:
        ret = True
        break

    bina[-1] += 1
    for j in range(len(bina) - 1, 0, -1):
        if bina[j] > 1:
            bina[j - 1] += 1
            bina[j] -= 2

if ret:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String arg[]) {
		Scanner scan = new Scanner(System.in);
		int x1 = scan.nextInt();
		int y1 = scan.nextInt();
		int z1 = scan.nextInt();
		
		int x2 = y1;
		int y2 = x1;
		int z2 = x2;
		x2 = z1;
		
		System.out.println(x2 + " " + y2 + " " + z2);
		
	}
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int n, k;
    cin >> n >> k;
    if((k == 1) || (k == (2 * n - 1))){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    if(n == 2){
        cout << 1 << endl << 2 << endl << 3 << endl;
        return 0;
    }
    if(n == 3){
        if(k == 2){
            cout << 5 << endl << 1 << endl << 2 << endl << 3 << endl << 4 << endl;
        }
        if(k == 3){
            for(int i = 1; i <= 5; i++){
                cout << i << endl;
            }
        }
        if(k == 4){
            cout << 3 << endl << 4 << endl << 5 << endl << 1 << endl << 2 << endl;
        }
        return 0;
    }
    if(n == k){
        for(int i = 1; i <= 2 * n - 1; i++){
            cout << i << endl;
        }
        return 0;
    }
    int ans[205000];
    bool checker = false;
    if(k <= 4){
        checker = true;
        k = 2 * n - k;
    }
    bool used[205000];
    for(int i = 1; i <= 2 * n - 1; i++){
        ans[i] = 0;
    }
    ans[n] = k;
    ans[n + 1] = 2 * n - 1;
    ans[n + 2] = 1;
    ans[n + 3] = 2;
    ans[n - 1] = 3;
    ans[n - 2] = 4;
    int now = 5;
    for(int i = 1; i <= 2 * n - 1; i++){
        if(ans[i] != 0){
            continue;
        }
        if(now == k){
            now++;
        }
        ans[i] = now;
        now++;
    }
    for(int i = 1; i <= 2 * n - 1; i++){
        if(checker){
            ans[i] = 2 * n - ans[i];
        }
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 2304
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
 
class Program
{
    static void Main()
    {
        var AB = ReadLine().Split().Select(int.Parse).ToArray();
        var A = AB[0];
        var B = AB[1];
 
        WriteLine(A < 9 && B < 9 ? "Yay!" : ":(");
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
ll zero_xor(ll n ){
  //if(n<0)return 0;
  if (n % 4 == 0) {
		return n;
	}
 
	if (n % 4 == 1) {
		return 1;
	}
 
	if (n % 4 == 2) {
		return n + 1;
	}
 
	return 0;
}
int main(){
  ll a,b;
  cin>>a>>b;
  ll ans = zero_xor(a-1) ^ zero_xor(b);

  cout<<ans<<endl;
  

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
    oreno_initializer() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} oreno_initializer;



string s;

signed main() {
    cin >> s;
    int n = s.size();
    int w = count(all(s), 'o') + 15-n;
    cout << (w>=8 ? "YES" : "NO") << endl;
}


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

x = []
y = []
for i in range(1,n+1):
  t = l + i - 1
  y.append(abs(t))
  x.append(t)
  
tmp = zip(y,x)
tmp2 = sorted(tmp)
c,ans = zip(*tmp2)
print(sum(ans[1:]))

Measured memory_bytes: 38512
use std::io::*;

use std::str::FromStr;

 

fn read<T: FromStr>() -> T {

    let stdin = stdin();

    let stdin = stdin.lock();

    let token: String = stdin

        .bytes()

        .map(|c| c.expect("failed to read char") as char)

        .skip_while(|c| c.is_whitespace())

        .take_while(|c| !c.is_whitespace())

        .collect();

    token.parse().ok().expect("failed to parse token")

}

fn main() {

    //点

    let n: usize = read();

    //次元

    let d: usize = read();

    let mut x: [[i32; 10]; 10] = [[0; 10]; 10];

    let mut ans: u32 = 0;

 

    for i in 0..n {

        for j in 0..d {

            x[i][j] = read();

        }

    }

 

    for i in 0..n {

        for j in i + 1..n {

            let mut sum = 0;

            for k in 0..d {

                sum += (x[i][k] - x[j][k]).abs().pow(2);

            }

            let distance = (sum as f64).sqrt();

            if distance % 1.0 == 0.0 {

                ans += 1;

            }

        }

    }

 

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

}

Measured memory_bytes: 4352
n = int(input())
vs = list(map(int, input().split()))
cs = list(map(int, input().split()))

# ret = - float('inf')
# for i in range((2 ** n)):
#     total_cost = 0
#     total_value = 0
#     j = 0
#     while i > 0:
#         if i & 1:
#             total_cost += cs[j]
#             total_value += vs[j]
#         i >>= 1
#         j += 1
#     ret = max(ret, total_value - total_cost)
# print(ret)

x = 0
y = 0
for i in range(n):
    if vs[i] > cs[i]:
        x += vs[i]
        y += cs[i]
print(x - y)


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

int main()
{
    int N;
    std::cin >> N;

    std::vector<int> d(N);
    for (int i = 0; i < N; i++) {
        std::cin >> d[i];
    }

    std::sort(std::begin(d), std::end(d));

    int i = N/2;
    int h = d[i] - d[i-1];
    //if (h > 0) h -= 1;

    std::cout << h << std::endl;

    return 0;
}

Measured memory_bytes: 640
import statistics as st
import math
N = int(input())
A = [0]*N
B = [0]*N
for i in range(N):
  A[i] , B[i] = map(int,input().split())
mA = st.median(A)
mB = st.median(B)
if N % 2 == 0:
  ans = (mB - mA)*2 + 1
else:
  ans = mB - mA + 1
print(int(ans))  

Measured memory_bytes: 28824
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    int n;
    cin >> n;
    VI s(1 << n);
    FOR(i, 0, (1 << n))cin >> s[i];
    SORT(s);

    multiset<int> set;//作る必要があるサイズ一覧
    FOR(i, 0, (1 << n) - 1)set.insert(s[i]);

    VI slimes = { s[(1 << n) - 1] }, next;
    FOR(i, 0, n) {
        next = slimes;
        FOR(j, 0, (1 << i)) {
            auto itr = set.lower_bound(slimes[j]);
            if (itr == set.begin()) {
                cout << "No\n";
                return 0;
            }
            next.push_back(*--itr);
            set.erase(itr);
        }

        rSORT(next, greater<int>());
        slimes = next;
    }
    cout << "Yes\n";
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i=0; i<n; i++){
        int l, r;
        cin >> l >> r;
        ans += (r-l+1);
    }
    cout << ans << endl;
    return 0;
}

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

#define min(x,y) ((x)<(y)?(x):(y))

int qsort_lld(const void *a, const void *b) {
    if (*(long long *)a < *(long long *)b) {
        return 1;
    }
    return -1;
}

int main(int argc, char *argv[])
{
    int x, y, z, k;
    long long a[1000], b[1000], c[1000];
    int yz;
    long long d[1000000];
    long long *e;
    int xyz;
    int i;
    int ans;

    e = malloc(sizeof(long long) * 3000000);

    scanf("%d %d %d %d", &x, &y, &z, &k);

    for (i = 0; i < x; i++) {
        scanf("%lld", &a[i]);
    }
    for (i = 0; i < y; i++) {
        scanf("%lld", &b[i]);
    }
    for (i = 0; i < z; i++) {
        scanf("%lld", &c[i]);
    }

    yz = y * z;
    for (i = 0; i < yz; i++) {
        d[i] = b[i / z] + c[i % z];
    }

    qsort(a, x, sizeof(long long), qsort_lld);
    qsort(d, yz, sizeof(long long), qsort_lld);

    yz = min(yz, 3000);
    xyz = x * yz;
    for (i = 0; i < xyz; i++) {
        e[i] = a[i / yz] + d[i % yz];
    }
    qsort(e, xyz, sizeof(long long), qsort_lld);

    for (i = 0; i < k; i++) {
        printf("%lld\n", e[i]);
    }

    return 0;
}


Measured memory_bytes: 54900
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())



void init() {

}

void input() {

}

void solve() {
  double w, h, x, y;
  cin >> w >> h >> x >> y;
  printf("%.6f ", w*h/2);
  if (x == w/2 && y == h/2) {
    cout << 1;
  } else {
    cout << 0;
  }
  cout << endl;
}

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


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def calc(N):
    return sum(int(x) for x in str(N))


def main():
    # sys.stdin = open("sample.txt")
    N, K = Scanner.map_int()
    if K % 2 == 0:
        c1, c2 = 0, 0
        for i in range(1, N+1):
            if i % K == 0:
                c1 += 1
            if i % K == K // 2:
                c2 += 1
        print(c1 ** 3 + c2 ** 3)
    else:
        print((N // K) ** 3)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 39532
#include<stdio.h>
int main(){
	int n, a, b;
	scanf("%d %d %d", &n, &a, &b);
	if(n == 1){
		if(a== b)
		printf("1\n");
		else printf("0\n");
	}else{
		if(a > b)
		printf("0\n");
		else{
			printf("%lld\n", (long long)(n-2)*(b-a)+1 );
		}
	}
	
	return 0;
}

Measured memory_bytes: 128
import math
 
A, B, H, M = map(int, input().split())
angleA = 30 * H + 30 / 60 * M
angleB = 360 / 60 * M
x = abs(angleA - angleB)
if x > 180:
    x = 360 - x
l = math.sqrt(A * A + B * B - 2 * A * B * math.cos(math.radians(x)))
print(l)

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

int main(){
    string s;
    int n,m,cnt;
    char tmp[100000];
    while(1){
        cnt = 0;
        cin >> n;
        if(n == 0) break;
        cin >> m >> s;
        memset(tmp,0,sizeof(tmp));
        for(int i=1,j=0;i<=2*n+1;i++){
            if(i % 2 == 1) tmp[i-1] = 'I';
            else if(i % 2 == 0){
                tmp[i-1] = 'O';
                j++;
            }
        }
        for(int i=0;i<m;i++){
            if(strcmp(s.substr(i,2*n+1).c_str(),tmp) == 0) cnt++;
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 2212
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())

_sum = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            _sum +=gcd(a, b, c)

print(_sum)

Measured memory_bytes: 69564
import math
a, b, x = map(int, input().split())
space = a*a*b
aki = space - x
if x >= space / 2:
    sankaku = aki / a
    y = sankaku * 2 / a
    z = (a*a + y*y)**0.5
    ans = math.degrees(math.atan(y/a))
else:
    sankaku2 = x / a
    a2 = sankaku2 * 2 / b
    d = (a2*a2 + b*b)**0.5
    ans1 = math.degrees(math.atan(a2/b))
    ans = 90 - ans1
print(ans)


Measured memory_bytes: 38320
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
template<class C>constexpr int size(const C &c){return (int)c.size();}
template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?9e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	ll n,m;
	cin>>n>>m;
	vp in(n);
	rep(i,n)cin>>in[i].first>>in[i].second;
	sort(all(in));
	ll out=inf;
	rep(i,n-1)loop(j,i+1,n){
		vi t;
		loop(k,i,j+1)t.pb(in[k].second);
		sort(all(t));
		if((int)t.size()-m+1>0)rep(k,t.size()-m+1)
			out=min(out,(in[j].first-in[i].first)*(t[k+m-1]-t[k]));
	}
	cout<<out<<endl;
}











Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;

    if (s == "abc" || s == "acb" || s == "bac" || s == "bca" || s == "cab" || s == "cba") {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main(void){
    char s[3]; 
    int yes = 1;

    scanf("%s", s);
    yes = 1;
//    printf("%s %c %c %c %d\n", s, s[0], s[1], s[2], yes);

    if(s[0] == s[1] && s[0] == s[2]){
        yes = 0;
//        printf("aaa\n");
    }
//    printf("%s %c %c %c %d\n", s, s[0], s[1], s[2], yes);

//    yes = 1;
    if(yes == 1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;

} 


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <map>
#include <iostream>
#include <cstring>
#include <cmath>
#define ull unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
void close(){
   	std::ios::sync_with_stdio(false);
   	std::cin.tie(0);
}
const int maxn=5e4+10;
int main(){
	char c;
	cin>>c;
	char a=char(c+1);
	cout<<a;	
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int h[n];
    bool good[n];

    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
        good[i] = true;
    }
    int a, b;
    for (int i = 0; i < m; i++)
    {
        cin >> a >> b;
        if (h[a - 1] > h[b - 1])
        {
            good[b - 1] = false;
        }
        else if (h[a - 1] < h[b - 1])
        {
            good[a - 1] = false;
        }
        else
        {
            good[a - 1] = false;
            good[b - 1] = false;
        }
    }
    int res = 0;
    for (int i = 0; i < n; i++)
    {
        if (good[i] == true)
            res++;
    }
    cout << res << endl;

    return 0;
}

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

int N, M, K;

int main() {
    scanf("%d %d %d", &N, &M, &K);

    for(int i = 0; i <= N; i++) {
        for(int j = 0; j <= M; j++) {
            if(i*j + (N - i)*(M - j) == K) {
                printf("Yes");
                return 0;
            }
        }
    }
    printf("No");
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
void ABC120(void);
void ABC121(void);
void ABC122(void);
void ABC123(void);
void ABC124(void);
void ABC125(void);
void ABC126(void);
void ABC127(void);
void ABC128(void);
void ABC129(void);

int main(void){
    ABC124();
}

void ABC124(){
    int a,b,sum=0;
    cin>>a>>b;
    if(a>b){
        sum=a;
        --a;
    }else{
        sum=b;
        --b;
    }
    if(a>b)sum+=a;
    else sum+=b;
    cout<<sum<<endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
Field = []
Field.append(['#'] * (W+2))
for _ in range(H):
    Field.append((list('#'+input()+'#')))
Field.append(['#'] * (W+2))

DPL = [[0 for _ in range(W+2)] for _ in range(H+2)]
DPR = [[0 for _ in range(W+2)] for _ in range(H+2)]
DPU = [[0 for _ in range(W+2)] for _ in range(H+2)]
DPD = [[0 for _ in range(W+2)] for _ in range(H+2)]

for h in range(1, H+1):
    for w in range(1, W+1):
        if Field[h][w] == '#':
            DPL[h][w] = 0
        else:
            DPL[h][w] = DPL[h][w-1] + 1
for h in range(1, H+1):
    for w in range(1, W+1):
        if Field[h][W-w+1] == '#':
            DPR[h][W-w+1] = 0
        else:
            DPR[h][W-w+1] = DPR[h][W-w+1+1] + 1
for h in range(1, H+1):
    for w in range(1, W+1):
        if Field[h][w] == '#':
            DPU[h][w] = 0
        else:
            DPU[h][w] = DPU[h-1][w] + 1   
for h in range(1, H+1):
    for w in range(1, W+1):
        if Field[H-h+1][w] == '#':
            DPD[H-h+1][w] = 0
        else:
            DPD[H-h+1][w] = DPD[H-h+1+1][w] + 1 
ans = 0          
for h in range(1, H+1):
    for w in range(1, W+1):
        ans = max(ans,DPL[h][w]+DPR[h][w]+DPU[h][w]+DPD[h][w])
print(ans-3)

Measured memory_bytes: 313864
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	int n;
	cin >> n;
	
	vi a(n);
	for(int i = 0; i < n; i++) cin >> a[i];	
	
	int mx = 0, mn = 0;
	for(int i = 0; i < n; i++) {
		if(a[mx] < a[i]) mx = i;
		if(a[mn] > a[i]) mn = i;
	}
	
	cout << 2 * n - 1 << endl;
	if(abs(a[mx]) >= abs(a[mn])) {
		for(int i = 0; i < n; i++) {
			cout << mx + 1 << " " << i + 1 << endl;
		}
		
		for(int i = 0; i < n - 1; i++) {
			cout << i + 1 << " " << i + 2 << endl;
		}
	} else {
		for(int i = 0; i < n; i++) {
			cout << mn + 1 << " " << i + 1 << endl;
		}
		
		for(int i = n - 1; i > 0; i--) {
			cout << i + 1 << " " << i << endl;
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 3660
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,H,W=get_i
ans=0
N.times do|i|
  a,b=get_i
  ans+=1 if a>=H and b>=W
end
puts ans

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

int main()
{

        long long P = 1e09 + 7;
        int N;
        cin >> N;


        long long power = 1;
        for (int i = 0; i < N; ++i) {
                power *= (i+1);
                power = power % P;
        }

        cout << power << endl;


}


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

#define LL long long
#define MOD 1000000007
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;

int main() {
    fastio;
    int l,r,k;
    cin >>l>>r>>k;
    int count=0;
    for(int i=l;i<=r;i++){
       
       if(i%k==0)
        count++;
    }
    cout<<count<<"\n";
    return 0;   
}

Measured memory_bytes: 3608
#include<stdio.h>
 #include <math.h> 
int abs(int a) {
 if(a>0)
 return a; 
else 
return -1*a; 
} 
int min(int a,int b) {
 if(a>b)
 return b;
 else 
return a;
 }
 int main()
 {
 int n,k;
 scanf("%d %d",&n,&k);
 int h[n];
 for(int i=0;i<n;i++) { 
scanf("%d",&h[i]);
 } 
int dp[n];
 for(int i=0;i<n;i++)
 dp[i]=(int) INFINITY; 
dp[0]=0; 
dp[1]= abs(h[1]-h[0]);
 for(int i=2;i<n;i++) { 
for(int j=1;j<=k;j++) { 
dp[i]=min(dp[i], abs(h[i-j]-h[i])+dp[i-j]);
 } 
}
 printf("%d",dp[n-1]);
 return 0;
 } 


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

#define fi first
#define se second

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

const int MAXN = 2e5 + 5;

const ll INF = 5e16;

int n;
int a[MAXN];

ll brute(int i, int qtt) {
	if (i > n) {
		if (qtt == n/2) return 0;
		else return -INF;
	}

	return max(a[i] + brute(i+2, qtt+1), brute(i+1, qtt));
}

ll memo[MAXN][5];
ll solve(int i, int duplo) {
	if (i > n) return duplo * -INF;

	ll& ret = memo[i][duplo];
	if (ret != -INF) return ret;

	ret = max(ret, a[i] + solve(i+2, duplo));
	if (duplo) ret = max(ret, solve(i+1, duplo-1));

	return ret;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);

	if (n <= 10) printf("%lld\n", brute(1, 0));
	else {
		for (int i = 1; i <= n; i++) for (int j = 0; j <= 4; j++)
			memo[i][j] = -INF;

		ll ans = -INF;
		if (n%2 == 0) {
			ans = solve(1, 1);
			ans = max(ans, solve(2, 0));
		} else {
			ans = solve(1, 2);
			ans = max(ans, solve(2, 1));
		}

		printf("%lld\n", ans);
	}
	
}

Measured memory_bytes: 17092
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W; cin >> H >> W;
	int ans = INF;
	rep(i, 0, H) {
		int a, b, c;
		a = i*W;
		b = (H - i) / 2 * W;
		c = (H - i + 1) / 2 * W;
		chmin(ans, max({ a, b, c }) - min({ a, b, c }));
		b = W / 2 * (H - i);
		c = (W + 1) / 2 * (H - i);
		chmin(ans, max({ a,b,c }) - min({ a,b,c }));
	}
	rep(j, 0, W) {
		int a, b, c;
		a = j*H;
		b = (W - j) / 2 * H;
		c = (W - j + 1) / 2 * H;
		chmin(ans, max({ a,b,c }) - min({ a,b,c }));
		b = H / 2 * (W - j);
		c = (H + 1) / 2 * (W - j);
		chmin(ans, max({ a,b,c }) - min({ a,b,c }));
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
	int a, b, c, k;

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

	if(a>b&&a>c){
		a = a*pow(2,k);
		a +=b + c;
		printf("%d\n",a);
	}else if(b>a&&b>c){
		b = b*pow(2,k);
		b +=a + c;
		printf("%d\n",b);
	}else{
		c = c*pow(2,k);
		c +=a + b;
		printf("%d\n",c);
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

struct Tag {
    int a;
    int b1, b2;
    bool start;

    Tag() : a(0), b1(0), b2(0), start(false) {}
    Tag(int aa, int bb1, int bb2, bool s) : a(aa), b1(bb1), b2(bb2), start(s) {}
};

bool cmp(const Tag &t1, const Tag &t2) {
    if(t1.a != t2.a) return t1.a < t2.a;
    return !t1.start;
}

int main() {
    while(true) {
        int N, R;
        cin >> N >> R;
        if(!N && !R) break;

        vector<Tag> xtag, ytag;
        for(int i = 0; i < N; ++i) {
            int x1, y1, x2, y2;
            scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
            xtag.push_back(Tag(x1, y1, y2, true));
            xtag.push_back(Tag(x2, y1, y2, false));
            ytag.push_back(Tag(y1, x1, x2, true));
            ytag.push_back(Tag(y2, x1, x2, false));
        }
        sort(xtag.begin(), xtag.end(), cmp);
        stable_sort(ytag.begin(), ytag.end(), cmp);

        int max_y = ytag[ytag.size()-1].a;
        int area = 0;
        int len = 0;
        for(int y = 0; y < max_y; ++y) {
            int depth = 0;
            int startx = 0;
            int prevx = -1;
            for(int i = 0; i < xtag.size(); ++i) {
                if(xtag[i].b1 <= y && y < xtag[i].b2) {
                    if(xtag[i].start) {
                        if(depth == 0) {
                            if(xtag[i].a != prevx) ++len;
                            else --len;
                            startx = xtag[i].a;
                        }
                        ++depth;
                    }
                    else {
                        if(--depth == 0) {
                            area += xtag[i].a-startx;
                            prevx = xtag[i].a;
                            ++len;
                        }
                    }
                }
            }
        }

        cout << area << endl;
        if(R == 1) continue;

        int max_x = xtag[xtag.size()-1].a;
        for(int x = 0; x < max_x; ++x) {
            int depth = 0;
            int prevy = -1;
            for(int i = 0; i < ytag.size(); ++i) {
                if(ytag[i].b1 <= x && x < ytag[i].b2) {
                    if(ytag[i].start) {
                        if(depth == 0) {
                            if(prevy != ytag[i].a) ++len;
                            else --len;
                        }
                        ++depth;
                    }
                    else {
                        if(--depth == 0) {
                            ++len;
                            prevy = ytag[i].a;
                        }
                    }
                }
            }
        }
        cout << len << endl;
    }
    return 0;
}

Measured memory_bytes: 1980