akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順

int main(){
  int K;cin>>K;
  string S;cin>>S;
  int l=S.length();
  if(K>=l){
    cout<<S<<endl;
  }else{
    for(int i=0;i<K;i++){
      cout<<S[i];
    }
    cout<<"...";
    cout<<endl;
  }

}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n, m; cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SZ(x) (int)(x).size()
#define ZERO(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<": "<<(x)<<"\n"
#define pb push_back
#define eb emplace_back
#define mp make_pair

int h,w;

int main() {
    cin>>h>>w;

    rep(y,h) rep(x,w) {
        string s;
        cin >> s;
        if(s == "snuke") {
            char c = 'A' + x;
            cout << c << y+1 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
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; }
// 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;}

int main() {
  int n; cin >> n;
  int p[n];
  FOR(i,0,n-1) cin >> p[i];

  int max = 2 * pow(10,5) + 10;
  int ans = 0;

  FOR(i,0,n-1){
    if(p[i]<max){
      ++ans;
      max = p[i];
    }
  } 
  cout << ans << endl;
}

Measured memory_bytes: 1152
//インクを落とす
#include<cstdio>

using namespace std;

int main(void){
	int pa[14][14];
	int i,j;	//ループカウンタ
	int x,y,size,da=0,not_=0;
	
	//二次元配列の初期化
	for(i=0;i<14;i++){
		for(j=0;j<14;j++)
			pa[i][j]=0;
	}

	while(scanf("%d,%d,%d",&x,&y,&size)!=EOF){
		x=x+2;
		y=y+2;
		switch(size){
			case 1:	//小
				pa[y][x]++;
				pa[y-1][x]++;
				pa[y+1][x]++;
				pa[y][x-1]++;
				pa[y][x+1]++;
				break;
			case 2:	//中
				for(i=-1;i<=1;i++){
					for(j=-1;j<=1;j++)
						pa[y+i][x+j]++;
				}
				break;
			case 3:	//大
				for(i=-1;i<=1;i++){
					for(j=-1;j<=1;j++)
						pa[y+i][x+j]++;
				}
				pa[y-2][x]++;
				pa[y+2][x]++;
				pa[y][x-2]++;
				pa[y][x+2]++;
				break;
		}
	}
	for(i=2;i<12;i++){
		for(j=2;j<12;j++){
			if(pa[i][j]==0)
				not_++;
			if(pa[i][j]>da)
				da=pa[i][j];
		}
	}
	printf("%d\n%d\n",not_,da);

	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstdint>

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

  if ((N%500) <= A) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}


Measured memory_bytes: 128
n,m,k = map(int, input().split())
mod = 998244353

def modconb(n,k,mod):
    # テーブルを作る
    fac = [0]*(n+1)
    finv = [0]*(n+1)
    inv = [0]*(n+1)  

    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2,n+1):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) % mod
        finv[i] = finv[i-1] * inv[i] %mod
    # 計算
    if n<k: return 0
    if n<0 or k<0: return 0
    
    modcombs = [1]
    for k in range(1,n+1):
        modcombs.append(fac[n]*(finv[k]*finv[n-k]%mod)%mod)
    return modcombs

if n == 1:
    print(m)
    exit()

mods = modconb(n-1,n-1,mod)
cnt = 0
for i in range(k+1):
    cnt += m*mods[i]*pow(m-1,n-i-1,mod)
    cnt %= mod
print(cnt)


# cnt = 100
# for i in range(99):
#     cnt *= 99
#     cnt %= mod

# print(cnt)    


Measured memory_bytes: 40416
def divide(iterable):
	return list(map((lambda x : x // 2),iterable))
    
N = int(input())
nums = list(map(int, input().split()))
count = 0
flag = 0
while 1:
  if flag == 1:
    break
  for num in nums:
    if num % 2 == 1:
      flag = 1
      break
  else:
    count += 1
    nums = divide(nums)
print(count)

Measured memory_bytes: 64776
#include <iostream>
#include <stdio.h>
int main(void){
  int N;
  int a[100];
  int col[9]={0,0,0,0,0,0,0,0};
  std::cin >> N;
  for(int i=0;i<N;i++){
    std::cin >> a[i];
    if(1 <= a[i] && a[i] <= 399){
      col[0]++;
    }else if(400 <= a[i] && a[i] <= 799){
      col[1]++;
    }else if(800 <= a[i] && a[i] <= 1199){
      col[2]++;
    }else if(1200 <= a[i] && a[i] <= 1599){
      col[3]++;
    }else if(1600 <= a[i] && a[i] <= 1999){
      col[4]++;
    }else if(2000 <= a[i] && a[i] <= 2399){
      col[5]++;
    }else if(2400 <= a[i] && a[i] <= 2799){
      col[6]++;
    }else if(2800 <= a[i] && a[i] <= 3199){
      col[7]++;
    }else{
      col[8]++;
    }
  }
  int max=0;
  int min=0;
  for(int i=0;i<9;i++){
    if(i <= 7 && col[i] != 0){
      max++;
      min++;
    }else if(i == 8 && col[i] != 0){
      max += col[i];
      if(min != 0)break;
      min++;
    }
  }
  printf("%d %d",min,max);
  return 0;
}

Measured memory_bytes: 256
#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;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
ll N;
ll ans;
const ll T = 55440;
ll a[T];
ll A[13], B[17], C[19], D[23];
int main() {
    while(cin >> N) {
        if(N == 0) break;
        for(int i = 0; i < T; i++) {
            a[i] = 0;
        }
        for(int i = 0; i < 13; i++) A[i] = 0;
        for(int i = 0; i < 17; i++) B[i] = 0;
        for(int i = 0; i < 19; i++) C[i] = 0;
        for(int i = 0; i < 23; i++) D[i] = 0;
        ans = 0;
        for(int i = 0; i < N; i++) {
            ll d;
            cin >> d;
            ll t;
            cin >> t;
            vector<ll> q(d);
            for(int j = 0; j < d; j++) cin >> q[j];
            if(d == 13 or d == 17 or d == 19 or d == 23) {
                for(int j = 0; j < d; j++) {
                    if(d == 13) A[j] += q[(j+t)%d];
                    if(d == 17) B[j] += q[(j+t)%d];
                    if(d == 19) C[j] += q[(j+t)%d];
                    if(d == 23) D[j] += q[(j+t)%d];
                }
                continue;
            }
            for(int j = 0; j < T; j++) {
                a[j] += q[(t + j) % d];
            }
        }
        ll maxi = 0;
        for(auto tmp : a) {
            chmax(maxi, tmp);
        }
        ans += maxi;
        maxi = 0;
        for(int i = 0; i < 13; i++) chmax(maxi, A[i]);
        ans += maxi;
        maxi = 0;
        for(int i = 0; i < 17; i++) chmax(maxi, B[i]);
        ans += maxi;
        maxi = 0;
        for(int i = 0; i < 19; i++) chmax(maxi, C[i]);
        ans += maxi;
        maxi = 0;
        for(int i = 0; i < 23; i++) chmax(maxi, D[i]);
        ans += maxi;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3428
import re
n = int(input())
s = input()


pattern = "a+|b+|c+|d+|e+|f+|g+|h+|i+|j+|k+|l+|m+|n+|o+|p+|q+|r+|s+|t+|u+|v+|w+|x+|y+|z+"
result = re.finditer(pattern, s)

count=0
for res in result:
  count+=1

print(count)

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

int main()
{
	ios::sync_with_stdio(false);
	
	int i;
	
	vector<int> n(3);
	
	for(i=0;i<3;i++)
		cin>>n[i];
	
	sort(n.begin(),n.end());
	
	if(n[0]==5&&n[1]==5&&n[2]==7)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int k=0,a[10010],n,i,j,b[65];
long int ans=0;
while(1){
scanf("%d\n",&n);
if(n==0){
break;
}
for(i=0;i<61;i++){
b[i]=0;
}
for(i=0;i<n;i++){
scanf("%d\n",&a[i]);
b[a[i]]++;
}
for(i=0;i<61;i++){
for(j=0;j<b[i];j++){
a[k]=i;
k++;
}
}
k=0;
for(i=0;i<n;i++){
ans=ans+a[i]*(n-i-1);
}
printf("%ld\n",ans);
ans=0;
}
return 0;
}


Measured memory_bytes: 2036
import sys
import numpy as np
input = sys.stdin.readline


n, c = map(int, input().split())
tv_guide = np.zeros((c, 10**5+1), dtype=np.int)

for _ in range(n):
    s, t, c = map(lambda x: int(x)-1, input().split())
    tv_guide[c][s:t+1] = 1

ans = 0
for time in range(10**5+1):
    count = sum(tv_guide[:,time])
    ans = max(count, ans)

print(ans)

Measured memory_bytes: 37956
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

bool used[100010];

ll calc(ll b, ll l, ll u, ll rem) {
    if (rem > b) {
        return l * b + u * (rem - b);
    } else {
        return l * rem;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, X;
    cin >> N >> X;
    ll b[N], l[N], u[N];
    ll aoval = 0;
    ll hi = 0;
    REP(i, 0, N) {
        cin >> b[i] >> l[i] >> u[i];
        aoval += l[i] * b[i];
        hi += b[i];
    }
    plglg p[N];
    REP(i, 0, N) {
        p[i] = plglg(l[i] * b[i] + u[i] * (X - b[i]), i);
    }
    sort(p, p + N);
    reverse(p, p + N);
    // ll hi = 1e12;
    ll lo = -1;
    while (hi - lo > 1) {
        ll mid = (hi + lo) / 2;
        ll num = mid / X;
        fill(used, used + N, false);
        ll sum = 0;
        REP(i, 0, num + 1) {
            sum += p[i].first;
            used[p[i].second] = true;
        }
        ll rem = mid % X;
        bool ok = false;
        REP(i, 0, N) {
            ll pt = p[i].second;
            ll val = calc(b[pt], l[pt], u[pt], rem);
            if (i < num) {
                val += sum - p[i].first;
            } else {
                val += sum - p[num].first;
            }
            if (val >= aoval) {
                ok = true;
            }
        }
        if (ok) {
            hi = mid;
        } else {
            lo = mid;
        }
    }
    cout << hi << endl;
}


Measured memory_bytes: 4224
// atcoder/abc129/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int a, b, c;
  while (cin >> a >> b >> c) {
    vector<int> v({a, b, c});
    sort(v.begin(), v.end());
    cout <<  v[0] + v[1] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int N = nextInt();
      ArrayList<Integer> list = nextIntArray();
      int output = 0;
      for(int i = 0; i < N; i++){
        int tmp = list.get(i);
        while(tmp % 2 == 0){
          output++;
          tmp /= 2;
        }
      }
      myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


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

typedef std::vector<int> TList;
void CountingSort(const TList& A, TList& B, int k)
{
    std::vector<int> C(k+1, 0);
    
    /* C[i] ??? i ???????????°????¨?????????? */
    for(int j = 0; j < A.size(); ++j){
        C[A[j]]++;
    }
    
    /* C[i] ??? i ??\????????°???????????°????¨??????????*/
    for(int i = 1; i <= k; ++i){
        C[i] = C[i] + C[i-1];
    }
    
    // for(int j = A.size() - 1; j >= 0; --j){
    //     B[C[A[j]]-1] = A[j];
    //     C[A[j]]--;
    // }
    for(int j = 0; j < A.size(); ++j){
        B[C[A[j]]-1] = A[j];
        C[A[j]]--;
    }
}
int main()
{
    int n;
    std::cin >> n;
    std::vector<int> A(n);
    for(int i = 0; i < n; ++i){
        std::cin >> A[i];
    }
    int k = *std::max_element(A.begin(), A.end());
    std::vector<int> B(n);
    CountingSort(A, B, k);
    for(int i = 0; i < n; ++i){
        if(i) std::cout << " ";
        std::cout << B[i];
    }
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 16800
def comp(a,b):
    if sum(a)<sum(b):
        return "right"
    elif sum(a)>sum(b):
        return "left"
    else:
        for i in range(8,-1,-1):
            if a[i]<b[i]:
                return "right"
            elif a[i]>b[i]:
                return "left"
        else:
            return "equal"

N,M=map(int,input().split())
A=list((map(int,input().split())))
 
m=[[1,2],[2,5],[3,5],[4,4],[5,5],[6,6],[7,3],[8,7],[9,6]]
B=[]
    
for a in A:
    B.append(m[a-1])

if [5,5] in B:
    if [2,5] in B:
        B.remove([2,5])
    if [3,5] in B:    
        B.remove([3,5])

if [3,5] in B and [2,5] in B:
    B.remove([2,5])

if [7,3] in B:
    if [6,6] in B:
        B.remove([6,6])
    if [9,6] in B:
        B.remove([9,6])
    
if [9,6] in B and [6,6] in B:
    B.remove([6,6])

if [1,2] in B and [7,3] in B:
    if [2,5] in B:
        B.remove([2,5])
    if [3,5] in B:
        B.remove([3,5])
    if [5,5] in B:
        B.remove([5,5])
    if [8,7] in B:
        B.remove([8,7])

if [1,2] in B and ([2,5] in B or [3,5] in B or [5,5] in B) and [8,7] in B:
    B.remove([8,7])
    
if [4,4] in B and [7,3] in B and [8,7] in B:
    B.remove([8,7])
    
if [1,2] in B and [4,4] in B:
    B.remove([4,4])
    
maxlist=[[0]*9 for _ in range(N+1)]
 
for i in range(N+1):
    if i!=0 and sum(maxlist[i])==0:
        continue
    else:
        for b in B:
            if i+b[1]>N:
                continue
            #ans=maxlist[i]+str(b[0])
            ans=[maxlist[i][k] for k in range(9)]
            ans[b[0]-1]+=1
            _max=maxlist[i+b[1]]
            if comp(ans,_max) == "left":
                maxlist[i+b[1]]=[ans[k] for k in range(9)]
 
for i in range(8,-1,-1):
    print(str(i+1)*maxlist[N][i],end="")
print()

Measured memory_bytes: 5356
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

using P = pair<int,int>;

long dist(P &a, P &b){
  long x=a.fi-b.fi;
  long y=a.se-b.se;
  return x*x+y*y;
}

double dist(P &a, P &b, P &c){
  long ipa = (b.fi-a.fi)*(c.fi-a.fi) + (b.se-a.se)*(c.se-a.se);
  long ipb = (a.fi-b.fi)*(c.fi-b.fi) + (a.se-b.se)*(c.se-b.se);
  if(ipa<=0 || ipb<=0) return min(dist(a,c), dist(b,c));
  else {
    long outacab = (c.fi-a.fi)*(b.se-a.se) - (c.se-a.se)*(b.fi-a.fi);
    return (double)outacab*outacab / dist(a,b);
  }
}

int main(){
  int n,m;
  cin>>n>>m;
  vector<P> p(n+1);
  cin>>p[0].fi>>p[0].se;
  rep(i,1,n+1) cin>>p[i].fi>>p[i].se;

  n++;

  vector<bool> used(n, false);
  used[0]=true;
  vector<double> dd(n); // dist^2
  rep(i,n) dd[i] = dist(p[0],p[i]);
  dd[0] = INF;

  double ans = 0;
  rep(_,m){
    int cand = 0;
    rep(j,1,n) if(!used[j] && dd[cand] > dd[j]) cand = j;

    double add = INF;
    int from = 0;
    rep(j,n) if(used[j] && dist(p[cand], p[j]) < add) from=j, add = dist(p[cand], p[j]);

    ans += sqrt(add);//dbg(add,from);
    used[cand] = true;

    rep(j,n) if(!used[j]) dd[j] = min<double>(dd[j], dist(p[cand], p[from], p[j]));
  }

  printf("%.10f\n", ans);

  return 0;
}

Measured memory_bytes: 3248
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>b;i--)
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
const int INF=numeric_limits<int>::infinity();
const int MOD=1000000007;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int n, k;
bool d[10];

int main() {
    cin >> n >> k;
    rep(i, 0, k) {
        int x; 
        cin >> x;
        d[x] = true;
    }
    
    rep(i, n, 10*n) {
        bool flag = true;
        int t = i;
        while (t) {
            if (d[t%10]) flag = false;
            t /= 10;
        }
        if (!flag) continue;
        else {
            printf("%d\n", i);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
/*  ***  In The Name of God ... ***  */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

#define all(v) v.begin() , v.end()
#define pb push_back

ll n , x , h , w;

int main ()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for(ll w = 1 ; w <= 3500 ; w++)
	{
		for(ll h = 1 ; h <= 3500 ; h++)
		{
			ll t = 4 * h * w - n * (h + w);
			ll tt = n * h * w;
			if(t <= 0 || tt <= 0)
				continue;
			if(tt % t == 0)
			{
				return cout << w << ' ' << h << ' ' << tt / t , 0 ;
			}
		}
	}
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int w = sc.nextInt();
      	int h = sc.nextInt();
      	int n = sc.nextInt();
      	int t = h;
      	int b = 0;
      	int l = 0;
      	int r = w;
      	for(int i = 0; i < n; i++){
      		int x = sc.nextInt();
      		int y = sc.nextInt();
      		int a = sc.nextInt();
        	if(a == 1){l = Math.max(l, x);}
        	else if(a == 2){r = Math.min(r, x);}
        	else if(a == 3){b = Math.max(b, y);}
        	else if(a == 4){t = Math.min(t, y);}
        }
      	if(l >= r || b >= t){
          System.out.println(0);
        }else{
      		int ans = (r - l) * (t - b);
			System.out.println(ans);
        }
	}
}


Measured memory_bytes: 21456
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int h=in(),w=in(),k=in();
    vector<vec> a(h,vec(w));
    vector<vector<bool>> done(h,vector<bool>(w,false));
    priority_queue<pair<int,pii>,vector<pair<int,pii>>,greater<pair<int,pii>>> q;
    rep(i,h){
        string s=stin();
        rep(j,w){
            a[i][j]=s[j]=='#'?1:0;
            if(s[j]=='S'){
                q.push(mp(0,mp(i,j)));
                done[i][j]=true;
            }
        }
    }
    vector<pii> p;
    while(!q.empty()){
        int s=q.top().second.first,t=q.top().second.second,dis=q.top().first;
        q.pop();
        p.push_back(mp(s,t));
        if(s<h-1)if(!done[s+1][t]){
            if(a[s+1][t]==0&dis<k)q.push(mp(dis+1,mp(s+1,t)));
            done[s+1][t]=true;
        }
        if(s>0)if(!done[s-1][t]){
            if(a[s-1][t]==0&dis<k)q.push(mp(dis+1,mp(s-1,t)));
            done[s-1][t]=true;
        }
        if(t<w-1)if(!done[s][t+1]){
            if(a[s][t+1]==0&dis<k)q.push(mp(dis+1,mp(s,t+1)));
            done[s][t+1]=true;
        }
        if(t>0)if(!done[s][t-1]){
            if(a[s][t-1]==0&dis<k)q.push(mp(dis+1,mp(s,t-1)));
            done[s][t-1]=true;
        }
    }
    int min_cost=INT_MAX;
    REP(x,p){
        min_cost=min(min_cost,min(min(x.first,x.second),min(h-1-x.first,w-1-x.second)));
    }
    cout<<(min_cost+k-1)/k+1<<endl;
}

Measured memory_bytes: 12024
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n,a,b,c,d;
    string s;
    std::cin >> n>>a>>b>>c>>d;
    a--;
    b--;
    c--;
    d--;
    std::cin >> s;
    if(c<d){
        bool ok = true;
        for (int i = a+1; i < c; i++) {
            if( s[i] == s[i+1] && s[i] == '#'  ){
                ok=false;
                break;
            }
        }
        if(!ok){
            std::cout << "No" << std::endl;
            return 0;
        }
        
        for (int i = b+1; i < d; i++) {
            if( s[i] == s[i+1] && s[i] == '#'  ){
                ok=false;
                break;
            }
        }
        if(!ok){
            std::cout << "No" << std::endl;
            return 0;
        }else{
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }else if(d<c){
        bool ok = true;
        for (int i = a; i < b; i++) {
            if( s[i] == s[i+1] && s[i] == '#'  ){
                ok=false;
                break;
            }
        }
        if(!ok){
            std::cout << "No" << std::endl;
            return 0;
        }
        
        for (int i = d; i < c; i++) {
            if( s[i] == s[i+1] && s[i] == '#'  ){
                ok=false;
                break;
            }
        }
        if(!ok){
            std::cout << "No" << std::endl;
            return 0;
        }
        ok = false;
        for (int i = b-1; i <= d-1; i++) {
            if( s[i] == s[i+1] && s[i+1] == s[i+2] && s[i] == '.' ){
                ok=true;
                break;
            }
        }
        if(!ok){
            std::cout << "No" << std::endl;
            return 0;
        }else{
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
}


Measured memory_bytes: 640
N = int(input())
T = [0] + list(map(int,input().split()))
V = [-1] + list(map(int,input().split()))

ans = 0
for i in range(1,N+1):
    T[i] += T[i-1]
time = T[-1]
upper  = {}

state = N
speed = 0

for t in range(2*time,0,-1):
    t *= 0.5
    if T[state-1] == t:
        speed = min(V[state],speed)
        state -= 1
    upper[t] = min(speed,V[state])
    speed += 0.5

speed = 0
pre = -1
Ans = []
for t in range(1,2*time+1):
    t = t*0.5
    speed += 0.5
    speed = min(speed,upper[t])
    Ans.append(speed)
    if pre == speed:
        ans += 0.5*speed
    elif pre > speed:
        ans += 0.5*speed + 0.125
    else:
        ans += 0.5*speed - 0.125
    pre = speed
print(ans)

Measured memory_bytes: 5872
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

class State{
public:
  int a, b, c, d;
  State(int a = 0, int b = 0, int c = 0, int d = 0)
    : a(a), b(b), c(c), d(d) {}
  bool operator < (const State& s) const {
    if(c == s.c){
      if(d == s.d) return a < s.a;
      return d < s.d;
    }
    return c > s.c;
  }
};

int n;
map<int, int> univ;
State data[300];

main(){
  while(cin >> n && n){
    univ.clear();
    for(int i=0;i<n;i++){
      cin >> data[i].a >> data[i].b >> data[i].c >> data[i].d;
    }
    sort(data, data+n);
    int cnt = 0;
    for(int i=0;i<n&&cnt<26;i++){
      if(cnt < 10){
        if(univ[data[i].b] < 3){
          cout << data[i].a << endl;
          univ[data[i].b]++;
          cnt++;
        }
      }else if(cnt < 20){
        if(univ[data[i].b] < 2){
          cout << data[i].a << endl;
          univ[data[i].b]++;
          cnt++;
        }
      }else{
        if(univ[data[i].b] < 1){
          cout << data[i].a << endl;
          univ[data[i].b]++;
          cnt++;
        }
      }
    }
  }
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <climits>
#include <list>
#include <queue>

using namespace std;

static const int INFTY = -1;

int H;
int A[101];
int NodeNum[101];
int IndexInA[100];


int parent(int i) {
	return i / 2;
}

int left(int i) {
	return 2 * i;
}

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

void minHeapify(int i) {
	int l = left(i);
	int r = right(i);
	int smallest = i;
	if (l <= H && A[l] < A[i]) {
		smallest = l;
	}
	if (r <= H && A[r] < A[smallest]) {
		smallest = r;
	}
	if (smallest != i) {
		int temp = A[i];
		A[i] = A[smallest];
		A[smallest] = temp;
		temp = NodeNum[i];
		NodeNum[i] = NodeNum[smallest];
		NodeNum[smallest] = temp;
		IndexInA[NodeNum[i]] = i;
		IndexInA[NodeNum[smallest]] = smallest;

		minHeapify(smallest);
	}
}

void insert(int d, int nodeNum) {
	int i = ++H;
	A[i] = d;
	NodeNum[i] = nodeNum;
	IndexInA[nodeNum] = i;
	int p = parent(i);
	while (i > 1 && A[p] > A[i]) {
		int temp = A[p];
		A[p] = A[i];
		A[i] = temp;
		temp = NodeNum[p];
		NodeNum[p] = NodeNum[i];
		NodeNum[i] = temp;
		IndexInA[NodeNum[p]] = p;
		IndexInA[NodeNum[i]] = i;
		i = p;
		p = parent(i);
	}
}

int heapExtractMinNodeNum() {
	int minNodeNum = NodeNum[1];
	A[1] = A[H];
	NodeNum[1] = NodeNum[H];
	IndexInA[NodeNum[1]] = 1;
	H--;
	minHeapify(1);

	return minNodeNum;
}

void decrese(int i, int value) {
	A[i] = value;
	int p = parent(i);
	while (i > 1 && A[p] > A[i]) {
		int temp = A[p];
		A[p] = A[i];
		A[i] = temp;
		temp = NodeNum[p];
		NodeNum[p] = NodeNum[i];
		NodeNum[i] = temp;
		IndexInA[NodeNum[p]] = p;
		IndexInA[NodeNum[i]] = i;
		i = p;
		p = parent(i);
	}
}

int main() {
	int Dist[100];
	int AdjacenceyList[100][100];
	int AdjacenceyWeightList[100][100];
	int Degree[100];
	int i, j;
	int N;
	int W;
	//int Deg;
	int MinTotalWeight = 0;
	int u, v;
	int k;
	bool inT[100];

	cin >> N;

	//for (i = 0; i < N; i++) {
	//	inT[i] = false;
	//	Dist[i] = INFTY;
	//	Deg = -1;
	//	for (j = 0; j < N; j++) {
	//		cin >> W;
	//		if (W != -1) {
	//			AdjacenceyList[i][++Deg] = j;
	//			AdjacenceyWeightList[i][Deg] = W;
	//		}
	//	}
	//	Degree[i] = Deg + 1;
	//}

	for (i = 0; i < N; i++) {
		inT[i] = false;
		Dist[i] = INFTY;
		cin >> u >> k;
		Degree[u] = k;
		for (j = 0; j < k; j++) {
			cin >> AdjacenceyList[u][j] >> AdjacenceyWeightList[u][j];
		}
	}


	H = 0;
	u = 0;
	inT[u] = true;
	Dist[u] = 0;
	for (i = 1; i <= N - 1; i++) {
		for (j = 0; j < Degree[u]; j++) {
			v = AdjacenceyList[u][j];
			if (inT[v] == false) {
				W = AdjacenceyWeightList[u][j];
				if (Dist[v] == INFTY) {
					//Dist[v] = W;
					//insert(W, v);
					Dist[v] = Dist[u] + W;
					insert(Dist[v], v);
				}
				//else if (W < Dist[v]) {
				else if(W + Dist[u] < Dist[v]){
					//Dist[v] = W;
					//decrese(IndexInA[v], W);
					Dist[v] = W + Dist[u];
					decrese(IndexInA[v], Dist[v]);
				}
			}
		}

		int minNodeNum = heapExtractMinNodeNum();
		inT[minNodeNum] = true;
		//MinTotalWeight += Dist[minNodeNum];
		u = minNodeNum;

	}

	//printf("%d\n", MinTotalWeight);

	for (i = 0; i < N; i++) {
		printf("%d %d\n", i, Dist[i]);
	}

	return 0;
}

Measured memory_bytes: 1220
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int main()
{
  int a,b;
  scanf("%d%d",&a,&b);
  if (a==1) a=14;
  if (b==1) b=14;
  if (a==b) printf("Draw\n");
  else if (a>b) printf("Alice\n");
  else printf("Bob\n");
  return 0;
}

Measured memory_bytes: 256
/*raghav0307 - Raghav Gupta*/
 
#include <bits/stdc++.h>
using namespace std;
 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#define ff first
#define ss second
#define pb push_back
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int ll

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
 
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

signed main(){
	fast_io();
	
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;

	int t1 = 60*h1 + m1;
	int t2 = 60*h2 + m2;

	cout << t2 - k - t1 << "\n";

	return 0;
}


Measured memory_bytes: 3648
/*
    Washief Hossain Mugdho
    19 September 2020
    Educational DP IndependentSet
*/

#ifndef DEBUG
#pragma GCC optimize("O3")
#endif

#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define fastio ios_base::sync_with_stdio(0)
#define untie cin.tie(0)
#define ms(a, b) memset(a, b, sizeof a)
#define mod 1000000007
using namespace std;
ll memo[100005][2];
int n, x, y;
list<int> adj[100005];

ll dp(int now, int parent, int prevCol)
{
    if (memo[now][prevCol] != -1)
        return memo[now][prevCol];
    ll res = 1;
    for (auto p : adj[now])
    {
        if (p != parent)
        {
            ll temp = dp(p, now, 1) % mod;
            if (prevCol)
                temp = (temp + dp(p, now, 0)) % mod;
            res = (res * temp) % mod;
        }
    }
    return memo[now][prevCol] = res;
}

int main()
{
#ifdef LOCAL_OUTPUT
    freopen(LOCAL_OUTPUT, "w", stdout);
#endif
#ifdef LOCAL_INPUT
    freopen(LOCAL_INPUT, "r", stdin);
#endif
    cin >> n;
    ms(memo, -1);
    for (int i = 1; i < n; i++)
    {
        cin >> x >> y;
        x--;
        y--;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    cout << (dp(0, -1, 0) + dp(0, -1, 1)) % mod << endl;
}


Measured memory_bytes: 22096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cmath>
using namespace std;

int main() {
	int N, M, C;
	cin >> N >> M >> C;
	vector <int>B(M);
	vector <vector<int>> A(M , vector<int>(N));

	for (int i = 0; i < M; i++) {
		cin >> B.at(i);
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			cin >> A.at(j).at(i);
		}
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		int sum = 0;
		for (int j = 0; j < M; j++) {
			sum += A.at(j).at(i) * B.at(j);
		}
		sum += C;
		if (sum > 0) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;
 
namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var ab = ReadStringArray();
            var a = ab[0];
            var b = ab[1];
            var ans = a == b ? "H" : "D";
            Console.WriteLine($"{ans}");
        }
    }
 
    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int h, w;
  while (cin >> h >> w) {
    if (!h && !w)
      break;
    rep(i, 0, h) {
      rep(j, 0, w) {
        if (i > 0 && i < h - 1 && j > 0 && j < w - 1)
          cout << ".";
        else
          cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
}



Measured memory_bytes: 3176
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<map>
#include<queue>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};



//#define int ll
signed main(){
    int h,w,D;
    cin>>h>>w>>D;
    int x[100010],y[100010];
    rep(i,0,h)rep(j,0,w){
        int a;cin>>a;
        x[a]=i,y[a]=j;
    }
    
    int q;cin>>q;
    int l,r;
    int d[100010];
    for(int i=D+1;i<=h*w;i++){
        d[i]=d[i-D]+abs(x[i]-x[i-D])+abs(y[i]-y[i-D]);
    }
    while(q--){
        cin>>l>>r;
        cout<<d[r]-d[l]<<endl;
    }
    return 0;
}

Measured memory_bytes: 2176
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        cij: [[i64; 3]; 3],
    }
    // a1 + b1 = cij[0][0] => a1 = cij[0][0] - b1
    // a1 + b2 = cij[0][1] => a1 = cij[0][1] - b2
    // a1 + b3 = cij[0][2] => a1 = cij[0][2] - b3

    // a2 + b1 = cij[1][0] => a2 = cij[1][0] - b1
    // a2 + b2 = cij[1][1] => a2 = cij[1][1] - b2
    // a2 + b3 = cij[1][2] => a2 = cij[1][2] - b3

    // a3 + b1 = cij[2][0] => a3 = cij[2][0] - b1
    // a3 + b2 = cij[2][1] => a3 = cij[2][1] - b2
    // a3 + b3 = cij[2][2] => a3 = cij[2][2] - b3

    for a1 in -1000..1001 {
        for b1 in -1000..1001 {
            let a2 = cij[1][0] - b1;
            let a3 = cij[2][0] - b1;
            let b2 = cij[0][1] - a1;
            let b3 = cij[0][2] - a1;
            if a2 == cij[1][1] - b2
                && a2 == cij[1][2] - b3
                && a3 == cij[2][1] - b2
                && a3 == cij[2][2] - b3
            {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}


Measured memory_bytes: 4352
N, M = map(int, input().split())
adj_matrix = [[0]* N for _ in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    adj_matrix[a-1][b-1] = 1
    adj_matrix[b-1][a-1] = 1

def dfs(v, used):
    if not False in used:
        return 1
    
    ans = 0
    for i in range(N):
        if not adj_matrix[v][i]:
            continue
        if used[i]:
            continue
        
        used[i] = True
        ans += dfs(i, used)
        used[i] = False
    
    return ans

used = [False] * N
used[0] = True

print(dfs(0, used))

Measured memory_bytes: 3064
#include <stdio.h>
 
int main(){
  int h, w, i, j;
  while(scanf("%d%d", &h, &w) && h && w){
    for(i = 0;i < h;i++){
      for(j = 0;j < w;j++){
        if(!i || !j || i == h - 1 || j == w - 1) putchar('#');
        else putchar('.');
      }
      puts("");
    }
    puts("");
  }
  return 0;
}


Measured memory_bytes: 2080
#include<iostream>
#include<vector>
using namespace std;
int main(void){
    long long int L , R ;
    cin >>L >>R;
    long long int a=2019;
 if (L / 2019 != R / 2019) {
    a = 0;
  }else{
    
          for(long long j=L+1; j<=R; j++){
            for(long long i=L; i<j; i++){
                if(i*j%2019 < a){
                   a = i*j%2019;
                }
            }
        }
  }    
        cout << a << endl;
    



    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;
const int N = 3;
int G[N][N];

bool check(int G[][3])
{
    for(int i=0; i<2; i++)
    {
        for(int j=0; j<2; j++)
        {
            if(G[i+1][j]-G[i][j] != G[i+1][j+1]-G[i][j+1])
                return 0;
        }
    }

    for(int j=0; j<2; j++)
    {
        for(int i=0; i<2; i++)
        {
            if(G[i][j+1]-G[i][j] != G[i+1][j+1]-G[i+1][j])
                return 0;
        }
    }
    return 1;
}

int main()
{
    for(int i=0; i<3; i++)
    {
        for(int j=0; j<3; j++)
        {
            scanf("%d",&G[i][j]);
        }
    }
    if(check(G))
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
minimum = min(a)+min(b)
for _ in range(M):
    x, y, c = map(int, input().split())
    minimum = min(a[x-1]+b[y-1]-c, minimum)
print(minimum)

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

int main() {
  ll n, m, s;
  cin >> n >> m >> s;
  vector<vector<tuple<int, ll, ll>>> g(n);
  for (int i = 0; i < m; i++) {
    ll u, v, a, b;
    cin >> u >> v >> a >> b;
    g[u - 1].push_back({v - 1, a, b});
    g[v - 1].push_back({u - 1, a, b});
  }
  vector<ll> c(n), d(n);
  for (int i = 0; i < n; i++) cin >> c[i] >> d[i];

  ll s_max = 50 * n;
  s = min(s_max, s);

  vector<vector<ll>> r(n, vector<ll>(s_max + 1, 1e18));
  r[0][s] = 0;

  queue<tuple<ll, ll, ll>> q;
  for (int i = 0;; i++) {
    q.push({0, min(s_max, s + i * c[0]), i * d[0]});
    if (s + i * c[i] >= s_max) break;
  }

  while (!q.empty()) {
    auto [i, s1, t1] = q.front();
    q.pop();
    // cerr << i << ' ' << s1 << ' ' << t1 << endl;
    for (auto [j, a, b] : g[i]) {
      // cerr << "  " << j << ' ' << a << ' ' << b << endl;
      for (int k = 0;; k++) {
        ll s2 = min(s_max, s1 + k * c[i] - a);
        ll t2 = t1 + k * d[i] + b;
        if (s2 >= 0 && t2 < r[j][s2]) {
          // cerr << "    " << j << ' ' << s2 << ' ' << t2 << endl;
          r[j][s2] = t2;
          q.push({j, s2, t2});
        }
        if (s2 >= s_max) break;
      }
    }
  }

  for (int i = 1; i < n; i++) cout << *min_element(r[i].begin(), r[i].end()) << endl;
}


Measured memory_bytes: 41036