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

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
#define DRT() int t; si(t); while(t--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//# define M_PI           3.14159265358979323846264338327950288
// DSU
void IO(){
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
}

int main(){
	IO();
	LL n,d;
	cin>>n>>d;
	LL x,y;
	LL ans =0;
	rep(i,0,n){
		cin>>x>>y;
		LL sum = x*x + y*y;
		if(sum <= d*d)
			ans++;
	}	
	dout(ans);
	return 0;
}

Measured memory_bytes: 3648
########関数部分##############
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
############################

def scorecalc(a,target):
    if len(a) == 0:
        ans = 10**9
    else:
        ans = 10*(len(a)-1)
        ans += abs(sum(a)-target)
    return ans

n,a,b,c = map(int,input().split())
l = []
for i in range(n):
    temp = int(input())
    l.append(temp)

mnm = 10**9

for i in range(1,4**n+1):
    test = Base_10_to_n(i,4)
    test = list(test)
    for k in range(n-len(test)):
        test.insert(0,"0")
    fora = []
    forb = []
    forc = []
    for k in range(n):
        if test[k] == "0":
            fora.append(l[k])
        elif test[k] == "1":
            forb.append(l[k])
        elif test[k] == "2":
            forc.append(l[k])
    temp = scorecalc(fora,a) + scorecalc(forb,b) + scorecalc(forc,c)
    if temp < mnm:
        mnm = temp
    
print(mnm)

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

int main() {
    int a[3];
    int i;
    for(i=0; i<3; ++i) {
        cin >> a[i];
    }
    sort(a, a+3);
    printf("%d %d %d\n", a[0], a[1], a[2]);
    return 0;    
}


Measured memory_bytes: 3248
x,t,a,b,c=map(int,input().split())
P=sorted(list(map(int,input().split())))
Q=sorted(list(map(int,input().split())))
R=sorted(list(map(int,input().split())))[::-1]+[-1]

A=[]
A +=P[a-x:a]
A +=Q[b-t:b]
A=sorted(A)
add,cnt=0,0
for apple in A:
    if apple<R[add]:
        cnt +=R[add]
        add +=1
    else:
        cnt +=apple
print(cnt)

Measured memory_bytes: 23200
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
# mod = 998244353
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"
INF = 1<<32-1
# INF = 10**18

def main():
    n = int(ipt())
    base = n+1
    a = [int(i) for i in ipt().split()]
    b = [int(i) for i in ipt().split()]
    na = [0]*(n+1)
    nb = [0]*(n+1)
    bl = b[-1]

    for i in range(n):
        na[a[i]] += 1
        nb[b[i]] += 1

    bs = []

    for i in range(1,n+1):
        nai = na[i]
        nbi = nb[i]
        if nai+nbi > n:
            print("No")
            exit()
        elif nai+nbi != 0:
            if bl != i:
                hpq.heappush(bs,(n-nai-nbi)*base+i)

    print("Yes")
    ans = []
    q = []
    for i,ai in enumerate(a):
        na[ai] -= 1
        while True:
            hi = hpq.heappop(bs)
            hiv = hi%base
            while True:
                hi = hpq.heappushpop(bs,(n-na[hiv]-nb[hiv])*base+hiv)
                if hiv == hi%base:
                    break
                else:
                    hiv = hi%base
            if na[hiv]+nb[hiv] < n-i and nb[bl] != 0:
                ans.append(bl)
                nb[bl] -= 1
                q.append((n-na[hiv]-nb[hiv])*base+hiv)
                break
            elif hiv == ai:
                if nb[hiv] != 0:
                    q.append((n-na[ai]-nb[ai])*base+hiv)
            elif nb[hiv] != 0:
                ans.append(hiv)
                nb[hiv] -= 1
                q.append((n-na[hiv]-nb[hiv])*base+hiv)
                break
        while q:
            hpq.heappush(bs,q.pop())

    print(" ".join(map(str,ans)))

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 140520
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int n;
int odd;

int main(){
	cin>>n;
	odd=(n&1?n/2+1:n/2);
	printf("%.10lf",odd*1.0/n);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (1000000007)

int main(){
    int N;
    int64_t K;
    // int res;
    vector<int> vA(2020);
    vector<vector<int>> mX(2020);
    vector<int> sX(2020, 0);
    int maxA = -1;

    cin >> N >> K;
    for (int i=0; i<N; i++){
        cin >> vA.at(i);
        mX[vA[i]].push_back(i);  // indice map
        sX[vA[i]]++;             // size
        maxA = max(maxA, vA[i]);
    }

    int64_t res = 0ll;

    // K=1
    int64_t kC1 = K;
    int64_t count = 0ll;
    // for (int x=1; x<maxA+1; x++){   // larger x
    //     for (int i: mX.at(x)){      // x's indice
    //         for (int y=1; y<x; y++){     // smaller y
    //             count += sX.at(y) - *lower_bound(mX.at(y).begin(), mX.at(y).end(), i);
    //         }
    //     }
    // }
    for (int i=0; i<N-1; i++){
        for (int j=i+1; j<N; j++){
            if (vA.at(i) > vA.at(j)) count++;
        }
    }

    (res += (count * kC1)) %= MOD;

    // K>=2
    if (K >= 2){

    vector<int> csX(2020, 0);  // cumsum
    for (int x=1; x<maxA+1; x++){
        csX.at(x) = csX.at(x-1) + sX.at(x);
    }
    
    int64_t kC2 = 1ll;
    int64_t count = 0ll;
    kC2 = K * (K-1) / 2 % MOD;  // overflow?
    for (int x=1; x<maxA+1; x++){
        (count += csX.at(x-1) * sX.at(x)) %= MOD;
    }

    (res += (count * kC2)) %= MOD;
    }
    cout << res <<endl;
    return 0;
}


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

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<long long> a, std::vector<long long> b){
  ll aa = 0;
  ll bb = 0;
  for(ll i=0; i<N; i++) {
    if(a[i]>b[i]) {
      aa+=a[i]-b[i];
    } else if(b[i]>a[i]) {
      bb+=(b[i]-a[i])/2;
    }
  }
  if(bb >= aa) {
    std::cout << YES << std::endl;
  } else {
    std::cout << NO << std::endl;
  }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    std::vector<long long> b(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&b[i]);
    }
    solve(N, std::move(a), std::move(b));
    return 0;
}


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

int main() {
    int a, b, c, ans;
    cin >> a >> b >> c;
    ans = 9 * max(a, max(b, c)) + a + b + c;
    cout << ans << endl;
}

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

template <class T>
T abs(T a) { return (a > 0 ? a : -a); }

int main() {
    long long n, x, y;
    std::cin >> n >> x >> y;
    std::vector<long long> a(n);
    for (auto i = 0ll; i < n; i++) std::cin >> a[i];

    if (n == 1) {
        std::cout << abs(a[0] - y) << std::endl;
        return 0;
    }

    std::cout << std::max({ abs(a[n - 1] - a[n - 2]), abs(a[n - 1] - y) }) << std::endl;

    return 0;
}

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

// VI tsort(VVI g) {
//   int n = g.size();
//   vector<bool> used(n, false);
//   vector<int> ans;
//
//   function<void(int)> dfs = [&](int u) {
//     if(used[u]) return;
//     used[u] = true;
//     for(auto& i: g[u]) dfs(i);
//     ans.push_back(u);
//   };
//
//   for(int i=0; i<n; ++i) dfs(i);
//   reverse(ans.begin(), ans.end());
//   return ans;
// }

VI tsort(VVI g) {
  const int n = g.size();
  VI h(n, 0);
  REP(i, n) for(int j: g[i]) h[j]++;

  stack<int> st;
  REP(i, n) if(h[i] == 0) st.push(i);

  VI ans;
  while(st.size()) {
    int i = st.top(); st.pop();
    ans.push_back(i);
    for(auto& j: g[i]) {
      h[j]--;
      if(h[j] == 0) st.push(j);
    }
  }

  return ans;
}

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

  int n, m;
  cin >> n >> m;
  VVI g(n, VI(0));
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    g[a].PB(b);
  }

  VI ans = tsort(g);
  for(int i: ans) cout << i << endl;

  return 0;
}



Measured memory_bytes: 4756
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k, n;
    cin >> k >> n;
    vector<ll> a(n);
    for(ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll ans = LLINF;
    for(ll i = 0; i < n - 1; i++) {
        chmin(ans, k - llabs(a[i + 1] - a[i]));
    }
    chmin(ans, k - (k - a[n - 1] + a[0]));
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<list>

typedef long long ll;

using namespace std;

int a[100010] , n;

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

int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i = 0 ; i<n ; i++){
		cin>>a[i];
	}
	
	int q = partition(0,n-1);
	
	for(int i = 0 ; i<n ; i++){
		if(i)
			printf(" ");
		if(i==q){
			printf("[%d]",a[i]);
		}
		else
			printf("%d",a[i]);
	}
	printf("\n");
	
		
	return 0;
}

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

using namespace std;

using ll = long long;

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

    int a, b, c;
    cin >> a >> b >> c;
    if (a + b > c && b + c > a && c + a > b && a == b && b == c)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<tuple>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;

#define INF ((int)(1e9))
#define MAX 11

int n, p[MAX],t[MAX];
bool next_parmutation(int a[], int b[]){
	priority_queue<int, vector<int>, greater<int>> Q;
	int num = -1, next = INF;
	for(int i = n-2; i >= 0; i--){
		if(a[i] < a[i+1]){
			num = i;
			break;
		}
	}
	if(num == -1) return false;
	
	for(int i = n-1; i > num; i--){
		if(a[num] < a[i])next = min(a[i],next);
	}
	for(int i = n-1; i >= num; i--){
		if(a[i] != next) Q.push(a[i]);
	}
	
	for(int i = 0; i < num; i++){
		b[i] = a[i];
	}
	
	b[num] = next;
	
	for(int i = num+1; i < n; i++){
		b[i] = Q.top(); Q.pop();
	}
	return true;
}

void p_array(int a[]){
	for(int i = 0; i < n; i++){
		cout<<(i?" ":"")<<a[i];
	}
	cout<<endl;
}

int main(){
	cin>>n;
	
	for(int i = 0; i < n; i++){
		p[i] = i+1;
	}
	
	do{ p_array(p);
	} while(next_parmutation(p,p));
	
	return 0;
}


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

int main(){
  vector<int> con(5);
  int i,j;
  for(i=0; i<con.size(); i++){
    cin >> con[i];
  }
  int k;
  cin >> k;
  int cantComm = 0;
  for(i=0; i<con.size(); i++){
    for(j=i+1; j<con.size(); j++){
      if(con[j]-con[i] > k){
        cantComm++;
      }
    }
  }
  if(cantComm == 0){
    cout << "Yay!" << endl;
  }else{
    cout << ":(" << endl;
  }
  return 0;
  
}

Measured memory_bytes: 384
#include<stdio.h>

int main()
{
  int i, j, N, M, A[1000], B[1000], score[1000], max;
  scanf("%d %d", &N, &M);
  for(i = 0; i < N; i++)
  {
    scanf("%d", &A[i]);
    score[i] = 0;
  }
  for(j = 0; j < M; j++)
  {
    scanf("%d", &B[j]);
    i = 0;
    while(A[i] > B[j]) {
       i++;
    }
    score[i]++;
  }
  max = 0;
  for(i = 0; i < N; i++)
  {
    if(score[max] < score[i])
      max = i;
  }
  printf("%d\n", max + 1);
  return 0;
}

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

int main(){

  int N, n;
  bool flg = false;
  
  cin >> N;
  cout << N << ":";

  n = N;
  while(n != 1){

    flg = false;
    for(int i=2;i*i<=N;i++){
      if(n%i == 0){
	n /= i;
	cout << " " << i;
	flg = true;
	break;
      }
    }

    if(!flg){ cout << " " << n; n /= n; }
  }
  cout << endl;

}

Measured memory_bytes: 1164
#include <cstdio>
#include <complex>
#include <cmath>
#include <vector>
using namespace std;

typedef complex<double> P;

double cross(P a, P b){
	return real(a) * imag(b) - imag(a) * real(b);
}

int main(){
	double x, y;
	vector<P> v;
	while(scanf("%lf,%lf", &x, &y) != EOF){
		v.push_back(P(x, y));
	}
	double s = 0.0;
	for(int i = 0; i < v.size(); ++i){
		s += cross(v[i], v[(i + 1) % v.size()]);
	}
	printf("%.10f\n", 0.5 * abs(s));
}

Measured memory_bytes: 1084
import fractions


N = int(input())
if N == 0:
  print(0)
elif N % 2 == 1:
  print(0)
else:
  ans = 0
  log = int(fractions.math.log(N//2,5))
  for l in range(1,log+1):
    power = 5**l
    ans += (N//2) // power
  print(ans)

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

using ll = long long;
#define For(i, a, b)	for(int i = (a); i < (b); ++i)
#define rep(i, n)		For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;

long long rec(int n, long long x) {
	// n-1 次元バーガーのサイズとそこに含まれるパティの数を知る
	if(n == 0) return 1;
	long long len = (1LL << (n+1)) - 3;
	long long num = (1LL << n) - 1;
	if(x == 1) return 0;
	else if(x <= len + 1) return rec(n-1, x-1);
	else if(x == len + 2) return num + 1;
	else if(x <= (len + 1) * 2 + 1) return num + 1 + rec(n-1,x-len-2);
	else return num * 2 + 1; //は？
}
int main(){
	int n;
	cin >> n;
	ll x;
	cin >> x;
	cout << rec(n, x) << endl;
}


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

int main(){
    int n;
    int x;
    vector<int> l;
    int tmp;
    int ans = 1;
    int d = 0;
    cin >> n >> x;
    for(int i=0; i<n; i++){
        cin >> tmp;
        l.push_back(tmp);
    }
    for(int i=0; i<n; i++){
        d += l[i];
        if(d>x){
            break;
        }
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
//#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

signed main(){
  int a[3][3];
  r(i,3)r(j,3)cin>>a[i][j];
  r(i,101){
    r(j,101){
      r(k,101){
        int b[3],f=0;
        r(a1,3){
          r(a2,3){
            if(!a1){
              if(a2==0)b[a2]=a[a1][a2]-i;
              if(a2==1)b[a2]=a[a1][a2]-i;
              if(a2==2)b[a2]=a[a1][a2]-i;
            }
            else if(a1==1){
              if(a2==0&&a[a1][a2]!=j+b[a2])f++;
              if(a2==1&&a[a1][a2]!=j+b[a2])f++;
              if(a2==2&&a[a1][a2]!=j+b[a2])f++;
              //if(a2==1)b[a2]=a[a1][a2]-j;
              //if(a2==2)b[a2]=a[a1][a2]-k;
            }
            else {
              if(a2==0&&a[a1][a2]!=k+b[a2])f++;
              if(a2==1&&a[a1][a2]!=k+b[a2])f++;
              if(a2==2&&a[a1][a2]!=k+b[a2])f++;
            }
          }
        }
        if(!f){
          cout<<"Yes"<<endl;
          return 0;
        }
      }
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    AB=[]
    for i in range(n):
        a,b=map(int,input().split())
        AB.append((a+b,a,b))    
    AB.sort(reverse=True)
    x=sum([-b[2] for b in AB])
    sum_ab=sum([ab[0] for ab in AB[::2]])
    print(x+sum_ab)


if __name__=='__main__':
    main()

Measured memory_bytes: 92764
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
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;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
//////////////////////////

int main(){fastio
    ll n,m;cin>>n>>m;
    ll dp[2][n+1][n+1];
    memset(dp,0,sizeof(dp));
    dp[0][1][1]=1;
    rep(i,0,m-1){
        rep(j,0,n)rep(k,0,n)dp[(i+1)&1][j][k]=0;
        rep(j,0,n){
            rep(k,0,n){
                if(k+1<=n)Add(dp[(i+1)&1][j][k+1],dp[i&1][j][k]*(n-k));
                Add(dp[(i+1)&1][j][k],dp[i&1][j][k]*(k-j));
                Add(dp[(i+1)&1][k][k],dp[i&1][j][k]*j);
            }
        }
        /*
        rep(j,0,n){
            rep(k,0,n){
                cout<<dp[(i+1)&1][j][k]<<" ";
            }cout<<endl;
        }cout<<endl;*/
    }
    
    cout<<mod(dp[m&1][n][n])<<endl;
    
    return 0;
}


Measured memory_bytes: 1664
gets
a = gets.strip.split(" ").map(&:to_i).sort
a_dic = {}
a.each do |i|
  a_dic[i] = a_dic[i].nil? ? 1 : a_dic[i]+1
end
q = gets.strip.to_i
ans = []

sum = a_dic.map {|key, val| key * val }.sum
q.times do |i|
  b,c = gets.strip.split(" ").map(&:to_i)
  unless a_dic[b].nil?
    a_dic[c] =  a_dic[c].nil? ? a_dic[b] : a_dic[b]+a_dic[c]
    ans[i]= i==0 ? sum+ (c-b)*a_dic[b] : ans[i-1] + (c-b)*a_dic[b]
    a_dic.delete(b)
  else
    ans[i] = i ==0 ? sum : ans[i-1]
  end
end
ans.each do |s|
  puts s
end

Measured memory_bytes: 26992
import java.util.*;


class Main {
  public static void main(String[] args) {
    int n, k;
    Scanner sc = new Scanner(System.in);
    n = sc.nextInt();
    k = sc.nextInt();
    
    int[] h = new int[n];
    for(int i = 0; i < n; i++) {
      h[i] = sc.nextInt();
    }
    int[] dp = new int[n];
    Arrays.fill(dp, Integer.MAX_VALUE);
    dp[0] = 0;
    dp[1] = Math.abs(h[0] - h[1]);
    for(int i = 2; i < n; i++) {
      for(int j = 1; j <= k && i-j >= 0; j++) {
          dp[i] = Math.min(dp[i], dp[i-j] + Math.abs(h[i] - h[i-j]));
      }
    }
   System.out.println(dp[n-1]);
  }
}


Measured memory_bytes: 50840
// Problem : C - Rectangle Cutting
// Contest : AtCoder - AtCoder Beginner Contest 130
// URL : https://atcoder.jp/contests/abc130/tasks/abc130_c?lang=en
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")  // disable
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define lll __int128
#define lp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define vec(v, type, sz) vector<type> v(sz)
#define in(v) \
    for (auto &i : v) cin >> i
#define all(v) v.begin(), v.end()
#define prv(v)                         \
    for (auto i : v) cout << i << " "; \
    cout << "\n"
#define MOD 1000000007
#define INF 1000000000
#define INFL 1000000000000000000ll
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vl vector<ll>
#define vii(v, n, m, val) vector<vector<int>> v(n, vector<int>(m, val))
#define viii(v, i, j, k, val)        \
    vector<vector<vector<int>>> v(i, \
                                  vector<vector<int>>(j, vector<int>(k, val)))
#define pii pair<int, int>
#define pb push_back
#define file_io                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define testc   \
    int tcc;    \
    cin >> tcc; \
    for (int tc = 1; tc <= tcc; tc++)
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while (!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) int idx,
               __attribute__((unused)) int LINE_NUM) {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if (idx > 0)
        cerr << ", ";
    else
        cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss;
    ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef DB
#define debug(...) \
    debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//#define int ll

signed main() {
	fast_io;
	ll w,h,x,y; cin>>w>>h>>x>>y;
	cout<<fixed<<((ld)w*h/2.0l)<<" "<<(2*x==w && 2*y==h);
}
// code!=think
// least efficient code to get ac


Measured memory_bytes: 3776
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, os, pdb
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)
def perr(s): return print(s, file=sys.stderr)

ans = []
lines_dict =None
d=None
def main():
    global AB, PX, T
    if 'LOCAL' in os.environ:
        N = 2* 10** 5
        Q = 2 * 10 ** 5
        AB = [[i, i + 1] for i in range(1, N)]
        PX = [[i, 10] for i in range(Q)]
    else:
        N, Q = LI()
        #  AB = []
        T = [[] for _ in range(N+1)]
        PX = [0] * (N+1)
        for i in range(N-1):
            a, b = LI()
            #  AB += (a, b)
            T[a] += [b]
            T[b] += [a]

        for i in range(Q):
            p, x = LI()
            PX[p] += x
        #  perr(AB)
        perr(PX)
        dfs(1, -1)
        for i in PX[1:]:
            print(i, end=' ')
        #  ans = [0 for _ in range(N)]

def dfs(parent: int, parent_parent: int) -> None:
    for node in T[parent]:
        if node != parent_parent:
            PX[node] += PX[parent]
            dfs(node, parent)

if __name__ == '__main__':
    main()


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



/*int main(){
	priority_queue<pair<int,int>> pq;
	int n, k;
	cin>>n>>k;
	vector<int> cc(n),df(n);
	for(int i = 0; i < n; i++) cin>>cc[i];
	for(int i = 0; i < n; i++) cin>>df[i];
	sort(cc.begin(), cc.end());
	sort(df.begin(), df.end(), greater<int>());
	for(int i = 0; i < n; i++){
		pair<int,int> t = {cc[i]*df[i],i};
		pq.push(t);
	}
	
	for(int i = 0; i < k; i++){
		auto t = pq.top(); pq.pop();
		int j = t.second;
		if(cc[j]){
			cc[j]--;
			t.first = cc[j]*df[j];
		}
		pq.push(t);
	}
	
	cout<<pq.top().first<<endl;
	
	
	return 0;
} */

vector<int> cc,df;
int n; 
long long k;

int check(long long val){
	long long c = k;
	for(int i =0; i < n; i++){
		int t = min<int long long>(cc[i], val/df[i]);
		c -= cc[i] - t;
		if(c < 0) return 0;
	}
	
	return 1;
}

int main(){
	cin>>n>>k;
	int t;
	for(int i = 0; i < n; i++){
		cin>>t;
		cc.push_back(t);
	}
	
	for(int i = 0; i < n; i++){
		cin>>t;
		df.push_back(t);
	}
	
	sort(cc.begin(),cc.end());
	sort(df.begin(), df.end(), greater<int>());
	
	
	long long l = 0, r = 1e12;
	while(l <= r){
		long long m = l + (r-l)/2;
		if(check(m)) r = m-1;
		else l = m+1;
	}
	
	cout<<l<<endl;
	return 0;
}
























Measured memory_bytes: 5500
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
map<int, int> factor(int m) {
	map<int, int>res;
	for (int i = 2; i*i <= m; i++) {
		while (m%i == 0) {
			res[i]++;
			m /= i;
		}
	}
	if (m != 1)res[m]++;
	return res;
}

/*--------Library Zone!--------*/


signed main() {
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	rep(i, n) {
		//cout << a + d * i - (n - i - 1)*c << " " << a + c * i - (n - i - 1)*d << endl;
		if (a + d * i - (n - i - 1)*c >= b && a + c * i - (n - i - 1)*d <= b) {
			puts("YES");
			endre;
		}
	}
	puts("NO");
	endre;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
using namespace std;

int main()
{
    int a, b, h;
    scanf("%d %d %d", &a, &b, &h);
    long long ans = (a + b) * h / 2;
    printf("%lld\n", ans);
}

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

using namespace std;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    ++ans;
    if (x >= a && x < b) --ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
n=int(input())
s=input()

ans = 0

for i in range(10):
    first = s.find(str(i))
    if first!=-1 and first!=n-1:
        for g in range(10):
            second = s[first+1:].find(str(g))+first+1
            if second!=first and second!=n-1:
                for l in range(10):
                    third = s[second+1:].find(str(l))+second+1
                    if third!=second:
                        ans+=1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <string>
#include <iomanip>
#include <map>
using namespace std;


int main() {
	int n;
	cin >> n;
	int count = 0;
	string s;
	int element;
	map<string, int>test2;
	while (count < n) {
		cin >> s;
		test2[s]++;
		count++;
	}
	cout << endl;
	//int big = test2[0];
	int big = 0;
	map<string, int>::iterator it = test2.begin();
	for (it; it != test2.end(); it++) {
		//cout << it->first << " " << it->second << endl;
		big = max(it->second, big);
	}
	vector<string>pop;
	it = test2.begin();
	for (it; it != test2.end(); it++) {
		if (it->second == big) {
			pop.push_back(it->first);
		}
	}
	sort(pop.begin(), pop.end());
	for (string s : pop) {
		cout << s << endl;
	}

	
}





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

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; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<pint>>;

int N,M,R;
vector<int> r;

int main(){
    cin>>N>>M>>R;
    r.resize(R);
    rep(i,R)cin>>r[i];
    rep(i,R)r[i]--;
    ll dp[210][210];
    rep(i,210)rep(j,210)dp[i][j] = INF;
    rep(i,M){
        int a,b,c; cin>>a>>b>>c;
        a--; b--;
        dp[a][b] = c;
        dp[b][a] = c;
    }
    rep(k,N){
        rep(i,N){
            rep(j,N){
                dp[i][j] = min(dp[i][j],dp[i][k]+dp[k][j]);
            }
        }
    }
    sort(r.begin(),r.end());
    ll res = INF;
    do{
        ll time = 0;
        rep(i,R-1){
            time += dp[r[i]][r[i+1]];
        }
        res = min(res,time);
    }while(next_permutation(r.begin(),r.end()));
    cout<<res<<endl;
}


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

#define REP(i,n) for(long long i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(long long i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int dp[3][100002];

int main(){
  int N;
  cin >> N;
  vector<vector<int>> cost(3, vector<int>(N));

  REP(i, N){
    REP(j, 3){
      cin >> cost[j][i];
    }
  }
  REP(i, N){
    REP(j, 3){
      REP(h, 3){
        if(j == h) continue;
        dp[j][i+1] = max(dp[j][i+1], dp[h][i] + cost[j][i]);
      }
    }
  }
  cout << max(dp[0][N], max(dp[1][N], dp[2][N])) << endl;
  return 0;
}


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

using namespace std;
using ll =long long;
using db = double;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;

//ここから書き始める

int main()
{
	cout << setprecision(10);
	string s;
	cin >> s;
	int n = s.size();
	int cku=0, crev= 0;
	ll ans = 0;
	ll M , m;
	rep(i,n){
		if(s[i] =='<') cku ++;
		else crev ++;
		//
		if(s[i]=='>'&&s[i+1]=='<'){
			M = max(cku,crev);
			m = min(cku,crev);
			ans += (M+1)*(M)/2;
			ans += (m-1)*(m)/2;
			cku = 0;
			crev = 0;
		}
	}
	M = max(cku,crev);
	m = min(cku,crev);
	ans += (M+1)*(M)/2;
	ans += (m-1)*(m)/2;
	cout << ans << endl;
}


Measured memory_bytes: 900
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int
vi ob[(int)3e5];
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    int h, w, n;
    cin >> h >> w >> n;
    FOR(i, n){
        int x, y;cin >> x>> y;
        ob[x].pb(y);
    }
    int moves = 1;
    int end = 1;
    FOR1(m, h -1 ){
        //check if end
        bool done = false;
        for(int yy: ob[m+1]){
            if(yy <= end){
                done = true;
                break;
            }
        }
        if(done)break;
        //check if blocked range
        moves++;
        bool no = true;
        for(int yy: ob[m+1]){
            if(yy == end + 1)no = false;
        }
        end += no;
    }
    cout << moves;

}




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

using namespace std ;

int main ()
{
    int a , cnt = 0 ;
    cin >> a ;
    for ( int i = 2 ; i <= a ; i += 2 ){
        for ( int j = 1 ; j <= a ; j += 2 ){
            cnt ++ ;
        }
    }
    cout << cnt ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}
//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

int strsum(const int n){
    string s = to_string(n);
    int b(0);
    rep(i,s.size()){
        b += s[i]-'0';
    }
    return b;
}

int main(){
    string s;
    cin >> s;

    rep(i,s.size()){
        char c = s[0];
        if(c!=s[i]){
            int x = atoi(s.c_str());
            rep(j,1000){
                x++;
                string ans = to_string(x);
                bool y(true);
                rep(k,ans.size()){
                    char b = ans[0];
                    if(ans[k]!=b){
                        y = false;
                        break;
                    }
                }
                if(y){
                    put(x);
                    return 0;
                }
                
            }
        }
    }
    put(s);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  bool ok=false;
  if(s.at(0)=='a'){
    if(s.at(1)=='b'){
      if(s.at(2)=='c'){
        ok=true;
      }
    }
  }
  if(s.at(0)=='a'){
    if(s.at(1)=='c'){
      if(s.at(2)=='b'){
        ok=true;
      }
    }
  }
  if(s.at(0)=='b'){
    if(s.at(1)=='a'){
      if(s.at(2)=='c'){
        ok=true;
      }
    }
  }
  if(s.at(0)=='b'){
    if(s.at(1)=='c'){
      if(s.at(2)=='a'){
        ok=true;
      }
    }
  }
  if(s.at(0)=='c'){
    if(s.at(1)=='a'){
      if(s.at(2)=='b'){
        ok=true;
      }
    }
  }
  if(s.at(0)=='c'){
    if(s.at(1)=='b'){
      if(s.at(2)=='a'){
        ok=true;
      }
    }
  }
  if(ok){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

int dp[20202];
constexpr int inf = 1e18;

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

    for (int i = 0; i < 20202; i++) dp[i] = inf;

    dp[0] = 0;

    int h, n;
    cin >> h >> n;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        for (int j = 0; j < 20202; j++) {
            if (j + a < 20202) dp[j + a] = min(dp[j + a], dp[j] + b);
        }
    }

    int ans = inf;
    for (int i = h; i < 20202; i++) ans = min(ans, dp[i]);
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
int c[500100];
const int K=sqrt(500100)+1;
struct Q{
	int l;
	int r;
	int num;
	Q(int l, int r, int num):l(l),r(r),num(num){}
};
vector<Q> buckets[K];
int cnt[500100];
int ans[500100];
 
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n, q;
	cin>>n>>q;
	rep(i,n)cin>>c[i];
	rep(i,q){
		int l,r;
		cin>>l>>r;
		l--;
		r--;
		buckets[l/K].eb(l,r,i);
	}
	for(int i=0;i<K;i++){
		sort(buckets[i].begin(),buckets[i].end(),[&](Q a, Q b){return a.r<b.r;});
		if(buckets[i].empty())continue;
		memset(cnt,0,sizeof(cnt));
		int cur=0;
		for(int j=buckets[i][0].l;j<=buckets[i][0].r;j++){
			cnt[c[j]]++;
			if(cnt[c[j]]==1)cur++;
		}
		ans[buckets[i][0].num]=cur;
		int pl=buckets[i][0].l;
		int pr=buckets[i][0].r;
		for(auto qr:buckets[i]){
			for(int j=pr+1;j<=qr.r;j++){
				cnt[c[j]]++;
				if(cnt[c[j]]==1)cur++;
			}
			pr=qr.r;
			for(int j=pl;j<qr.l;j++){
				cnt[c[j]]--;
				if(cnt[c[j]]==0)cur--;
			}
			for(int j=qr.l;j<pl;j++){
				cnt[c[j]]++;
				if(cnt[c[j]]==1)cur++;
			}
			pl=qr.l;	
			ans[qr.num]=cur;
		}
	}
	for(int i=0;i<q;i++){
		cout<<ans[i]<<'\n';
	}
}

Measured memory_bytes: 18680
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<string> >data(h, vector<string>(w));
    for(int i = 0; i < h; i++){
        string s;
        cin >> s;
        for(int j = 0; j < w; j++){
            data.at(i).at(j) = s.at(j);
        }
    }
    solve();
    vector<bool>hn(h);
    vector<bool>wn(w);
    for (int i = 0; i < h; i++){
        bool ck = true;
        for(int j = 0; j < w; j++){
            if(data.at(i).at(j) == "#"){
                ck = false;
            }
        }
        if(ck)
        hn.at(i) = true;
    }
    for(int i = 0; i < w; i++){
        bool ck = true;
        for(int j = 0; j < h; j++){
            if(data.at(j).at(i) == "#"){
                ck = false;
            }
        }
        if(ck){
            wn.at(i) = true;
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(!hn.at(i) && !wn.at(j)){
                cout << data.at(i).at(j);
            }
            if(j == w - 1 && !hn.at(i)){
                cout << endl;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N;
  cin >> N;
  ll ans = 1000 - N % 1000;
  if (N % 1000 == 0) ans = 0;
  ANS;
  return 0;
}

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

int main() {
    int a1, a2, a3, b1, b2, b3;
    vector<vector<int>> data(3, vector<int>(3));
    for(int i=0; i<3; i++) {
        for(int j=0; j<3; j++) {
            cin >> data.at(i).at(j);
        }
    }
    bool flag=false;
    for(int a1=0; a1<=100; a1++) {
        b1=data.at(0).at(0)-a1;
        b2=data.at(0).at(1)-a1;
        b3=data.at(0).at(2)-a1;
        a2=data.at(1).at(0)-b1;
        a3=data.at(2).at(0)-b1;
        if(a2+b2==data.at(1).at(1) && a2+b3==data.at(1).at(2)) {
            if(a3+b2==data.at(2).at(1) && a3+b3==data.at(2).at(2)) {
                flag=true;
                break;
            }
        }
    }
    if(flag) cout << "Yes";
    else cout << "No";
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 A, B, C;
    cin >> A >> B >> C;

    if ((A + B + C) >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<atcoder/all>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; using namespace atcoder;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, D, X[1010][2];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> D;
	rep(i, 0, N) rep(j, 0, 2) cin >> X[i][j];

	two_sat ts(N);
	rep(x1, 0, N) rep(b1, 0, 2) rep(x2, x1 + 1, N) rep(b2, 0, 2) {
		int d = abs(X[x1][b1] - X[x2][b2]);
		if (d < D) ts.add_clause(x1, b1, x2, b2);
	}
	bool ans = ts.satisfiable();

	if (!ans) {
		printf("No\n");
		return;
	}

	auto v = ts.answer();

	printf("Yes\n");
	rep(i, 0, N) printf("%d\n", X[i][1 - v[i]]);
}







Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    char x;
    cin>>x;
    if(x=='a' || x=='e' || x=='i' || x=='o' || x=='u')
        cout<<"vowel"<<endl;
    else
        cout<<"consonant"<<endl;

    return 0;
}


Measured memory_bytes: 3640