akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;

class mint{
    public:
        ll x;
        static unsigned long long mod;
        static unsigned long long mod_plus;
        mint(){x = 0;}
        mint(ll _x) : x((_x < 0 ? ((_x += mod_plus) < 0 ? _x + mod_plus : _x) : _x)%mod){}
        /*mint& operator=(const ll &a){
            x = a;
            return *this;
        }*/

        mint operator-(){
            return x == 0 ? 0 : mod - x;
        }
        mint& operator+=(const mint& a){
            if((x += a.x) >= mod) x -= mod;
            return *this;
        }
        mint operator+(const mint& a) const{
            mint res(*this);
            return res += a;
        }
        mint& operator-=(const mint& a){
            if((x -= a.x) < 0) x += mod;
            return *this;
        }
        mint operator-(const mint& a) const{
            mint res(*this);
            return res -= a;
        }
        mint& operator*=(const mint& a){
            (x *= a.x)%=mod;
            return *this;
        }
        /*mint& operator*=(const ll& a){
            mint temp(a);
            return *this *= temp;
        }*/
        mint operator*(const mint& a) const{
            mint res(*this);
            return res *= a;
        }
        /*mint operator*(const ll& a) const{
            mint res(*this);
            return res *= a;
        }*/
        mint pow(unsigned long long pw) const{
            mint res(1), comp(*this);
            while(pw){
                if(pw&1) res *= comp;
                comp *= comp;
                pw >>= 1;
            }
            return res;
        }
        //以下、modが素数のときのみ
        mint inv() const{
            mint res(*this);
            return res.pow(mod - 2);
        }
        mint& operator/=(const mint &a){
            (x *= a.inv().x)%=mod;
            return *this;
        }
        mint operator/(const mint &a) const{
            mint res(*this);
            return res /= a;
        }
};
ostream& operator<<(ostream& os, const mint& a){
    os << a.x;
    return os;
}
unsigned long long mint::mod = int(1e+9) + 7;
unsigned long long mint::mod_plus = (LLONG_MAX / mint::mod) * mint::mod;
typedef vector<mint> vm;


mint fastpow(mint a, ll pw) {
	mint res = 1;
	while (pw) {
		if (pw & 1) res = res * a;
		a = a * a;
		pw >>= 1;
	}
	return res;
}
int main() {
    cin>>N>>K;
    mint ans = 0;
    vm dp(K+1, 0);
    Rreps(g, K+1, 1){
        dp[g] = fastpow(mint(K / g), N);
        for(int n = g * 2; n <= K; n += g) dp[g] -= dp[n];
        ans += dp[g] * g;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3964
#define N 105
#include <stdio.h>

void showArray(int a[], int n) {
    for (int i = 0; i < n; i++) {
        if (i > 0) {
            printf(" ");
        }
        printf("%d", a[i]);
    }
    printf("\n");
}

int bubbleSort(int a [], int n) {
    int flag = 1;
    int times = 0;
    while (flag) {
        flag = 0;
        for (int i = n - 1; i > 0; i--) {
            if (a[i - 1] > a[i]) {
                int tmp = a[i - 1];
                a[i - 1] = a[i];
                a[i] = tmp;
                times++;
                flag = 1;
            }
        }
    }
    return times;
}

int main() {
    int a[N];
    int n = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    int times = bubbleSort(a, n);
    showArray(a, n);
    printf("%d\n", times);
    return 0;
}


Measured memory_bytes: 2040
a, b, x = gets.split.map(&:to_i)

if x >  a * a * b / 2.0
  rad = Math.atan(2*b/a.to_f - (2*x) / (a*a*a).to_f)
  puts rad.abs * 180 / Math::PI
  exit
else
  rad = Math.atan(((b*b*a).to_f/(2*x)))
  puts rad * 180 / Math::PI
  exit
end



Measured memory_bytes: 2044
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
        // freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    // #endif
    int n;
    cin>>n;
    long long int ans = 1;
    for(int i=1;i<=n;i++)
    {
        ans = (ans%MOD)*(i%MOD);
        ans = ans%MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    char b;
    cin >> b;
    if (b == 'A') print('T');
    else if (b == 'T') print('A');
    else if (b == 'G') print('C');
    else if (b == 'C') print('G');
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <bitset>
#include<list>
#include <iomanip>
using namespace std;
#define Clear(a) memset(a,-1,sizeof(a))
#define FILL(a) fill(a,a+1000000,true);
#define fastIO ios::sync_with_stdio(false)
#define mp make_pair
#define All(a) a.begin(),a.end()
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;
#define PI 3.1415926535897932385
#define INF 1000000000
#define eps 1e-7
#define MOD 100000000
#define maxN 500010
const int OO = (int)1e6;
using namespace std;
int n, m;
vi v;
int a[100009], b[100009], c[100009];
ll dp[100009][6];
ll  solve(int x, int l) {
	if (x == n)return 0;
	if (dp[x][l] != -1)return dp[x][l];
	ll ans1 = 0, ans2 = 0, ans3 = 0, ans = 0;
	if (l != 1) {
		ans = max(ans, solve(x + 1, 1) + a[x]);
	}
	if (l != 2) {
		ans = max(ans, solve(x + 1, 2) + b[x]);
	}
	if (l != 3) {
		ans = max(ans, solve(x + 1, 3) + c[x]);
	}
	return dp[x][l] = ans;
}
int main()
{
	fastIO;
	Clear(dp);
	cin >> n;
	for (int cc = 0; cc < n; cc++) {
		cin >> a[cc] >> b[cc] >> c[cc];
	}
	cout << solve(0,5) << endl;
	return 0;
}

Measured memory_bytes: 10752
package main

import "fmt"

func main() {
	var A, B, C int
	fmt.Scan(&A, &B, &C)
	for i := 1; i <= 100; i++ {
		x := A * i
		if x%B == C {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}


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

using namespace std;

struct Edge
{
    int n1;
    int n2;

    Edge(int n1, int n2)
        : n1(n1)
        , n2(n2) {}

    int op(const int n) const
    {
        return n == n1 ? n2 : n1;
    }
};

struct Graph
{
    vector<vector<int>> graph;
    vector<Edge> edge_list;

    Graph(const int n)
    {
        graph.resize(n);
    }

    void connect(const int n1, const int n2)
    {
        Edge e(n1, n2);
        edge_list.push_back(e);
        graph[n1].push_back(edge_list.size() - 1);
        graph[n2].push_back(edge_list.size() - 1);
    }
};

int dfs(const int idx, const Graph &g, vector<int> &visited, vector<int> &list, const int visit)
{
    list.push_back(idx);
    visited[idx] = visit;

    for (int ei : g.graph[idx])
    {
        const int nv = g.edge_list[ei].op(idx);

        if (visited[nv] == -1)
        {
            dfs(nv, g, visited, list, visit);
        }
    }
}

int main()
{
    int n, m;
    cin >> n >> m;

    vector<int> vs(n);
    for (int &v : vs)
    {
        cin >> v;
        v--;
    }

    Graph g(n);

    for (int i = 0; i < m; i++)
    {
        int n1, n2;
        cin >> n1 >> n2;
        n1--; n2--;
        g.connect(n1, n2);
    }

    vector<int> visited(n, -1);

    int visit = 0;
    int count = 0;

    for (int i = 0; i < n; i++)
    {
        if (visited[i] == -1)
        {
            vector<int> list;
            visit++;
            dfs(i, g, visited, list, visit);

            for (int idx : list)
            {
                if (visited[vs[idx]] == visit)
                {
                    count++;
                }
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 13172
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  double ans;

  int sum = 1;
  for(int i=1; i<=n; i++){
    sum *= i;
  }

  vector<int> v;
  for(int i=0; i<n; i++) v.push_back(i);
  sort(v.begin(), v.end());
  do{
      double tmp=0;
      for(int i = 0; i < v.size()-1; i++){
        // cout << v[i];
        tmp += sqrt(pow(x[v[i]]-x[v[i+1]], 2) + pow(y[v[i]]-y[v[i+1]], 2));
      }
      // cout << endl;
      ans += tmp / sum;
  }while(next_permutation(v.begin(), v.end()));

  // for(int i=0; i<n-1; i++){
  //   for(int j=i+1; j<n; j++){
  //     ans += sqrt(pow(x[i]-x[j], 2) + pow(y[i]-y[j], 2)) / n;
  //   }
  // }
  printf("%.10f", ans);

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
using lint  =                           long long int;
using pint  =                           pair<int, int>;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD                             1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T>                    bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T>                    bool mmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }


/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

void solve(){  
    lint N;
    cin >> N;

    lint sum = 0;
    for(int i = 1;i <= N; ++i) { 
       if(i%3 && i%5){
          sum += i;
       }
    }
    cout << sum << endl;
}

int main(){   
  
 solve();

 return 0;
}


Measured memory_bytes: 3652
A11,A12,A13 = map(int,input().split())
A21,A22,A23 = map(int,input().split())
A31,A32,A33 = map(int,input().split())
A = [[A11,A12,A13],[A21,A22,A23],[A31,A32,A33]]
N = int(input())
b_i = list([int(input()) for _ in range(N)])

for bi in b_i:
    for i in range(3):
        for j in range(3):
            if A[i][j] == bi:
                A[i][j] = 'on'

flag_no_bingo = False
#縦調査
for j in range(3):
    if A[0][j] == 'on':
        if A[1][j] == 'on' and A[2][j] == 'on':
            flag_no_bingo = True
#横調査
for i in range(3):
    if A[i][0] == 'on':
        if A[i][1] == 'on' and A[i][2] == 'on':
            flag_no_bingo = True
#斜め調査
if A[0][0] == 'on' and A[1][1] == 'on'  and A[2][2] == 'on' :
    flag_no_bingo = True
if A[0][2] == 'on' and A[1][1] == 'on' and A[2][0] == 'on' :
    flag_no_bingo = True
#結果出力
if flag_no_bingo == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
N = int(input())
ans = 0
for i in range(1,N+1):
    if (i%2 == 0) : continue
    l = 0
    for j in range(1,i+1):
        if (i % j == 0):
            l += 1
    if (l == 8):
        ans += 1

print(ans)

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

int main(){
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    tx -= sx; ty -= sy; sx = 0; sy = 0;
    REP (u, ty) cout << "U";
    REP (r, tx) cout << "R";
    cout << "D";
    REP (l, tx - 1) cout << "L";
    REP (D, ty - 1) cout << "D";
    cout << "LL";
    REP (u, ty + 1) cout << "U";
    REP (r, tx + 1) cout << "R";
    cout << "DRDD";
    REP (l, tx - 1) cout << "L";
    REP (D, ty - 1) cout << "D";
    cout << "LLU" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
mod = 10**9+7

def gcm(a,b):
    while(a%b!=0):
        a,b = b,a%b
    return b


def main():
    N = I()
    A = LI()

    l = A[0]

    for i in range(1,N):
        l = l*A[i] // gcm(l,A[i])
        
    B = [0]*N
    for i in range(N):
        B[i] = l * pow(A[i],mod-2,mod)

    ans = 0
    for i in range(N):
        ans += B[i]

    print(ans%mod)

if __name__ == "__main__":
    main()


Measured memory_bytes: 281864
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int k = scanner.nextInt();

        Map<Integer, List<Integer>> map = new HashMap<>();

        for (int i = 0; i < k; i++) {
            int d = scanner.nextInt();
            for (int j = 0; j < d; j++) {
                int person = scanner.nextInt();

                if (!map.containsKey(person)) {
                    map.put(person, new ArrayList<>());
                }
                map.get(person).add(d);
            }
        }

        int count = 0;
        for (int i = 1; i <= n; i++) {
            if (!map.containsKey(i)) {
                count++;
            }
        }

        System.out.println(count);

    }
}

Measured memory_bytes: 46460
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int> > vvi;
#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define frpn(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define fornd(i, n) for(int i=(int)(n); i>=0; --i)

const int INF = (int)1e6+5;
const int NAX = (int)2e5+5;
const int MOD = (int)1e9+7;

template <class T>
inline void rem(T &n){
   n = (-MOD <= n && n <= MOD) ? n : n%MOD ;
  if(n < 0) n += MOD; 
}

int N;
int d[NAX];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    forn(i, N){
       cin >> d[i];
    }
    sort(d, d+N);
    cout << d[N/2] - d[N/2-1]  << "\n";
    return 0;
}


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

int main(){
  int n,ans=1,f=0;cin>>n;
  if(n==1||n==2){
    cout<<4;
    return 0;
  }
  while(1){
    if(n==4){
      if(f){
        cout<<ans;
        return 0;
      }else f=1;
    }
    if(n%2) n=n*3+1;
    else n/=2;
    ans++;
  }
}

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

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





    if(n>=1800)  cout<<1;

    else   if(n>=1600) cout<<2;

         else if(n>=1400) cout<<3;
    else if(n>=1200) cout<<4;

       else if(n>=1000) cout<<5;
        else if(n>=800) cout<<6;
     else if(n>=600) cout<<7;
      else if(n>=400) cout<<8;
}


Measured memory_bytes: 3672
#include <stdio.h>

int main(void)
{
	int hi, bl;
	int na, nb, a[4], b[4];
	int i, j;
	
	while (scanf("%d %d", &na, &nb), na != 0 || nb != 0){
		hi = bl = 0;
		for (i = 3; 0 <= i; i--){
			a[i] = na % 10;
			b[i] = nb % 10;
			na /= 10;
			nb /= 10;
		}
		for (i = 0; i < 4; i++){
			for (j = 0; j < 4; j++){
				if (a[i] == b[j] && i == j){
					hi++;
				}
				else if (a[i] == b[j]){
					bl++;
				}
			}
		}
		printf("%d %d\n", hi, bl);
	}
	return (0);
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <functional>
#include <math.h>
using namespace std;

#define ll long long
#define int ll
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

#define dump(x)  cerr << #x << " = " << (x) << endl; 

typedef pair<int, int> P;
struct Point{
	int x, y;
};
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = {1,0,-1,0};

bool isprime(ll  n){
	if (n < 2) return false;
	else if (n == 2) return true;
	else if (n % 2 == 0) return false;
	else
		for (int i = 3; i*i <= n; i++)
			if (n%i == 0) return false;

	return true;
}

// n以下のエラトステネスのふるい
vector<bool> prime_table(int n){
	vector<bool> v(n + 1);

	for (int i = 0; i <= n; i++){
		v[i] = true;
	}
	v[0] = v[1] = false;
	for (int i = 2; i*i <= n; i++){
		if (isprime(i)){
			int j = 2 * i;
			while (j <= n){
				v[j] = false;
				j = j + i;
			}
		}
	}
	return v;
}

int a[100001], s[100001];
signed main(){

	vector<bool> v = prime_table(100000);

	for (int i = 3; i <= 100000; i++){
		if (v[i] && v[(i+1)/2]) a[i] = 1;
		s[i] = s[i - 1] + a[i];
	}

	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++){
		int l, r;
		cin >> l >> r;
		cout << s[r] - s[l - 1] << endl;
	}

	return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
const lli INF = 1e9 + 100;
const lli INF64 = (1LL << 61) + 100;
const lli MOD = 1e9 + 7;
const lli MH1 = 1599614977, MH2 = 2034417103, MH3 = 1090250123, MH4 = 2024491871;
const int N = 105;
int nums[N];
lli bpow(lli baseee, lli exponenttt) {
	if(exponenttt < 0) return 0;
	lli res = 1;
	baseee %= MOD;
	while (exponenttt > 0) {
		if ((exponenttt & 1) == 1) res = (res*baseee) % MOD;
		baseee = (baseee*baseee) % MOD;
		exponenttt >>= 1;
	}
	return res;
}
lli multInverse(lli a) {//if_mod_is_prime
	return bpow(a, MOD - 2);
}
lli divm(lli a, lli b) {//if_mod_is_prime
	return (a * multInverse(b)) % MOD;
}
lli multm(lli a, lli b) {
	return (a * b) % MOD;
}
lli subm(lli a, lli b) {
	a += MOD;
	lli r = a - b;
	if(r >= MOD) return r - MOD;
	return r;
}
lli addm(lli a, lli b) {
	lli r = a + b;
	if(r >= MOD) return r - MOD;
	return r;
}
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i++) cin >> nums[i];
	int sum = accumulate(nums + 1, nums + n + 1, 0);
	int ans = 0;
	for(int i = 1; i <= n; i++)
		if(nums[i] * (4*m) >= sum) 
			ans++;
	
	cout << (ans >= m ? "Yes" : "No") << "\n";
	return 0;
}

Measured memory_bytes: 256
use proconio::{input, fastout};

macro_rules! chmin {
    ($base:expr, $($cmps:expr),+ $(,)*) => {{
        let cmp_min = min!($($cmps),+);
        if $base > cmp_min {
            $base = cmp_min;
            true
        } else {
            false
        }
    }};
}

macro_rules! chmax {
    ($base:expr, $($cmps:expr),+ $(,)*) => {{
        let cmp_max = max!($($cmps),+);
        if $base < cmp_max {
            $base = cmp_max;
            true
        } else {
            false
        }
    }};
}

macro_rules! min {
    ($a:expr $(,)*) => {{
        $a
    }};
    ($a:expr, $b:expr $(,)*) => {{
        std::cmp::min($a, $b)
    }};
    ($a:expr, $($rest:expr),+ $(,)*) => {{
        std::cmp::min($a, min!($($rest),+))
    }};
}

macro_rules! max {
    ($a:expr $(,)*) => {{
        $a
    }};
    ($a:expr, $b:expr $(,)*) => {{
        std::cmp::max($a, $b)
    }};
    ($a:expr, $($rest:expr),+ $(,)*) => {{
        std::cmp::max($a, max!($($rest),+))
    }};
}

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

    let mut dp = vec![std::i64::MAX; n];
    dp[0] = 0;

    for i in 0..n {
        for j in 1..k+1 {
            if i + j >= n { continue; }
            chmin!(dp[i+j], dp[i] + (h[i] - h[i+j]).abs());
        }
    }
    println!("{}", dp[n-1]);
}


Measured memory_bytes: 4040
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a2 = [0]
b2 = [0]
for i in range(n):
    a2.append(a2[i]+a[i])
for i in range(m):
    b2.append(b2[i]+b[i])
ans = 0
cnt = m
for i in range(n+1):
    if a2[i] > k:
        break
    sm = 0
    while b2[cnt] > k-a2[i]:
        cnt -= 1
    ans = max(cnt+i, ans)
print(ans)

Measured memory_bytes: 47372
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Control.Monad
import Data.Array

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine

calc :: Int -> Array Int Int -> Int -> Int -> Int
calc tSum ts' p x = tSum - ts' ! p + x

calcAll tSum ts' (ps:pss) = do
  print $ calc tSum ts' (head ps) (last ps)
  when (pss /= []) $ calcAll tSum ts' pss

main = do
  n <- getInt
  ts <- getIntList
  m <- getInt
  pss <- getIntNList m
  let tSum = sum ts
  let ts' = listArray (1, length ts) ts
  calcAll tSum ts' pss


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

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

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

  int sum = 0;
  int b0, b1 ;
  b0 = 100000000;
  rep(i,n-1){
    cin >> b1;
    sum += min(b0,b1);
    b0 = b1;    
  }
  sum += b1;
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include<iomanip>
#include <string>
using namespace std;

int gcd(int a, int b)
{
    if (a < b) swap(a,b);
    while(b>0)
    {
        int r = a % b;
        a = b;
        b = r;
    }
    return a;
}

int main() {
    int x,y;
    cin >> x >> y;
    cout << gcd(x,y) << endl;
    return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
using namespace std;
int n,x,y,z,dp[44][1<<18] ;
int fun(int id , int msk)
{
    msk&=((1ll<<18)-1) ;
    if((msk>>x&1) && (msk>>(x+y)&1) && (msk>>(x+y+z)&1))
        return 0 ;
    if(id==n) return 1 ;
    if(dp[id][msk]!=-1) return dp[id][msk] ;
    int as=0 ;
    for(int i = 1 ; i <= 10 ; i++)
    {
        as+=fun(id+1,((msk<<i)|(1<<i))) ; as%=mod ;
    }
    return dp[id][msk]=as ;
}
int32_t main()
{
    ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
    memset(dp,-1,sizeof(dp)) ;
    cin>>n>>x>>y>>z ;
    int ans=1 ;
    for(int i = 1 ; i <= n ; i++) {ans*=10 ;ans%=mod ;}
    //cout<<ans<<endl ;
    int aa=fun(0,0) ;
    //cout<<aa<<endl ;
    cout<<(ans-aa+mod)%mod<<endl ;
}


Measured memory_bytes: 93744
#include <iostream>

using namespace std;

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

	cin >> a >> b >> c >> k;

	int max;
	
	if (a >= k) {
		max = k;
	}
	else if (a + b >= k) {
		max = a;
	}
	else {
		max = a - (k - b - a);
	}
	
	cout << max << endl;

	return 0;
}

Measured memory_bytes: 3192
#include<iostream>
#include<utility>
#include<vector>

using namespace std;

int main() {

	long N; cin >> N;
	vector<long> A; A.push_back(0);
	for (int i = 1; i <= N; i++) { long inp; cin >> inp; A.push_back(inp); } //入力。先頭は0。

	for (int i = 1; i <= N; i++) {
        int ind = i;
		while (A[ind] < A[ind - 1]) { swap(A[ind - 1], A[ind]); ind--; } 

		for (int j = 1; j <= N; j++) cout << (j==1?"":" ") << A[j]; //出力。
		cout << endl;
	}
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes                \
    cout << "Yes" << endl; \
    return 0;
#define No                \
    cout << "No" << endl; \
    return 0;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template <typename T>
void print(const T &v);

int main()
{
    int s, w;
    cin >> s >> w;
    if (s <= w)
    {
        cout << "unsafe" << endl;
    }
    else
    {
        cout << "safe" << endl;
    }
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


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

int main() {
    int n, k;
    int a[200001];
    cin >> n >> k;
    double shaku = 0.0;
    double max_shaku = 0;

    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }

    for(int i = 0; i < k; i++) {
        shaku += ((double)(1 + a[i])) / 2;
        max_shaku = shaku;
    }

    for(int i = k; i < n; i++) {       
        shaku -= ((double)(1 + a[i - k])) / 2; 
        shaku += ((double)(1 + a[i])) / 2;

        if(shaku > max_shaku) {
            max_shaku = shaku;
        }
    }

    cout << fixed << max_shaku << endl;
 }

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define all(a) a.begin(),a.end()
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(auto x:v) cout<<" "<<x; cout<<endl;
int power(ll x,ll y){ll res = 1;while(y>0){if(y&1)res = (res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	int T=1;
	//cin>>T;
	while(T--){
		int n;
		cin>>n;
		ll a[n];
		for(int i=0;i<n;i++)
			cin>>a[i];
		ll mn=a[0];
		ll ans=0;
		for(int i=1;i<n;i++){
			if(a[i]<mn){
				ans=ans+mn-a[i];
				a[i]=mn;
			}
			else
				mn=a[i];
		}
		cout<<ans<<endl;
	}
}


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

int main(void) {
  int x;
  cin >> x;
  if (x < 1200) {
    cout << "ABC" << endl;
  }
  else if (x < 2800) {
    cout << "ARC" << endl;
  }
  else {
    cout << "AGC" << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 998244353;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
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; }


int main() {   
    int n, m; cin >> n >> m;
    int res = n*(n-1)/2 + m*(m-1)/2;
    cout << res << ln;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll A, B;
    cin >> A >> B;
    cout << A * B << "\n";
}

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

using namespace std;

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i )
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i )

typedef long long LL;

template<typename Type>
inline bool chkmin(Type &x , const Type &y) { return x > y ? (x = y , 1) : 0; }
template<typename Type>
inline bool chkmax(Type &x , const Type &y) { return x < y ? (x = y , 1) : 0; }

template<typename Type>
inline Type read(Type &f)
{
    f = 0; int x = 1 ; char c = getchar();
    while(!isdigit(c))
        x = (c == '-' ? -1 : 1) , c = getchar();
    while(isdigit(c))
        (f *= 10) += c & 15 , c = getchar();
    return f = x * f;
}

const int N = 200000 + 5;

int n , m , x , y , v;

int A[N] , cnt[N] , g[N];

int main()
{
    read(n) , read(m);
    rep(i , 1 , n) read(A[i]) , cnt[A[i]]++;
    rep(i , 1 , n) if(cnt[i])
    {
        rep(j , max(0 , i - cnt[i]) , i - 1) g[j]++;
    }
    int Ans = 0;
    rep(i , 0 , n - 1) if(g[i] == 0) Ans++;
    while(m--)
    {
        read(v) , read(y);
        x = A[v] , A[v] = y;
        if(x >= cnt[x])
        {
            if(--g[x - cnt[x]] == 0) Ans++;
        }
        cnt[x]-- , cnt[y]++;
        if(y >= cnt[y])
        {
            if(g[y - cnt[y]]++ == 0) Ans--;
        }
        printf("%d\n" , Ans);
    }
    return 0;
}




Measured memory_bytes: 3840
N,K = map(int,input().split())
A = list(map(int,input().split()))
L = [1]
s = set()
s.add(1)
now = 1
for _ in range(N):
    if A[now - 1] in s:
        K -= L.index(A[now - 1])
        if K >= 0: K %= len(L) - L.index(A[now - 1])
        break
    L.append(A[now - 1])
    s.add(A[now - 1])
    now = A[now - 1]
#print(L)
#print(K)
print(L[K + L.index(A[now - 1])])




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

using namespace std;
int n, a, b;
const int maxN = 3 * (int)1e5 + 10;
int c[maxN];
int main() {
    cin >> n >> a >> b;
    if (n > 1LL * a * b) {
        cout << "-1";
        return 0;
    }
    if (n < a + b - 1) {
        cout << "-1";
        return 0;
    }
    for (int i = 1; i <= n; i++) {
        c[i] = n + 1 - i;
    }
    int lst = 0;
    reverse(c + 1, c + a + 1);
    lst += a;
    for (int i = 2; i <= b; i++) {
        lst++;
        int sz = n - lst + 1;
        int block_sz = sz / (b - i + 1);
        reverse(c + lst, c + lst + block_sz);
        lst += block_sz - 1;
    }
    for (int i = 1; i <= n; i++) cout << c[i] << " ";
    return 0;
}


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

int main(void) {
	string n;
	cin >> n;
	for (int i = 0; i < n.length(); i++) {
		if (n[i] == '1') {
			n[i] = '9';
		} else if (n[i] == '9') {
			n[i] = '1';
		}
	}
	cout << n << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 14;
char cn[cm], * ci = cn, ct;
const double p = 0.01;

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


	fread(ci, 1, cm, stdin);

	int N = 0;
	while ((ct = *ci++) >= '0') N = N * 10 + ct - '0';

	double dp[1501] = {};
	dp[0] = 1.0;
	int M = N / 2;

	rep(i, N) {
		ci += 2;
		int k = (*ci++ - '0') * 10;
		k += *ci++ - '0';
		double P = p * k;
		ci++;

		for (int j = min(M, i); j >= max(0, i - M); j--) {
			dp[j + 1] += dp[j] * P;
			dp[j] *= 1 - P;
		}
	}

	printf("%.15f", dp[M + 1]);

	Would you please return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;




#define SIZE 1000005


ll fact[SIZE],inv_fact[SIZE];


ll mod_pow(ll x,ll count, ll mod){

	if(count == 0)return 1;
	ll ret = mod_pow((x*x)%mod,count/2,mod);
	if(count%2 == 1){

		ret = (ret*x)%mod;
	}
	return ret;
}

ll extgcd(ll a,ll b,ll &x,ll &y){
	ll d = a;
	if(b != 0){
		d = extgcd(b,a%b,y,x);
		y -= (a/b)*x;
	}else{
		x = 1;
		y = 0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}

ll nCk(ll n,ll k){

	ll ret = fact[n]*inv_fact[k];
	ret %= MOD;
	ret *= inv_fact[n-k];

	return ret%MOD;
}

ll nPk(ll n,ll k){

	ll ret = fact[n]*inv_fact[n-k];
	return ret%MOD;
}



int main(){

	fact[0] = 1;
	for(ll i = 1; i < SIZE; i++){
		fact[i] = i*fact[i-1];
		fact[i] %= MOD;
	}
	inv_fact[SIZE-1] = mod_inverse(fact[SIZE-1],MOD);
	for(ll i = SIZE-1; i >= 1; i--){

		inv_fact[i-1] = inv_fact[i]*i;
		inv_fact[i-1] %= MOD;
	}

	ll N,M;
	scanf("%lld %lld",&N,&M);

	ll ans = 0;

	for(ll i = 0; i <= N; i++){
		ll base = nPk(M,N); //Aの数列の個数
		ll work = nCk(N,i); //一致する数の個数
		base *= work;
		base %= MOD;
		base *= nPk(M-i,N-i);
		base %= MOD;

		if(i%2 == 0){

			ans += base;

		}else{

			ans -= base;
			if(ans < 0){

				ans += MOD;
			}
		}
		ans %= MOD;
	}

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

	return 0;
}



Measured memory_bytes: 19456
#include <bits/stdc++.h>
#define show(x) cerr << #x << " = " << x << endl
using namespace std;
template <typename Functor>
struct fix_type
{
    Functor functor;
    template <typename... Args>
    decltype(auto) operator()(Args&&... args) const& { return functor(functor, std::forward<Args>(args)...); }
};
template <typename Functor>
fix_type<typename std::decay<Functor>::type> fix(Functor&& functor) { return {std::forward<Functor>(functor)}; }
int main()
{
    int N;
    cin >> N;
    vector<int> x(N);
    for (int i = 0; i < N; i++) { cin >> x[i]; }
    int M;
    cin >> M;
    vector<vector<int>> to(M, vector<int>(2));
    vector<int> num(M);
    for (int i = 0; i < M; i++) {
        cin >> num[i] >> to[i][0] >> to[i][1];
        to[i][0]--, to[i][1]--;
    }
    using P = pair<int, vector<int>>;
    map<P, bool> memo;
    auto f = fix([&](auto&& self, const int node, const vector<int>& arr) -> bool {
        if (memo.find({node, arr}) != memo.end()) { return memo[{node, arr}]; }
        const int sz = arr.size();
        if (sz == 1) { return memo[{node, arr}] = (arr[0] == num[node]); }
        const int c1 = to[node][0], c2 = to[node][1];
        for (int i = 1; i <= sz - 1; i++) {
            if (self(self, c1, vector<int>{arr.begin(), arr.begin() + i}) and self(self, c2, vector<int>{arr.begin() + i, arr.end()})) { return memo[{node, arr}] = true; }
        }
        return memo[{node, arr}] = false;
    });
    cout << (f(0, x) ? "Yes" : "No") << endl;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  int ans = INT_MAX;
  for(int i = a.at(0); i <= a.at(n-1); i++){
    int cost = 0;
    for(int j = 0; j < n; j++){
      cost += pow(a.at(j)-i,2);
    }
    ans = min(ans,cost);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
//                        Bismillahir Rahmanir Rahim
//ALGO:
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define FILL(a, x) memset(a, x, sizeof(a))
#define ll long long
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define INF INT_MAX
#define MX 1000010
#define mod 1000000007
#define dout if(debug) cout
#define FR(i, n) for(int i=0; i<n; i++)
#define FOR(i, n) for(int i=1; i<=n; i++)
const double Pi=acos(-1);
using namespace std;
int debug=01;
void solve(){
    int n, f=0, t=0, a, b;
    cin>>n;
    while(n--){
        cin>>a>>b;
        if(a==b)t++;
        else t=0;
        if(t==3)f=1;
    }
    cout<<(f?"Yes":"No");
}
int main() {
    Fast
    int tst=1;
    //cin>>tst;
    for(int T=1; T<=tst; T++){
        //cout<<"Case "<<T<<": ";
        solve();
    }
}


Measured memory_bytes: 3652
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<min(a+b,min(a+c,b+c))<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;



int main(){
    
  ll l,r;
  cin>>l>>r;

  if(r-l>=2019)cout<<0<<endl;
  else{
    ll mi=2018;
    for(ll i=l;i<=r;i++){
       for(ll j = i + 1; j <= r; j++){
      mi = min(mi, (i * j) % 2019);
       
       }
    }
     cout<<mi<<endl;
  }
}


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

using namespace std;

#define IO ios_base::sync_with_stdio(0);cin.tie(0);

int main()
{
  IO;
	int n, m; cin >> n >> m;
	vector <vector <long long>> a(n, vector <long long> (3));
	for (int i = 0; i < n; ++i)
		cin >> a[i][0] >> a[i][1] >> a[i][2];

	long long res = -1e18;
	for (int mask = 0; mask <= 7; ++mask) {
		vector <long long> c(n);
		if ((mask >> 0) % 2 == 0)
		for (int i = 0; i < n; ++i) c[i] += a[i][0] * -1;
		else for (int i = 0; i < n; ++i) c[i] += a[i][0];
		if ((mask >> 1) % 2 == 0)
		for (int i = 0; i < n; ++i) c[i] += a[i][1] * -1;
		else for (int i = 0; i < n; ++i) c[i] += a[i][1];
		if ((mask >> 2) % 2 == 0)
		for (int i = 0; i < n; ++i) c[i] += a[i][2] * -1;
		else for (int i = 0; i < n; ++i) c[i] += a[i][2];

		sort(c.rbegin(), c.rend());
		long long sum = 0;
		for (int i = 0; i < m; ++i)
			sum += c[i];
		res = max(res, sum);
	}
	cout << res << endl;

	return 0;
}


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

int main() {
  int n,m,x,y;
  cin >> n >> m >> x >> y;
  vector<int> xa(n+1);
  vector<int> ya(m+1);

  for(int i=0;i<n;i++){
  cin >> xa[i];
  }
   for(int i=0;i<m;i++){
  cin >> ya[i];
  }

  xa[n]=x;
  ya[m]=y;

  sort(xa.begin(),xa.end());
  sort(ya.begin(),ya.end());

  if(xa[n] < ya[0]){
  cout << "No War" << endl;
  }
  else{
  cout << "War" << endl;
  }

}

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

using namespace std;

typedef pair<char, char> P;

int main() {

	string s, t;
	cin >> s >> t;

	set<char> st;
	set<char> nuse;
	map<char, char> mp;

	bool hh = true;

	for (int i = 0; i < s.size(); i++) {
		//cout << s[i] << ' ';
		if (s[i] != t[i]) {
			if (nuse.find(s[i]) != nuse.end() || nuse.find(t[i]) != nuse.end()) {
				hh = false;
			}
			else {
				for (int j = i + 1; j < s.size(); j++) {
					if (s[j] == s[i]) {
						s[j] = t[i];
					}
					else if (s[j] == t[i]) {
						s[j] = s[i];
					}
				}
				s[i] = t[i];
			}
		}
		nuse.insert(s[i]);
		//cout << s[i] << endl;
	}

	if (hh) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

ans='Yes'
h=1
while h<=H:
    w=1
    while w<=W:
        if hw[h][w]=='#':
            if all([hw[h-1][w]=='.',hw[h+1][w]=='.',hw[h][w-1]=='.',hw[h][w+1]=='.']):
                ans='No'
        w+=1
    h+=1

print(ans)

Measured memory_bytes: 3064
n = int(input())

if n == 1:
	G = [1]
else:
	G = [g for g in [1, 4, 10, 23, 57, 132, 301, 701] if g < n]
	while True:
		g = int(2.25 * G[-1])
		if g > n:
			break
		G.append(g)
	G.reverse()

A = [int(input()) for _ in range(n)]
cnt = 0
for g in G:
	for j, v in enumerate(A[g:]):
		while j >= 0 and A[j] > v:
			A[j+g] = A[j]
			j -= g
			cnt += 1
		A[j+g] = v

print(len(G))
print(*G)
print(cnt, *A, sep='\n')


Measured memory_bytes: 60988
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int width = sc.nextInt();
        int height = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();

        if (isOutOfRectangle(x, y, width, height, r)) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }

    public static boolean isOutOfRectangle(int x, int y, int width, int height, int r) {
        if (x - r < 0 || y - r < 0) {
            return true;
        }
        if (x + r > width || y + r > height) {
            return true;
        }

        return false;
    }
}



Measured memory_bytes: 26348
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;

#define huge 1000000007

int main(void) {
	int s = 0;
	int a = 0, b = 0, h = 0;
	cin >> a >> b >> h;
	s=(a + b)*h / 2;
	
	cout << s << endl;
	

	return 0;


}

Measured memory_bytes: 256
#include <cstdio>
#include <complex>
#include <utility>
#include <vector>
#include <algorithm>

using namespace std;

typedef complex<double> point_t;
typedef pair<point_t,double> circle_t;

const double eps=1e-9;

circle_t cs[62];
point_t meats[62];
double hardness[62];

int N,K;

void add_intersect(const circle_t & c1,const circle_t & c2,vector<point_t> & v){
    auto d=abs(c1.first-c2.first);
    auto rc=(d*d+c1.second*c1.second-c2.second*c2.second)/(2*d);
    auto diff=c1.second*c1.second-rc*rc;

    if (abs(diff)<eps) diff=0.;

    if (diff<0.) return;
    auto rs=sqrt(diff);

    auto dir=(c2.first-c1.first)/d;

    if (diff==0.) v.push_back(c1.first+diff*point_t(rc,rs));
    else {
        v.push_back(c1.first+diff*point_t(rc,rs));
        v.push_back(c1.first+diff*point_t(rc,-rs));
    }
}

vector<point_t> is_cc(circle_t c1, circle_t c2) {
	vector<point_t> res;
	auto d = abs(c1.first - c2.first);
	auto rc = (d*d + c1.second*c1.second - c2.second*c2.second) / (2 * d);
	auto dfr = c1.second*c1.second - rc * rc;
	if (abs(dfr) < eps)dfr = 0.0;
	if (dfr < 0.0)return res;
	auto rs = sqrt(dfr);
	auto diff = (c2.first - c1.first) / d;
	res.push_back(c1.first + diff * point_t(rc, rs));
	if (dfr != 0.0)res.push_back(c1.first + diff * point_t(rc, -rs));
	return res;
}

int cnt(const point_t &  p){
    int ret=0;

    for(int i=1;i<=N;i++){
        // printf("r=%lf\n",cs[i].second);
        auto dist=abs(cs[i].first-p);
        // printf("dist=%lf\n",dist);
        if (dist < cs[i].second + eps) ret++;
    }
    // printf("pos=%lf,%lf ret=%d\n",p.real(),p.imag(),ret);
    return ret;
}

bool valid(){
    vector<point_t> candidate;
    for(int i=1;i<=N;i++) candidate.push_back(meats[i]);

    for(int i=1;i<=N;i++)
        for(int j=i+1;j<=N;j++){
            auto m=is_cc(cs[i],cs[j]);
            for(auto p: m) candidate.push_back(p);
        }
            // add_intersect(cs[i],cs[j],candidate);

    // for(auto &p:candidate) printf("pos=%lf %lf\n",p.real(),p.imag());

    for(auto &p:candidate) if (cnt(p)>=K) return true;

    return false;
}

int main(){
    scanf("%d%d",&N,&K);
    for(int i=1;i<=N;i++){
        double x,y,c;
        scanf("%lf%lf%lf",&x,&y,&c);
        meats[i]=point_t(x,y);
        hardness[i]=c;

        // printf("pos=%lf %lf\n",meats[i].real(),meats[i].imag());
    }
    
    double l=0.0,r=1e6;
    double ans=r;
    for(int i=1;i<100;i++){
        // printf("l=%lf r=%lf\n",l,r);
        auto mid=(l+r)/2.;
        for(int i=1;i<=N;i++)
            cs[i]=circle_t(meats[i],mid/hardness[i]);

        if (valid()) r=mid,ans=mid;
        else l=mid;
    }

    printf("%.7lf\n",r);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, M;
	cin >> N >> M;
	vector<int> D(N);
	for(int i = 0; i < N; i++) cin >> D[i];
	vector<bool> V_ok(N, false);
	vector< pair<int, int> > E(M), Es(M);
	for(int i = 0; i < M; i++) {
		cin >> E[i].ff >> E[i].ss;
		Es[i] = {max(D[--E[i].ff], D[--E[i].ss]), i};
		if(D[E[i].ff] >= D[E[i].ss]) V_ok[E[i].ff] = true;
		if(D[E[i].ff] <= D[E[i].ss]) V_ok[E[i].ss] = true;
	}
	for(int i = 0; i < N; i++) if(!V_ok[i]) {
		cout << "-1\n";
		return 0;
	}
	sort(begin(Es), end(Es));
	vector<int> ans_c(N, 0), ans_w(M, 1e9);
	vector< vector<int> > comp(N);
	vector<int> in_comp(N);
	for(int i = 0; i < N; i++) comp[i] = {i}, in_comp[i] = i;
	for(int i = 0; i < M; i++) {
		int u = in_comp[E[Es[i].ss].ff], v = in_comp[E[Es[i].ss].ss];
		if(u == v) continue;
		ans_w[Es[i].ss] = Es[i].ff;
		if(comp[u].size() < comp[v].size()) swap(u, v);
		int c_dif = (ans_c[E[Es[i].ss].ff] == ans_c[E[Es[i].ss].ss]);
		for(auto w : comp[v]) {
			comp[u].push_back(w);
			in_comp[w] = u;
			ans_c[w] ^= c_dif;
		}
	}
	string S;
	for(int i = 0; i < N; i++) S += ans_c[i] ? 'B' : 'W';
	cout << S << "\n";
	for(int i = 0; i < M; i++) cout << ans_w[i] << "\n";
	return 0;
}

// look at my code
// my code is amazing


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}

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


int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll tmp = lcm(C, D);
    ll a = B/C - (A-1)/C;
    ll b = B/D - (A-1)/D;
    ll c = B/tmp - (A-1)/tmp;
    cout << (B-A+1) - (a + b - c) << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var n int
	fmt.Fscan(r, &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &a[i])
	}

	var s int
	for i := 0; i < n; i++ {
		s ^= a[i]
	}

	for i := 0; i < n; i++ {
		fmt.Fprint(w, s^a[i])
		if i < n-1 {
			fmt.Fprint(w, " ")
		} else {
			fmt.Fprintln(w)
		}
	}
}


Measured memory_bytes: 7320