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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(ll i = 0; i<n; i++)
#define rep_s(i, start, n) for(ll i= start;  i<n; i++)
#define rep_down(i, n) for(ll i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(ll i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()
#define print(ans) cout << ans << endl;
#define MOD 1000000007
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll keta_num(ll num){
  ll total = 0;
  while(num){
    num /= 10;
    total++;
  }
}


ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

ll fibonacchi(ll num){
  ll f0 = 0, f1 = 1, f2;
  ll count = 0;
  while(count<num){
    f2 = f0+f1;
    f0 = f1;
    f1 = f2;
    count++;
  }
  return f2;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, A, B;
  cin >>A >> B;
  for (double i=1; i<1010; i++){
    int a = int(i*0.08), b = int(i*0.10);
    if(a ==A && b==B){
      cout << i<<endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 3800
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cctype>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvii;
typedef pair<int, int> ii;
typedef vector<ii> vii;

////////////////////////////////

void solve() {
	
}
const int INF = 1e9 + 5;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	vector<int> dp(n, INF);
	dp[0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 1; j <= k; ++j) {
			if (i + j >= n) continue;
			dp[i + j] = min(dp[i + j], dp[i] + abs(a[i] - a[i + j]));
		}
	}
	cout << dp[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
  int x;
  int coins[6] = {500, 5, 100, 50, 10, 1};
  int after[6];
  int point = 0;
  scanf("%d", &x);
  for(int i = 0; i < 6; i++) {
    after[i] = x / coins[i];
    x %= coins[i];
    if(i == 0) {
      point += after[i] * 1000;
    } else if(i == 1) {
      point += after[i] * 5;
    }
  }
  printf("%d", point);
  return 0;
}


Measured memory_bytes: 1736
#include <algorithm>
#include <array>
#include <assert.h>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
typedef long long ll;
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<ld>> vvd;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;


int main() {
    cout << setprecision(30);
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    ll n;
    cin >> n;
    vl h(n + 1);
    for (ll i = 0; i < n; ++i) {
        cin >> h[i];
    }
    h[n] = 1e12;
    vl dp(n);
    ll ans = 0;
    ll curr = 0;
    for (ll i = n - 1; i >= 0; --i) {
        if (h[i] < h[i + 1]) curr = 0;
        ++curr;
        ans = max(ans, curr);
    }
    cout << (ans - 1) << endl;

    return 0;
}


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

int main() {
    int N;
    cin >> N;
    string S ;
    cin >> S;
    int mojisu = (S.size())-2;
    int ans =0;
    for (int i=0; i<mojisu; i++){
        if(S.at(i) == 'A' && S.at(i+1) == 'B' && S.at(i+2) == 'C'){
                ans ++;
        }
    }
    cout << ans << endl;
}


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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int32_t main() {
    //ios::sync_with_stdio(false); cin.tie(nullptr);

    string s;
    cin >> s;
    if (s[2] == s[3] and s[4] == s[5]) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }            
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, *a = map(int, read().split())
a.sort()
a1 = 2 * (sum(a[(n + 1) // 2:]) - sum(a[:(n + 1) // 2]))
a2 = 2 * (sum(a[n // 2:]) - sum(a[:n // 2]))
if n % 2 == 0:
    v = a[n // 2] - a[n // 2 - 1]
    a1 -= v
    a2 -= v
else:
    a1 += a[n // 2 - 1] + a[n // 2]
    a2 -= a[n // 2 + 1] + a[n // 2]
print(max(a1, a2))


Measured memory_bytes: 13028
n = int(input())
a=[]
for i in range(n):
    a.append(int(input()))
a.sort()
cnt = 1
ans = 0
for i in range(n-1):
    if a[i]==a[i+1]:
        cnt += 1
    else:
        ans += cnt%2
        cnt = 1
ans += cnt%2
print(ans)

Measured memory_bytes: 7492
program ABC059A
    implicit none
    character(10)::s1,s2,s3
    read(5,*)s1,s2,s3
    print'(A,A,A)',char(ichar(s1(1:1))-32),char(ichar(s2(1:1))-32),char(ichar(s3(1:1))-32)
end program ABC059A

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

using namespace std;

#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))
#define  nl "\n";
#define FIO ios_base::sync_with_stdio(false);cout.setf(ios::fixed);cout.precision(10);cout.tie(nullptr);cin.tie(nullptr);

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

template < class T> inline T biton(T n, T pos) { return n | ((T)1 << pos); }
template < class T> inline T bitoff(T n, T pos) { return n & ~((T)1 << pos); }
template < class T> inline T ison(T n, T pos) { return (bool)(n & ((T)1 << pos)); }
template < class T> inline T gcd(T a, T b) { while (b) { a %= b; swap(a, b); }return a; }

template <class T> inline T bigmod(T p, T e, T m) {
	T ret = 1;
	for (; e > 0; e >>= 1) {
		if (e & 1) ret = (ret * p) % m; p = (p * p) % m;
	} return (T)ret;
}

#define DEBUG

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
	cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " is " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define debug(...)
#endif

void solve()
{
	char a;
	cin>>a;

	if(isupper(a)){
		cout<<'A'<<nl;
	}
	else{
		cout<<'a'<<nl;
	}
}

int main()
{
	FIO;

	int t = 1;

	while (t--)
	{
		solve();
	}

	return 0;
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int s; cin >> s;
  int S = (s%2 == 0 ? s/2 : 3*s+1);
  int m = 2;
  map<int, int> mp;
  mp[s]++; mp[S]++;
  while(mp[S] < 2){
    s = S;
    S = (s%2 == 0 ? s/2 : 3*s+1);
    m++;
    mp[S]++;
  }
  cout << m << endl;
}





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

int main(void) {
	int N, M;
	cin >> N >> M;

	vector<int> Town1(M), Town2(M);
	for (int i = 0; i < M; i++)
	{
		cin >> Town1.at(i) >> Town2.at(i);
	}

	for (int i = 0; i < N; i++)
	{
		int sum = 0;
		for (int j = 0; j < M; j++)
		{
			if (Town1.at(j) == (i + 1) || Town2.at(j) == (i + 1))
			{
				sum++;
			}
		}
		cout << sum << endl;
	}

	return 0;
}

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

int main (){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  bool ok = true;
  while(ok){
    c-=b;
    if (c<=0){
      cout << "Yes" << endl;
      return 0;
    }
    a-=d;
    if (a<=0){
      cout << "No" << endl;
      return 0;
    }
  }
}
    

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

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
using pii = pair<int, int>;
constexpr ll MAX = 1e6+5;
constexpr ll INF = 2134567890;
constexpr ll MOD = 998244353;

ll fpow(ll b, ll a, ll MOD = MOD) {
    b %= MOD;
    ll r = 1;
    for(; a; b=b*b%MOD, a>>=1)
        a&1 && (r = r*b%MOD);
    return r;
}

signed main() {
    FAST;

    ll N, A, B;
    cin >> N >> A >> B;
    ll ans = N;
    if (A%2 == B%2)
        ans = abs(A-B)/2;
    else {
        ans = min((A+B-1)/2, (N-A-B+N+1)/2);
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#pragma GCC optimize("O3")

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <assert.h>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <random>
#include <cmath>
#include <chrono>
#include <bitset>

#define ld long double
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;

const int INF = 2e18;
const int MOD = 1e9 + 7;
const int MB = 20;

vector<vector<int>> g;

vector<int> a, s;

void dfs(int v, int p = -1) {
	a.pb(v);
	s[v] = 1;
	for (int u : g[v]) {
		if (u != p) {
			dfs(u, v);
			s[v] += s[u];
		}
	}
}

void solve() {
	int n, q;
	cin >> n >> q;
	g.resize(n);
	for (int i = 0; i < n - 1; i++) {
		int from, to;
		cin >> from >> to;
		from--; to--;
		g[from].pb(to);
		g[to].pb(from);
	}

	s.resize(n);
	dfs(0);

	vector<int> link(n);
	for (int i = 0; i < n; i++) link[a[i]] = i;

	vector<int> t(n + 1);
	for (int i = 0; i < q; i++) {
		int v, x;
		cin >> v >> x;
		v--;
		int l = link[v];
		int r = link[v] + s[v] - 1;
		t[l] += x;
		t[r + 1] -= x;
	}

	int now = 0;
	vector<int> ans(n);
	for (int i = 0; i < n; i++) {
		now += t[i];
		ans[a[i]] = now;
	}

	for (int i : ans) cout << i << " ";
}
signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(12);
	solve();
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{

  int a, b;
  cin >> a >> b;
  if (a >= 13)
    pr(b);
  else if (a >= 6)
    pr(b / 2);
  else
    pr(0);
  return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
int main(){
        int s,h,m,t;
        scanf("%d",&t);
        h =t/3600;
        m =(t-3600*h)/60;
        s =t-(h*3600+m*60);
        printf("%d:",h);
        printf("%d:",m);
        printf("%d\n",s);
        return 0;
}

Measured memory_bytes: 592
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();

        int count = 0;
        for (int i = 0; i < n; i++) {
           long x = sc.nextInt();
           long y = sc.nextInt();
           double z = Math.sqrt(x*x + y*y);
           if (z <= d) count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 59636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

int par[200100];
int ranks[200100];

void init(int n){
  for(int i=0;i<n;i++){
    par[i]=i;
    ranks[i]=0;
  }
}

int find(int x){
  if(par[x]==x){
    return x;
  }else{
    return par[x]=find(par[x]);
  }
}

void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y){
    return ;
  }
  if(ranks[x]<ranks[y]){
    par[x]=y;
  }
  else{
    par[y]=x;
  }
  if(ranks[x]==ranks[y]){
    ranks[x]++;
  }
}

bool same(int x,int y){
  return find(x)==find(y);
}

struct edge {int u,v,cost;};

bool comp(const edge& e1, const edge& e2){
  return e1.cost<e2.cost;
}

typedef pair<int,int> P;

int INF=1000000007;
int d[100020];

int main(){
  vector<edge> E;
  int N,x,y;
  vector<P> x_axis,y_axis,plot;
  cin>>N;
  for(int i=0;i<N;++i){
    cin>>x>>y;
    x_axis.push_back(P(x,i));
    y_axis.push_back(P(y,i));
    plot.push_back(P(x,y));
  }
  sort(x_axis.begin(),x_axis.end());
  sort(y_axis.begin(),y_axis.end());

  int total_count=0;
  for(int i=0;i<N-1;++i){
      int tcost=x_axis[i+1].first-x_axis[i].first;
      E.push_back(edge{x_axis[i].second,x_axis[i+1].second,tcost});
      total_count+=1;
      tcost=y_axis[i+1].first-y_axis[i].first;
      E.push_back(edge{y_axis[i].second,y_axis[i+1].second,tcost});
      total_count+=1;
    }
  sort(E.begin(),E.end(),comp);
  init(N);
  int ans=0;
  for(int i=0;i<total_count;++i){
    edge e=E[i];
    if(!same(e.u,e.v)){
      unite(e.u,e.v);
      ans+=e.cost;
    }
  }
  cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 7900
using System;
class Program
{
    static void Main(string[] args)
    {
        int n, k, i = 0, q, j;
        int[] m, x = new int[4], y = new int[4], p = new int[] { 10, 50, 100, 500 };

        while (true)
        {
            n = int.Parse(Console.ReadLine());
            if (n==0) { break; }
            if (i!=0) { Console.WriteLine(); }
            i++;
            k = 0;
            m = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            for (j = 3; j >= 0; j--)
            {
                k += m[j] * p[j];
            }
            q = k - n;
            for (j = 3; j >= 0; j--)
            {
                x[j] = q / p[j]; q -= x[j] * p[j];
                y[j] = Math.Max(0, m[j] - x[j]);
            }

            for (j = 0; j < 4; j++)
            {
                if (y[j]!=0) { Console.WriteLine("{0} {1}", p[j], y[j]); }
            }
        }
    }
}


Measured memory_bytes: 9360
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std;

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

//Degree <-> Radian
double toRad(double d){ double rad; rad=d*PI/180; return rad; }
double toDegree(double rad){ double d; d=rad*180/PI; return d; }
//The least common multiple : lcm
ll lcm(int a,int b){ return a*b/__gcd(a,b); }
//素数判定
bool isPrime(int n){
    int i; 
    if(n<2) return 0;
    else if(n==2) return 1;
    if(n%2==0) return 0;
    for(i=3;i*i<=n;i+=2) if(n%i==0) return 0;
    return 1;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    rep(i,0,s.size()){
        cout << "x";
    }cout ENDL;
    
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int const N = 1e5 + 5;
int a[N];
int n, k;
int mem[N];
int oo = 0x3f3f3f3f;
int solve(int i = 0){
    if(i+1 == n)
        return 0;
    int &ret = mem[i];
    if(~ret)
        return ret;
    ret = oo;
    for(int j=1; j<=k; j++){
        if(i + j >= n) continue;
        ret = min(ret, solve(i+j) + abs(a[i]-a[i+j]));
    }
    return ret;
}

int main() {
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false), cin.tie(0);
#endif
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    memset(mem, -1, sizeof(mem));
    cin>>n>>k;
    for(int i=0; i<n; i++)
        cin>>a[i];
    cout<<solve()<<'\n';
}

Measured memory_bytes: 10688
import java.util.*;

public class Main {
	static int a, b, t, count;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b = sc.nextInt();
		t = sc.nextInt();
		count = 0;
		for(int i = a; i <= t+0.5; i+=a) {
			count+=b;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cout.precision(10);
ll a, b;
cin >> a >> b;
cout << b * 2 - a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;
typedef pair<int,int> P;

struct UF{
	int par[1000];
	int rank[1000];

	void init(int n){
		rep(i,n){
			par[i] = i;
			rank[i] = 0;
		}
	}

	int find(int x){
		if(par[x] == x) return x;
		else return par[x] = find(par[x]);
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		
		if(rank[x] < rank[y]) par[x] = y;
		else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int n, m;
vector<P> v[1000];
UF uf;

void solve(){
	rep(i,1000) v[i].clear();
	rep(i,m){
		int s, t, c;
		cin >> s >> t >> c;
		s--; t--;
		v[s].push_back(P(t,c));
	}
	int s = 0, e = 10000, mid;
	while(true){
		if(e-s == 1) break;
		mid = (s+e)/2;
		uf.init(n);
		rep(i,n){
			rep(j,v[i].size()){
				P p = v[i][j];
				if(p.second <= mid) uf.unite(i,p.first);
			}
		}
		int cnt = 0;
		rep(i,n) if(uf.par[i] == i) cnt++;
		if(cnt <= n/2) e = mid;
		else s = mid;
	}
	cout << e << endl;
}

int main(){
	while(cin >> n >> m){
		if(n == 0 && m == 0) break;
		solve();
	}
}

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

struct Node{//binary tree's node
    int key;
    Node *parent, *left, *right;
};

Node *root, *NUL;

void insert(int node){
    //Now Searching...
    Node *nowNode = root;//start with root
    Node *nowParent = NUL;//root node's parent node is NULL
    while(nowNode!=NUL){
        if(nowNode->key<node){
            nowParent = nowNode;
            nowNode = nowParent -> right;
        }else{
            nowParent = nowNode;
            nowNode = nowNode -> left;
        }
    }
    //Now Creating new Node
    Node *newNode = new Node();
    newNode->key = node;
    newNode->left = newNode->right = NUL;
    //Now Inserting
    if(nowParent==NUL){//empty tree's root node
        root = newNode;
    }else if(node<nowParent->key){
        nowParent->left = newNode;
    }else{
        nowParent->right = newNode;
    }
}

void preOrder(Node *nowNode){
    if(nowNode==NUL) return;
    cout<<' '<<nowNode->key;
    preOrder(nowNode->left);
    preOrder(nowNode->right);
}

void inOrder(Node *nowNode){
    if(nowNode==NUL) return;
    inOrder(nowNode->left);
    cout<<' '<<nowNode->key;
    inOrder(nowNode->right);
}

bool find(int toFind, Node *nowNode){
    //cout<<"-- now finding :"<<nowNode->key<<endl;
    if(nowNode==NUL) return false;
    if(nowNode->key == toFind) return true;
    if(toFind>nowNode->key){
        return find(toFind, nowNode->right);
    }else{
        return find(toFind, nowNode->left);
    }
}

int main(){
    root = NUL;//initial root
    int ope;
    cin>>ope;
    for(int i=0; i<ope; i++){
        string op;
        int toInsert;
        int toFind;
        cin>>op;
        if(op=="print"){
            inOrder(root);
            cout<<endl;
            preOrder(root);
            cout<<endl;
        }else if(op=="insert"){
            cin>>toInsert;
            insert(toInsert);
        }else{
            cin>>toFind;
            if(find(toFind, root)){
                cout<<"yes"<<endl;
            }else{
                cout<<"no"<<endl;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 21808
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

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

    ll L,R;
    cin >> L >> R;
    
    ll ans = 2019;
    for(ll i = L; i <= min(L+2020, R); i++){
        for(ll j = i+1; j <= min(L+2020, R); j++){
            ans = min(ans, i*j % 2019);
        }
    }

    cout << ans << endl;
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
  double r;
  double s,h;
 

  scanf("%lf",&r);

  s = r*r*M_PI;
  h = 2*r*M_PI;


  printf("%lf %lf\n",s,h);


  return 0;

}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
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; }
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

ll gcd(ll a,ll b){
    if(a < b)swap(a, 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;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

//modの値の確認をすること
int main(){
    
    ll x,a;
    cin >> x;
    a = x;
    ll n = 0;
    while (x > 0) {
        n += x % 10;
        x /= 10;
    }
    if(a % n == 0)yes;
    else no;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
#pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
#define plll pair <ll, pair <ll, ll>>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define all(a) a.begin(), a.end()
#define vvl vector <vector <ll> >
 
typedef long long ll;
 
typedef long double ld;
 
using namespace std;
 
const ll maxn = 1e6 + 100;
const ll mod = 998244353;

ll n, m, k, t;

ll st2[maxn];

ll F[maxn];

int main() {
    pyshnapyshnakaa;
    ll q, w, e, a, b, c;
    cin >> n;
    F[0] = 1;
    for (q = 1; q < maxn; q++) {
        F[q] = F[q - 1] * q % mod;
    }
    st2[0] = 1;
    for (q = 1; q < 63; q++) {
          st2[q] = st2[q - 1] * 2;
    }
    n *= 3;
    string s;
    cin >> s;
    vector <ll> A;
    for (q = 0; q < n; q++) {
        // cout << 
        if (s[q] == 'R') {
            A.pb(0);
        }
        if (s[q] == 'B') {
            A.pb(1);
        }
        if (s[q] == 'G') {
            A.pb(2);
        }
    }
    ll ans = 1;
    map <ll, ll> M;
    ll allmsk = st2[3] - 1;
    for (q = 0; q < n; q++) {
        // cout << "Q " << q << endl;
        ll val = A[q];
        if (M[allmsk - st2[val]] != 0) {
            // cout << "CASE 1 " << endl;
            ans *= M[allmsk - st2[val]];
            ans %= mod;
            M[allmsk - st2[val]]--;
            continue;
        }
        bool f = 0;
        for (w = 0; w < 3; w++) {
            if (w == val) {
                continue;
            }
            if (M[st2[w]] != 0) {
                // cout << "CASE 2 " << w << endl;
                ans *= M[st2[w]];
                ans %= mod;
                M[st2[w]]--;
                M[st2[w] + st2[val]]++;
                f = 1;
            }
        }
        if (f) {
            continue;
        }
        // cout << "CASE 3 "<< endl;
        M[st2[val]]++;
    }
    cout << ans * F[n / 3] % mod;
    return 0;
}


Measured memory_bytes: 15664
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main()
{
    unsigned long long int X,Y;
    cin >> X >> Y;
    unsigned long long int ins = X;
    unsigned long long int ans = 1;
    while(true){
        unsigned long long int wo = ins * 2;
        if(wo <= Y){
            ans++;
            ins = ins * 2;
        }else{
            break;
        }
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
int inf=1000001000;
ll INF=1e18;
ll MOD=INF;
ll mod=INF;


int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  int c=1;
  sort(all(a));
  reverse(all(a));
  ll ans=0;
  rep(i,n-1){
      ans+=a[c/2];
      c++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4836
from collections import defaultdict

def factorize(n):
    result = defaultdict(int)
    m = n
    p = 2
    while p*p <= m:
        while n % p == 0:
            n = n // p
            result[p] += 1
        p += 1
    if n > 1:
        result[n] += 1
    return result

n = int(input())
factors = factorize(n)
ans = '{}:'.format(n)
for p, num in factors.items():
    ans += ' {}'.format(p) * num
print(ans)


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

int main()

{
    int n,x,t;
    cin>>n;
    cin>>x;
    cin>>t;

    int vagfol=(n/x);
    int vagshesh=(n%x);
    if(vagfol==0)
    {
        t=t;
    }
    else if (vagfol>0 && vagshesh>0)
    {
      t=(t*(vagfol+1));
    }

    else
    {
        t=t*vagfol;
    }


    cout<<t;


    }



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

#define ll long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//const int MOD = 1e9 + 7;
const int MAX = 2e5 + 1;
int a[MAX];

int main()
{
	//IOS
	int t = 1;
	//cin >> t;
	while(t--)
	{
		int n, k;
		cin >> n >> k;
		for(int i = 1; i <= n; ++i)
		{
			cin >> a[i];
		}
		int st = 1;
		for(int i = k + 1; i <= n; ++i)
		{
			if(a[i] > a[st]) cout << "Yes\n";
			else cout << "No\n";
			st += 1;
		}
	}
	return 0;
}



Measured memory_bytes: 4404
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repm(i, a, n) for (int i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define vd vector<double>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

//最小公倍数
template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

//最大公約数
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

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

int eve(int x)
{
    if (x % 400 == 0)
        return 1;
    if (x % 100 == 0)
        return 0;
    if (x % 4 == 0)
        return 1;
    return 0;
}

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

    ll cnt = 0, n = 0;
    rep(i, 0, s.size())
    {
        if (s[i] == 'S')
            n++;
        else
        {
            if (n > 0)
                cnt++, n--;
        }
    }
    cout << s.size() - 2 * cnt << endl;
}

Measured memory_bytes: 640
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    string fr = "";
    int f = 0;
    int q;
    cin >> q;
    REP(i,q){
        int t;
        cin >> t;
        if(t==1){
            f = 1-f;
        }else{
            int fi;
            char c;
            cin >> fi >> c;
            if((f==0&&fi==1)||(f==1&&fi==2)){
                fr.push_back(c);
            }else{
                s.push_back(c);
            }
        }
    }
    if(f==0){
        int fl = (int)fr.size();
        REP(i,fl){
            cout << fr[fl-1-i];
        }
        cout << s << endl;
    }else{
        int l = (int)s.size();
        REP(i,l){
            cout << s[l-1-i];
        }
        cout << fr << endl;
    }
    return 0;
}

Measured memory_bytes: 980
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

int main(){
    int n,s[200010]={},ans=1000000;
    cin>>n;
    string S;
    cin>>S;
    fr(i,n){
        s[i+1]=s[i];
        if(S[i]=='#') s[i+1]++;
    }
    fr(i,n+1){
        ans=min(ans,s[i]+n-i-s[n]+s[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1412
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;
bool my_compare(pair<ll, ll> a, pair<ll , ll> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
         return a.first < b.first; // 昇順
        //return a.first > b.first; // 降順
    }

    // それ以外はsecondで比較
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        // どちらも同じ
        return true;
    }
}

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

    ll a,b,c,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    ll h,w;
    cin>>h>>w;
   cout<<h-w+1;


    


    return 0;
}


Measured memory_bytes: 3632
from collections import deque
n = int(input())
lst = list(map(int, input().split()))
b = deque()
for i in range(n):
  if i % 2 == 0:
    b.append(lst[i])
  else:
    b.appendleft(lst[i])
b = list(b)
if n % 2 == 1:
  b = b[::-1]
print(' '.join(map(str, b)))

Measured memory_bytes: 39444
#include<iostream>

using namespace std;

int main(){

    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    if(a+b<=2*c){
        cout << a * x + b * y << endl;
    }
    else{
        int ans = 0;
        if (x < y)
        {
            ans += 2 * c * x;
            if(b<2*c){
                ans += (y - x) * b;
            }
            else{
                ans += (y - x) * 2 * c;
            }
        }
        else{
            ans += 2 * c * y;
            if(a<2*c){
                ans += (x - y) * a;
            }
            else{
                ans += (x - y) * 2 * c;
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import copy
import sys
import math

def main():
	n = int(input())
	a = list(map(int,input().split()))
	a.sort()
	tmp = listtodict(a)
	b = {}
	for k,v in tmp.items():
		b[k] = int(v/2)
	b = sorted(b.items(), key=lambda x:x[0])
	w = -1
	for i in reversed(b):
		k=i[0]
		v=i[1]
		if(v>1 and w==-1):
			print(k**2)
			sys.exit()
		elif(v>0 and w==-1):
			w = k
		elif(v>0):
			print(w*k)
			sys.exit()
	print(0)


def listtodict(a):
	b = {}
	for i in a:
		try:
			b[i] += 1
		except:
			b[i] = 1
	return b

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

main()

Measured memory_bytes: 83560
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)














int main(){
    ll h, w;
    cin >> w >> h;
    while(h || w){
        vector<string> s1(h), s2(h);
        ll sy1, sx1, sy2, sx2;
        REP(i, h){
            cin >> s1[i] >> s2[i];
            REP(j, w){
                if(s1[i][j] == 'L'){
                    sy1 = i;
                    sx1 = j;
                }
                if(s2[i][j] == 'R'){
                    sy2 = i;
                    sx2 = j;
                }
            }
        }
        bool memo[50][50][50][50] = {};
        const ll dy[4] = {-1, 0, 1, 0};
        const ll dx[4] = {0, 1, 0, -1};
        queue<pair<pair<ll, ll>, pair<ll, ll>>> que;
        que.push({{sy1, sx1}, {sy2, sx2}});
        bool ok = false;
        while(!que.empty()){
            auto tmp = que.front(); que.pop();
            ll y1 = tmp.first.first, x1 = tmp.first.second;
            ll y2 = tmp.second.first, x2 = tmp.second.second;
            if(memo[y1][x1][y2][x2]) continue;
            memo[y1][x1][y2][x2] = true;
            if(s1[y1][x1] == '%' && s2[y2][x2] == '%'){
                ok = true;
                break;
            }
            else if(s1[y1][x1] == '%' || s2[y2][x2] == '%'){
                continue;
            }
            REP(i, 4){
                ll yy1 = y1 + dy[i], xx1 = x1 + dx[i];
                ll yy2 = y2 + dy[i], xx2 = x2 - dx[i];
                if(yy1 < 0 || yy1 >= h || xx1 < 0 || xx1 >= w || s1[yy1][xx1] == '#'){
                    yy1 -= dy[i];
                    xx1 -= dx[i];
                }
                if(yy2 < 0 || yy2 >= h || xx2 < 0 || xx2 >= w || s2[yy2][xx2] == '#'){
                    yy2 -= dy[i];
                    xx2 += dx[i];
                }
                que.push({{yy1, xx1}, {yy2, xx2}});
            }
        }
        cout << ((ok)? "Yes" : "No") << endl;
        
        cin >> w >> h;
    }
}


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

using namespace std;

struct PART{
  int id, score;
  bool operator < (const PART &right) const {
    return (score != right.score ? score > right.score : id < right.id);
  }
};

int main()
{
  int m;
  while(cin >> m, m){
    PART p[40];
    for(int i = 0; i < m; i++){
      cin >> p[i].id;
      p[i].score = 0;
      int ext = 0;
      int frame = 0;
      bool flag = false;
      while(1){
	int pin = 0;
	for(int k = 0; k < 2 && pin < 10; k++){
	  int x;
	  cin >> x;
	  pin += x;
	  p[i].score += x;
	  if(ext > 0) p[i].score += x, ext--;
	  if(flag) p[i].score += x, flag = false;
	  if(k == 0 && pin == 10){
	    if(ext > 0) ext += 1, flag = true;
	    else ext += 2, flag = false;
	  }
	  else if(k == 1 && pin == 10) ext += 1;
	}
	if(frame == 9 && ext > 0){
	  while(ext--){
	    int x;
	    cin >> x;
	    if(flag) p[i].score += x, flag = false;
	    p[i].score += x;
	  }
	}
	frame++;
	if(frame == 10) break;
      }
    }
    sort(p, p + m);
    for(int i = 0; i < m; i++){
      cout << p[i].id << " " << p[i].score << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;

const int maxn = 2000+10;
int l[maxn][maxn],r[maxn][maxn],u[maxn][maxn],d[maxn][maxn];

int32_t main(){
	IOS
	for(int i=0;i<maxn;i++){
		for(int j=0;j<maxn;j++){
			l[i][j]=r[i][j]=u[i][j]=d[i][j]=0;
		}
	}
	int n,m;
	cin>>n>>m;
	vector<string>s(n+1);
	for(int i=1;i<=n;i++){
		cin>>s[i];s[i]='$'+s[i];
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			u[i][j] = s[i][j]=='#' ? 0 : u[i-1][j]+1;
		}
	}
	for(int i=n;i>=1;i--){
		for(int j=1;j<=m;j++){
			d[i][j] = s[i][j]=='#' ? 0 : d[i+1][j]+1;
		}
	}
	for(int j=1;j<=m;j++){
		for(int i=1;i<=n;i++){
			l[i][j] = s[i][j]=='#' ? 0 : l[i][j-1]+1;
		}
	}
	for(int j=m;j>=1;j--){
		for(int i=1;i<=n;i++){
			r[i][j] = s[i][j]=='#' ? 0 : r[i][j+1]+1;
		}
	}
	int ans = 0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			//bug6(i,j,u[i][j],d[i][j],l[i][j],r[i][j]);
			if(s[i][j]=='.'){
				ans=max(ans,l[i][j]+r[i][j]+u[i][j]+d[i][j]-4+1);
			}
		}
	}
	cout<<ans;
 }
/*
 * long long or int?
 * index out of bound? 
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 133500
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    ll n;
    cin >> n;
    n--;
    ll d = 26;
    while (n >= d) {
        n -= d;
        d *= 26;
    }
    d /= 26;
    string ans;
    while (d > 0) {
        ans += 'a' + n / d;
        n %= d;
        d /= 26;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int value[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int K;
	cin >> K;

	cout << value[K - 1];

	return 0;
}

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

# define ll long long int



const int md = 1e9+7;

ll cn=0;

ll dp[2005];

ll  rec(ll s)
{
   
  if(dp[s]!=-1) return dp[s];

  if(s==0)
  {
    return 1;
  }

  if(s<0) return 0 ;

  ll ans=0;

  for(int i=3;i<=s;i++)
  {
    ans = (ans%md +rec(s-i)%md)%md;
  }

  dp[s] =ans;

  return ans;


}



int main() {

  ll s;
  cin>>s;

  memset(dp,-1,sizeof(dp));

  cout<<rec(s)<<endl;

 
    
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef unsigned long long int lli;
typedef pair<int, int> pi;
#define oset tree<int, null_type,greater<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    lli h;
    cin >> h;
    lli in = log2(h);
    lli po[50];
    po[0] = 1;
    for(int i=1; i<50; i++){
        po[i] = po[i-1]<<1;
    }
    cout << po[in+1]-1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    string s;
    int a;
    cin >> a >> s;
    if(a>=3200) cout<<s<<endl;
    else cout<<"red"<<endl;
    return 0;
}

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


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

  vector<int> A(N + 1);
  vector<bool> ans(N + 1,false);
  int num = 0;
  

  for(int i = 1;i <= N;i++) {
      cin >> A.at(i);
  }

    
  for(int i = N;i >= 1;i--) {
      if(i >= N / 2 + 1) {
          if(A.at(i) == 1) {
              ans.at(i) = true;
              num++;
          }
        }else {
            int m = (N / i) * i,sum = 0;

            while(m > i) {
                if(ans.at(m)) sum++;
                m -= i;
            }

            if(sum % 2 != A.at(i)) {
                num++;
                ans.at(i) = true;
            }
        }
  }

    cout << num << endl;

    for(int i = 1;i <= N;i++) {
      if(ans.at(i)) cout << i << " ";
    }

  

 
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

int main(void) {
	int n, m, kx, ky, x, i;
	cin >> n >> m >> kx >> ky;
	for (i = 0; i < n; i++) {
		cin >> x;
		kx = max(x, kx);
	}
	for (i = 0; i < m; i++) {
		cin >> x;
		ky = min(x, ky);
	}
	if (kx < ky)
		printf("No War\n");
	else
		printf("War\n");
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

def nCr(n, r):
    r = min(r, n-r)
    numerator = 1
    for i in range(n, n-r, -1):
        numerator *= i

    denominator = 1
    for i in range(r, 1, -1):
        denominator *= i

    return numerator // denominator

if N<=1 and M<=1:
    print(0)
elif N<=1:
    print(nCr(M, 2))
elif M<=1:
    print(nCr(N, 2))
else:
    print(nCr(N, 2) + nCr(M, 2))

Measured memory_bytes: 3064