akhauriyash/Code-Regression huggingface dataset:
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def No(): print('No')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

S = input()
ans = [0 for _ in range(len(S))]

def set_value(r_count, l_count, l_index):
    
    ave = (r_count+l_count)/2
    floor_value = math.floor(ave)
    ceil_value = math.ceil(ave)
    
    if (max(r_count, l_count) - 1) % 2 != 1:
        tmp = floor_value
        floor_value = ceil_value
        ceil_value = tmp
    if r_count >= l_count:
        ans[l_index-1] = floor_value
        ans[l_index] = ceil_value
    else:
        ans[l_index-1] = ceil_value
        ans[l_index] = floor_value


r_count = 0
l_count = 0
l_index = -1
for i in range(len(S)):
    if S[i] == 'R':
        if r_count > 0 and l_count > 0:
            set_value(r_count, l_count, l_index)
            r_count = 0
            l_count = 0
            l_index = -1
        r_count += 1
    else:
        l_count += 1
        if l_index == -1:
            l_index = i
if l_index != -1:
    set_value(r_count, l_count, l_index)
print(*ans)


Measured memory_bytes: 11640
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
#define mp make_pair
#define pb push_back
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
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 ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    if(n%10==2 || n%10==4 || n%10==5 || n%10==7 || n%10==9)
        cout << "hon" << endl;
    else if(n%10==0 || n%10==1 || n%10==6 || n%10==8)
        cout << "pon" << endl;
    else cout << "bon" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 2e5 + 2;
const int M = 1e5 + 2;
const int mod = 998244353;
const int inf = 1e9;
const ll INF = 1e16;
 
void data() {
    #ifdef PC
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
}
 
template <typename T>
void scerr(T nums) {
	for (auto it : nums)
		cerr << it << " | ";
	cerr << "\n";
}

int ch[N], n = (int)2e5, a;
si pr;

int main() {
	for (int i = 2; i <= n; ++i) {
		if (!ch[i]) {
			pr.insert(i);
			for (int j = i + i; j <= n; j += i)
				ch[j] = 1;
		}
	}
	scerr(pr);
	scanf("%d", &a);
	printf("%d", *pr.lb(a));
}
 
/*
	Timus: 288481RF
	CodeForces: __fractal
*/


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(ll i=(x);i<(y);i++)
#define disp(a) cout << a << endl;
typedef long long ll;
using namespace std;
int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	cout << min(A, B) + min(C, D) << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>){
    val (N, M) = readLine()!!.split(" ").map(String::toInt)
    val A = Array(N){readLine()!!}
    val B = Array(M){readLine()!!}
    for(i in 0..N-M){
        for(j in 0..N-M){
            if((0..M-1).all{A[i+it].substring(j,j+M) == B[it]}){
                println("Yes")
                return
            }
        }
    }
    println("No")
}


Measured memory_bytes: 37680
from fractions import gcd
A,B,C,D = map(int,input().split())

Ans = []

for i in [B,A-1]:
  N = i
  E = (C * D) // gcd(C,D)
  modC = N//C
  modD = N//D
  modE = N//E
  Ans += [N - modC - modD + modE]
  
print(Ans[0]-Ans[1])

Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef pair <int,int> pr;
#define fr(i, n) for(int i = 0; i < n; i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c)(c).begin(), (c).end()
#define tr(c, i) for (typeof ((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c, x)((c).find(x) != (c).end())
#define cpresent(c, x)(find(all(c), x) != (c).end())
// for mod power a^b%m use power<lli> (a,b,m)
template < class mytype >
mytype power(mytype a, mytype b, mytype m){if (b == 1) return a % m;if (b == 0) return 1;
mytype root = power < lli > (a, b / 2, m);mytype ans = (root * root) % m;if (b % 2) ans = (ans * a) % m;
return ans;
}
// for gcd use gcd<int> (a,b)
template < class type >type gcd(type a, type b){if (a == 0) return b;else return gcd(b % a, a);}
template < class type >type mod_inv(type a, type p) {return power(a, p - 2, p);}


int main()
{
    int n , k;
    cin >> n >> k;
    vector<int> h(n) , cost(n , 1e9+7);
    for(int i = 0 ; i < n ; i++) cin >> h[i];
    cost[0] = 0;
    for(int i = 0 ; i < n-1 ; i ++){
        for(int j = i+1 ; j <= i+k ; j++){
            if(j < n) cost[j] = min(cost[j] , cost[i] + abs(h[i] - h[j]));
        }
    }
    cout << cost[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1152
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int MAXN = 60;
int n, b[MAXN][26];
int a[MAXN];
char s[MAXN];

int main() {
	int i, j;
	scanf("%d", &n);
	for(i = 1; i <= n; i++) {
		scanf("%s", s);
		int l = strlen(s);
		for(j = 0; j < l; j++) b[i][s[j]-'a']++;
	}
	for(i = 0; i < 26; i++) a[i] = 10000;
	for(i = 1; i <= n; i++) 
		for(j = 0; j < 26; j++) a[j] = min(a[j], b[i][j]);
	for(i = 0; i < 26; i++) 
		while(a[i]--) printf("%c", i+'a');
	return 0;
}


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

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        c: i32,
        b: [i32; m],
    };

    let mut count = 0;
    for _ in 0..n {
        input! {
            a: [i32; m],
        };

        let a: Vec<i32> = a;

        let mut sum: i32 = 0;
        for (ai, bi) in a.iter().zip(b.iter()) {
            sum += ai * bi;
        }
        sum += c;

        if sum > 0 {
            count += 1;
        }
    }

    println!("{}", count);
}


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

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

    int A, B;
    cin >> A >> B;
    cout << (A + B - 3) / (A - 1) << endl;

    return 0;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}



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

    vector<ll> s(N+1,0);
    REP(i,N) {
        cin >> s[i+1];
        s[i+1] += s[i];
    }
    sort(all(s));

    map<ll,ll> mp;

    ll c=0;
    ll ans=0;
    REP(i,N+1) {
        ans+=mp[s[i]];
		mp[s[i]]++;
    }

    pl(ans)

    return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    int n,a,b;
    cin >>n>>a>>b;
    cout << min(n*a,b) << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect

# スペース区切りの整数の入力
n = int(input())
l_list = input().split(" ")
l_int_list = []
for item in l_list:
    l_int_list.append(int(item))

l_int_list.sort()

count = 0


for i in range(len(l_int_list)):
    for j in range(i+1, len(l_int_list)):
        index = bisect.bisect_left(
            l_int_list, l_int_list[i]+l_int_list[j], j+1, len(l_int_list))
        count += index - j - 1

print(count)


Measured memory_bytes: 3188
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
//        int t = in.nextInt();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) throws IOException {
            int n = in.nextInt();
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextLong();
            }
            long max = -1;
            long next = 0;
            for (int i = n-2; i >= 0; i--) {
                long count;
                if (arr[i] >= arr[i+1]){
                    count = next + 1;
                }else {
                    count = 0;
                }
                if (count > max){
                    max = count;
                }
                next = count;
            }
            out.println(Math.max(max, 0));
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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

        public char nextChar() {
            return next().charAt(0);
        }

        public String nextLine() throws IOException {
            return reader.readLine().trim();
        }
    }
}


Measured memory_bytes: 39004
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <queue>
using namespace std;

void solve(){
  int a, b, c; cin >> a >> b >> c;
  cout << c << " " << a << " " << b << endl;
  return;
}

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


Measured memory_bytes: 256
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>

using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define ull unsigned long long
#define ll long long
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}

#define max(a,b)((a)>(b)?(a):(b))
ll clkwise[100005];
ll clkwise2[100005];
ll mclkwise[100005];
ll mclkwise2[100005];

ll aclkwise[100005];
ll aclkwise2[100005];
ll maclkwise[100005];
ll maclkwise2[100005];

ll xs[100005];
ll vs[100005];
int N;
ll C;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	cin >> N >> C;
	rep(i,0,N) {
		cin >> xs[i] >> vs[i];
	}

	ll cum_v = 0;
	rep(i,0,N) {
		cum_v += vs[i];
		clkwise[i] = cum_v-xs[i];
		clkwise2[i] = cum_v - 2*xs[i];

		mclkwise[i+1] = max(mclkwise[i], clkwise[i]);

		mclkwise2[i+1] = max(mclkwise2[i], clkwise2[i]);
	}

	cum_v = 0;
	rep(i,0,N) {
		cum_v += vs[N-1-i];
		aclkwise[i] = cum_v-(C-xs[N-1-i]);
		aclkwise2[i] = cum_v-2*(C-xs[N-1-i]);

		maclkwise[i+1] = max(maclkwise[i], aclkwise[i]);
		
		maclkwise2[i+1] = max(maclkwise2[i], aclkwise2[i]);
	}

	ll res = 0;
	rep(i, 0, N+1) {
		Max(res, mclkwise2[i]+maclkwise[N-i]);
		Max(res, mclkwise[i]+maclkwise2[N-i]);
	}
	cout << res << endl;
}

Measured memory_bytes: 8064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] values = new int[w];
		for (int i = 0; i < values.length; i++) {
			values[i] = i + 1;
		}
		for (int i = 0; i < n; i++) {
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) - 1;
			int c = values[a];
			values[a] = values[b];
			values[b] = c;
		}
		for (int i = 0; i < values.length; i++) {
			System.out.println(values[i]);
		}
	}
}

Measured memory_bytes: 25948
N,K,S = map(int,input().split())
INF = 10**9

A = []
for i in range(K):
    A.append(S)
if S != INF:
    for i in range(N-K):
        A.append(INF)
else:
    for i in range(N-K):
        A.append(INF-1)

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


Measured memory_bytes: 15128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
void Main(){
    int N;cin>>N;
    vector<int> P(N);
    For(i,0,N){
        cin>>P[i];P[i]--;
    }
    int cnt=0;
    For(i,0,N){
        if(P[i]==i) {
            cnt++;
            i++;
        }
    }
    cout<<cnt<<endl;
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 640
n, q = map(int, input().split())
s = input()
td = [input().split() for i in range(q)]
s = "s" + s + "e"

def can_go(i, left=True):
    end = 0 if left else n+1
    if i == end:
        return True
    start = i
    for t, d in td:
        if start == end:
            return True
        if t == s[start]:
            if d == "L":
                start -= 1
            else:
                start += 1
    return start == end

ans = []

left = 0
right = n+1
while right - left > 1:
    center = (left+right)//2
    if can_go(center):
        left = center
    else:
        right = center
ans.append(left)

left = 0
right = n+1
while right - left > 1:
    center = (left+right)//2
    if can_go(center, left=False):
        right = center
    else:
        left = center
ans.append(right)

#print(ans)
print(max(0, ans[1]-ans[0]-1))

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;




int cap[maxn];
int siz[maxn];
int par[maxn];


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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    int n, h, w;
    cin>>n>>h>>w;

    for (int i=0; i<h+w; i++) {
	cap[i] = 1;
	siz[i] = 1;
	par[i] = i;
    }
    
    
    vector<pair<ll,pair<int,int>>> cards;
    for (int i=0; i<n; i++) {
	int r,c,a;
	cin>>r>>c>>a;
	--r; --c;
	cards.push_back({a,{r,c}});
    }

    sort(cards.begin(), cards.end());


    ll res = 0;

    while (!cards.empty()) {
	auto card = cards.back();
	ll val = card.first;
	int r = card.second.first;
	int c = card.second.second + h;
	cards.pop_back();

	r = parent(r);
	c = parent(c);

	if (r==c) {
	    if (cap[r] >= 1) {
		res += val;
		cap[r]--;
	    }
	} else {
	    if (cap[r]+cap[c] >= 1) {
		res += val;
		if (siz[r] < siz[c]) {
		    swap(r, c);
		}
		siz[r] += siz[c];
		par[c] = r;
		cap[r] += cap[c];
		cap[r]--;
	    }
	}
    }

    cout<<res<<endl; 
    return 0;
}


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

typedef long long ll;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

ll mod=1e9+7;

using namespace std;


ll inputValue(){
	ll a;
	cin >> a;
	return a;
};

void inputArray(int * p, ll a){
	rep(i, a){
		cin >> p[i];
	}
};

template<typename T>
void inputVector(vector<T>& p, ll a){
	rep(i, a){
		T input;
		cin >> input;
		p.emplace_back(input);
	}
}


template <typename T>
void output(T a) {
	cout << a << "\n";
}

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

  ll n,k;
  cin >> n >> k;
  vector<ll> dp(n,mod);
  vector<ll> h;

  inputVector(h,n);
  dp[0]=0;

  for(ll i=1;i<n;++i){
    for(ll j=max<ll>(i-k,0);j<i;++j){
      dp[i]=min(dp[i], dp[j]+abs(h[i]-h[j]));
    }
  }

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

	return 0;
}



Measured memory_bytes: 2168
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

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

	int n;
	cin >> n;
	vector<double> p(n);
	rep(i, n) cin >> p[i];

	// ナップザック系？
	vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0.0));
	// dp[i][j] = i番目まで見たときに表がj個である確率

	dp[0][0] = 1.0;

	rep(i, n) {
		rep(j, n) {
			// 表の時
			dp[i + 1][j + 1] += dp[i][j] * p[i];
			// 裏の時
			dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
		}
	}

	double ans = 0;
	int border = (n + 1) / 2;
	Rep(j, border, n + 1) {
		ans += dp[n][j];
	}

	//ans /= (double)n;
	cout << fixed << setprecision(10) << ans << endl;

	return 0;
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
    #include<ext/pb_ds/assoc_container.hpp>
    #include<ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    using namespace std;
    template <typename T>
    using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
    # define ll long long
    # define int long long  //comment it out when MLE
    //# define endl "\n"
    #define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //# define m 163577857
    # define mo 998244353
    # define pi acos(-1)
    # define fi first
//    # define se second
    #define REP(i,n) for (int i = 1; i <= n; i++)
    const ll mod = 1000000007;
    //const int K = 2;
    //typedef vector<vector<int> > matrix;
/*
    int add(int a, int b,int mod) {
        a%=mod;
        b%=mod;
        a += b;
        if (a >= mod) a -= mod;
        if(a<0)
        {
            a += mod;
            a %= mod;
        }
        return a;
    }

    int mul(ll a, int b,int mod) {
        a%=mod;
        b%=mod;
        a *= b;
        a += mod;
        return a % mod;
    }
    int po(int a,int b,int mod)
    {
        if(b==0)
            return 1;
        if(b%2==0)
            return po(mul(a,a,mod),b/2,mod);
        return mul(a,po(mul(a,a,mod),(b-1)/2,mod),mod);
    }


    ll fact[1000003];
    ll inv[1000003];

    void fact0()
    {
        int i,j;
        fact[0]=1;
        for(i=1;i<=600000;i++)
        {
            fact[i]=i*fact[i-1]%mod;
        }
        inv[0]=1;
        inv[1]=1;
        ll p=mod;
        for (i=2; i<=600000; i++)
            inv[i] = (p - (p/i) * inv[p%i] % p) % p;

        for(i=2;i<=600000;i++)
        {
            inv[i]*=inv[i-1];
            inv[i]%=mod;
        }
    }
    int help(int a,int b)
    {
       // cout<<a<<" "<<b<<endl;
        int an = fact[a];
        //cout<<an<<endl;
        an *= inv[b];
        an %= mod;
        an *= inv[a-b];
        an %= mod;
        return an;
    }

    void random()
    {
      srand(time(0));
	for (int i = 0; i < n; i ++)
		perm[i] = i + 1;
	random_shuffle(perm, perm + n);
    }

*/



signed main(){
    gok
 int n,k;
 cin>>n>>k;
 int a[n];
 int ss=0;
 for(int i=0;i<n;i++){
    cin>>a[i];
    ss += a[i];
 }

     //int re[n+1]={0};
     for(int i=0;i<min((int)500,k);i++)
     {
         int tt[n+1]={0};
         for(int i=0;i<n;i++)
         {
             int st = max((int)0,i-a[i]);
             int en = min(n,i+a[i]+1);
             tt[st]+=1;
             tt[en]-=1;
         }
         for(int i=1;i<n;i++)
            tt[i] += tt[i-1];
         for(int i=0;i<n;i++)
            a[i]=tt[i];
            if(a[0]==n)
                break;
     }
     for(int i=0;i<n;i++)
        cout<<a[i]<<" ";





















}






Measured memory_bytes: 6736
#include<iostream>
using namespace std;
int main()
{
    long long n, a, b;
    cin >> n >> a >> b;
    if(a > b) cout << 0 << endl;
    else if(n == 1) cout << (a == b) << endl;
    else cout << (b-a) * (n-2) + 1 << endl;
    return 0;
}

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

int main(){
	int R, G, B, N, i, j, ans = 0;
	scanf("%d%d%d%d", &R, &G, &B, &N);
	for(i = 0; i <= N; i++){
		for(j = 0; j <= N; j++){
			int a = R * i + G * j;
			if(a <= N && (N - a) % B == 0){
				ans++;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 1e5+10;

int main(){
    int n;cin >> n;
    string s[n];
    map<string,int> score;
    rep(i,n){
        cin >> s[i];
        score[s[i]]++;
    }
    int m;cin >> m;
    string t[m];
    rep(i,m){
        cin >> t[i];
        score[t[i]]--;
    }
    int ans = 0;
    for(auto itr = score.begin();itr != score.end();){
        ans = max(ans,(*itr).second);
        itr = next(itr,1);
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N,K = map(int,input().split())
arrA = list(map(int,input().split()))
cnt = Counter(arrA)
shurui_num = len(cnt.keys())
cnts_lis = list(cnt.values())
cnts_lis.sort()
if shurui_num<=K:
    print(0)
else:
    lis = cnts_lis[::-1]
    ans = sum(lis[K:])
    print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 32540
import java.util.Scanner;

public class Main {
    private static Scanner sc;

    public Main() {
    }

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

    }

    private void solve() {
        String S = sc.next();

        boolean[] used = new boolean[26];

        String ans = "yes";
        for (int i = 0; i < S.length(); i++) {
            char c = S.charAt(i);
            if (used[c - 'a']) {
                ans = "no";
                break;
            }
            used[c - 'a'] = true;
        }

        System.out.println(ans);
    }
}


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

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

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

int main()
{
    int x,n;
    cin >> x >> n;
    set<int> p;
    for (int i = 0; i < n; i++)
    {
        int pp;
        cin >> pp;
        p.insert(pp);
    }
    for (int i = 0; i < 1000; i++)
    {
        if(!p.count(x - i))
        {
            cout << x - i << endl;
            break;
        }
        if(!p.count(x + i))
        {
            cout << x + i << endl;
            break;
        }
    }
    
}


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

int main()
{
    int d,n;
    cin >> d >> n;
    int t[d];
    for(int i=0;i<d;i++)
        cin >> t[i];
    int ma[n],mi[n],a[n];
    for(int i=0;i<n;i++)
        cin >> mi[i] >> ma[i] >> a[i];
    int b[d][n]={},dp[d][n]={};
    for(int i=0;i<d;i++)
        for(int j=0;j<n;j++)
            if(ma[j]>=t[i]&&mi[j]<=t[i])
                b[i][j]=1;//1..ok
    for(int i=0;i<d-1;i++)
        for(int j=0;j<n;j++){
            if(b[i+1][j]==1){
                int m=0;
                for(int k=0;k<n;k++){
                    if(b[i][k]==1){
                        m=max(m,abs(a[j]-a[k])+dp[i][k]);
                    }
                }
                dp[i+1][j]=m;
            }
        }
    int ans=0;
    for(int i=0;i<n;i++)
        ans=max(ans,dp[d-1][i]);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3400
n = gets.to_i
ws = n.times.map{gets.chomp.chars}
ans = "Yes"
unless ws.size == ws.uniq.size
  ans = "No"
end
previous = ws.shift
ws.each do |w|
  unless previous[-1] == w[0]
    ans = "No"
    break
  end
  previous = w
end
puts ans


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n;
    cin >> n;
    vector<int> a(n);
    vector<ll> sum(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        sum[i] = a[i];
    }
    for(int i = 0; i + 1 < n; ++i)  sum[i + 1] += sum[i];
    ll ans = 1e+15;
    ll S = 0;
    ll add = 0;
    vector<ll> foo = sum;
    for(int i = 0; i < n; ++i){
        foo[i] += add;
        if(i % 2 == 0 && foo[i] <= 0){
            S += 1 - foo[i];
            add += 1 - foo[i];
        }
        if(i % 2 != 0 && foo[i] >= 0){
            S += foo[i] + 1;
            add -= foo[i] + 1;
        }
    }
    chmin(ans, S);
    S = 0;
    add = 0;
    for(int i = 0; i < n; ++i){
        sum[i] += add;
        if(i % 2 == 0 && sum[i] >= 0){
            S += sum[i] + 1;
            add -= sum[i] + 1;
        }
        if(i % 2 != 0 && sum[i] <= 0){
            S += 1 - sum[i];
            add += 1 - sum[i];
        }
    }
    chmin(ans, S);
    cout << ans << endl;
}

Measured memory_bytes: 2176
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        int x = 0;
        int y = 0;
        for(int i=0; i<n; ++i){
            int a, b;
            cin >> a >> b;
            if(a > b)
                x += a + b;
            else if(a < b)
                y += a + b;
            else{
                x += a;
                y += b;
            }
        }

        cout << x << ' ' << y << endl;
    }
}

Measured memory_bytes: 0
#include<iostream>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<deque>
#include<array>
#include<map>

#define REP(i,a,b) for(int i = (a); i < b; ++i)
#define inf 1e9+10
#define MOD 1000000007

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

inline ll modpow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

inline ll mod(ll val, ll m) {
    ll res = val % m;
    if (res < 0) res += m;
    return res;
}

template <typename T>
struct PrimeFact {
    vector<T> spf;
    PrimeFact(T N) { init(N); }
    void init(T N) { // 前処理。spf を求める
        spf.assign(N + 1, 0);
        for (T i = 0; i <= N; i++) spf[i] = i;
        for (T i = 2; i * i <= N; i++) {
            if (spf[i] == i) {
                for (T j = i * i; j <= N; j += i) {
                    if (spf[j] == j) {
                        spf[j] = i;
                    }
                }
            }
        }
    }
    map<T, T> get(T n) { // nの素因数分解を求める
        map<T, T> m;
        while (n != 1) {
            m[spf[n]]++;
            n /= spf[n];
        }
        return m;
    }
};

int main() {
    int n;
    cin >> n;
    int sum = 0;
    REP(i, 1, n + 1) {
        sum += (n - 1) / i;
    }
    
    cout << sum;

    return 0;
}

Measured memory_bytes: 3616
// atcoder/abc147/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string s;
  while (cin >> s) {
    int cnt = 0;
    for (int i = 0; i < s.size() / 2; ++i) {
      cnt += (s[i] != s[s.size() - i - 1]);
    }
    cout << cnt << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

int main(){
    lli x,ans;
    lli i,j,k;
    cin>>x;
    ans=(x/500)*1000;
    x%=500;
    ans+=(x/5)*5;
    cout<<ans<<endl;
}


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

int main(){
    int n, k;
    cin >> n >> k;
    int integer = 1;

    for (int i = 0; i < n; i++){
        if(integer < k){
            integer *= 2;
        }else{
            integer += k;
        }
    }

    cout << integer << endl;
}

Measured memory_bytes: 3592
k=int(input())
L=[1,2,3,4,5,6,7,8,9]
Sz=['0']
Tz=[]
Sn=[1,2,3,4,5,6,7,8,9]
Tn=[]

i=9
while i<=k:
    for z in Sz:
        L.append(int('1'+z))
        i+=1
        Tn.append(int('1'+z))
        Tz.append('0'+z)
    Sz=[]
    Sz=Tz[:]
    Tz=[]
    
        
    for n in Sn:
        if int(str(n)[0])==1:
            Sz.append(str(int(str(n)[0])-1)+str(n))
            L.append(int(str(n)[0]+str(n)))
            L.append(int(str(int(str(n)[0])+1)+str(n)))
            Tn.append(int(str(n)[0]+str(n)))
            Tn.append(int(str(int(str(n)[0])+1)+str(n)))
            i+=2
        elif 2<=int(str(n)[0])<=8:
            L.append(int(str(int(str(n)[0])-1)+str(n)))
            L.append(int(str(n)[0]+str(n)))
            L.append(int(str(int(str(n)[0])+1)+str(n)))
            Tn.append(int(str(int(str(n)[0])-1)+str(n)))
            Tn.append(int(str(n)[0]+str(n)))
            Tn.append(int(str(int(str(n)[0])+1)+str(n)))
            i+=3
        else:    
            L.append(int(str(int(str(n)[0])-1)+str(n)))
            L.append(int(str(n)[0]+str(n)))
            Tn.append(int(str(int(str(n)[0])-1)+str(n)))
            Tn.append(int(str(n)[0]+str(n)))
            i+=2
    Sn=[]
    Sn=Tn[:]
    Tn=[]

LS=sorted(L)
print(LS[k-1])

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

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	LL s;
	cin >> s;
	LL r = sqrt(s);
	if(r * r < s)
		r++;
	cout << "0 0 " << r << " " << r * r - s << " 1 " << r;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define aint(v) v.begin(),v.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define ump gp_hash_table<int,int,custom_hash>
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
/*int **dp,in main function,int row,col;dp=new int*[n];rep(i,n)dp[i]=new int[m]*/
//**** Maths Section*******/
int power(int x,int y);
bool isPrime(int n);
int modInv(int a,int b);
int gcdExtended(int a,int b,int *x,int* y);
int mpower(int a,int b,int p);
/***************************/
int32_t main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  fastio
  int a,b;
  cin>>a>>b;
  int flag=0;
  repre(i,1,1250)
  {
    int r1=(i*8)/100;
    int r2=i/10;
    if(r1==a && r2==b){flag=i;break;}
  }
  if(flag==0)flag=-1;
  cout<<flag<<endl;
  return 0;
}

int modInv(int a, int m)
{
int x, y;
int g = gcdExtended(a, m, &x, &y);
int res = (x%m + m) % m;
return res;
}

int gcdExtended(int a, int b, int *x, int *y)
{
if (a == 0){
    *x = 0, *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtended(b%a, a, &x1, &y1);
  *x = y1 - (b/a) * x1;
  *y = x1;
  return gcd;
}

int mpower(int x, int y, int p)
{
int res = 1;
x = x % p;
while(y > 0){
    if(y & 1) res = (res*x) % p;
      y = y>>1;
      x = (x*x) % p;
    }
    return res;
}
int power(int x, int y)
{
int res = 1;
while (y > 0){
    if (y & 1) res = res*x;
      y = y>>1;
      x = x*x;
    }
    return res;
}

bool isPrime(int n)
{
if (n <= 1)  return false;
  if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
      int p=sqrt(n);
      for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
          return false;
      return true;
}


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

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

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

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

  int min = *min_element(a.begin(), a.end());
  int max = *max_element(a.begin(), a.end());

  cout << abs(max - min) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int n;
int X[1001], Y[1001];
int M;
int OutputArray[1000];
char OutputString[1000];


int main()
{
	int i, j;
	int u, v;

	cin >> n;

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

	int mod2Result = (X[0] + Y[0]) % 2;
	//cout << mod2Result;
	for (i = 1; i < n; i++)
	{
		//cout << (X[i] + Y[i]) % 2;
		if (abs((X[i] + Y[i]) % 2) != abs(mod2Result))
		{
			cout << "-1\n";
			return 0;
		}
	}

	M = 31;
	for (i = 30; i >= 0; i--)
	{
		OutputArray[30 - i] = (1 << i);
	}
	if (mod2Result == 0)
	{
		M++;
		OutputArray[31] = 1;
	}

	cout << M << "\n";
	for (i = 0; i < M; i++)
	{
		cout << OutputArray[i] << " ";
	}
	cout << "\n";
	for (i = 0; i < n; i++)
	{
		u = X[i] + Y[i];
		v = X[i] - Y[i];

		for (j = 0; j < M; j++)
		{
			//cout << u << " " << v << "\n";
			if (u >= 0)
			{
				if (v >= 0)
				{
					OutputString[j] = 'R';
					u -= OutputArray[j];
					v -= OutputArray[j];
				}
				else
				{
					OutputString[j] = 'U';
					u -= OutputArray[j];
					v += OutputArray[j];
				}
			}
			else
			{
				if (v >= 0)
				{
					OutputString[j] = 'D';
					u += OutputArray[j];
					v -= OutputArray[j];
				}
				else
				{
					OutputString[j] = 'L';
					u += OutputArray[j];
					v += OutputArray[j];
				}
			}
		}
		OutputString[M] = 0;
		cout << OutputString << "\n";
	}
	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<string,int> P;
int k[15],s[15][15],p[15];
bool l[15];
int c,C,ans;
int main(void){
	int n,m; cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>k[i];
		for(int j=0;j<k[i];j++){
			cin>>s[i][j];
		}
	}
	for(int i=0;i<m;i++){
		cin>>p[i];
	}
	for(int bit=0;bit<(1<<n);bit++){
		for(int i=0;i<n;i++){
			l[i]=false;
			if(bit&(1<<i)){
				l[i]=true;
			}
		}
		for(int i=0;i<n;i++){
			//cout<<l[i]<<" ";
		}
		//cout<<endl;
		for(int i=0;i<m;i++){
			c=0;
			for(int j=0;j<k[i];j++){
				if(l[s[i][j]-1]){
					c++;
				}
			}
			//cout<<c<<" ";
			if(c%2==p[i]){
				C++;
			}
		}
		//cout<<C<<" ";
		//cout<<endl;
		if(C==m){
			ans++;
		}
		C=0;
	}
	cout<<ans<<endl;
	
}


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

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

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

    for(int i = n-1; i >0; i--) {
        cout << a[i] << " ";
    }
    cout << a[0] << endl;

    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define Graph vector<vector<int>>;
#define iterG(next_v, G, v) for(auto next_v : G[v]
int main(){
    int n, m;
    cin >> n >> m;
    int ans;
    ans = 0;
    ans += n * (n - 1) / 2;
    ans += m * (m - 1) / 2;
    cout << ans << endl;
    return 0;
}



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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

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

int main(int argc, char **argv)
{
	ll N, R; cin >> N >> R;
	if (N <= 10)
	{
		std::cout << R + 100*(10-N) << std::endl;
	}
	else
		std::cout << R << std::endl;
}


Measured memory_bytes: 256
x=int(input())
dic={}
for i in range(10**5):
  dic[i**5]=i
  dic[(-i)**5]=-i
for i in range(10**5):
    if i**5+x in dic:
      print(dic[i**5+x],i)
      break
    if (-i)**5+x in dic:
      print(dic[(-i)**5+x],-i)
      break

Measured memory_bytes: 38348
#include<bits/stdc++.h>
#include<string.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int m,d;

	cin>>m>>d;

	ll t=0;
	for(int i=4; i<m+1; i++){
		for(int j=2; j<d+1; j++){
			if(j/10*(j%10)==i&&j/10>=2&&j%10>=2){
				t++;
			}
		}
	}
	cout<<t<<endl;
	return 0;
}


Measured memory_bytes: 256
n,m=gets.chomp.split.map(&:to_i)
MOD=1000000007
a=[]
m.times do
  a << gets.to_i
end
if a.size > 0 and a[0] == 1
  dp=[1,0]
  j=1
else
  dp=[1,1]
  j=0
end
2.upto(n) do |i|
  if j < a.size and a[j] == i
    dp[i] = 0
    j += 1
  else
    dp[i] = (dp[i-1] + dp[i-2]) % MOD
  end
end
p dp[n]


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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<double> p(n);
    vector<double> cs(n + 1);
    vector<double> sums(n - k + 1);
    rep(i, n) cin >> p[i];
    for (int i = 1; i < n + 1; i++)
    {
        cs[i] = cs[i - 1] + (p[i - 1] + 1.0) / 2.0;
    }
    for (int i = 0; i < n - k + 1; i++)
    {
        sums[i] = cs[i + k] - cs[i];
    }
    double max = 0.0;
    for (auto x : sums)
        if (max < x)
            max = x;

    printf("%.10f\n", max);

    return 0;
}

Measured memory_bytes: 4992