akhauriyash/Code-Regression huggingface dataset:
def main():
    N, K = list(map(int, input().split()))
    sushi_list = list()
    for _ in range(N):
        t, d = list(map(int, input().split()))
        t -= 1
        sushi_list.append((t, d))
    sushi_list.sort(key=lambda s: s[1], reverse=True)  # おいしさの降順でソート
    # おいしさTop Kのすしをとるのを初期解とする
    neta_flag_list = [0] * N
    topk_extra_sushi_list = list()  # Top Kのすしで、各ネタ最大のおいしさはないすし
    additional_sushi_list = list()  # Top Kのすしのネタ以外で、各ネタの最大のおいしさのすし
    point_topk = 0
    for k, sushi in enumerate(sushi_list):
        if k < K:
            if neta_flag_list[sushi[0]] == 1:
                topk_extra_sushi_list.append(sushi)
            point_topk += sushi[1]
        else:
            if neta_flag_list[sushi[0]] == 0:
                additional_sushi_list.append(sushi)
        neta_flag_list[sushi[0]] = 1
    n_neta = K - len(topk_extra_sushi_list)
    point_topk += n_neta ** 2
    # その他のネタをt種類追加する場合を考えて、初期解と比較していく
    d_extra, d_additional = 0, 0
    ans = point_topk
    n_additional_neta = min(K - n_neta, len(topk_extra_sushi_list), len(additional_sushi_list))
    for t in range(1, n_additional_neta + 1):
        n_cur_neta = n_neta + t
        d_extra += topk_extra_sushi_list[-t][1]
        d_additional += additional_sushi_list[t - 1][1]
        point = point_topk - d_extra + d_additional + (n_cur_neta**2 - n_neta**2)
        ans = max(ans, point)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 23932
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N; cin >> N;
	V<int> d(N); rep(i,N) cin >> d[i];
	int s = 0;
	rep(i,N) rep(j,i) s += d[i]*d[j];
	cout << s << endl;
}


Measured memory_bytes: 256
using System;

namespace ITP1_10_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            double a = double.Parse(input[0]);
            double b = double.Parse(input[1]);
            double rad = double.Parse(input[2]) * Math.PI / 180;
            double sin = Math.Sin(rad);
            double cos = Math.Cos(rad);
            double S = a * b * sin / 2;
            double L = a + b + Math.Sqrt(a * a + b * b - 2 * a * b * cos);
            double h = b * sin;
            Console.WriteLine("{0}\n{1}\n{2}", S, L, h);
        }
    }
}

Measured memory_bytes: 9216
#include<iostream>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  	int a,b,c,k;
  	cin>>a>>b>>c>>k;
  	int ans=max(a,b);
  	ans=max(ans,c);
  	if(a==ans){
  		for(int i=1;i<=k;i++)
  			a*=2;
	}
	else if(b==ans){
  		for(int i=1;i<=k;i++)
  			b*=2;
	}
	else if(c==ans){
  		for(int i=1;i<=k;i++)
  			c*=2;
	}
	int sum=a+b+c;
	cout<<sum<<endl;
  	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cmath>
using namespace std;

static const double pi = 3.141592653589793;
double rad = 60 * (pi / 180);

struct Point {
    double x;
    double y;
};

void koch(int n, Point a, Point b) {
    if (n == 0) {
        return;
    }
    
    Point s, t, u;
    s.x = (2 * a.x + 1 * b.x) / 3;
    s.y = (2 * a.y + 1 * b.y) / 3;
    t.x = (1 * a.x + 2 * b.x) / 3;
    t.y = (1 * a.y + 2 * b.y) / 3;
    u.x = (t.x - s.x) * cos(rad) - (t.y - s.y) * sin(rad) + s.x;
    u.y = (t.x - s.x) * sin(rad) + (t.y - s.y) * cos(rad) + s.y;
    
    koch(n - 1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n - 1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n - 1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n - 1, t, b);

    return;
}

int main() {
    int n;
    cin >> n;
    Point a, b;
    a.x = 0;
    a.x = 0;
    b.x = 100;
    b.y = 0;

    printf("%.8f %.8f\n", a.x, a.y);
    koch(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);

    return 0;
}


Measured memory_bytes: 3384
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_asc(const void* a, const void* b) {
    return *((size_t*)a) < *((size_t*)b) ? -1 : 1;
}

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_i64_asc(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_i64_desc(const void* a, const void* b) {
    return *((int64_t*)a) > * ((int64_t*)b) ? -1 : 1;
}

int compare_c_asc(const void* a, const void* b) {
    return *((char*)a) < *((char*)b) ? -1 : 1;
}

int compare_c_desc(const void* a, const void* b) {
    return *((char*)a) > * ((char*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t p[100000];

int main(void) {
    size_t N;

    scanf("%zu\n", &N);
    for (size_t i = 0; i < N; i++) {
        scanf("%zu", &(p[i]));
        if (i < N - 1) {
            scanf(" ");
        }
        p[i]--;
    }

    size_t cnt = 0;

    for (size_t i = 0; i < N - 1; i++) {
        if (i < N - 2) {
            if (p[i] == i) {
                const size_t tmp = p[i];
                p[i] = p[i + 1];
                p[i + 1] = tmp;

                cnt++;
            }
        }
        else {
            if (p[i] == i || p[i + 1] == i + 1) {
                const size_t tmp = p[i];
                p[i] = p[i + 1];
                p[i + 1] = tmp;

                cnt++;
            }
        }
    }

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

    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll N;
string S;
bool Left[205000];
ll now = 0;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> S;
    S = "#" + S;
    for(int i = 1; i < S.size(); i++) {
        if(S[i] == 'B' && now % 2 == 0) {
            Left[i] = true;
            now++;
        } else if(S[i] == 'B' && now % 2 == 1) {
            Left[i] = false;
            now++;
        } else if(S[i] == 'W' && now % 2 == 0) {
            Left[i] = false;
            now++;
        } else if(S[i] == 'W' && now % 2 == 1) {
            Left[i] = true;
            now++;
        }
        //cerr << Left[i] << " ";
    }
    now = 0;
    ll ans = 1;
    for(ll i = 1; i <= N; i++) ans = ans * i % mod;
    for(int i = 1; i < S.size(); i++) {
        if(Left[i]) {
            now++;
            continue;
        } else {
            ans *= now;
            ans %= mod;
            now--;
        }
    }
    if(now != 0) ans = 0;
    cout << ans << endl;
    return 0;
}


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

int main(void){
    long long lucas[87] = {2, 1};
    int i;
    for(i = 2; i <= 86; i++){
        lucas[i] = lucas[i - 1] + lucas[i - 2];
    }
    
    int n;
    cin >> n;
    
    cout << lucas[n] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = long long;
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
const ll inf = 1e15;
int a, b;
ll s[100005], t[100005];
void solve() {
	ll x;
	scanf("%lld", &x);
	auto its = lower_bound(s, s + a + 2, x), itt = lower_bound(t, t + b + 2, x);
	ll ans = 1e18;
	ans = min(ans, max((*its), (*itt--)) - x);
	ans = min(ans, min(*its - x, x - *itt) + (*its--) - (*itt++));
	ans = min(ans, min(x - *its, *itt - x) + (*itt--) - *its);
	ans = min(ans, x - min(*its, *itt));
	printf("%lld\n", ans);
}
int main() {
	int q;
	scanf("%d%d%d", &a, &b, &q);
	rep(i, a) scanf("%lld", &s[i + 1]);
	rep(i, b) scanf("%lld", &t[i + 1]);
	s[0] = t[0] = -inf;
	s[a + 1] = t[b + 1] = inf;
	while (q--) solve();
	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, l; scanf("%d%d", &n, &l);
	
	const int A = n * (n - 1) / 2 + l * n;
	
	std::vector<std::pair<int, int>> vec;
	for(int i = 0; i < n; i++) {
		int B = A - (i + l);
		vec.push_back({std::abs(A - B), B});
	}
	sort(begin(vec), end(vec));
	
	printf("%d\n", vec.front().second);
	return 0;
}


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

int main() {
	cin.tie(NULL);
	cout.tie(NULL);
	int cnt=0;
	ll l,r,d;
	cin>>l>>r>>d;
	for(ll i=l;i<=r;i++)
	{
		if(i>=d&&i%d==0)
		cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3588
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;

int Gcd(int a, int b){
    int tmp;
    if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  int r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
    return b;
}

int main(){
    int N, A[100001];
    cin >> N;
    for(int i=1; i<=N; ++i){
        cin >> A[i];
    }
    /*
    sort(A+1, A+N);
    int min = 2100000000;
    for(int i=2;i<=N;++i){
        if(A[i]%A[1] != 0 && A[i]%A[1] < min){
            min = A[i]%A[1];
        }
    }
    cout << min;
    */
    for(int i = 2; i <= N; ++i){
        A[1] = Gcd(A[1], A[i]);
    }
    cout << A[1];
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<(int)N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=0;i--)
#define p(s) cout<<(s)<<endl
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9;

int N,A,B;
string s;
int nai,gai,pass;
int main() {
	cin>>N>>A>>B>>s;
	REP(i,0,s.size()){
		if((s[i]=='a')&&nai+gai<A+B){
			nai++;
			p("Yes");
		}else if(s[i]=='b'&&gai+nai<A+B&&gai<B){
			gai++;
			p("Yes");
		}
		else p("No");
	}
	return 0;
}


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

import sys
import copy
import math

sys.setrecursionlimit(1000000)

# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~

N = int(input())
p = []
for i in range(N):
    x = int(input())
    p.append(x)

p.sort(reverse=True)
print(p[0] // 2 + sum(p[1:]))


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
static const long double pi = 3.141592653589793;



int main(){
    ll H, W, K;
    cin>>H>>W>>K;
    vector<ll> C={1,1,2,3,5,8,13,21,34};
    vector<vector<ll>> R(H+1, vector<ll>(W, 0));
    R[0][0]=1;
    rep(i, H){
        rep(j, W){
            if(j==0){
                R[i+1][0]+=R[i][0]*C[W-1];
                R[i+1][0]%=MOD;
                R[i+1][0]+=R[i][1]*C[W-2];
                R[i+1][0]%=MOD;
                continue;
            }
            if(j==W-1){
                R[i+1][W-1]+=R[i][W-1]*C[W-1];
                R[i+1][W-1]%=MOD;
                R[i+1][W-1]+=R[i][W-2]*C[W-2];
                R[i+1][W-1]%=MOD;
                continue;
            }
            R[i+1][j]+=R[i][j]*C[j]*C[W-1-j];
            R[i+1][j]%=MOD;
            R[i+1][j]+=R[i][j+1]*C[j]*C[W-2-j];
            R[i+1][j]%=MOD;
            R[i+1][j]+=R[i][j-1]*C[j-1]*C[W-1-j];
            R[i+1][j]%=MOD;
        }
    }
    cout<<R[H][K-1]<<endl;
}
     

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

using namespace std;

int main() {
    int n;
    double v;
    cin>>n;
    vector <double> a(n);
    double sum=0;
    for (int i = 0; i < n; ++i) {
        cin>>v;
        a[i]=v;
    }
    sort(a.begin(),a.end());
    sum=(a[0]+a[1])/2;
    for (int j = 2; j < a.size(); ++j) {
        sum=(sum+a[j])/2;
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 256
#two alpinist
N = int(input())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))
mod = 10**9+7
 
#fixed[i]: i 山の高さが確定してる
fix_a= [0]*(N)
fix_b= [0]*(N)
fix_a[0] = A[0]
fix_b[-1] = B[-1]
for i in range(N-1):
    if A[i+1]>A[i]:
        fix_a[i+1] = A[i+1]
    if B[-(i+2)]>B[-(i+1)]:
        fix_b[-(i+2)] = B[-(i+2)]

ans = 1
for i in range(N):
    if fix_a[i]:
        if B[i]<fix_a[i]:
            ans = 0
            break
    if fix_b[i]:
        if A[i]<fix_b[i]:
            ans = 0
            break
            
for i in range(N):
    if fix_a[i] or fix_b[i]:
        continue
    ans *= min(A[i], B[i])
    ans %= mod
    
if A[-1] != B[0]:
    ans = 0
    
print(ans)



Measured memory_bytes: 19008
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int curX = 0;
        int curY = 0;
        int curT = 0;
        for (int i = 0; i < n; i++) {
            int t = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();
            int dX = Math.abs(x - curX);
            int dY = Math.abs(y - curY);
            int d = dX + dY;
            int dT = Math.abs(t - curT);
            int diff = dT - d;
            if (d > dT || diff % 2 != 0) {
                System.out.println("No");
                return;
            }
            
            curT = t;
            curX = x;
            curY = y;
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 87180
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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; }

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

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

  int a;
  int rainbow=0;
  vi ok(8,0);
  rep(i,n){
    cin >> a;
    if(a>=3200) rainbow++;
    else {
      ok[a/400]=1;
    }
  }
  cout << ((accumulate(ok.begin(), ok.end(),0)==0) ? 1 : accumulate(ok.begin(), ok.end(),0)) << " " << accumulate(ok.begin(), ok.end(),0)+rainbow << endl;
  return 0;
}

Measured memory_bytes: 3548
import sys

import numpy as np


def input():
    return sys.stdin.readline().strip()


n, k = map(int, input().split())
H = np.array(list(map(int, input().split())))

INF = 10 ** 9
dp = np.array([INF] * n)
dp[0] = 0
for i in range(n - 1):
    gaps = np.abs(H[i + 1:i + k + 1] - H[i]) + dp[i]
    dp[i + 1:i + k + 1] = np.minimum(dp[i + 1:i + k + 1], gaps)
print(dp[-1])


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

final class Main {

    private Main() {
    }

    public static void main(final String[] argv) throws IOException {
        final BufferedReader inputReader =
                new BufferedReader(new InputStreamReader(System.in));
        double max = Double.MIN_VALUE;
        double min = Double.MAX_VALUE;
        while (true) {
            String input = inputReader.readLine();
            if (input == null) {
                break;
            }
            double val = Double.parseDouble(input);
            if (max < val) {
                max = val;
            }
            if (min > val) {
                min = val;
            }
        }
        System.out.println(max - min);
    }
}

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

minm = A[0]
ans = 0
for i in range(1,N):
    if A[i] < minm:
        ans += minm - A[i]
    if A[i] > minm:
        minm = A[i]
        
print(ans)

Measured memory_bytes: 32160
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x){
  return x * x;
}

signed main (){
  string A,B,C;
  cin >> A >> B >> C;
  if(A.at(A.size() - 1) == B.at(0) && B.at(SZ(B)-1) == C.at(0)){
cout << "YES" << endl;
return 0;
  }else{
cout << "NO" <<endl;
  }
    return 0;
}


Measured memory_bytes: 256
/**
*    author:  yuya1234
*    created: 26.06.2020 11:25:49
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

    int c[3][3];

    REP(i,3)
    {
        cin>>c[i][0]>>c[i][1]>>c[i][2];
    }

    int sum=0;

    REP(i,3){
        REP(j,3){
            sum+=c[i][j];
        }
    }

    string ans="No";

    if(sum/3==c[0][0]+c[1][1]+c[2][2] 
    && sum/3==c[0][2]+c[1][1]+c[2][0]
    && sum/3==c[1][0]+c[0][1]+c[1][2]+c[2][1]-c[1][1])ans="Yes";

    cout<<ans<<endl;


        

    return 0;
}

Measured memory_bytes: 3660
<?php
fscanf(STDIN,"%d %d",$n, $k);
$result = 0;
$a = explode(" ", rtrim(fgets(STDIN)));
for($i=0; $i<$n; $i++)
{
    $count[$a[$i]]++;
}
sort($count);
for($i=0; $i<sizeof($count)-$k; $i++)
{
    $result+=$count[$i];
}

echo($result);

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll H, W, D, Q;
map<ll, PL> memo;

signed main() {
    cin >> H >> W >> D;
    REP(i, H) REP(j, W) { memo[IN()] = {i, j}; }
    VL d(H * W + 1, 0);
    FOR(i, D + 1, H * W + 1) {
        d[i] = d[i - D] + abs(memo[i].fi - memo[i - D].fi)
               + abs(memo[i].se - memo[i - D].se);
    }
    cin >> Q;
    REP(i, Q) {
        LCIN(L, R);
        cout << d[R] - d[L] << "\n";
    }
}


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


ll a[11][11];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++){
        ll now = i;
        while(now >= 10) now/=10;
        a[now][i%10]++;
    }
    ll ans = 0;
    for(ll i=1;i<=9;i++){
        for(ll j=1;j<=9;j++){
            ans += a[i][j] * a[j][i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9;
long long n, l, r, t, m, k, res;

int solve(vector<int> & a, int n, vector<int> b, int m){
	vector<long long> t(n + 1, 0), r(m + 1, 0);
	for(int i = 1; i <= n; ++i){
		t[i] = t[i - 1] + a[i];
	}
	for(int i = 1; i <= m; ++i){
		r[i]= r[i - 1] + b[i];
	}
	int res = 0;
	for(int i = 1; i <= n; ++i){
		if(t[i] <= k){
			long long x = (k - t[i]);
			auto y = lower_bound(r.begin(), r.end(), x);
			int p = (y - r.begin());
			if(r[p] > x || p > m)p--;
			if(t[i] + r[p] <= k){
				res = max(res, i + p);
			}
			else{
				res = max(res, i);
			}
		}
	}
	return res;
}


int main(){
	cin>>n>>m>>k;
	vector<int> a(n + 1, 0), b(m + 1, 0);
	for(int i = 1; i <= n; ++i)cin>>a[i];
	for(int i = 1; i <= m; ++i)cin>>b[i];
	int ans = 0;
	ans = max(ans, solve(a, n, b, m));
	ans = max(ans, solve(b, m, a, n));
	
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8804
import sys

n, k, *v = map(int, sys.stdin.read().split())

def main():
    m = min(n, k)
    ls = [None] * (m + 1)
    rs = [None] * (m + 1)
    l_neg = [None] * (m + 1)
    r_neg = [None] * (m + 1)
    
    ls[0] = 0
    rs[0] = 0
    l_neg[0] = []
    r_neg[0] = []

    for i in range(m):
        l = v[i]; r = v[-(i+1)]
        ls[i+1] = ls[i] + l
        rs[i+1] = rs[i] + r
        
        l_neg[i+1] = l_neg[i].copy()
        if l < 0:
            l_neg[i+1].append(l)
        r_neg[i+1] = r_neg[i].copy()
        if r < 0:
            r_neg[i+1].append(r)
    
    res = 0
    for i in range(m+1):
        for j in range((m-i)+1):
            s = ls[i] + rs[j]
            neg = sorted(l_neg[i] + r_neg[j])
            s -= sum(neg[:k-(i+j)])
            res = max(res, s)
    return res
        
if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
    int n,i,j,max,min;
    scanf("%d",&n);
    int r[n+1];
    for(i=0;i<n;i++)
    scanf("%d",&r[i]);
    min=r[0];
    max=r[1]-r[0];
    for(i=1;i<n;i++){
    	if(r[i-1]<min)
        min=r[i-1];
    	if(r[i]-min>max)
    	max=r[i]-min;  
    }
    printf("%d\n",max);
    return 0;
}


Measured memory_bytes: 2580
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int X = Integer.parseInt(sc.next());
        int Y = Integer.parseInt(sc.next());
        
        int ans = 0;
        for(int i=0; i<N; i++){
            if(i < K){
                ans += X;
            }else{
                ans += Y;
            }
        }
        
        System.out.println(ans);
    }
}


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

using namespace std;

int n, x[6005], y[2005][2005], add, ans, mx[2005], mxx;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n * 3; i++)
		scanf("%d", x + i);
	for (int i = 1; i <= n; i++) {
		mx[i] = INT_MIN;
		for (int j = 1; j <= n; j++)
			y[i][j] = INT_MIN;
	}
	mx[x[0]] = mx[x[1]] = 0;
	y[x[0]][x[1]] = y[x[1]][x[0]] = 0;
	for (int i = 2; i + 3 <= n * 3; i += 3) {
		sort(x + i, x + i + 3);
		vector<tuple<int, int, int>> v;
		if (x[i] == x[i + 2]) {
			add++;
			continue;
		}
		if (x[i] == x[i + 1])
			for (int j = 1; j <= n; j++)
				v.emplace_back(j, x[i + 2], y[x[i]][j] + 1);
		else if (x[i + 1] == x[i + 2])
			for (int j = 1; j <= n; j++)
				v.emplace_back(j, x[i], y[x[i + 1]][j] + 1);
		for (int j = i; j < i + 3; j++)
			v.emplace_back(j == i ? x[i + 1] : x[i], j == i + 2 ? x[i + 1] : x[i + 2], y[x[j]][x[j]] + 1);
		v.emplace_back(x[i], x[i + 1], mxx);
		v.emplace_back(x[i], x[i + 2], mxx);
		v.emplace_back(x[i + 1], x[i + 2], mxx);
		for (int j = 1; j <= n; j++)
			for (int k = i; k < i + 3; k++)
				v.emplace_back(j, x[k], mx[j]);
		for (auto& j : v) {
			int ta, tb, tc;
			tie(ta, tb, tc) = j;
			y[ta][tb] = max(y[ta][tb], tc);
			y[tb][ta] = max(y[tb][ta], tc);
			mx[ta] = max(mx[ta], tc);
			mx[tb] = max(mx[tb], tc);
			mxx = max(mxx, tc);
		}
	}
	y[x[n * 3 - 1]][x[n * 3 - 1]]++;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			ans = max(ans, y[i][j]);
	printf("%d\n", ans + add);
}


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

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, k;
int a[N];
ll f[N];


int main () {
	SpeedForce;
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		f[i] = f[i-1] + a[i];
	}

	for (int i = 0; i <= n; i ++)
		f[i] += (n - i) * (ll)k;

	ll ans = 0;
	ordered_set < pair < ll, int > > q;
	for (int i = 1; i <= n; i ++) {
		q.insert(mp(f[i-1], i-1));
		ans += q.order_of_key(mp(f[i], i));
	}

	cout << ans << '\n';

   	return Accepted;
}

// B...a

Measured memory_bytes: 16384
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
for i in range(1,10):
    if n%i==0 and n//i<10:
        ans = "Yes"
        break
else:
    ans = "No"
print(ans)

Measured memory_bytes: 61932
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;

using namespace std;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const int MOD = 1e9 + 7;

template <typename T>
void read(vector<T>& a) {
    for (auto &v : a)
        cin >> v;
}

int h, w;

bool a[200][200]{0};
int dp[200][200]{0};

int main() {
    ios::sync_with_stdio(false);
    cin.tie();
    cin >> h >> w;
    for (int i = 0; i < h; i++){
        string s;
        cin >> s;
        for (int j = 0; j < w; j++)
            a[i][j] = s[j] == '#';
    }
    dp[0][0] = a[0][0] == 1;
    for (int i = 1; i < h; i++) {
        dp[i][0] = dp[i - 1][0] + (a[i-1][0] == 0 && a[i][0] == 1);
    }
    for (int j = 1; j < w; j++){
        dp[0][j] = dp[0][j-1] + (a[0][j-1] == 0 && a[0][j] == 1);
    }
    for (int i = 1; i < h; i++){
        for (int j = 1; j < w; j++){
            dp[i][j] = min(dp[i-1][j] + (a[i-1][j] == 0 && a[i][j] == 1), dp[i][j-1] + (a[i][j-1] == 0 && a[i][j] == 1));
        }
    }
    cout << dp[h-1][w-1];
}


Measured memory_bytes: 384
#include<stdio.h>
main()
{
    int a,b,i5=0,i7=0,i;
    for(i=0;i<3;i++){
        scanf("%d",&a);
        if(a==5){i5++;}
        if(a==7){i7++;}
    }
    if(i5==2&&i7==1){
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
}


Measured memory_bytes: 1588
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    sort(t.begin(),t.end(),greater<char>());
    sort(s.begin(),s.end());
    if(s<t){
        cout <<"Yes\n";
    }else{
        cout <<"No\n";
    }
}

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();
		
		if(a>=b) {
			for(int i=0;i<a;i++) {
				System.out.print(b);
			}
		}
		else {
			for(int i=0;i<b;i++) {
				System.out.print(a);
			}
		}
		
	}
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	long long int a,b,c,d;
	long long int pro1,pro2,pro3,pro4;
	std::cin >> a >> b>> c>> d;
	pro1 = a*c;
	pro2 = b*c;
	pro3 = a*d;
	pro4 = b*d;
	std::cout << max(max(pro1,pro2),max(pro3,pro4)) << std::endl;
	return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int res, m, d;

int main(){
    cin >> m >> d;
    for(int i = 10;i <= d;i++){
        int d1 = i / 10;
        int d2 = i % 10;
        if(d1 >= 2 && d2 >= 2 && d1 * d2 <= m)res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using mat = vector<vector<ll>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};

int h,w;

void solve(){
  vector<vector<int>> field(h, vector<int>(w, 0));
  int n; cin >>n;
  rep(i, n){
    int x,y; cin >>x >>y; x--; y--;
    field[x][y] = 1;
  }
  vector<vector<ll>> dp(h, vector<ll>(w, 0));
  dp[0][0] = 1;
  if (field[0][0] == 1) dp[0][0] = 0;
  for (int i=0; i<h; i++){
    for (int j=0; j<w; j++){
      if (i+1<h) if (!field[i+1][j]) dp[i+1][j] += dp[i][j];
      if (j+1<w) if (!field[i][j+1]) dp[i][j+1] += dp[i][j];
    }
  }
  ll res = dp[h-1][w-1];
  cout <<res <<endl;

  cin >>h >>w;
}

int main() {
  cin >>h >>w;
  while (h > 0 || w > 0) solve();
}


Measured memory_bytes: 3156
n,m=map(int,input().split())
L=[0]*m
R=[0]*m
table=[0]*(n+2)
for i in range(m):
   L[i],R[i]=map(int,input().split())
   table[L[i]]+=1
   table[R[i]+1]-=1
s=[0]*(n+2)#累積和をするリスト
for i in range(1,n+2):
   s[i]=s[i-1]+table[i]
print(s.count(m))

Measured memory_bytes: 15836
//#pragma GCC optimize("-O3")
/*
				C++
				encoding: UTF-8
				Last Modified: 30/May/20 05:45:35 PM
*/

#include <bits/stdc++.h>
#ifdef H4wk3ye
#	include <prettypr.hpp>
#endif

using namespace std;

// clang-format off

#define		int                    long long
#define		ve                     vector
#define		pb                     push_back
#define		endl                   "\n"
#define		ff                     first
#define		ss                     second
#define		pii                    pair<int, int>
#define		len(v)                 (int)v.size()
#define		all(v)                 v.begin(), v.end()
#define		reset(a, b)            memset(a, b, sizeof(a));
#define		fr(i, s, n)            for (int i = s ; i < n ; ++i)
#define		dfr(i, s, n)           for (int i = s ; i > n ; --i)

template < typename T > void pr (const T& t) {
    cout << t << "\n";
}

template < typename T, typename U, typename... ARGS >
void pr (const T& t, const U& u, const ARGS&... args) {
    cout << t << " ";
    pr (u, args...);
}

// clang-format on


signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	string s;
	cin >> s;
	string ans;

	if (s[0] == '?') {
		if (len (s) > 1) {
			if (s[1] == 'D')
				ans += 'P';
			else if (s[1] == '?') {
				ans += 'P';
			} else {
				ans += 'D';
			}
		} else {
			ans += 'D';
		}
	} else {
		ans += s[0];
	}

	fr (i, 1, len (s)) {
		if (s[i] != '?') {
			ans += s[i];
		} else {
			if (ans.back () == 'P')
				ans += 'D';
			else {
				if (i + 1 < len (s)) {
					if (s[i + 1] == 'D' or s[i + 1] == '?') {
						ans += 'P';
					} else
						ans += 'D';
				} else {
					ans += 'D';
				}
			}
		}
	}
	pr (ans);
	return 0;
}

Measured memory_bytes: 3892
import math
n, m = map(int, input().split())
kotae=1

for i in range(1,int(math.sqrt(m))+1):
	if m%i==0:
		if i*n<=m:
			kotae=max(kotae, i)
		if (m//i)*n<=m:
			kotae=max(kotae, m//i)
print(kotae)

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, k; cin>>n>>k;
	vll h(n);
	rep(i, n) cin >> h[i];
	sort(all(h));
	ll ans = LONG_LONG_MAX;
	rep(i, n-k+1){
		ans = min(ans, h[i+k-1]-h[i]);
	}
	cout << ans << "\n";
	return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;

	auto check = [&](ll m) { return n/m == n%m; };
	
	ll res = 0;
	for (ll k = 1; k*k <= n; k++) if (n%k == 0) {
		if (k > 1 && check(k-1)) res += k-1;
		if (k != n/k && check(n/k-1)) res += n/k-1;
	}
	cout << res << endl;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int H,W; cin >> H >> W;
    vector<string> S(H);
    rep(i,H) cin >> S[i];

    vector<bool> R(H),C(W);
    rep(i,H) rep(j,W) {
        if (S[i][j]=='#') R[i] = C[j] = 1;
    }
    rep(i,H) {
        if (!R[i]) continue;
        rep(j,W) if (C[j]) cout << S[i][j];
        cout << ln;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main(){
    cin>>a>>b;
    if(a>0)puts("Positive");               //情况1
    else if(b>=0)puts("Zero");             //情况2
    else if((a&1)^(b&1))puts("Positive");  //情况3
    else puts("Negative");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> d(n), c(n);
    int sum = 0, ans = 0;
    rep(i, 0, n){
        cin >> d[i] >> c[i];
        sum += d[i] * c[i];
        ans += c[i];
    }
    ans = ans - 1 + (sum - 1) / 9;
    cout << ans << endl;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second

using namespace std;

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

const int N=60005;

int n,m,op[N],vi[N];
pi b[N];

vector<int>e[N];
int nc,dfc,bcc,dfn[N],low[N],qu[N],bel[N],tp;
bool in[N];
int id[N<<1];

void build(int x,int l,int r){
	id[x]=++nc;
	if(l==r){e[id[x]].pb(op[l]);return;}
	int ls=x<<1,rs=ls|1,mid=(l+r)>>1;
	build(ls,l,mid);e[id[x]].pb(id[ls]);
	build(rs,mid+1,r);e[id[x]].pb(id[rs]);
}
void link(int x,int l,int r,int s,int t,int u){
	if(l==s&&r==t){e[u].pb(id[x]);return;}
	int ls=x<<1,rs=ls|1,mid=(l+r)>>1;
	if(t<=mid)link(ls,l,mid,s,t,u);
	else if(s>mid)link(rs,mid+1,r,s,t,u);
	else link(ls,l,mid,s,mid,u),link(rs,mid+1,r,mid+1,t,u);
}
void tarjan(int x){
	dfn[x]=low[x]=++dfc,qu[++tp]=x,in[x]=true;
	for(int v:e[x]){
		if(!dfn[v])tarjan(v),low[x]=min(low[x],low[v]);
		else if(in[v])low[x]=min(low[x],dfn[v]);
	}
	if(low[x]==dfn[x]){
		int v;++bcc;
		do bel[v=qu[tp]]=bcc,in[v]=false,qu[tp--]=0;while(v!=x);
	}
}
bool chk(int x){
	while(nc)dfn[nc]=low[nc]=bel[nc]=0,e[nc].clear(),nc--;
	nc=m;dfc=bcc=0;
	build(1,1,m);
	int l=1,r=1;
	for(int i=1;i<=m;i++){
		while(b[l].fi<=b[i].fi-x&&l<=m)l++;
		while(b[r].fi<b[i].fi+x&&r<=m)r++;
		if(l<i)link(1,1,m,l,i-1,i); 
		if(i<r-1)link(1,1,m,i+1,r-1,i); 
	}
	for(int i=1;i<=nc;i++)if(!dfn[i])tarjan(i);
	for(int i=1;i<=m;i++)if(bel[i]==bel[op[i]])return false;
	return true;
}

int main(){
	scanf("%d",&n);
	for(int i=1,x;i<=n;i++)for(int j:{0,1})scanf("%d",&x),b[++m]={x,i};
	sort(b+1,b+m+1);
	for(int i=1,j;i<=m;i++)if(!vi[j=b[i].se])vi[j]=i;else op[vi[j]]=i,op[i]=vi[j];
	int l=0,r=(b[m].fi-b[1].fi)/(n-1),mid=(l+r+1)>>1;
	while(l<r){
		if(chk(mid))l=mid;else r=mid-1;
		mid=(l+r+1)>>1;
	}
	printf("%d\n",mid);
	return 0;
}

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

int main()
{	
	int n,i;
	cin>>n;
	for(i=9;i>=1;i--)
	{
		if(n%i==0)
		{	if(n/i<10)
				cout<<"Yes\n";
			else cout<<"No\n";
		break;
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    unsigned long long int n,k,temp;
    cin>>n>>k;
    if(n%k==0)
    cout<<0;
    else
    {
        temp=n/k;
        n = n - temp*k;
        cout<<min(n,k-n);
    }
}

Measured memory_bytes: 256
date = input()
aa = date[0:2]
bb = date[2:4]

aa = int(aa)
bb = int(bb)

if (aa > 12 and bb > 12):
    print ('NA')
if aa>12 and bb ==0:
    print ("NA")
if aa>12 and 1<=bb<=12:
    print ("YYMM")

if (0<aa<=12 and bb ==0) or (0<aa<=12 and bb>12):
    print ("MMYY")
if 0<aa<=12 and 0<bb<=12:
    print ("AMBIGUOUS")

if (aa == 0 and bb ==0) or(aa ==0 and bb> 12):
    print ("NA")
if aa ==0 and 0< bb<=12:
    print ("YYMM")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int n;
P pos;
vector<bool> prime;
int dr[4] = {0, -1, 0, 1};
int dc[4] = {1, 0, -1, 0};
void search(vvi &b, vector<vector<bool>> &p, int r, int c, int now, int ed, int cnt, int nowma, int prevma, int dir) {
  if(now == 1097) {
  }
  if(now == ed+1) return;
  if(cnt == nowma && nowma == prevma) {
    search(b, p, r, c, now, ed, 0, nowma+1, nowma, (dir + 1) % 4);
  } else if(cnt == nowma) {
    search(b, p, r, c, now, ed, 0, nowma, nowma, (dir + 1) % 4);
  } else {
    int nr = r + dr[dir], nc = c + dc[dir];
    b[nr][nc] = now;
    if(prime[now]) p[nr][nc] = true;
    if(now == n) pos = {nr, nc};
    search(b, p, nr, nc, now+1, ed, cnt+1, nowma, prevma, dir);
  }
  return;
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  prime.resize(1000001, true);
  prime[0] = false;
  prime[1] = false;
  for(int i=2;i*i<=1000000;++i) {
    if(prime[i]) {
      int now = 2*i;
      while(now <= 1000000) {
        prime[now] = false;
        now += i;
      }
    }
  }
  while(1) {
    int m; cin >> m >> n;
    if(m == 0) break;
    vvi b(1001, vi(1001, 0));
    b[500][500] = 1;
    pos = {500, 500};
    vector<vector<bool>> p(1001, vector<bool>(1001, false));
    search(b, p, 500, 500, 2, m, 0, 1, 0, 0);
    vector<vector<P>> dp(1001, vector<P>(1001, {0, 0}));
    int sr = pos.first, sc = pos.second;
    dp[sr][sc] = {p[sr][sc], (p[sr][sc] ? b[sr][sc] : 0)};
    for(int i=sr;i<1000;++i) {
      for(int j=-(i-sr)+sc;j<=i-sr+sc;++j) {
        if(!(0 <= j && j < 1001)) continue;
        for(int k=-1;k<=1;++k) {
          if(!(0 <= j+k && j+k < 1001)) continue;
          if(dp[i+1][j+k].first < dp[i][j].first + p[i+1][j+k]) {
            dp[i+1][j+k] = {dp[i][j].first + p[i+1][j+k], (p[i+1][j+k] ? b[i+1][j+k] : dp[i][j].second)};
          } else if(dp[i+1][j+k].first == dp[i][j].first + p[i+1][j+k]) {
            dp[i+1][j+k].second = (p[i+1][j+k] ? b[i+1][j+k] : max(dp[i+1][j+k].second, dp[i][j].second));
          }
        }
      }
    }
    int ma = 0;
    int argma = 0;
    for(int i=0;i<1001;++i) {
      if(ma < dp[1000][i].first) {
        ma = dp[1000][i].first;
        argma = dp[1000][i].second;
      } else if(ma == dp[1000][i].first) {
        argma = max(argma, dp[1000][i].second);
      }
    }
    cout << ma << " " << argma << endl;
  }
}



Measured memory_bytes: 14816
n, m, l = map(int, input().split())
A = [list(map(int, input().split())) for i in range(n)]
B = [list(map(int, input().split())) for i in range(m)]
C = [[0] * l for i in range(n)]
for i in range(n):
    for j in range(l):
        C[i][j] = sum(A[i][k]*B[k][j] for k in range(m))
for line in C:
    print(*line)


Measured memory_bytes: 6968
#include <iostream>

using namespace std;

int a,b;

int gcd(int x,int y);
int lcm(int x,int y);

int main(){
	while(cin>>a>>b){
		cout<<gcd(a,b)<<" "<<lcm(a,b)<<endl;
	}
	return 0;
	
}

int gcd(int x,int y){
	if(x==0&&y==0)return 0;
	while(x!=y){
		if(x>y)x=x-y;
		else y=y-x;
	}
	return x;
} 

int lcm(int x,int y){
	if(x==0&&y==0)return 0;
	return (x/gcd(x,y))*y;
}

Measured memory_bytes: 3076