akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  ll n,k;
  cin >> n >> k;
  ll ans = 0;
  for(ll a = 1;a<=n;a++){
    ll c = n/a;
    ll num = max(0LL,a-k)*c;
    ll amari = n%a;
    ll add = max(0LL,amari-k+1);
    ans+=num+add;
  }
  if(k == 0) ans = n*n;
  print(ans);
  return 0;
}

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

int main() {
  int n, k = 0, o = 0;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++)
    cin >> a.at(i);
  sort(a.begin(), a.end());
  for(int i = 1; i < n; i++) {
    k++;
    if(a.at(i) != a.at(i - 1)) {
      o += k % 2;
      k = 0;
    }
  }
  o += (k + 1) % 2;
  cout << o << endl;
}

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

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

    ll ans = 0;
    for(int i = 1; i < N; i++)
    {
        ans += (N - 1) / i;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main() {
    int A;
    int B;
    scanf("%d", &A);
    scanf("%d", &B);
    if ((A + B) % 2 != 0) {
        printf("IMPOSSIBLE\n");
        return 0;
    }

    printf("%d\n", (A + B) / 2);

    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().run();

	}
	
	private void run(){
		Scanner scan = new Scanner(System.in);
		int s = 0;
		int t = 0;
		for (int i = 0; i < 4; i++) {
			s += scan.nextInt();
		}
		for (int i = 0; i < 4; i++) {
			t += scan.nextInt();
		}
		System.out.println(Math.max(s, t));
	}

}

Measured memory_bytes: 15328
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define st first
#define nd second
#define pii pair<int,bool>
#define mp make_pair

using namespace std;

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

    string s; cin>>s;
    if(s.back() != 's') s+="s";
    else s+="es";
    cout<<s;

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <bitset>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef complex<double> P;

P syoki, maou;
P houseki[20];
int n;
vector<bool> v;

bool rec(int now, double time) {
  // REP(i,n) {
  //   cout << v[i];
  // }cout << endl;
  // printf("now=%d, time=%f\n",now,time);
  bool ff = 0;
  REP(i,n) {
    if (!v[i]) {
//      cout << i << " " << abs(maou-houseki[i]) << ", " << time+abs(houseki[i]-houseki[now]) << endl;
      if (abs(maou-houseki[i]) <= time+abs(houseki[i]-houseki[now])) {
        return false;
      }
      ff = 1;
    }
  }
  if (!ff) {                    // ツ全ツ閉板づづつス
    return true;
  }

  REP(i,n) {
    if (!v[i]) {
      v[i] = 1;
      if (rec(i, time+abs(houseki[i]-houseki[now])))
        return true;
      v[i] = 0;
      ff = 1;
    }
  }
}

int main() {
  int hx,hy,dx,dy;
  while(cin>>n>>hx>>hy>>dx>>dy,n||hx||hy||dx||dy) {
    syoki = P(hx,hy);
    maou = P(dx,dy);
    REP(i,n) {
      double x,y;
      cin >> x >> y;
      houseki[i] = P(x,y);
    }
    v = vector<bool>(n);
    bool f = 0;
    REP(i,n) {
      v[i] = 1;
      if (abs(houseki[i]-syoki) < abs(houseki[i]-maou))
        if (rec(i, abs(houseki[i]-syoki))) {
          f = 1;
          break;
        }
      v[i] = 0;
    }
    if (f)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
      
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;

int main() {

  int n, k;
  cin >> n >> k;
  cout << ((n+1)/2 >= k ? "YES" : "NO") << endl;

  return 0;
}


//EOF


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <string>
#include <deque>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <assert.h>
#include <sstream>
typedef long long ll;
#define vi vector<int>
using namespace std;

int dX[4] = { 0, 0, -1, 1 };
int dY[4] = { -1, 1, 0, 0 };
int R, C, sr, sc, tr, tc;
int main() {
	cin >> R >> C;
	cin >> sr >> sc;
	cin >> tr >> tc;
	sr--; sc--; tr--; tc--;
	vector<string> grid(R);
	for (int r = 0; r < R; r++) {
		cin >> grid[r];
	}
	vector<vi> dist(R, vi(C, 1e9));
	dist[sr][sc] = 0;
	deque<vi> dq;
	dq.push_back({ 0, sr, sc });
	while (!dq.empty()) {
		vi curr = dq.front();
		dq.pop_front();
		if (curr[0] > dist[curr[1]][curr[2]]) continue;
		for (int i = 0; i < 4; i++) {
			int nr = curr[1] + dX[i];
			int nc = curr[2] + dY[i];
			if (nr < 0 || nr >= R || nc < 0 || nc >= C || grid[nr][nc] == '#' || dist[nr][nc] <= curr[0]) continue;
			dist[nr][nc] = curr[0];
			dq.push_front({ curr[0], nr, nc });
		}
		for (int nr = curr[1] - 2; nr <= curr[1] + 2; nr++) {
			for (int nc = curr[2] - 2; nc <= curr[2] + 2; nc++) {
				if (nr < 0 || nr >= R || nc < 0 || nc >= C || grid[nr][nc] == '#' || dist[nr][nc] <= curr[0] + 1) continue;
				dist[nr][nc] = curr[0] + 1;
				dq.push_back({ curr[0] + 1, nr, nc });
			}
		}
	}
	if (dist[tr][tc] == 1e9) {
		cout << -1 << '\n';
	}
	else {
		cout << dist[tr][tc] << '\n';
	}
}

Measured memory_bytes: 10088
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE
vector< int > divisor(int n) {
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
} 
  

void solve(void)
{
  int N;cin>>N;
  auto div = divisor(N);
  int ANS = INF;
  for (auto &&x : div)
  {
    chmin(ANS,max(to_string(x).size(),to_string(N/x).size()));
  }
  cout<<ANS<<endl;
  

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
int X[N][N];

void initialize();
void print();
void succ(int);

int main(){
    int k,r,c;
    initialize();
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            X[i][j]=0;
        }
    }
    scanf("%d",&k);
    for(int i=0;i<k;i++){
       scanf("%d%d",&r,&c);
       X[r][c]=1;
    }
    succ(0);

    return 0;
}
void initialize(){
    for(int i=0;i<N;i++){
        row[i]=FREE; col[i]=FREE; }
    for(int i=0;i<2*N-1;i++){
        dpos[i]=FREE; dneg[i]=FREE; }   
}

void print(){
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(X[i][j]){
                if(row[i]!=j) return;
            }
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            printf("%c",row[i]==j?'Q':'.');
        }
        printf("\n");
    }
}

void succ(int i){
    if(i==N){
        print();
        return;
    }
   for(int j=0;j<N;j++){
       if(NOT_FREE==col[j] ||
          NOT_FREE==dpos[i+j] ||
          NOT_FREE==dneg[i-j+N-1]) continue;
          row[i]=j;col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
          succ(i+1);
          row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
   }
}



Measured memory_bytes: 2104
import copy

def bfs(x, y):
    global tmp
    global cnt
    dx = [-1, 0, 1, 0]
    dy = [0, -1, 0, 1]
    for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]
        if 0 <= nx < h and 0 <= ny < w and maze[nx][ny] == ".":
            tmp.append((nx, ny))
            maze[nx][ny] = "#"
            cnt += 1
    return tmp

h, w = map(int, input().split())
maze = [list(input()) for i in range(h)]
ans = 0
cnt = 0
tmp = []
for i in range(h):
    for j in range(w):
        if maze[i][j] == "#":
            tmp.append((i, j))
            cnt += 1

while cnt < h * w:
    tmp_ = copy.copy(tmp)
    tmp = []
    while tmp_:
        p = tmp_.pop()
        bfs(p[0], p[1])
    ans += 1
print(ans)

Measured memory_bytes: 136056
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

const double PI=3.141592653589793238462643383279502884L;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int r;
    cin >> r;
    cout << setprecision(12) << PI*r*2 << endl;
    return 0;
}

Measured memory_bytes: 3828
import string
S = input()
ans = [False,False,False]
if S[0] == 'A':
    ans[0] = True
if 'C' in S[2:-1]:
    ans[1] = True
if ans[0] == True and ans[1] == True and list(S).count('C') == 1:
    x = list(S)
    del x[0]
    x.remove('C')
    for i in range(len(x)):
        if x[i] not in list(string.ascii_lowercase):
            break
        if i == len(x) -1:
            ans[2] = True
if ans[0] and ans[1] and ans[2]:
    print('AC')
else:
    print('WA')

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
	int N;
	cin >> N;
	int AC = 0;
	int WA = 0;
	int TLE = 0;
	int RE = 0;
	for(int i=0; i<N; ++i){
		string S;
		cin >> S;
		if(S=="AC") ++AC;
		else if(S=="WA") ++WA;
		else if(S=="TLE") ++TLE;
		else ++RE;
	}
	cout << "AC x " << AC << endl;
	cout << "WA x " << WA << endl;
	cout << "TLE x " << TLE << endl;
	cout << "RE x " << RE << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
using namespace std;

int getMaxKByO(const vector<int>& counts, const vector<int>& sums, int O) {
    auto pos = lower_bound(counts.begin(), counts.end(), O);
    int pos_idx = pos - counts.begin();
    if (pos_idx == 0) {
        return counts.size();
    } else {
        return counts.size() - pos_idx + sums[pos_idx - 1] / O;
    }
}

int getMaxO(const vector<int>& counts, const vector<int>& sums, int N, int K) {
    int lo_o = 0;
    int hi_o = N / K;
    if (getMaxKByO(counts, sums, hi_o) >= K) {
        return hi_o;
    }

    while (lo_o + 1 < hi_o) {
        int mid_o = (lo_o + hi_o) / 2;
        if (getMaxKByO(counts, sums, mid_o) >= K) {
            lo_o = mid_o;
        } else {
            hi_o = mid_o;
        }
    }
    return lo_o;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    unordered_map<int, int> num_count;
    int max_count = 0;
    for (int num : A) {
        num_count[num] += 1;
        max_count = max(max_count, num_count[num]);
    }

    vector<int> counts;
    counts.reserve(num_count.size());
    for (auto it = num_count.begin(); it != num_count.end(); ++it) {
        counts.push_back(it->second);
    }
    sort(counts.begin(), counts.end());
    vector<int> sums(counts.size());
    for (int i = 0; i < sums.size(); ++i) {
        sums[i] = i == 0 ? counts[i] : counts[i] + sums[i - 1];
    }
    
    for (int K = 1; K <= N; ++K) {
        cout << getMaxO(counts, sums, N, K) << endl;
    }
}

Measured memory_bytes: 18396
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1]))
  member this.Scan3 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2]))
  member this.Scan4 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2], a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = [| for i in 1..n -> stream.ReadLine() |> f |]
  member this.ScanMatrix n f  = [ for i in 1..n do yield stream.ReadLine().Split() |> Array.map f ]
  member this.ScanCharMatrix n = [ for i in 1..n -> stream.ReadLine().ToCharArray() ]
  member this.Close () = stream.Close()

let util = ABC(stdin)

let N, Q = util.Scan2 int
let S = util.Scan1 id
let qs = util.ScanMatrix Q int

let M = S
        |> Seq.pairwise
        |> Seq.scan (fun a -> fun cp -> a + (if cp = ('A','C') then 1 else 0)) 0
        |> Seq.toArray
qs
|> List.map (fun q ->
    sprintf "%d" (M.[q.[1]-1] - M.[q.[0]-1]))
|> String.concat "\n"
|> printfn "%s"


Measured memory_bytes: 38168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi = 3.1415926;
const ll mod = 1e9+7;
const int N = 200000 + 5;
int a[N];

int main()
{
	int n,k;
	cin >> n >> k;
	ll sum=0,z1=0,z2=n,t1=1,t2=n-1;
	for(int i = k; i <= n + 1; i++){
		while(t1 < i){
			z1 = (z1 + t1) % mod;
			z2 = (z2 + t2) % mod;
			t1++;
			t2--;
		}
		sum = (sum + z2 + mod - z1 + 1) % mod;
	}
	cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
N,D=map(int,input().split())
X=[]
for k in range(N):
    X.append(list(map(int,input().split())))

e=10**(-10)
count=0
for i in range(N-1):
    for j in range(i+1,N):
        #print(X[i],X[j])
        tmp=0
        for d in range(D):
            tmp+=(X[i][d]-X[j][d])**2
        tmp=tmp**(1/2)

        if (tmp-tmp//1)<e:
            count+=1

print(count)



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

typedef long long ll;

int main(void) {
	ll N;
	int K;
	cin >> N >> K;

	ll p = (ll)1;
	int dig = 1;
	while (true) {
		p *= K;
		if (p > N)
			break;
		++dig;
	}

	cout << dig << '\n';
	return 0;
}


Measured memory_bytes: 256
import sys

p=10**9+7
dthbit=lambda d,n: (n>>d)&1

def main(n):
    dp=[[0 for _ in range(3)] for _ in range(64)]
    dp[63][0]=1
    for d in range(62,-1,-1):
        b=dthbit(d,n)
        s=dp[d+1][:]
        dp[d][0]=dp[d+1][0]+(1^b)*dp[d+1][1] % p
        dp[d][1]=b*dp[d+1][0]+dp[d+1][1] % p
        dp[d][2]=(1+b)*dp[d+1][1]+3*dp[d+1][2] % p
    return sum(dp[0][:]) % p

n=int(input())
print(main(n))


Measured memory_bytes: 9176
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BChocolate solver = new BChocolate();
        solver.solve(1, in, out);
        out.close();
    }

    static class BChocolate {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt(), d = in.nextInt();
            long ans = in.nextLong()
                    + IntStream.range(0, n)
                    .map(x -> divceil(d, in.nextInt()))
                    .sum();
            out.println(ans);
        }

        public int divceil(int a, int b) {
            return (a + b - 1) / b;
        }

    }
}



Measured memory_bytes: 30292
object Main extends App {
	val k = scala.io.StdIn.readLine.split(" ")
	
	def test(x: String): Int = {
		x match {
			case "A" => 10
			case "B" => 11
			case "C" => 12
			case "D" => 13
			case "E" => 14
			case "F" => 15
			case _ => 0
		}
	}

	if(test(k(0)) == test(k(1))){
		println("=")
	}else if(test(k(0)) > test(k(1))){
		println(">")
	}else{
		println("<")
	}

}


Measured memory_bytes: 27204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n, m, c, ans = 0;
	cin >> n >> m >> c;

	vector<int> b(m);
	for(int i=0;i<m;i++) cin >> b.at(i);
	for(int i=0;i<n;i++){
		int sum = 0;
		for(int j=0;j<m;j++){
			int a;
			cin >> a;
			sum += b.at(j) * a;
		}
		if(sum+c>0) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8


def solve(*args: str) -> str:
    k = int(args[0])
    a, b = map(int, args[1].split())

    return 'OK' if -(-a//k)*k <= b else 'NG'


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


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

int main(){
  int a;
  cin>>a;
  if(a%10==2 || a%10==4 || a%10==5 || a%10==7 || a%10==9){
    cout<<"hon"<<endl;
  }else if(a%10==0 || a%10==1 || a%10==6 || a%10==8){
    cout<<"pon"<<endl;
  }else{
    cout<<"bon"<<endl;
  }
}

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

int main(){
   LL n;
   cin>>n;
   LL a[n];
   for(LL i=0;i<n;i++){
    cin>>a[i];
   }
   LL dp[n];
   memset(dp,0,sizeof(dp));
   dp[1]=abs(a[1]-a[0]);
   for(LL i=2;i<n;i++){
    dp[i]=min((abs(a[i]-a[i-1])+dp[i-1]),(abs(a[i]-a[i-2])+dp[i-2]));
   }

   cout<<dp[n-1]<<endl;
}

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

const ll MAXN = 1e18;
vector<pair<ll, ll>> points;

int main() {
	int n;
	cin >> n;
	for(int i=0; i<n; i++) {
		ll a, b;
		cin >> a >> b;
		points.push_back({a, b});
	}
	ll smallest = MAXN, biggest = -MAXN;
	for(int i=0; i<n; i++) {
		smallest = min(smallest, points[i].first+points[i].second);
		biggest = max(biggest, points[i].first+points[i].second);
	}
	ll ans = abs(biggest-smallest);
	smallest = MAXN, biggest = -MAXN;
	for(int i=0; i<n; i++) {
		smallest = min(smallest, points[i].first-points[i].second);
		biggest = max(biggest, points[i].first-points[i].second);
	}
	ans = max(ans, abs(biggest-smallest));
	cout << ans << endl;
}

Measured memory_bytes: 7440
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

vector<int> A;
int n;

int main(){
    cin >> n;
    A.resize(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }

    int all = A[0];
    for(int i = 1; i < n; i++)all = all ^ A[i];

    for(int i = 0; i < n; i++){
        int as = all ^ A[i];
        cout << as;
        if (i < n-1)cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3672
import sys
input = sys.stdin.readline

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            if L[i] != L[j] and L[j] != L[k] and L[k] != L[j] and L[i] + L[j] > L[k]:
                ans += 1
print(ans)


Measured memory_bytes: 68048
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

char arr[2001][2001];
int u[2001][2001], d[2001][2001], l[2001][2001], r[2001][2001];

int main(){
    int m = 0;
    int h, w;
    cin >> h >> w;
    for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) cin >> arr[i][j];
    for(int j = 0; j < w; j++) u[0][j] = (arr[0][j] == '#' ? 0 : 1);
    for(int i = 0; i < h; i++) l[i][0] = (arr[i][0] == '#' ? 0 : 1);
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(arr[i][j] == '#') l[i][j] = u[i][j] = 0;
            else {
                if(j != 0) l[i][j] = l[i][j-1] + 1;
                if(i != 0) u[i][j] = u[i-1][j] + 1;
            }
        }
    }
    for(int j = 0; j < w; j++) d[h-1][j] = (arr[h-1][j] == '#' ? 0 : 1);
    for(int i = 0; i < h; i++) r[i][w-1] = (arr[i][w-1] == '#' ? 0 : 1);
    for(int i = h-1; i >= 0; i--){
        for(int j = w-1; j >= 0; j--){
            if(arr[i][j] == '#') r[i][j] = d[i][j] = 0;
            else {
                if(j != w-1) r[i][j] = r[i][j+1] + 1;
                if(i != h-1) d[i][j] = d[i+1][j] + 1;
            }
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(arr[i][j] != '#') m = max(m, u[i][j] + d[i][j] + r[i][j] + l[i][j]);
        }
    }
    cout << (m == 0 ? 0 : m - 3) << '\n';
}


Measured memory_bytes: 66816
program prob3
    implicit none
    integer :: N, i, ans
    integer, allocatable :: a(:)
    read(*,*) N
    allocate(a(N))
    read(*,*) a
    ans = 0
    do i = 1, N
        if(a(a(i)) == i)then
            ans = ans + 1
        end if
    end do
    ans = ans / 2
    write(*,*) ans



    deallocate(a)

    stop
contains
end program prob3

Measured memory_bytes: 3468
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int H,W;
    cin >> H >> W;
    int C[10][10] = {};
    int cnt[10] = {};//0~9のカウント
    for(int i = 0;i < 10;i++){
        for(int j = 0;j < 10;j++){
            cin >> C[i][j];
        }
    }
    for(int i = 0;i < 10;i++){
        for(int j = 0;j < 10;j++){
            for(int k = 0;k < 10;k++){
                C[j][k] = min(C[j][k], C[j][i] + C[i][k]);
            }
        }
    }
    for(int i = 0;i < H*W;i++){
        int a;
        cin >> a;
        if(a >= 0)cnt[a]++;
    }
    int sum = 0;
    for(int i = 0;i < 10;i++){
        sum += C[i][1] * cnt[i];
    }
    cout << sum << endl;
}

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

int main(){
  int N, mod= 1e9+7;
  cin >> N;
  vector<ll> vec(N);
  for(int i=0; i<N; ++i){
    cin >> vec.at(i);
  }
  ll ans=0;
  for(int i=0; i<60; ++i){
    ll x=0;
    for(int j=0; j<N; ++j){
      if(vec.at(j)>>i&1) ++x;
    }
    ll now= x*(N-x)%mod;
    for(int j=0; j<i; ++j){
      now = now * 2 %mod;
    }
    ans += now;
    ans %= mod;
  }
  cout << ans << endl;
}

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

int main()
{
    string s; cin >> s;
    bool flag = true;
    for (int i = 0; i < s.length(); i++) {
        if (i % 2 == 0 && s[i] == 'L') flag = false;
        if (i % 2 == 1 && s[i] == 'R') flag = false;
    }
    cout << ((flag) ? "Yes" : "No") << endl;
    return 0;
}

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

int main(){
  ll S;
  cin >> S;
  ll X,Y;
  ll Q = 1000000000;
  if(S%Q==0){
    cout << "0 0 1000000000 1 0 " << S/Q << endl;
    return 0;
  }else{
    cout << "0 0 1000000000 1 " << (Q-S%Q) << " " << S/Q+1 << endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
#define MAX_N 100010

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

// Input
int N;
long long a[MAX_N][3];

// DP table
long long dp[MAX_N][3];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) for (int j = 0; j < 3; j++) cin >> a[i][j];

    // Initialization
    // for (int i = 0; i < N; i++) for (int j = 0; j < 3; j++) dp[i][j] = 0LL;
    
    // Initial state
    // ~~~

    // Update
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j == k) continue;
                chmax(dp[i+1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    // Answer
    long long res = 0;
    for (int j = 0; j< 3; j++) chmax(res, dp[N][j]);
    cout << res <<endl;
}


Measured memory_bytes: 4992
n=int(input())
a=[-int(j) for j in input().split()]
a.sort()
import heapq
l=[a[0]]
heapq.heapify(l)
ans=0
for i in a[1:]:
    heapq.heappush(l,i)
    heapq.heappush(l,i)
    p=heapq.heappop(l)
    ans-=p
print(ans)

Measured memory_bytes: 31612
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<string> vs;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

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

	string S; cin >> S;

	regex re("A[A-Z]*Z");
	smatch match;
	regex_search(S, match, re);
	string t = match[0];

	int ans = t.size();
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 88212
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 5*1e5;

int main() {
    int x, a, b; cin >> x >> a >> b;
    x -= a;
    cout << x-x/b*b << endl;
}

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

const int DIM = 2e5 + 5;

int arr[DIM];

int main( void ) {
    
    int n, t;
    cin >> n >> t;
    
    int ans = 0;
    for( int i = 1; i <= n; i ++ ) {
        cin >> arr[i];
        
        if( i == 1 )
            ans += t;
        else
            ans += t - max( arr[i - 1] + t - arr[i], 0 );
    }
    
    cout << ans;
    return 0;
}

Measured memory_bytes: 1024
//

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int n, m, c;

int main() {
    cin >> n >> m >> c;
    int b[m];
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    int count = 0;
    for (int i = 0; i < n; i++) {
        int sum = c;
        for (int j = 0; j < m; j++) {
            int a_j;
            cin >> a_j;
            sum += a_j * b[j];
        }
        if (sum > 0) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


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

int main()
{
    int A, B, C;
    size_t K;
    cin >> A >> B >> C >> K;
    // A < B < C
    size_t count = 0;
    while (A >= B)
    {
        B *= 2;
        count++;
    }
    while (B >= C)
    {
        C *= 2;
        count++;
    }
    if (count <= K)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

bool U[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    vector<pll> ans;
    if (N % 2 == 1) {
        REP(i, M) {
            ans.push_back(pll(i + 1, N - 1 - i));
        }
    }
    else {
        ll es = 1, os = N;
        for (ll m = M; m > 0; --m) {
            if (m % 2 == 0) {
                ans.push_back(pll(es, es + m));
                es++;
            }
            else {
                ans.push_back(pll(os, os - m));
                os--;
            }
        }
    }

    REP(i, ans.size()) {
        cout << ans[i].first << " " << ans[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 5328
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x) { return mrand() % x; }
ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a%mod; a = a * a%mod; }return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
// head

const int MAXN = 200000 + 5;
int N;
int a[MAXN], b[MAXN];
vi G[MAXN];
//set<int> GDis3[MAXN];
int label[MAXN];
int rbnum[2];

void dfs(int from, int color)
{
	label[from] = color;
	rbnum[color]++;
	for (int to : G[from]) {
		if (label[to] == -1) {
			dfs(to, color ^ 1);
		}
	}
}

//#define DDD
int main()
{
	cin >> N;
	rep(i, 0, N-1)
	{
		cin >> a[i] >> b[i];
		G[a[i]].push_back(b[i]);
		G[b[i]].push_back(a[i]);
	}

	memset(label, -1, sizeof(label));
	dfs(1, 0);
	
	int xorbit = 0;
	if (rbnum[0] > rbnum[1]) xorbit = 1;

	int mod3_0 = 3;
	int mod3_1 = 1;
	int mod3_2 = 2;

	if (rbnum[0 ^ xorbit] <= N / 3) {
		rep(i, 1, N + 1)
		{
			if (label[i] ^ xorbit == 0) {
				label[i] = mod3_0;
				mod3_0 += 3;
			}
			else {
				if (mod3_1 <= N) {
					label[i] = mod3_1;
					mod3_1 += 3;
				} else if (mod3_2 <= N) {
					label[i] = mod3_2;
					mod3_2 += 3;
				}
				else {
					label[i] = mod3_0;
					mod3_0 += 3;
				}
			}
		}
	}
	else {
		rep(i, 1, N + 1)
		{
			if (label[i] ^ xorbit == 0) {
				if (mod3_1 <= N) {
					label[i] = mod3_1;
					mod3_1 += 3;
				}
				else {
					label[i] = mod3_0;
					mod3_0 += 3;
				}
			}
			else {
				if (mod3_2 <= N) {
					label[i] = mod3_2;
					mod3_2 += 3;
				}
				else {
					label[i] = mod3_0;
					mod3_0 += 3;
				}
			}
		}
	}

	rep(i, 1, N + 1)
	{
		if (i > 1) cout << " ";
		cout << label[i];
	}
	cout << endl;
	
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n){
        cin >> a[i];
    }
    ll ans = 0;
    for(int i = 1; i < n; i++){
        if(a[i-1] > a[i]){
            ans += a[i-1] - a[i];
            a[i] = a[i-1];
        }
    }
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 4836
N, M = [int(i) for i in input().split()]

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

def cmb(n, r):
    N, R = n, r
    for i in range(1, r):
        N *= n - i
        R *= r - i
    return N // R

from collections import Counter
A = Counter(prime_decomposition(M))

mod = 10 ** 9 + 7
result = 1
for a in A.values():
    result = result * cmb(a + N - 1, a) % mod

print(result)

Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
#include <vector>
#include<cmath>
#include<iomanip>
#include<queue>
using namespace std;
typedef long long int lont;
int main() {
	int N; 
	cin >> N;
	vector<int>vecb(N - 1);
	for (int ia = 0; ia < N - 1; ia++) {
		cin >> vecb.at(ia);
	}
	vector<int>veca(N);
	veca.at(0) = vecb.at(0);
	veca.at(N - 1) = vecb.at(N - 2);
	for (int ib = 0; ib < N - 2; ib++) {
		veca.at(ib + 1) = min(vecb.at(ib),vecb.at(ib + 1));
	}
	int sum = 0;
	for (int ic = 0; ic < N; ic++) {
		sum += veca.at(ic);
	}
	cout << sum << endl;
}



	


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

#define all(v) v.begin(), v.end()
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;

int main() {
    string s; cin >> s;
    deque<int> d;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '0') d.push_back(0);
        if(s[i] == '1') d.push_back(1);
        if(s[i] == 'B'){
            if(d.size() == 0) continue;
            else d.pop_back();
        }
    }
    for(int i = 0; i < d.size(); i++){
        cout << d[i];
    }
    cout << endl;
}


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

using i64 = int64_t;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> v;
    for(int i=0;i<n;++i){
        int h;
        cin >> h;
        v.push_back(h);
    }
    sort(v.rbegin(), v.rend());
    i64 ans = 0;
    for(int i=k;i<n;++i){
        ans += v[i];
    }

    cout << ans << endl;

    return 0;
}

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

long long GCD(long long A, long long B) {
	if (B == 0) return A;
	return GCD(B, A % B);
}

long long LCM(long long A, long long B) {
	return A * (B / GCD(A, B));
}

int main() {
	long long N, A, L = 1;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A;
		L = LCM(L, A);
	}
	cout << L << endl;
}


Measured memory_bytes: 3120
N = int(input())
S = input()

r = [0 for _ in range(N + 1)]
g = [0 for _ in range(N + 1)]
b = [0 for _ in range(N + 1)]

for i in reversed(range(N)):
    r[i] = r[i + 1]
    g[i] = g[i + 1]
    b[i] = b[i + 1]
    if S[i] == "R":
        r[i] += 1
    if S[i] == "G":
        g[i] += 1
    if S[i] == "B":
        b[i] += 1
        
ans = 0

for i in range(N):
    if S[i] == "R":
        for j in range(i + 1, N):
            if S[j] == "G":
                if 2 * j - i < N:
                    if S[2 * j - i] == "B":
                        ans += (b[j + 1] - 1)
                    else:
                        ans += b[j + 1]
                else:
                    ans += b[j + 1]
                    
for i in range(N):
    if S[i] == "R":
        for j in range(i + 1, N):
            if S[j] == "B":
                if 2 * j - i < N:
                    if S[2 * j - i] == "G":
                        ans += (g[j + 1] - 1)
                    else:
                        ans += g[j + 1]
                else:
                    ans += g[j + 1]
                    
for i in range(N):
    if S[i] == "B":
        for j in range(i + 1, N):
            if S[j] == "R":
                if 2 * j - i < N:
                    if S[2 * j - i] == "G":
                        ans += (g[j + 1] - 1)
                    else:
                        ans += g[j + 1]
                else:
                    ans += g[j + 1]
                    
for i in range(N):
    if S[i] == "B":
        for j in range(i + 1, N):
            if S[j] == "G":
                if 2 * j - i < N:
                    if S[2 * j - i] == "R":
                        ans += (r[j + 1] - 1)
                    else:
                        ans += r[j + 1]
                else:
                    ans += r[j + 1]
                    
for i in range(N):
    if S[i] == "G":
        for j in range(i + 1, N):
            if S[j] == "R":
                if 2 * j - i < N:
                    if S[2 * j - i] == "B":
                        ans += (b[j + 1] - 1)
                    else:
                        ans += b[j + 1]
                else:
                    ans += b[j + 1]
                    
for i in range(N):
    if S[i] == "G":
        for j in range(i + 1, N):
            if S[j] == "B":
                if 2 * j - i < N:
                    if S[2 * j - i] == "R":
                        ans += (r[j + 1] - 1)
                    else:
                        ans += r[j + 1]
                else:
                    ans += r[j + 1]
                    
print(ans)

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

#define llong long long
#define inf 999999999
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<PP, int> PPP;
typedef struct data{
	int now;
	int cost;
}data;
int nh[4] = {1, 0, -1, 0};
int nw[4] = {0, 1, 0, -1};





int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a + b < c) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<int, ll> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
const ll MAXN = 1003;

int n, m, a, b;
int ans[MAXN][MAXN];
/********** Good Luck :) **********/
int main () {
    TIME(main);
    IOS();
    cin >> n >> m >> a >> b;
    
    REP (i, b) {
        REP (j, a) {
            ans[i][j] = true;
        }
    }
    for (int i=b; i<n; i++) {
        for (int j=a; j<m;j++) {
            ans[i][j] = true;
        }
    }

    REP (i, n) {
        REP (j, m) {
            cout << ans[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
using namespace std;
#define ll long long

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

	ll N; cin >> N;

	ll ans = 0;
	for (ll i = 1; i <= N; i++)
		ans += (i + N / i * i) * (N / i) / 2;

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
const char newl = '\n';
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
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; }
const long long INF = 1LL<<60;

int main(){
    string s,t;cin >> s >> t;
    t.erase(t.size()-1);
    if(s==t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <queue>
#include <algorithm>
#include <limits>

constexpr size_t NMAX = 100001;
constexpr size_t SIZE_T_MAX = std::numeric_limits<size_t>::max();
//size_t YEN[NMAX][NMAX];
/*
size_t SNUKE[NMAX][NMAX];

size_t YEN_FROM_S[NMAX];
*/

size_t N, M, S, T;


struct Node {
    size_t to, yen, snuke;
};

struct PQNode {
    PQNode(size_t v, size_t cost) : v(v), cost(cost) {}
    size_t v;
    size_t cost;
    bool operator>(const PQNode &rhs) const {
        return cost > rhs.cost;
    }
};

int main()
{
    std::multimap<size_t, Node> connections;
    std::cin >> N >> M >> S >> T;
    for (size_t i = 1; i <= M; i++) {
        size_t u, v, a, b;
        std::cin >> u >> v >> a >> b;
        /*
        YEN[u][v] = YEN[v][u] = a;
        SNUKE[u][v] = SNUKE[v][u] = b;
        */
        connections.emplace(u, Node{v, a, b});
        connections.emplace(v, Node{u, a, b});
    }


    std::vector<size_t> min_yen(N + 1, SIZE_T_MAX);
    std::priority_queue<PQNode, std::vector<PQNode>, std::greater<PQNode>> q;
    q.emplace(S, 0);
    bool init = true;

    while (!q.empty()) {
        auto node = q.top(); q.pop();
        if (init || node.cost < min_yen[node.v] ) {
            init = false;
            min_yen[node.v] = node.cost;

            auto es = connections.equal_range(node.v);
            for (auto it = es.first; it != es.second; ++it) {
                size_t v = it->second.to;
                size_t yen = it->second.yen;
                if (min_yen[v] >= yen + min_yen[node.v]) {
                    q.emplace(v, yen + min_yen[node.v]);
                }
            }
        }

    }


    std::vector<size_t> min_snuke(N+1, SIZE_T_MAX);
    q.emplace(T, 0);
    init = true;
    while (!q.empty()) {
        auto node = q.top(); q.pop();
        if (init || node.cost < min_snuke[node.v] ) {
            init = false;
            min_snuke[node.v] = node.cost;

            auto es = connections.equal_range(node.v);
            for (auto it = es.first; it != es.second; ++it) {
                size_t v = it->second.to;
                size_t snuke = it->second.snuke;
                if (min_snuke[v] >= snuke + min_snuke[node.v]) {
                    q.emplace(v, snuke + min_snuke[node.v]);
                }
            }
        }

    }


    std::vector<size_t> cost(N+1, SIZE_T_MAX);
    for (size_t i = 1; i <= N; i++) {
        cost[i] = min_snuke[i] + min_yen[i];
    }
    std::vector<size_t> min_cost(N+1, SIZE_T_MAX);
    size_t min = SIZE_T_MAX;
    for (size_t i = N; i >= 1; i--) {
        min = std::min(cost[i], min);
        min_cost[i] = min;
    }
    for (size_t i = 1; i <= N; i++) {
        uint64_t init_yen = 1000000000000000;
        std::cout << init_yen - min_cost[i] << std::endl;
    }



    return 0;
}


Measured memory_bytes: 21108
#include<bits/stdc++.h>
#define ll long long
#define uint unsigned
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
using namespace std;
int n,e[505][505];
void divide(int l,int r,int d){
	if (l==r) return;
	int mid=(l+r)/2;
	divide(l,mid,d+1);
	divide(mid+1,r,d+1);
	For(i,l,mid) For(j,mid+1,r) e[i][j]=d;
}
int main(){
	scanf("%d",&n);
	divide(1,n,1);
	For(i,1,n-1){
		For(j,i+1,n) printf("%d ",e[i][j]);
		puts("");
	}
}

Measured memory_bytes: 1536
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while (run(sc)) {
    }
  }
  public static boolean run(Scanner sc) {
    int w = sc.nextInt();
    int h = sc.nextInt();
    if (w + h == 0) {
      return false;
    }
    int sy = 0;
    int sx = 0;
    int ey = h - 1;
    int ex = w - 1;
    int[][] map = new int[h][w];
    map[sy][sx] = 1;
    boolean[][][][] wall = new boolean[h][w][h][w];
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w - 1; j++) {
        wall[i][j][i][j + 1] = wall[i][j + 1][i][j] = sc.nextInt() == 1;
      }
      if (i == h - 1) {
        continue;
      }
      for (int j = 0; j < w; j++) {
        wall[i + 1][j][i][j] = wall[i][j][i + 1][j] = sc.nextInt() == 1;
      }
    }
    Queue<Integer> queueX = new ArrayDeque<>();
    Queue<Integer> queueY = new ArrayDeque<>();
    queueX.add(sx);
    queueY.add(sy);
    int[] vec = new int[]{0, 1, 0, -1, 0};
    while (!(sx == ex && sy == ey)) {
      // System.out.println(p);
      for (int i = 0; i < 4; i++) {
        int nx = vec[i] + sx;
        int ny = vec[i + 1] + sy;
        if (nx < 0 || w <= nx || ny < 0 || h <= ny || map[ny][nx] != 0) {
          continue;
        }
        if (wall[sy][sx][ny][nx]) {
          continue;
        }
        map[ny][nx] = map[sy][sx] + 1;
        queueX.add(nx);
        queueY.add(ny);
      }
      if (queueX.size() == 0) {
        break;
      }
      sx = queueX.poll();
      sy = queueY.poll();
    }
    System.out.println(map[ey][ex]);
    return true;
  }
}

Measured memory_bytes: 102320