akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a,b,c;
int sum;
int ans=0;
int main()
{
    cin>>a>>b>>c>>sum;
    for(int i=0;i<=a;i++)
    for(int j=0;j<=b;j++)
    for(int l=0;l<=c;l++)
    {
        if(500*i+100*j+50*l==sum) ans++;
        if(500*i+100*j+50*l>sum) break;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;

int N, K;
vector<int> D;
vector<int> allow;

int main() {
	cin >> N >> K;
	D.resize(N);
	for (int n = 0; n < N; n++)cin >> D[n];
	for (int d = 0; d < 10; d++) {
		bool flag = true;
		for (int n = 0; n < K; n++) {
			if (d == D[n]) {
				flag = false;
				break;
			}
		}
		if (flag)allow.push_back(d);
	}
	K = allow.size();
	for (int d4 = 0; d4 < K; d4++) {
		int num = allow[d4];
		if (num >= N) {
			cout << num << endl;
			return 0;
		}
	}
	for (int d3 = 0; d3 < K; d3++) {
		for (int d4 = 0; d4 < K; d4++) {
			int num = 10 * allow[d3] + allow[d4];
			if (num >= N) {
				cout << num << endl;
				return 0;
			}
		}
	}
	for (int d2 = 0; d2 < K; d2++) {
		for (int d3 = 0; d3 < K; d3++) {
			for (int d4 = 0; d4 < K; d4++) {
				int num = 100 * allow[d2] + 10 * allow[d3] + allow[d4];
				if (num >= N) {
					cout << num << endl;
					return 0;
				}
			}
		}
	}
	for (int d1 = 0; d1 < K; d1++) {
		for (int d2 = 0; d2 < K; d2++) {
			for (int d3 = 0; d3 < K; d3++) {
				for (int d4 = 0; d4 < K; d4++) {
					int num = 1000 * allow[d1] + 100 * allow[d2] + 10 * allow[d3] + allow[d4];
					if (num >= N) {
						cout << num << endl;
						return 0;
					}
				}
			}
		}
	}
	for (int d0 = 0; d0 < K; d0++) {
		for (int d1 = 0; d1 < K; d1++) {
			for (int d2 = 0; d2 < K; d2++) {
				for (int d3 = 0; d3 < K; d3++) {
					for (int d4 = 0; d4 < K; d4++) {
						int num = 10000 * allow[d0] + 1000 * allow[d1] + 100 * allow[d2] + 10 * allow[d3] + allow[d4];
						if (num >= N) {
							cout << num << endl;
							return 0;
						}
					}
				}
			}
		}
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math;
import java.util.ArrayList;
import java.util.List;
//List<String> color = new ArrayList<>();
//int[] n = new int[k];

class Main {
	static void swap(int[] a, int idx1, int idx2) {
		int t = a[idx1];
		a[idx1] = a[idx2];
		a[idx2] = t; 
	}
	static void quicksort(int[] a, int left, int right) {
		int pl = left;
		int pr = right;
		int x = a[(pl + pr) / 2];

		do {
			while (a[pl] < x) pl++;
			while (a[pr] > x) pr--;
			if (pl <= pr)
				swap(a, pl++, pr--);
		}	while (pl <= pr);

		if (left < pr)
			quicksort(a, left, pr);
		if (pl < right)
			quicksort(a, pl, right);
	}

	static void quicksort2(int[] a, int n) {
		quicksort(a, 0, n - 1);
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] l = new int[n];
		for (int i = 0; i < n; i++)
			l[i] = stdIn.nextInt();
		quicksort2(l, n);
		int s = 0;
		for (int i = 0; i < n - 1; i++)
			s = s + l[i];

		String a = (s > l[n-1]) ? "Yes" : "No";
		System.out.println(a);
	}
}

Measured memory_bytes: 21972
x0,y0,x1,y1 = map(float,input().split())
n = int(input())
vx1,vy1 = x1-x0,y1-y0

for i in range(n):
    x2,y2 = map(float,input().split())
    vx2,vy2 = x2-x0,y2-y0
    sqr = vx1**2 + vy1**2
    in_p = vx1*vx2 + vy1*vy2
    xt,yt = 2*in_p*vx1/sqr + 2*x0-x2,2*in_p*vy1/sqr + 2*y0-y2
    print("{0:.10f} {1:.10f}".format(xt,yt))

Measured memory_bytes: 7672
/***************************************************************
	File name: F.cpp
	Author: huhao
	Create time: Thu 16 Jan 2020 06:26:45 PM CST
***************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=r*10+c-48;
		c=getchar();
	}
	return r*t;
}
#define i64 long long
const int N=1000010,mod=1000000007;
i64 power(i64 a,i64 b,i64 p)
{
	i64 r=1;
	while(b)
	{
		if(b&1) r=r*a%p;
		a=a*a%p; b>>=1;
	}
	return r;
}
i64 inv(i64 a){ return power(a,mod-2,mod); }
namespace C
{
	i64 f[N],F[N];
	void init(int n)
	{
		f[0]=1;
		fr(i,1,n) f[i]=f[i-1]*i%mod;
		F[n]=inv(f[n]);
		fd(i,n,1) F[i-1]=F[i]*i%mod;
	}
	i64 C(i64 a,i64 b){ return f[a]*F[b]%mod*F[a-b]%mod; }
	i64 inv(i64 a){ return F[a]*f[a-1]%mod; }
}
int n;
i64 f[3],F[3],ans;
int main()
{
	n=read()-1; C::init(n+3); f[0]=1;
	fr(i,1,n+1)
	{
		fr(j,0,2){ F[j]=f[j]; f[j]=0; }
		fr(j,0,2) fr(k,0,2) if(j!=k) f[j]=(f[j]+F[k])%mod;
//		printf("%lld ",f[1]*C::C(n+1,i)%mod);
		ans=(ans+f[1]*C::C(n+1,i)%mod*power(3,mod-1-(n+1),mod)%mod*C::inv(n+1)%mod*C::inv(i))%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 15744
#include <stdio.h>

int main(void)
{
  int a[5],tmp,i,j;
  for(i=0;i<5;i++)
    scanf("%d",&a[i]);
  for(i=0;i<5;i++)
    for(j=4;j>i;j--)
      if(a[j-1]<a[j])
	{tmp=a[j-1];
	  a[j-1]=a[j];
	  a[j]=tmp;}
  printf("%d",a[0]);
  for(i=1;i<5;i++)
    printf(" %d",a[i]);
  puts("");
  return 0;
}

Measured memory_bytes: 608
N = int(input())
X = input().split()
X = [int(s) for s in X]
max = max(X)
min = min(X)

minSum = 0
for i in range(max):
	sum = 0
	for j in range(N):
		sum += (X[j] - i-1) ** 2
	if (i == 0):
		minSum = sum
	elif (minSum > sum):
		minSum = sum
print(minSum)



Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
N = int(input())
S = input()[: -1]
table = [S.count(chr(ord("a") + x)) for x in range(26)]
res = 1
mod = 10 ** 9 + 7
for x in range(26):
  res *= table[x] + 1
  res %= mod
print(res - 1)

Measured memory_bytes: 62416
n=int(input())
l=[[i]+list(map(int,input().split())) for i in range(n)]

l.sort(key=lambda x:-(x[1]+x[2]))
pa,pb=0,0
used=set()

v=0
while pa<n and pb<n:
  while pa<n and l[pa][0] in used:
    pa+=1
  if pa<n:
    used.add(l[pa][0])
    v+=l[pa][1]
  while pb<n and l[pb][0] in used:
    pb+=1
  if pb<n:
    used.add(l[pb][0])
    v-=l[pb][2]

print(v)

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

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

    int n, m;
    cin >> n >> m;
    int l = 1, r = n;
    rep(i, m)
    {
        int x, y;
        cin >> x >> y;
        l = max(l, x);
        r = min(r, y);
    }
    cout << max(0, r - l + 1) << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static double a;
    static double b;

    private static void init() {
        Scanner scanner = new Scanner(System.in);
        a = scanner.nextInt();
        b = scanner.nextInt();

        scanner.close();
    }


    public static void main(String args[]) {
        init();

        int ans =(int) Math.ceil((a + b) / 2);
        System.out.println(ans);
    }
}


Measured memory_bytes: 21588
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n, k, s;
    cin >> n >> k >> s;
    if(s == 1e9){
        rep(i,k)cout << s <<" ";
        rep(i,n-k)cout << 1 << " ";
        cout << endl;
    }else{
        rep(i,k)cout << s << " ";
        rep(i,n-k)cout << s + 1 << " ";
        cout << endl;
    }
}


Measured memory_bytes: 1280
/**
 * File    : D.cpp
 * Author  : Kazune Takahashi
 * Created : 1/20/2019, 9:07:59 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, K;
int t[100010];
ll d[100010];

typedef tuple<ll, int> sushi;
vector<sushi> V;
priority_queue<sushi, vector<sushi>, greater<sushi>> Q;
int cnt[100010];

int main()
{
  cin >> N >> K;
  for (auto i = 0; i < N; i++)
  {
    cin >> t[i] >> d[i];
    t[i]--;
    V.push_back(sushi(d[i], t[i]));
  }
  sort(V.begin(), V.end());
  reverse(V.begin(), V.end());
  fill(cnt, cnt + N, 0);
  ll ans = 0;
  ll tans = 0;
  for (auto i = 0; i < K; i++)
  {
    ll cost = get<0>(V[i]);
    int val = get<1>(V[i]);
    tans += cost;
    cnt[val]++;
    Q.push(V[i]);
  }
  ll v = 0;
  for (auto i = 0; i < N; i++)
  {
    if (cnt[i] > 0)
    {
      v++;
    }
  }
  ans = tans + v * v;
  for (auto i = K; i < N; i++)
  {
    ll cost = get<0>(V[i]);
    int val = get<1>(V[i]);
    if (cnt[val] == 0)
    {
      while (!Q.empty())
      {
        ll cost_q = get<0>(Q.top());
        int val_q = get<1>(Q.top());
        Q.pop();
        if (cnt[val_q] >= 2)
        {
          cnt[val_q]--;
          tans -= cost_q;
          cnt[val]++;
          tans += cost;
          v++;
          ans = max(ans, tans + v * v);
          break;
        }
      }
    }
  }
  cout << ans << endl;
}

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

using namespace std;
const int N=3e5+5;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    long long n;
    cin>>n;
    cout<<n*(n+1)/2-n<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
      
        for(int i = A;i <= B;i++){
            if(i >= A+K && i <= B-K){
              continue;
            }
          System.out.println(i);
        }
    }
}

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

const int
	MAX = 5e5 + 5,
	MOD = 1e9 + 7;
int n, m, a, b, inv[MAX], f[MAX];

int exp(int a, int b) {
	if(b == 0)
		return 1;

	if(b & 1)
		return 1LL * a * exp(a, b - 1) % MOD;

	int sq = exp(a, b / 2);
	return 1LL * sq * sq % MOD;
}

int comb(int n, int k) {
	if(n < k)
		return 0;

	int ans = 1LL * f[n] * inv[k] % MOD;
	ans = 1LL * ans * inv[n - k] % MOD;

	return ans;
}

int ways(int f0, int c0, int f, int c) {
	return comb(f - f0 + c - c0, f - f0);
}

int main() {
	inv[0] = f[0] = 1;

	for(int i = 1; i < MAX; i++) {
		f[i] = 1LL * i * f[i - 1] % MOD;
		inv[i] = exp(f[i], MOD - 2);
	}

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

	int ans = 0;
	for(int i = 1; i <= n - a; i++) {
		int w1 = ways(1, 1, i, b);
		int w2 = ways(i, b + 1, n, m);

		int v = 1LL * w1 * w2 % MOD;
		ans = (ans + v) % MOD;
	}

	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 4096
// Solution by ** Abhishek Mittal **
#include<iostream>
#include<fstream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<math.h>

#define FIO ios_base::sync_with_stdio(0);  cin.tie(0);
#define PI 3.14159265358979323846
#define mod 1000000007
#define ll long long
#define vll vector<long long>  

#define all(c) c.begin(), c.end()

// Used to traverse in any STL container with iterators
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

// Find whether element is present in given container or not
#define present(container, element) (container.find(element) != container.end())

// Finds whether element in present container is present in vector or not
#define cpresent(container, element) (find(all(container),element) != container.end())

using namespace std;

const ll mxlen = 1e6;

// vector<int> adj(mxlen);

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    FIO
    int n;
    cin>>n;
    if(n>=30)cout<<"Yes";
    else cout<<"No";

    return 0;
}

Measured memory_bytes: 3136
#!/usr/bin/env python3
n = int(input())
p = list(map(int, input().split()))
ans = all(p[i] < p[i + 1] for i in range(n - 1))
for i in range(n):
    for j in range(i + 1, n):
        a = p[:]
        a[i], a[j] = a[j], a[i]
        f = True
        for k in range(n - 1):
            if a[k] >= a[k + 1]:
                f = False
        if f:
            ans = True
print(['NO', 'YES'][ans])


Measured memory_bytes: 3064
#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>;
#define chmin(x,y) x = min(x,y)

const int INF = 1001001001;
int dp[1000005][2];

int main() {//snukeさんの解答から if文を2つ抜いた
//https://atcoder.jp/contests/abc155/submissions/10109587
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  s += '0';
  int n = s.size();
  rep(i,n+1)rep(j,2) dp[i][j] = INF;
  dp[0][0] = 0;
  rep(i,n)rep(j,2) {
    int x = s[i]-'0';
    x += j;
	// if (x < 10) chmin(dp[i+1][0], dp[i][j]+x);
    // if (x > 0) chmin(dp[i+1][1], dp[i][j]+(10-x));
    chmin(dp[i+1][0], dp[i][j]+x);
    chmin(dp[i+1][1], dp[i][j]+(10-x));
  }
  int ans = dp[n][0];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12084
#include <stdio.h>
struct dice{
    int d[6], tmp[6];
};
struct dice dice1;
void init(int n[6]){
    int i;
    for (i=0;i<6;i++){
        dice1.d[i]=n[i];
    }
}
void throwdice(char c){
    int i;
    for(i=0;i<6;i++){
        dice1.tmp[i]=dice1.d[i];
    }
    if(c=='N'){
        dice1.d[0]=dice1.tmp[1];
        dice1.d[1]=dice1.tmp[5];
        dice1.d[2]=dice1.tmp[2];
        dice1.d[3]=dice1.tmp[3];
        dice1.d[4]=dice1.tmp[0];
        dice1.d[5]=dice1.tmp[4];
    }
    else if(c=='E'){
        dice1.d[0]=dice1.tmp[3];
        dice1.d[1]=dice1.tmp[1];
        dice1.d[2]=dice1.tmp[0];
        dice1.d[3]=dice1.tmp[5];
        dice1.d[4]=dice1.tmp[4];
        dice1.d[5]=dice1.tmp[2];
    }
    else if(c=='W'){
        dice1.d[0]=dice1.tmp[2];
        dice1.d[1]=dice1.tmp[1];
        dice1.d[2]=dice1.tmp[5];
        dice1.d[3]=dice1.tmp[0];
        dice1.d[4]=dice1.tmp[4];
        dice1.d[5]=dice1.tmp[3];
    }
    else if(c=='S'){
        dice1.d[0]=dice1.tmp[4];
        dice1.d[1]=dice1.tmp[0];
        dice1.d[2]=dice1.tmp[2];
        dice1.d[3]=dice1.tmp[3];
        dice1.d[4]=dice1.tmp[5];
        dice1.d[5]=dice1.tmp[1];
    }
    else if(c=='R'){
        dice1.d[0]=dice1.tmp[0];
        dice1.d[1]=dice1.tmp[3];
        dice1.d[2]=dice1.tmp[1];
        dice1.d[3]=dice1.tmp[4];
        dice1.d[4]=dice1.tmp[2];
        dice1.d[5]=dice1.tmp[5];
    }
}


int main(int argc, const char * argv[]) {
    int q;
    int n[6];
    int i,j;
    for(i=0;i<6;i++){
        scanf("%d",&n[i]);
    }
    init(n);
    scanf("%d",&q);
    for(i=0;i<q;i++){
        int ok = 0;
        int up, front;
        scanf("%d %d",&up,&front);
        for(j=0;j<4;j++){
            throwdice('S');
            if(dice1.d[0]==up){
                ok = 1;
                break;
            }
        }
        if(!ok){
            while(1){
                throwdice('W');
                if(dice1.d[0] == up){
                    break;
                }
            }
        }
        
        for (j=0;j<4;j++){
            throwdice('R');
            if (dice1.d[1]==front){
                break;
            }
        }
        printf("%d\n",dice1.d[2]);
    }
    
    return 0;
    
}


Measured memory_bytes: 2032
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#define lli long long int
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);


using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57;
const int M = 1e6 + 500;

lli dp[5000][5000];

void solve()
{
    string s, t;
    cin>>s>>t;
    s = '$' + s;
    t = '$' + t;
    for(int i = 1; i < s.size(); i ++)
    {
        for(int j = 1; j < t.size(); j ++)
        {
            if(s[i] == t[j])
                dp[i][j] = max(dp[i][j - 1], max(dp[i - 1][j], dp[i - 1][j - 1] + 1));
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    int i = s.size() - 1;
    int j = t.size() - 1;
    vector<char> v;
    while(dp[i][j] != 0)
    {
        if(dp[i - 1][j] == dp[i][j])
            i --;
        else if(dp[i][j - 1] == dp[i][j])
            j --;
        else
            v.push_back(t[j]), i --, j --;
    }
    reverse(v.begin(), v.end());
    for(auto i : v)
        cout<<i;
    return ;
}
/*
*/

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

    lli t;
    t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 118400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}

int main() {
    string s, t;
    cin >> s >> t;
    t = t.substr(0, s.size());
    s == t ? cout << "Yes" << endl : cout << "No" << endl;
}

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

using ll = long long;

int main() {
    int W, H, N, x, y, a;
    cin >> W >> H >> N;
    int xmin = 0, xmax = W, ymin = 0, ymax = H;
    rep(i, N) {
        cin >> x >> y >> a;
        if (a == 1) {
            xmin = max(xmin, x);
        }
        if (a == 2) {
            xmax = min(xmax, x);
        }
        if (a == 3) {
            ymin = max(ymin, y);            
        }
        if (a == 4) {
            ymax = min(ymax, y);
        }
    }
    cout << max(xmax - xmin, 0) * max(ymax - ymin, 0) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
 
typedef struct{
  short x,y;
  int cost;
  short ch;
}mouse;
const int MAX=(1<<15)-1;
mouse Q[MAX+1];
int s,num;
 
mouse t;
short cx,cy,nx,ny,ch,nch,h,w,n;
int cost;
 
main(){
  scanf("%d%d%d ",&h,&w,&n);
  short maxch[h][w];
  char ku[h][w];
  
  rep(i,h)fread(ku[i],1,w+1,stdin);
 
 
  rep(i,h)rep(j,w){
    if(ku[i][j]=='S')cx=i,cy=j;
    maxch[i][j]=-1;
  }
 
 
  Q[s+num++]=(mouse){cx,cy,0,0};
  maxch[cx][cy]=0;
 
  while(true){
    t=Q[s++&MAX];
    num--;
    cx=t.x,cy=t.y,cost=t.cost;
    ch=t.ch;
 
    rep(i,4){
      nx=cx+dx[i],ny=cy+dy[i];
      if(nx<0 || nx>=h || ny<0 || ny>=w)continue;
      if(ku[nx][ny]=='X')continue;
      nch=ch;
      if(ku[nx][ny]<='9' && ku[nx][ny]>='1' && ku[nx][ny]-'0'==t.ch+1){
        nch=ch+1;
      }
 
      if(maxch[nx][ny]>=nch)continue;
      if(nch==n){
        printf("%d\n",cost+1);
        return 0;
      }
      maxch[nx][ny]=nch;
      Q[s+num++&MAX]=(mouse){nx,ny,cost+1,nch};
    }
  }
}

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define FOR(i, n, m) for(ll i = (ll)n; i < (ll)(m); i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define PRINT(x) cout << x << endl
 
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; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) os << v[i] << " ";  
    return os; 
}

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{
    ll X;
    cin >> X;
    ll ans = X / 500;
    ans *= 1000;

    ll tmp = X % 500;
    ans += (tmp / 5) * 5;
    PRINT(ans);
    return 0;
} 

Measured memory_bytes: 256
a,b,c= input().split()
x,y,z=(int(a),int(b),int(c))
if x >= z:
    a_b = str(x-z)
    print(a_b +' '+ str(y))
elif x+y >= z:
    a_c = str(x+y-z)
    print('0 ' + a_c)
else:
    print('0 0')

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
//#define int long long

//入力例で問題をきちんと確認
void solve() {
    int N; cin >> N;
    vector<int> a(N);
    map<int, int> mp;
    rep(i, N) {
        cin >> a[i];
        a[i] /= 400;
        if(a[i] >= 8) a[i] = 8;
        mp[a[i]] ++;
    }
    int mini = 0, maxi = 0;
    rep(i, 8) {
        if(mp[i] >= 1) mini ++;
    }
    maxi = mini;
    if(mp[8] >= 1) {
        if(mini == 0) mini ++;
        maxi += mp[8];
    }
    cout << mini << " " << maxi << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;
        Solver s = new Solver();
        for (int i = 1; i <= t; i++) {
            s.solve(i, in, out);
        }
        out.close();
    }

}

class Solver {
    void solve(int test, InputReader in, PrintWriter out) throws IOException {
        int a = in.nextInt();
        int b = in.nextInt();
        String s = in.next();
        for (int i = 0; i < s.length(); i++) {
            if (i == a) {
                if (s.charAt(i) != '-') {
                    out.println("No");
                    return;
                }
            } else {
                if (!Character.isDigit(s.charAt(i))) {
                    out.println("No");
                    return;
                }
            }
        }
        out.println("Yes");
    }
}

class InputReader {
    BufferedReader br;
    StringTokenizer st;

    public InputReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
        st = null;
    }

    public String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return st.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public String nextLine() throws IOException {
        return br.readLine();
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 21460
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int ans=0;
    while(a>0 && k>0){
        ans++;a--;k--;
    }
    while(b>0 && k>0){
        b--;k--;
    }
    while(c>0 && k>0){
        ans--;c--;k--;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3548
#include <stdio.h> 
 
int main(void)
{   
    int n, m, l, i, j, k;
    int a[100][100], b[100][100];
    long c[100][100] = {0};
 
    scanf("%d %d %d",&n, &m, &l);
 
    for(i=0; i<n; i++)
    {
        for(j=0; j<m; j++)
        {
            scanf("%d",&a[i][j]);
        }
    }
 
    for(i=0; i<m; i++)
    {
        for(j=0; j<l; j++)
        {
            scanf("%d",&b[i][j]);
        }
    }
 
    for(i=0; i<n; i++)
    {
        for(j=0; j<m; j++)
        {
            for(k=0; k<l; k++)
            {
                c[i][k] = c[i][k] + a[i][j] * b[j][k];
            }
        }
    }
 
    for(i=0; i<n; i++)
    {
        for(j=0; j<l; j++)
        {
            printf("%ld", c[i][j]);
 
            if(l-1 == j)
            {
                printf("\n");
            }
            else
            {
                printf(" ");
            }
 
        }
    }
 
    return 0;
}

Measured memory_bytes: 764
#!/usr/bin/env python

from collections import deque
import sys

sys.setrecursionlimit(1000000)

while True:
    S_ = raw_input()
    if S_ == '.':
        break

    lst = []
    for i in range(3):
        for j in range(3):
            for k in range(3):
                lst.append((str(i), str(j), str(k)))
    
    ans = 0
    for p in lst:
        S = S_
        S = S.replace("P", p[0])
        S = S.replace("Q", p[1])
        S = S.replace("R", p[2])
        for loop in range(50):
            for loop2 in range(100):
                S_pre = S
                S = S.replace("-0", "2")
                S = S.replace("-1", "1")
                S = S.replace("-2", "0")
                if S == S_pre:
                    break
            for loop2 in range(50):
                S_pre = S
                S = S.replace("(0*0)", "0")
                S = S.replace("(0*1)", "0")
                S = S.replace("(0*2)", "0")
                S = S.replace("(1*0)", "0")
                S = S.replace("(1*1)", "1")
                S = S.replace("(1*2)", "1")
                S = S.replace("(2*0)", "0")
                S = S.replace("(2*1)", "1")
                S = S.replace("(2*2)", "2")
                S = S.replace("(0+0)", "0")
                S = S.replace("(0+1)", "1")
                S = S.replace("(0+2)", "2")
                S = S.replace("(1+0)", "1")
                S = S.replace("(1+1)", "1")
                S = S.replace("(1+2)", "2")
                S = S.replace("(2+0)", "2")
                S = S.replace("(2+1)", "2")
                S = S.replace("(2+2)", "2")
                if S == S_pre:
                    break
        if S == "2":
            ans += 1
    print ans


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

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

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

    vector<int> ans(N, 0);
    ans[0] = 0;
    ans[1] = abs(h[0] - h[1]);
    for (int i = 2; i < N; i++)
    {
        ans[i] = min(ans[i - 1] + abs(h[i - 1] - h[i]),
                     ans[i - 2] + abs(h[i - 2] - h[i]));
    }
    cout << ans.back() << endl;
}

Measured memory_bytes: 1024
(defun f (a b c)
    (+ (* a 500) (* b 100) (* c 50)))

(let ((a (read))
      (b (read))
      (c (read))
      (x (read))
      (ans 0))
    
    (dotimes (i (1+ a))
        :do (dotimes (j (1+ b))
            :do (dotimes (k (1+ c))
                (when (= (f i j k) x) (incf ans)))))
    (princ ans))

Measured memory_bytes: 4576
#include<bits/stdc++.h>
#define re register
#define inc(i,j,k) for(re int i=j;i<=k;i++)
#define ll long long
using namespace std;
const int N=4005;
const int mod=998244353;
int n,k;
ll c[N][N],f[N][N],ans[N];
ll get(int x){
	if(x>k) return f[k][n];
	ll ans=0;
	inc(i,0,n) (ans+=f[x-1][i]*c[n+k-x-i][n-i]%mod)%=mod;
	return ans;
}
int main(){
	scanf("%d%d",&k,&n);
	inc(i,0,4000){
		c[i][0]=1;
		inc(j,1,i) c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
	}
	f[0][0]=1; 
	inc(i,1,2000){
		f[i][0]=1;
		inc(j,1,2000){
			if(i&1) f[i][j]=(f[i-1][j]+f[i-1][j-1])%mod;
			else f[i][j]=(f[i-1][j]+f[i][j-1])%mod;
		}
	}
	inc(i,2,k+1) ans[i]=get(i); 
	inc(i,k+2,2*k) ans[i]=ans[2*k+2-i];
	inc(i,2,2*k) printf("%lld\n",ans[i]);
}

Measured memory_bytes: 188672
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001

int32_t main()
{
    string str;
    cin>>str;
    int n=str.length()-1;
    if(str[n]=='s')
    {   
        str.pb('e');
        str.pb('s');
        cout<<str<<endl;
    }
    else
    {
        str.pb('s');
        cout<<str<<endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
	// 入力
	int N, M, C;
	cin >> N >> M >> C;
	vector<int> B(M);
	for (int i = 0; i < M; i++)
	{
		cin >> B[i];
	}
	vector<vector<int>> A(N, vector<int>(M));
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++)
		{
			cin >> A[i][j];
		}
	}
	
	int answer = 0;
	int sourceValue = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++)
		{
			sourceValue += A[i][j] * B[j];
			if (j == M - 1)
			{
				sourceValue += C;
				// この問題に正答するソースコードチェック
				if (sourceValue > 0)
				{
					answer++;
				}
			}
		}
		// 再計算のための初期化
		sourceValue = 0;
	}
	
	// 出力
	cout << answer << endl;
	
	return 0;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }


string s;
map<int, int> mp;
void solve() {
    cin >> s;
    if (s == "zyxwvutsrqponmlkjihgfedcba")cout << -1 << endn;
    else if (s.size() != 26) {
        rep(i, s.size()) {
            mp[s[i] - 'a']++;
        }
        cout << s;
        rep(i, 26) {
            if (mp[i] == 0) {
                cout << char('a' + i) << endn;
                break;
            }
        }
    }
    else {
        int p = 0;
        repd(i, 26) {
            if (s[i - 1] < s[i]) {
                p = i;
                break;
            }
        }
        next_permutation(s.begin() + p - 1, s.end());
        s = s.substr(0, p);
        cout << s << endn;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void)
{
    int n;
    int a, b;
    int p[100];
    int acnt = 0;
    int bcnt = 0;
    int ccnt = 0;
    int count = 0;
    cin >> n >> a >> b;
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    for (int i = 0; i < n; i++)
    {
        if (p[i] <= a)
        {
            acnt++;
        }
        if (a + 1 <= p[i] && p[i] <= b)
        {
            bcnt++;
        }
        if (p[i] >= b + 1)
        {
            ccnt++;
        }
    }
    while (acnt != 0 && bcnt != 0 && ccnt != 0)
    {
        acnt--;
        bcnt--;
        ccnt--;
        count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
flush = sys.stdout.flush
def query(x):
    print("%d\n" % x)
    flush()
    # ジャッジから返される値を取得
    return readline().strip()


n = int(input())

right = n-1
left = 0

print(0, flush = True)
lefti = input()
if lefti == "Vacant":
    exit(0)
print(n-1, flush = True)
righti = input()
if righti == "Vacant":
    exit(0)

while True:
    mid = left + (right-left)//2
    midi = query(mid)
    if midi == "Vacant":
        exit(0)
    if (lefti == midi and (mid - left) % 2 == 1) or ((lefti != midi) and (mid - left) % 2 == 0):
        righti = midi
        right = mid
    else:
        lefti = midi
        left = mid


Measured memory_bytes: 3660
# AOJ 0057 The Number of Area

while line = gets
  n = line.to_i

  # 新しく引く直線が、引かれている直線にぶつかるごとに領域が 1 つ増える。
  # さらに、ぶつかり得るすべての直線にぶつかった後、（仮定した）進行方向に
  # 存在する領域を分割するので、領域が 1 つ増える。
  # 領域の数が最大となる場合は、新しく引く直線が引かれているすべての
  # 直線とぶつかる場合。したがって、分割数 N について
  #   N(n) = N(n - 1) + n
  # が成り立つ。N(0) = 1 だから、
  #   N(n) = N(0) + \sum_{i = 0}^{n - 1} (i + 1)
  #        = N(0) + \sum_{i = 1}^n k
  #        = 1 + n * (n + 1) / 2
  puts 1 + n * (n + 1) / 2
end

Measured memory_bytes: 6080
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j,a;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
    trace(A, n);
  /*

    your code

   */

  for(i=1;i<n;i++){
 
   for(j=i+1;j>1;j--){

    if(A[j]<A[j-1]){

      a=A[j];
      A[j]=A[j-1];
      A[j-1]=a;

}
    }

   trace(A,n);

}

  return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cctype>
using namespace std;



int main(){
  string name;
  char type,pre_type;

  while(true){
    cin >> name >> type;
    if(type == 'X')break;
    for(int i=0;i<name.size();i++){
      if(type == 'U'){
	if(i == 0){
	  cout << (char)toupper(name[i]);
	  continue;
	}
	if(name[i] == '_'){
	  name[i+1] = toupper(name[i+1]);
	  continue;
	}
	cout << name[i];
      }
      else if(type == 'L'){
	if(i == 0){
	  cout << (char)tolower(name[i]);
	  continue;
	}
	if(name[i] == '_'){
	  name[i+1] = (char)toupper(name[i+1]);
	  continue;
	}
	cout << name[i];
      }
      else if(type == 'D'){
	if(i == 0){
	  cout << (char)tolower(name[i]);
	  continue;
	}
	if(isupper(name[i])){
	  cout << "_" << (char)tolower(name[i]);
	  continue;
	}
	cout << name[i];
      }
    }

  cout << endl;


  }



}

Measured memory_bytes: 1180
#include <iostream>
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define li long ll
#define pp pair<ll, ll> 
#define lb lower_bound
#define ub upper_bound
#define mk make_pair
#define pb push_back
#define llp(i, x, n) for (ll i = x; i < n; i++)
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define fr first
#define ss second
ll p=1e9+7;
using namespace std;
ll power(ll x, ll y)  
{  
    ll res = 1;     
    x = x % p; 
    if (x == 0)
    return 0; 
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}  
int main()
{
	fast;
	int n;
	cin>>n;
	vector<pp> v,v1,v2;
	for(ll i=0;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		v.pb(mk(x,y));
		v1.pb(mk(x+y,i));
		v2.pb(mk(x-y,i));
	}
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	ll a=v1[n-1].ss;
	ll b=v1[0].ss;
	ll c=v2[n-1].ss;
	ll d=v2[.0].ss;
	ll dis1,dis2;
	dis1=abs(v[a].fr-v[b].fr)+abs(v[a].ss-v[b].ss);
	dis2=abs(v[c].fr-v[d].fr)+abs(v[c].ss-v[d].ss);
	cout<<max(dis1,dis2)<<endl;
}

Measured memory_bytes: 12816
using System;

namespace AtCoder
{
	class Programs
	{
		static void Main ()
		{
			var s = Console.ReadLine ();
			int sn = 0;
			for (int i = 0; i < s.Length; i++) {
				sn += s [i] - '0';
			}
			Console.WriteLine (int.Parse(s)%sn == 0 ? "Yes":"No");
		}
	}
}

Measured memory_bytes: 11092
from math import sqrt

N = int(input())
result = [0] * N

n = int(sqrt(N))

for x in range(1, n+1):
    for y in range(1, n+1):
        for z in range(1, n+1):
            check = x**2 + y**2 + z**2 + x * y + y * z + z * x

            if check <= N:
                result[check-1] += 1

for i in result:
    print(i)


Measured memory_bytes: 9308
#include <cstdio>
#include <cstring>

using namespace std;
int n;
int main(){
scanf("%d",&n);
for(int i = 0;i <= 25;++i)
for(int j = 0;j <= 14;++j)
if(4*i + 7*j == n){puts("Yes");return 0;}
puts("No");
return 0;
}


Measured memory_bytes: 128
using System.Collections.Generic;
using System.Linq;
using static System.Console;

namespace dwyl.ABC._112
{
    public class CT
    {
        public short Cost { get; set; }
        public short Time { get; set; }
    }

    public class Program
    {


        public void Solve()
        {
            var nt = ReadLine().Split(' ').Select(x => short.Parse(x)).ToArray();
            var n = nt[0];
            var t = nt[1];

            var candidates = new List<CT>();

            for (int i = 0; i < n; i++)
            {
                var line = ReadLine().Split(' ').Select(x => short.Parse(x)).ToArray();

                if (line[1] <= t )
                {
                    candidates.Add(new CT() { Cost = line[0], Time = line[1] });
                }
            }

            if (candidates.Count == 0)
            {
                WriteLine("TLE");
            }
            else
            {
                WriteLine(candidates.Select(x =>x.Cost).Min());
            }

        }
        static void Main()
        {
            var solver = new Program();
            solver.Solve();
        }

    }
}


Measured memory_bytes: 13396
#include <cmath>
#include <iostream>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <algorithm>

#define rep(i, n) for(long long i = 0; i < n; i++)

const int MIN = 200001;
const int MOD = 1000000007;

using namespace std;

int main() {
	int h, n, r = 0, c;
	
	cin >> h >> n;
	
	rep(i, n) {
		cin >> c;
		r += c;
	}
	
	cout << ((r >= h) ? "Yes" : "No") << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

        int a, b, c, d;

        cin >> a >> b >> c >> d;

        int e, f;

        if ( a <= b ) e = a;

        else e = b;

        if ( c <= d) f = c;

        else f = d;

        cout << e + f << endl;

}

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

using namespace std;

int main()
{
    #ifdef HOME
    freopen("input.txt", "rt", stdin);
    #endif // HOME
    int n;
    cin >> n;
    long long ans = 0;
    for (int i = 0; i < n; i++){
        long long l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=200200,oo=1000000000;
const double pi=acos(-1.0);
int i,j,k,n,m,fgx,fgy,ch,ff,ans;
int lis[N];
double Ans;
struct cc {
	int x,y;
	bool operator < (const cc &n) const {
		return x<n.x;
	}
} S,T,t,A[N];
void R(int &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
int main() {
	R(S.x);R(S.y);R(T.x);R(T.y);
	if (S.x>T.x) fgx=-1,S.x=-S.x,T.x=-T.x;
	else fgx=1;
	if (S.y>T.y) fgy=-1,S.y=-S.y,T.y=-T.y;
	else fgy=1;
	R(n);
	for (i=1;i<=n;i++) {
		R(t.x);R(t.y);
		t.x*=fgx;
		t.y*=fgy;
		if (S.x<=t.x && t.x<=T.x && S.y<=t.y && t.y<=T.y) A[++m]=t;
	}
	sort(A+1,A+m+1);
	ans=0;
	lis[0]=-oo;
	for (i=1;i<=m;i++) {
		if (A[i].y>lis[ans]) lis[++ans]=A[i].y;
		else {
			int l=0,r=ans,mid;
			while (l<r) {
				mid=(l+r+1)>>1;
				if (lis[mid]<A[i].y) l=mid;
				else r=mid-1;
			}
			lis[l+1]=A[i].y;
		}
	}
	Ans=(T.x+T.y-S.x-S.y)*100.0;
	Ans+=5.0*pi*ans-20.0*ans;
	if (T.x-S.x+1==ans || T.y-S.y+1==ans) Ans+=5.0*pi;
	printf("%.15lf\n",Ans);
}

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

int main(){
    int N;  cin >> N;
    vector<ll> A(N), B(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
        if(i==0) B[i] = A[i];
        else B[i] = A[i] + B[i-1];
    }

    ll ans = 1000000000000000;
    int m1 = 0, m3 = 2;
    for(int m2=1; m2<=N-3; m2++){
        ll P = B[m1];
        ll Q = B[m2] - B[m1];
        ll delPQ = abs(P-Q);
        while(delPQ >= abs(P-Q+2*A[m1+1])){
            m1++;
            P = B[m1];
            Q = B[m2] - B[m1];
            delPQ = abs(P-Q);
        }

        ll R = B[m3] - B[m2];
        ll S = B[N-1] - B[m3];
        ll delRS = abs(R-S);
        while(delRS >= abs(R-S+2*A[m3+1])){
            m3++;
            R = B[m3] - B[m2];
            S = B[N-1] - B[m3];
            delRS = abs(R-S);
        }

        ll M = max(P,max(Q,max(R,S)));
        ll m = min(P,min(Q,min(R,S)));
        ans = min(ans, abs(M-m));
    }

    cout << ans << endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9+5
int dp[100006];
vector<int >v;
int solve(int n,int k)
{
   // cout<<n<<endl;
    if(n==0)
        return 0;
    if(dp[n]!=-1)
        return dp[n];
    int answer=INF;
    for(int i=1;i<=k;i++)
    {
        if(n-i>=0)
            answer=min(answer,solve(n-i,k)+abs(v[n-i]-v[n]));
    }
    return dp[n]=answer;
}
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        int temp;
        cin>>temp;
        v.push_back(temp);
    }
    memset(dp,-1,sizeof(dp));
    cout<<solve(n-1,k)<<endl;
   // for(int i=0;i<n;i++)
     //   cout<<i<<" "<<dp[i]<<endl;
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    sort(v.rbegin(), v.rend());
    ll ans = 0;
    rep2(i, 1, n) {
        ans += v[i/2];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=mpowe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}

int main()
{
    fastio();
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    ll n,s,k;
    cin>>n>>k>>s;
    for(int i=0;i<k;i++)
    {
        cout<<s<<" ";
    }
    for(int i=k;i<n;i++)
    {
        if(s<100000000)
          cout<<s+1<<" ";
      	else
          cout<<s-1<<" ";
    }
    nl;
}

Measured memory_bytes: 1280