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

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

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}

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

int a[205];
signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) cin >> a[i];

  int ans = -100;
  REP(i, 100) {
    bool flag = true;
    REP(j, n) {
      if(a[j]%2) {flag = false; break;}
      a[j] /= 2;
    }
    if(!flag) {ans = i; break;}
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

int main(int argc, char *argv[]){
    int A,B;
    std::cin >> A >> B;
    std::cout << std::max(0,A-2*B) << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 9223372036854775807;
const ll half_inf = 0x3f3f3f3f;
const ll inf = 0x7fffffff;
const ll mod = 1e9 + 7;
const ll maxn = 200005;
int a[50]={0,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 main(){  
	cin.tie(0);
    ios::sync_with_stdio(false);
	int k;
	scanf("%d",&k);
	printf("%d",a[k]);
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    int n, ans = 1;
    string s;
    cin >> n >> s;
    char c = s[0];
    for (int i = 1; i < n; i++)
    {
        if (c != s[i])
        {
            ans++;
            c = s[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

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;}

#define P (1'000'000'007)

signed main() {
    int x, k, d;
    cin >> x >> k >> d;

    x = abs(x);
    int c = x / d;
    if (c >= k) {
        cout << x - d * k;
        return 0;
    }

    x -= (c + (k - c) % 2) * d;
    cout << abs(x);

    return 0;
}

Measured memory_bytes: 3192
#include <stdio.h>
#include <vector>
#include <string.h>

#pragma warning(disable:4996)
int main(void) {
	int a,b;
	scanf("%d %d", &a, &b);
	if (a <= 5) {
		printf("0");
	}
	else if (a <= 12) {
		printf("%d", b / 2);
	}
	else {
		printf("%d", b);
	}
	printf("\n");
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define MOD ((int)(1e9) + 7)
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define filename "lynext"
#define freop freopen(filename ".cik","w",stdout);freopen(filename ".gir","r",stdin)
const long long int N = ((long long int)3e3) + 5;
const long long int M = ((long long int)1e3) + 5;
const long long int llinf = (long long int)1e18;
const int inf = INT_MAX;
typedef long long int lli;

int n;
double arr[N];
double dp[N][N];

double f (int x, int head, int tail)
{
	if (dp[x][head] != -1.0f)
		return dp[x][head];
	if (x > n)
	{
		if (head > tail)
			return 1.0f;
		return 0.0f;
	}
	double t1 = f(x + 1, head + 1, tail) * arr[x];
	double t2 = f(x + 1, head, tail + 1) * (1.0f - arr[x]);
	return dp[x][head] = t1 + t2;
}

int main ()
{
	fast;
	//freop;
	cin >> n;
	for (int i = 0; i <= N - 1; i++)
		for (int j = 0; j <= N - 1; j++)
			dp[i][j] = -1.0f;
	for (int i = 1; i <= n; i++)
	{
		cin >> arr[i];
	}
	cout << std::setprecision(10) << f(1,0,0) << "\n";
}


Measured memory_bytes: 71040
n=int(input())
a=list(map(int,input().split()))
min=10**10
for i in range(n):
    if min>abs(a[i]):
        min=abs(a[i])
cnt=0
for j in range(n):
    if a[j]<0:
        a[j]=abs(a[j])
        cnt+=1
if min==0 or cnt%2==0:
    print(sum(a))
else:
    print(sum(a)-min*2)


Measured memory_bytes: 14284
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	vector<ll> a(n);
	ll sum = 0LL;
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		sum += a[i];
	}
	
	ll ans = 1e18;
	ll m = 0LL;
	for(int i = 0; i < n - 1; ++i) {
		m += a[i];
		ans = min(ans, abs(sum - 2 * m));
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1792
#!/usr/local/bin/ruby
while line=gets
   rec=line.split(" ").map(&:to_i)
   x,y=rec[0].to_i,rec[1].to_i
   s=x*y
   while true
      k = x % y
      x = y
      y = k
      break if k==0
   end
   lcm = s/x
   puts "#{x} #{lcm}"
end

Measured memory_bytes: 6100
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int x, n;
    cin >> x >> n;
    unordered_set<int> v;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        v.insert(t);
    }
    int d = 0;
    while(1) {
        if (v.find(x - d) == v.end()) {
            cout << x - d << endl;
            return 0;
        }
        if (v.find(x + d) == v.end()) {
            cout << x + d << endl;
            return 0;
        }
        d++;
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
int main()
{
    IOS
     // freopen("input.txt","r",stdin);
     // freopen("output.txt","w",stdout);
     // freopen("error.txt","w",stderr);
     ll x,n;
     cin>>x>>n;
     set<ll>p;
     for(ll i=0;i<n;i++)
     {
        ll x;
        cin>>x;
        p.insert(x);
     }
    ll d=1e9+7;
    ll ans=0;
     for(ll i=-100;i<=101;i++)
     {
        ll dval=abs(x-i);
        if(p.count(i))
            continue;
        if(dval<d)
        {
            d=dval;
            ans=i;
        }
     }
     cout<<ans<<endl;
    return 0;
}

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

int H, W, h, w, a[501][501];
long long sum;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> H >> W >> h >> w;
	for(int k1 = 1; h*k1 <= H; k1++)
		for(int k2 = 1; w*k2 <= W; k2++) a[h*k1][w*k2] = -1000*(h*w-1)-1, sum += a[h*k1][w*k2];
	for(int i = 1; i <= H; i++) for(int j = 1; j <= W; j++) if(!a[i][j]) {
		a[i][j] = 1000;
		sum += 1000;
	}
	if(sum <= 0) cout << "No", exit(0);
	cout << "Yes\n";
	for(int i = 1; i <= H; i++, cout << '\n') for(int j = 1; j <= W; j++) cout << a[i][j] << ' ';
}



Measured memory_bytes: 2560
function main(input) {
  var a = Number(input.split(" ")[0]);
  var b = Number(input.split(" ")[1]);
  var c = Number(input.split(" ")[2]);

  var ans = 0;
  if(b>=c){
    ans += c+b;
    c=0;
  }else{
    ans += b*2;
    c-=b, b=0;
  }
  if(c>0){
    var tmp = Math.min(c,a);
    c-=tmp;
    ans+=tmp;
  }
  if(c>0) ans++;
  console.log(ans);


}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

int main(){
    int N;
    cin >> N;
    vector<int> X(N);
    for(int i = 0;i < N;i++){
        cin >> X.at(i);
    }
    int min = 10000000;
    for(int p = 1;p <= 100;p++){
        int total = 0;
        for(int i = 0;i < N;i++){
            total += pow(X.at(i) - p,2);
        }
        if(min > total){
            min = total;
        }
    }
    cout << min << endl;
}

Measured memory_bytes: 256
use std::io;


fn main() {
    let (a, p) = {
        let i = read::<usize>();
        (i[0], i[1])
    };
    println!("{}", (a * 3 + p) / 2);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include"bits/stdc++.h"
// #include "prettyprint.hpp"

using namespace std;

typedef long long ll;


#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, n) for(ll i=n; i>=0; i--)
#define reps(i, s, e) for(ll i=s; i<e; i++)
#define all(x) x.begin(),x.end()

int main(){
	int N,M;

	cin >> N >> M;

	vector<ll> A(N);

	int sum = 0;

	rep(i,N){
		cin >> A[i];

		sum += A[i];
	}

	sort(A.begin(), A.end(), greater<int>());

	if(A[M-1] >= sum/(4.0*M)) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}	

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		final int m = sc.nextInt();
		
		if(n % 2 != 0){
			final int fst = n / 2 + 1;
			final int snd = n / 2;
			
			for(int i = 0; i < fst; i++){
				System.out.print((i == 0 ? "" : " ") + 0);
			}
			for(int i = 0; i < snd; i++){
				System.out.print(" " + m);
			}
			System.out.println();
		}else{
			final int fst = n / 2;
			
			for(int i = 0; i <= fst; i++){
				System.out.print((i == 0 ? "" : " ") + 0);
			}
			for(int i = 0; i < fst - 1; i++){
				System.out.print(" " + m);
			}
			System.out.println();
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

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

int main()
{
  int N, A, n;
  cin >> N >> A;
  n = N % 500;
  if (n <= A)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

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

p = [1]
pb = [1]
np = 0
nx = X

for _ in range(N):
    p.append(p[-1] * 2 + 1)
    pb.append(pb[-1] * 2 + 3)


def dfs(level):
    global np, nx

    if nx == 0:
        return

    if nx >= pb[level]:
        nx -= pb[level]
        np += p[level]
        return

    nx -= 1
    if nx == 0:
        return

    dfs(level - 1)

    if nx == 0:
        return

    nx -= 1
    np += 1

    if nx == 0:
        return

    dfs(level - 1)

    if nx == 0:
        return

    nx -= 1


dfs(N)

print(np)


Measured memory_bytes: 9104
N,M,X = gets.split.map &:to_i
A = [[0]*(M+2)]
N.times {
  *l = gets.split.map &:to_i
  A[0,A.size].each {|a|
    A << a = a.dup
    a[0] += l[0]
    m = 1<<60
    1.upto(M) {|i| m = a[i] if m > a[i]+=l[i] }
    a[-1] = m
  }
  A << (l << l[1,M].min)
}
c = 1<<60
A.each {|a| c = a[0]  if X<=a[-1] && a[0]<c}
p c>=(1<<60) ? -1 : c

Measured memory_bytes: 15376
void main() {
	(x => (x / 11)*2 + ceil(x%11 / 6.).to!ulong)(readAs!long).writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <cstdio>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <functional>
#include <queue>
#include <regex>
// #include "bits/stdc++.h"

using namespace std;
//debug

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep2(i, N, M) for (ll i = N; i < M; i++)
#define pb push_back



typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef priority_queue<pll, vector<pll>, greater<pll>> greater_pq;


#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define vec(a) vector<a>

#define MAX_NUM 2<<20



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

	cout<<(regex_match(S, regex("A[a-z][a-z]*C[a-z]*[a-z]"))?"AC":"WA");
	return 0;
}



Measured memory_bytes: 256
import queue as q

direction = [[1, 0], [-1, 0], [0, -1], [0, 1]]

H, W = map(int, input().split())
s = []
for i in range(H):
    s_i = input()
    s.append([s_i[i] for i in range(len(s_i))])


def do_bfs(s, que):
    while True:
        if que.empty():
            break
        pos = que.get()
        for arrow in direction:
            next = [pos[0] + arrow[0], pos[1] + arrow[1]]
            if next[0] == -1 or next[0] == H or next[1] == -1 or next[1] == W:
                continue
            if s[next[0]][next[1]] == "#":
                que.put(next)
                s[next[0]][next[1]] = "."


for i in range(H):
    for j in range(W):
        if s[i][j] == "#":
            # check not isolated
            is_conneted = False
            for arrow in direction:
                neighbor = [i + arrow[0], j + arrow[1]]
                if (
                    neighbor[0] == -1
                    or neighbor[0] == H
                    or neighbor[1] == -1
                    or neighbor[1] == W
                ):
                    continue
                if s[neighbor[0]][neighbor[1]] == "#":
                    is_conneted = True
                    break
            if is_conneted:
                s[i][j] = "."
                que = q.Queue()
                que.put([i, j])
                do_bfs(s, que)
# check
for i in range(H):
    for j in range(W):
        if s[i][j] == "#":
            print("No")
            exit()
print("Yes")


Measured memory_bytes: 4080
N = int(input())

A = []
for i in range(N):
    a = int(input())
    A.append([a, i])
    
A_ = sorted(A, reverse=True)

#print(A_)

for i in range(N):
    if A_[0][1] == i:
        print(A_[1][0])
    else:
        print(A_[0][0])

Measured memory_bytes: 39384
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int k,s;
    int ans = 0;
    scanf("%d%d",&k,&s);
    for(int i = 0 ; i<=k;i++){
        for(int j = 0 ; j <=k ;j++){
            if(s - i - j <= k && s- j - i >= 0){
                ans++;
            }
        }
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll md = 10007;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    vl a(n);
    for(int i = 0; i < n; i++) {
    	cin >> a[i];
    }
    vl dp(n+1, 0);
    dp[0] = 0;
    for(int i = 1; i < n; i++) {
    	ll lo = 1e10;
    	for(int j = max(i-k, 0); j < i; j++) {
    		lo = min(lo, dp[j] + abs(a[i] - a[j]));
    	}
    	dp[i] = lo;
    }
    cout << dp[n-1] << "\n";
    return 0;
}

Measured memory_bytes: 4744
#!/usr/bin/env python3
import sys

def main():
    X = int(input())
    N = 2*10**2
    for i in range(N):
        for j in range(i,N):
            tmp = j**5 - i**5
            if tmp == X:
                print(j,i)
                exit()
            elif tmp == X - 2*(i**5):
                print(j,-i)
                exit()

if __name__ == '__main__':
    main()

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int S = 60;
int dp[S + 10][2];

signed main(){

    int n, k; cin >> n >> k;
    vector<int> info(S);

    for(int i = 0; i < n; i++){
        int val; cin >> val;
        for(int j = 0; j < S; j++){
            if((1LL << j) & val) info[j]++;
        }
    }

    reverse(info.begin(), info.end());

    string s = "";
    for(int i = 0; i < S; i++){
        if(k & (1LL << i)) s = "1" + s;
        else s = "0" + s;
    }

    fill(dp[0], dp[S + 1], -1);
    dp[0][0] = 0;
    //cout << s << endl;
    for(int i = 0; i < S; i++){
        for(int f = 0; f < 2; f++){
            if(dp[i][f] == -1) continue;

            int lim = f ? 1 : s[i] - '0';
            //cout << lim << endl;
            for(int x = 0; x <= lim; x++){
                int val = (1LL << (S - i - 1));
                int add = (x == 0 ? info[i] : n - info[i]) * val;
                int nf = f || x < lim;
                dp[i + 1][nf] = max(dp[i + 1][nf], dp[i][f] + add);
                //cout << "dp[" << i + 1 << "][" << nf << "] = " << dp[i + 1][nf] << endl;
            }
        }
    }

    cout << max(dp[S][0], dp[S][1]) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;

vector<int> p;
int num[168];

void prime(){
  p.push_back(2);
  for(int i=3;i<=1000;i+=2){
    rep(j,p.size() ){
      if(i%p[j]==0) break;
      else if(j==p.size()-1)  p.push_back(i);
    }
  }
}
  
int main(){
  int n;
  rep(i,168){
    num[i]=1;
  }
  ll ans=1;
  prime();
  cin>>n;
  rep(i,n+1){
    int b=i;
    rep(j,168){
      if(b<=1) continue;
      while(b%p[j]==0){
	b/=p[j];
	num[j]++;
      }
    }
  }
  rep(i,168) (ans*=num[i])%=MOD;
  cout<<ans<<endl;	
  return 0;
}







Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn solve(mut aa: Vec<Vec<i64>>) -> i64 {
    let n = aa.len();

    for i in 0..n {
        for j in 0..n {
            if i == j { continue }

            for k in 0..n {
                if i == k || j == k { continue }

                let ij = aa[i][j];
                let ik = aa[i][k];
                let jk = aa[j][k];

                if ij == -1 ||
                    ik == -1 ||
                    jk == -1 { continue }
                if ij + ik < jk {
                    return -1
                }

                if ij + ik == jk {
                    aa[j][k] = -1;
                    aa[k][j] = -1;
                }
            }
        }
    }

    aa.iter().map(|v| v.iter().filter(|&a| *a > 0).sum::<i64>()).sum::<i64>() / 2
}

fn main() {
    let n = parse_line!(usize);

    println!("{}", solve((0..n).map(|_| parse_vec!(i64)).collect()));
}

#[test]
fn solve_test() {
    assert_eq!(solve(vec![vec![0,1,3],
                          vec![1,0,2],
                          vec![3,2,0]]), 3);

    assert_eq!(solve(vec![vec![0,1,3],
                          vec![1,0,1],
                          vec![3,1,0]]), -1);


    assert_eq!(solve(vec![vec![0, 21, 18, 11, 28],
                          vec![21, 0, 13, 10, 26],
                          vec![18, 13, 0, 23, 13],
                          vec![11, 10, 23, 0, 17],
                          vec![28, 26, 13, 17, 0]]), 82);
}


Measured memory_bytes: 4352
s = input()
w = int(input())
if len(s)%w == 0:
    num = int(len(s)/w)
else:
    num = int(len(s)/w)+1
start = [w*i for i in range(num)]
moji = []
for i in start:
    moji.append(s[i])
print("".join(moji))

Measured memory_bytes: 3064
n = int(input())
a = list(map(int,input().split()))
c = 0
for i in range(1,n-1):
    if(a[i] == a[i-1]):
        a[i] = a[i+1]+1
        c += 1
if(a[-1] == a[-2]):c+=1
print(c)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    int a,b;
    cin>>a>>b;
    rep(i,1e7){
        if(floor(i*0.08)==a&&floor(i*0.1)==b){
            fin(i);
            return 0;
        }
    }
    fin(-1);
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Main {

	public static void main(String args[]) {
		FastScanner cin = new FastScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	private static void solve(FastScanner cin, PrintWriter cout) {
		int n = cin.nextInt();
		int[][] xs = new int[n][];
		int[][] ys = new int[n][];
		for (int i = 0; i < n; i++) {
			xs[i] = new int[] { cin.nextInt(), i };
			ys[i] = new int[] { cin.nextInt(), i };
		}

		long ans = solve(n, xs, ys);
		cout.println(ans);
	}

	private static long solve(int n, int[][] xs, int[][] ys) {
		// editorialと他人の解答を参考
		// 速度・メモリを調整中

		ArrayList<int[]> edges = new ArrayList<>();

		Arrays.sort(xs, Comparator.comparingInt((vi) -> vi[0]));
		Arrays.sort(ys, Comparator.comparingInt((vi) -> vi[0]));
		for (int[][] vis : new int[][][] { xs, ys })
			for (int i = 1; i < n; i++)
				edges.add(new int[] { Math.abs(vis[i - 1][0] - vis[i][0]), vis[i - 1][1], vis[i][1] });

		// 最小全域木
		// https://ja.wikipedia.org/wiki/%E5%85%A8%E5%9F%9F%E6%9C%A8
		// https://en.wikipedia.org/wiki/Kruskal%27s_algorithm
		long ans = 0;
		Collections.sort(edges, Comparator.comparingInt((edge) -> edge[0]));

		rt = new int[n];
		Arrays.fill(rt, -1);

		for (int[] edge : edges) {
			int w = edge[0];
			int fr = edge[1];
			int to = edge[2];
			if (!unite(fr, to))
				continue;
			ans += w;
		}
		return ans;
	};

	private static int[] rt;

	private static int root(int operand) {
		if (rt[operand] < 0)
			return operand;
		return rt[operand] = root(rt[operand]);
	}

	private static boolean unite(int fr, int to) {
		int a = root(fr);
		int b = root(to);
		if (a == b)
			return false;
		if (rt[a] > rt[b]) {
			int tmp = a;
			a = b;
			b = tmp;
		}
		rt[a] += rt[b];
		rt[b] = a;
		return true;
	}

	/**
	 * How to read input in Java — tutorial <br />
	 * By Flatfoot<br />
	 * http://codeforces.com/blog/entry/7018
	 */
	static class FastScanner {
		private BufferedReader br;
		private StringTokenizer st;

		FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new IllegalStateException(e);
				}
			return st.nextToken();
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				throw new IllegalStateException(e);
			}
			return str;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


Measured memory_bytes: 54280
M1, D1 = input().split(" ")
M1, D1 = int(M1), int(D1)

M2, D2 = input().split(" ")
M2, D2 = int(M2), int(D2)

if M1 == M2 and D1+1 == D2:
	print("0")
elif M1 + 1 == M2 and D2 == 1:
	if 28 <= D1 <= 31:
		print("1")
	else:
		print("0")
else:
	print("0")

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
    char str[1000];
    int i, sum;
    while (1) {
        scanf("%s", str);
        
        if (str[0] == '0') break;
        else {
            sum = 0;
            for (i = 0; str[i] != '\0'; i++) {
                sum += str[i] - '0';
            }
            printf("%d\n", sum);
        }
    }

    return 0;
}

Measured memory_bytes: 536
n,m=map(int,input().split())
bs=[False for i in range(n)]
bt=[False for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  if a==1 and (b!=n):
    bs[b-1]=True
  elif a!=1 and b==n:
    bt[a-1]=True
bool1=False
for i in range(1,n-1):
  if bs[i] and bt[i]:
    bool1=True
if bool1:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 6320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(int argc, char** argv) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if (argc == 2 && atoi(argv[1]) == 123456789)
        freopen("d:\\code\\cpp\\stdin", "r", stdin);


    int n;
    cin >> n;
    if (n==1)
        cout << "Hello World";
    else{
        int a,b;
        cin >> a >> b;
        cout << a+b;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;


int main()
{
    ll a;
    long double b;
    scanf("%lld %Lf",&a,&b);
    
    a=a*b;

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

    return 0;
}

Measured memory_bytes: 1756
(defun solve (s1 s2)
  (let ((h1 (make-hash-table))
        (h2 (make-hash-table))
        (len (length s1)))
    (dotimes (i len)
      (let ((c1 (char s1 i))
            (c2 (char s2 i)))
        (when (or (and (gethash c1 h1) (not (eq c2 (gethash c1 h1))))
                  (and (gethash c2 h2) (not (eq c1 (gethash c2 h2)))))
          (return-from solve "No"))
        (setf (gethash c1 h1) c2)
        (setf (gethash c2 h2) c1)))
    "Yes"))
(format t "~A~%" (solve (read-line) (read-line)))

Measured memory_bytes: 19552
//  main.cpp
//  競技20190629

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
#define ll long long int

int br(){
    printf("\n");
    return 0;
}
ll combi(int n, int k) {
    if (n == k || k == 0)
        return 1;
    else {
        return combi(n - 1, k - 1) + combi(n - 1, k);
    }
}
int gcd(int a,int b){//最大公約数
    if(b==0){
        return a;
    }else{
        return gcd(b,a%b);
    }
}


//sort(a,a+100,greater<int>());大きい順
//sort(a,a+100);小さい順
/*
 int N;
 cin >> N;
 vector<int> d(N);
 int i = 0;
 int n = N;
 while(n--){
 cin >> d[i];
 i++;
 }
 
 sort(d.begin(),d.end());
 d.erase( unique(d.begin(),d.end()), d.end());隣り合った重複を削除し、き消し多分要素数を詰める
 cout<<d.size()<<endl;
 return 0;
*/

int X(){
    string s;
    cin >> s;
    size_t size = s.length();
    
    string ans;
    
    for(int i=0;i<size;i++){
        if(i%2==0){
            ans = ans+s[i];
            
        }
    }
    cout << ans << endl;
    
    return 0;
}

int Ap(){
    string s;
    cin >> s;
    if(s[0]==s[1] && s[1]==s[2] && s[2]==s[3]){return printf("No\n");}
    if(s[0]==s[1] && s[2]==s[3]){return printf("Yes\n");}
     if(s[0]==s[2] && s[1]==s[3]){return printf("Yes\n");}
     if(s[0]==s[3] && s[1]==s[2]){return printf("Yes\n");}
  return printf("No\n");
}

int main(){
    Ap();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n,d[10000],p[10000],i,j,sum,sumd,tmp1,tmp2;
  long long int m;

  for(;;){
    scanf("%d %d", &n, &m);
    if(!(n|m)) break;

    for(i=0,sumd=0;i<n;i++){
      scanf("%d %d", &d[i], &p[i]);
      sumd+=d[i];
    }
    if(m>=sumd){
      printf("0\n"); continue;
    }
    for(i=0;i<n-1;i++){
      for(j=0;j<n-1;j++){
	if(p[j]<p[j+1]){
	  tmp1=p[j]; p[j]=p[j+1]; p[j+1]=tmp1;
	  tmp2=d[j]; d[j]=d[j+1]; d[j+1]=tmp2;
	}
      }
    }
    for(i=0;i<n;i++){
      if(m>=d[i]){
	m-=d[i]; d[i]=0;
      } else if(m<d[i]){
	d[i]-=m; m=0;
      }
      if(!m) break;
    }
    for(i=0,sum=0;i<n;i++){
      if(p[i]) sum+=d[i]*p[i];
    }
    printf("%d\n", sum);
  }

  return 0;
}


Measured memory_bytes: 688
function Main(s){
  s = s.split("\n").map(a => a.trim());
  const n = parseInt(s[0]);
  var ans = ["1", "1"];
  for(var i = 0; i < n; i++){
    var t = s[i+1].split(" ");
    var a = waru(ans[0], t[0], 1);
    a = max(a, waru(ans[1], t[1], 1));
    ans[0] = kakeru64(t[0], a);
    ans[1] = kakeru64(t[1], a);
  }
  console.log(tasu(ans[0], ans[1]));
}
function tasu(a,b){
	var c = +a.slice(-15) + b.slice(-15) * 1;
	var d = +a.slice(0, -15) + b.slice(0, -15) * 1 + Math.floor(c / 1e15);
	if(d > 0) c = ("00000000000000" + c).slice(-15);
	else d = "";
	return d + c;
}
function kakeru64(a,b){
	var c = +a.slice(-10);
	var d = +b.slice(-10);
	a = +a.slice(0, -10);
	b = +b.slice(0, -10);
	var e = kakeru32(c,d);
	var f = kakeru32(a,d)+"0000000000";
	f = tasu(kakeru32(b,c)+"0000000000",f);
	return tasu(e,f);
}
function kakeru32(a,b){
	var c = a % 1e5 * b;
	var d = Math.floor(a / 1e5) * b + Math.floor(c / 1e5);
	c %= 1e5;
	if(d > 0)c = ("00000" + c).slice(-5);
	else d = "";
	return d + c;
}
function waru(a,b,c){
	c = c||0;
	var d = +a.slice(-5);
	a = +a.slice(0, -5);
	var e = Math.floor(a / b);
	a = a % b * 1e5 + d;
	a /= b;
	switch(c){
		case 0: a = Math.floor(a);break;
		case 1: a = Math.ceil(a);break;
		case 2: a = Math.round(a);break;
	}
	if(e > 0)a = ("00000" + a).slice(-5);
	else e = "";
	return e + a;
}
function max(a,b){
	var al = a.length, bl = b.length;
	if(al < bl)return b;
	if(al > bl)return a;
	for(var i = 0;i < al; i++){
		if(a[i] < b[i])return b;
		if(a[i] > b[i])return a;
	}
	return a;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 10516
#include <iostream>
#include<cmath>
using namespace std;
int n,m,i,j,x,y,z,lx,ly,lz;
string st;
int main()
{
	lx=ly=0;
	cin>>n;
	while (n--)
	{
		cin>>z>>x>>y;
		if (abs(lx-x)+abs(ly-y)>(z-lz))
		{
			cout<<"No\n";
			return 0;
		}
		if ((abs(lx-x)+abs(ly-y))%2!=(z-lz)%2)
		{
			cout<<"No\n";
			return 0;
		}
		lx=x;
		ly=y;
		lz=z;
	}
	cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 256
#-swank
(unless (member :child-sbcl *features*)
  (quit
	:unix-status
	(process-exit-code
	  (run-program *runtime-pathname*
				   `("--control-stack-size" "128MB"
					 "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
					 "--eval" "(push :child-sbcl *features*)"
					 "--script" ,(namestring *load-pathname*))
				   :output t :error t :input t))))

(defun print-# (w)
  (dotimes (i (+ w 2))
	(princ #\#)))

(let ((h (read)) (w (read)))
  (print-# w)
  (fresh-line)
  (dotimes (i h)
	(princ #\#)
	(princ (read-line))
	(princ #\#)
	(fresh-line))
  (print-# w)
  (fresh-line))


Measured memory_bytes: 6584
N, C, K = map(int, input().split())
T = sorted([int(input()) for _ in range(N)])
ans = 1
now = T[0]
cap = C
for t in T:
    if t in range(now, now + K + 1):
        if cap == 0:
            ans += 1
            now = t
            cap = C
    else:
        ans += 1
        now = t
        cap = C
    cap -= 1
print(ans)

Measured memory_bytes: 8280
import java.util.Scanner;

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

		double a,b,c,d;
		double p,q,x,y;
		
		while(cin.hasNext())
		{
			a=cin.nextDouble();
			b=cin.nextDouble();
			p=cin.nextDouble();
			c=cin.nextDouble();
			d=cin.nextDouble();
			q=cin.nextDouble();
		
			x = ( d*p-b*q)/(a*d-b*c);
			y = (-c*p+a*q)/(a*d-b*c);
		
			if(x==0.0) x=0.0;
			if(y==0.0) y=0.0;
			
			System.out.printf("%.3f %.3f\n",x,y);
		}
	}
}

Measured memory_bytes: 12000
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	cnt4 := 0
	cnt2 := 0
	for i := 0; i < n; i++ {
		a := scanInt()
		if a%4 == 0 {
			cnt4++
		} else if a%2 == 0 {
			cnt2++
		}
	}

	if n%2 == 1 {
		n--
	}
	n -= cnt4 * 2
	n -= cnt2
	if n <= 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	vector<string> s(h);
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}

	vector<vector<int>> points(h, vector<int>(w, 0));

	for (int i = 0; i < h; i++) {
		vector<int> v = {-1};
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#') {
				v.emplace_back(j);
			}
		}
		v.emplace_back(w);

		for (int k = 1; k < v.size(); k++) {
			// 半開区間で
			int lower = v[k-1] + 1;
			int upper = v[k];

			int point = upper - lower;

			for (int z = lower; z < upper; z++) {
				points[i][z] += point;
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < w; i++) {
		vector<int> v = {-1};
		for (int j = 0; j < h; j++) {
			if (s[j][i] == '#') {
				v.emplace_back(j);
			}
		}
		v.emplace_back(h);

		for (int k = 1; k < v.size(); k++) {
			// 半開区間で
			int lower = v[k-1] + 1;
			int upper = v[k];

			int point = upper - lower - 1;

			for (int z = lower; z < upper; z++) {
				points[z][i] += point;
				ans = max(ans, points[z][i]);
			}
		}
	}

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


Measured memory_bytes: 20096
#include <bits/stdc++.h>
#define ll long long
#define pb emplace_back

using namespace std;

const int MAXN = 1e5 + 10, MD = 1e9 + 7;
int n;
ll dp[MAXN][2];
vector<int> g[MAXN];

void Dfs(int v = 1, int p = -1){
	dp[v][0] = 1;
	dp[v][1] = 1;
	for (auto i : g[v]) {
		if (p == i)
			continue;
		Dfs(i, v);
		dp[v][0] = dp[v][0] * (dp[i][0] + dp[i][1]) % MD;
		dp[v][1] = dp[v][1] * dp[i][0] % MD;
	}
}

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

	cin >> n;
	for (int i = 0; i < n - 1; ++i) {
		int a, b;
	 	cin >> a >> b;
		g[a].pb(b);
		g[b].pb(a);
	}
	Dfs();
	ll ans = dp[1][0] + dp[1][1];
	cout << (ans + MD) % MD << '\n';

	return 0;
}


Measured memory_bytes: 14208
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  while(n >= 0){
    if(n % 4 == 0){
      cout << "Yes" << endl;
      return 0;
    }
    n -= 7;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3592
while True:
    H,W = map(int, input().split())
    if H == 0 and W == 0: break
    for i in range(H):
        for j in range(W):
            if (j == 0 or j == (W - 1)) or (i == 0 or i == (H - 1)):
                print("#", end="")
            else:print(".", end="")
        print("")
    print("")


Measured memory_bytes: 7008
#define    ll           long long
#define    dn           double
#define    mp           make_pair
#define    pb           push_back
#define    se           second
#define    fi           first
#define    mod          1000000007
#define    sob(v)       v.begin(),v.end()
#define    sobr(v)      v.rbegin(),v.rend()
#define    fr(i,a,b)    for(int i=a;i<=b;++i)
#define    frr(i,a,b)   for(int i=a;i>=b;--i)
#define    pi           acos(-1.00)
#define    check        cout<<"*"<<endl
#define    ffix(x)      cout<<fixed<<setprecision(x)
#define    fast         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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

typedef vector<int> vi;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<int,vi> pp;

int dr[8]= {0,0,-1,1,-1,-1,+1,+1};
int dc[8]= {-1,1,0,0,-1,+1,-1,+1};

const int N=200005;

/*inline void normal(ll &a){if(a>mod) a%=mod; (a<0) && (a+=mod);}
inline ll mod_mul(ll a,ll b){normal(a),normal(b); return (a*b)%mod;}
inline ll mod_add(ll a,ll b){normal(a),normal(b); return (a+b)%mod;}
inline ll mod_sub(ll a,ll b){normal(a),normal(b); a-=b; normal(a); return a;}
inline ll mod_pow(ll a,ll b){ll r=1; while(b>0){if(b&1)r=mod_mul(r,a); a=mod_mul(a,a); b>>=1;} return r;}
inline ll mod_inverse(ll a){return mod_pow(a,mod-2);}
inline ll mod_div(ll a,ll b){return mod_mul(a,mod_inverse(b));}*/

vector<int>g[N];
int vis[N],cnt=0;

void dfs(int v)
{
    vis[v]=1;
    cnt++;
    for(int to:g[v])
    {
        if(!vis[to])
        {
            dfs(to);
        }
    }
}
int main()
{
    int n,m;
    cin>>n>>m;
    while(m--)
    {
        int u,v;
        cin>>u>>v;
        g[v].pb(u);
        g[u].pb(v);
    }
    int maxi=0;
    fr(i,1,n)
    {
        cnt=0;
        if(!vis[i])dfs(i);
        maxi=max(maxi,cnt);
    }
    cout<<maxi<<endl;
    return 0;
}


Measured memory_bytes: 21560
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;


void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main() {
	int n;
	cin >> n;
	double o = 0, e = 0;
	rep(i, n){
		if((i+1)%2==0){
			e++;
		} else {
			o++;
		}
	}
	cout << fixed << setprecision(10) << o / (o + e) << endl;

	return 0;
}

Measured memory_bytes: 256
cards = {
    'S': set(),
    'H': set(),
    'C': set(),
    'D': set(),
}
N = int(input())
for _ in range(N):
    type, num = input().split()
    cards[type].add(int(num))
fullset = set(range(1, 14))
for type in ('S', 'H', 'C', 'D'):
    numbers = sorted(list(fullset - cards[type]))
    for num in numbers:
        print(type, num)



Measured memory_bytes: 5600
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#pragma GCC optimize "trapv"
#define _GLIBCXX_DEBUG
#define ll long long int
#define ld long double
#define ull unsigned long long int  // ranges from (0 - twice of long long int)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define MOD 1000000007LL
#define llpair pair<ll,ll>
#define INF 1000000000000000000ll		// this is 1e18 long long 
#define np next_permutation
#define PI acos(-1)
#define DEB(x) cout<<#x<<" "<<x<<endl;
#define rotate_left(vec,amt) rotate(vec.begin(),vec.begin()+amt,vec.end());
#define rotate_right(vec,amt) rotate(vec.begin(),vec.begin()+vec.size()-amt,vec.end());
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define clr(x) memset(x,0,sizeof(x))
using namespace std;
int main()
{
    speed;
    ll t=1;
    // cin>>t;
    while(t--)
    {
        ll n ,k;
        cin>>n>>k;
        ll a[n],temp=1;
        for(ll i=0;i<n;i++)
        {
            cin>>a[i];
        }
        for(ll i=k;i<n;i++)
        {
            if(a[i]>a[i-k])
            {
            cout<<"Yes"<<endl;
            }
            else
            cout<<"No"<<endl;
            
        }
    }
    return 0;
}

Measured memory_bytes: 5192
n = $stdin.gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)
q = $stdin.gets.chomp.to_i
ans = 0
hash = Hash.new(0)
a.each do |k|
 hash[k] += 1
  ans += k
end

q.times do |j|
  b, c = gets.chomp.split(' ').map(&:to_i)
  if hash.has_key?(b)
    ans += (c-b)*hash[b]
    hash[c] = hash[c]+ hash[b]
    hash.delete(b)
  end
puts ans

end

Measured memory_bytes: 26384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'
template <class T> bool updmax(T& a, T b) { if (b > a) { a = b; return true;} return false;}
template <class T> bool updmin(T& a, T b) { if (b < a) { a = b; return true;} return false;}

char s[25][25];
int c[25][25];

int offset[] = {-1, 0, 1, 0, -1};
int main() {
    fastio;
    int ans=0;
    ll H,W;
    cin >> H >> W;
    rep1(h,H) rep1(w,W) {
        cin >> s[h][w];
    }
    auto bfs = [&](int h, int w) {
        if (s[h][w] != '.')
            return;
        rep(i,25) rep(j,25) c[i][j] = -1;
        queue<pair<int,int>> q;
        q.push({h,w});
        c[h][w] = 0;
        while (q.size()) {
            auto p = q.front(); q.pop();
            rep(i,4) {
                int toh = p.first + offset[i];
                int tow = p.second + offset[i+1];
                if (s[toh][tow] == '.' && c[toh][tow] == -1) {
                    c[toh][tow] = 1 + c[p.first][p.second];
                    q.push({toh,tow});
                }
            }
        }
        rep(i,25) rep(j,25) updmax(ans, c[i][j]);
    };
    rep1(h,H) rep1(w,W) {
        bfs(h,w);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3648
// LightOj Pass : qavajxyq

#include <bits/stdc++.h>
#define deb(x)     cerr << (#x) << " : " << x << "\n"
#define ll long long int
#define ld long double
using namespace std;
const ll MOD = 1e9 + 7 ;
const ll INF = 1e18;

ll powmod(ll a, ll b, ll mod = MOD){
	ll res = 1ll;
	b %= (mod - 1ll), a %= mod;
	while(b){
		if(b%2 == 1)	res = (res * a) % mod;
		a = (a * a) % mod;
		b /= 2;
	}
	return res;
}

ll d[300000];
ll n;

bool comp(int a, int b){
	return d[a] < d[b];
}

vector<vector<int>> edges;
int cnt = 0;
ll res = 0;
ll tree[400000];
bool visited[4000000];
bool state = true;

void dfs(int u, int par = -1, ll dpth = 0){
	cnt++;
	res += dpth;
	tree[u] = 1;
	visited[u] = true;
	int tmp = 0;
	for(auto v : edges[u]){
		if(!visited[v]){
			dfs(v, u, dpth + 1ll);
			tree[u] += tree[v];
		}
		else{
			tmp++;
		}
	}

	if(tmp > 1)	state = false;
}


void dfs2(int u, int par = -1, ll ans = res){
	if(ans != d[u])	state = false;
	for(auto v : edges[u]){
		if(v != par)	dfs2(v, u, ans - tree[v] * 2 + n);
	}
}

int main(){	

 
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n;
	edges.resize(n+1);
	memset(visited, false, sizeof(visited));
	int arr[n];
	map<ll, int> mp;
	ll sub[n+1];
	for(int i = 1; i <= n; i++)	cin >> d[i], arr[i-1] = i, mp[d[i]] = i, sub[i] = 1;

	sort(arr, arr + n, comp);
	bool vis[n+1];
	memset(vis, false, sizeof(vis));

	int cur, par;
	int parent[n];

	vector<pair<int, int>> edge;
	for(int i = n-1; i >= 0; i--) {
		
		if(vis[arr[i]])	continue;
		cur = arr[i];
		deb(cur);
		vis[cur] = true;
		while(cur != 0){
			par = 0;
			if(mp.count(d[cur] + (2 * sub[cur]) - n) and !vis[ mp[d[cur] + (2 * sub[cur]) - n]])	par = mp[d[cur] + (2 * sub[cur]) - n];
			if(par)	sub[par] += sub[cur], edges[cur].push_back(par), edges[par].push_back(cur), vis[cur] = true, edge.push_back({cur, par});
			cur = par;
			deb(sub[par]);
			deb(par);
		}
	}

	dfs(arr[0]);
	if(cnt != n or res != d[arr[0]] or !state)	{
		cout << -1;
		return 0;
	}

	dfs2(arr[0]);
	if(!state){
		cout << -1;
		return 0;
	}

	for(auto x : edge)	cout << x.first << " " << x.second << "\n"; 
}

Measured memory_bytes: 27252