akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int back(int tree[],int start){
	int root;
	if(tree[start]==-1)return start;
	root=back(tree,tree[start]);
	tree[start]=root;
	return root;
}

int main(){
	int n,m;
	cin>>n>>m;
	int h1[n],h2[n];
	rep(i,n){
		h1[i]=-1;
		h2[i]=0;
	}
	int a,b,aroot,broot;
	rep(i,m){
		cin>>a>>b;
		a--;
		b--;
		aroot=back(h1,a);
		broot=back(h1,b);
		if(aroot!=broot)h1[aroot]=broot;
	}
	rep(i,n)h2[back(h1,i)]++;
	int mm=0;
	rep(i,n)mm=max(mm,h2[i]);
	cout<<mm;
	return 0;
}


Measured memory_bytes: 8244
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>
#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


ll a[MAX], sum[MAX];



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


  cin >> n >> m;
  rep(i, n) {
    cin >> a[i];
    sum[a[i]]++;
  }
  rep(i, MAX - 2) sum[i + 1] += sum[i];
  FOR(i, 1, n) {
    ll cnt = 0;
    rep(j, i + 1) if (a[i] < a[j]) cnt++;
    (ans += cnt * m) %= mod;
  }
  rep(i, n) {
    tmp = sum[a[i] - 1] * ((m *(m - 1) / 2) % mod);
    (ans += tmp) %= mod;
  }
  cout << ans << endl;



  return 0;
}


Measured memory_bytes: 2048
A, B, C, X, Y = map(int, input().split())

v1 = A * X + B * Y
v2 = A * max(X-Y, 0) + B * max(Y-X, 0) + C * 2 * min(X, Y)
v3 = C * 2 * max(X, Y)

print(min(v1, v2, v3))


Measured memory_bytes: 2940
const main = (arg) => {
  const lines = arg.trim().split('\n');
  const N = Number.parseInt(lines[0]);
  const A = lines[1].split(' ').map((v) => Number.parseInt(v));
  A.sort((a, b) => b - a);
  console.log(A[0] - A[N-1]);
};
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29860
import java.util.Scanner;

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

        String S = sc.next();
        
        if (S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 22996
using System;

class ABC071A
{
	static public void Main(string[] args)
	{
		int x,a,b;
		string[] vals = Console.ReadLine().Split(' ');

		x = int.Parse(vals[0]);
		a = int.Parse(vals[1]);
		b = int.Parse(vals[2]);

		int da = Math.Abs(x - a);
		int db = Math.Abs(x - b);

		if(da < db)
		{
			Console.WriteLine("A");
		}
		else
		{
			Console.WriteLine("B");
		}
	}
}


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

int main() {
    int x, N;
    x = 0;
    string S;
    cin >> N >> S;
    int count = N;
    vector<int> num(N+1);
    num.at(0) = x;
    for (int i = 0; i < count; i++)
    {
        if(S.at(i) == 'I'){
            x++;
            num.at(i+1) = x;
        }
        else if(S.at(i) == 'D' ){
            x--;
            num.at(i+1) = x;
        }
    }
    sort(num.begin(), num.end());
    cout << num.at(N) << endl;
    
    
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x,a,b;
int main(){
	scanf("%lld",&x);
	for(ll i=-200;i<=200;i++){
		for(ll j=-200;j<=200;j++){
			if(i*i*i*i*i-j*j*j*j*j==x){
				return printf("%lld %lld",i,j),0;
			}
		}
	}
}

Measured memory_bytes: 3784
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <memory>
#include <algorithm>
#include <cstring>

#define ll long long

using namespace std;


int main() {
    string s;
    cin >> s;
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
        cout << "Bad";
    else
        cout << "Good";

    return 0;
}


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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

	ll n;
	cin>>n;
	
	map<ll,ll> d;

	for(ll i=0; i<n; i++){
		ll tmp;cin>>tmp;

		if(d[tmp] ==0){
			d[tmp]++;
		}else {
			writeln("NO");
			return 0;
		}
	}
	writeln("YES");



}


Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
 
using namespace std;
using ll = long long;
 
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){ return a/gcd(a, b)*b; };
 
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Unique(a) a.erase(unique(Range(a)), a.end());
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

int main(void){
    Cin(ll, n, k);
    vector<pair<int, int>> a(n);
    For(i, n) cin >> a[i].first >> a[i].second;
    Sort(a);
    
    ll pos = 0;
    For(i, n){
        pos += a[i].second;
        if(k <= pos){
            Cout(a[i].first);
            return 0;
        }
    }
    
}

Measured memory_bytes: 1024
import sys

# import numpy as np

def _sum_ob_divisors(n):
    def f(n, x):
        y = n // x
        return y * (y + 1) * x // 2
    return sum(f(n, i) for i in range(1, n + 1))


# def _sum_ob_divisors(n):
#     L = [1] * (n + 1)
#     # L = np.ones(n + 1, dtype=np.int64)
#     for i in range(2, n + 1):
#         for j in range(i, n + 1, i):
#             L[j] += 1
#         # L[i:n + 1:i] += 1
#     # print(f'{L=}')
#     return sum(i * x for i, x in enumerate(L))


def sum_ob_divisors(f):
    n = int(f.read())

    return _sum_ob_divisors(n)


def main():
    ans = sum_ob_divisors(sys.stdin.buffer)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
object Main extends App {
	val Array(a, b) = scala.io.StdIn.readLine.split(" ").map(_.toLong)

	val gp0 = if(a < b) a else b
	val gp1 = if(a < b) b else a

	var ans = gp1

	while(ans % gp0 != 0L){
		ans += gp1
	}

	println(ans)

}

Measured memory_bytes: 25656
//#pragma optimization_level 3
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordset;
*/
#define fr first
#define sc second
#define vec vector
#define pb push_back
#define pii pair<int, int>
#define forr(x,y,z) for(int x = (int)y ; x <= (int)z ; ++x)
#define forn(x,y) for(int x = 1; x <= (int)y; ++x)
#define all(x) (x).begin(),(x).end()
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> pll;
typedef unsigned int uint;
typedef complex<ll> point;
const int nmax = 200005;
const ll linf = 1e18;
const ll mod = 1e9+7;
const int inf = 1e9;





int n;
int main(){
	fast;
	cin >> n;
	cout << 360 / __gcd(n,360) << '\n';
}




Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define N 200100
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i+=1)
#define rep(i,l,r) for(int i=l;i<=r;i+=1)
#define INF 100000000000000
#define pii pair<int,int>
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


signed main()
{
    
    speed
    int n;
    cin>>n;
    int f=0;
    while(n){
        int xd=n%10;
        if(xd==7){
            cout<<"Yes"<<endl;
            f=1;
            break;
        }
        n/=10;
    }
    if(!f)
        cout<<"No"<<endl;
    
   
    
    
    
    return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll n, k;

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

vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n/i) res.push_back(n/i);
        }
    }
    return res;
}

ll solve() {
    vector<ll> d = divisor(n);
    sort(ALL(d));
    int l = d.size();
    ll num[l];
    for (int i = 0; i < l; i++) {
        num[i] = mod_pow(k, d[i]/2+(d[i]%2));
        for (int j = 0; j < i; j++) {
            if (d[i] % d[j] == 0) {
                num[i] = (num[i] - num[j] + mod) % mod;
            }
        }
    }

    ll res = 0;
    for (int i = 0; i < l; i++) {
        res = (res + num[i] * (d[i]%2==0?d[i]/2:d[i]) % mod) % mod;
    }
    return res;
}

void input() {
    cin >> n >> k;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int food[5];
  
  int saigo = 0;
  int maxSa = 0;
  for (int i = 0; i < 5; i++) {
    cin >> food[i];
    int sa = 10 - (food[i] % 10);
    if (sa != 10 && sa > maxSa) {
      saigo = i;
      maxSa = sa;
    }
  }
  
  int time = 0;
  for (int i = 0; i < 5; i++) {
    if (i == saigo) {
      continue;
    }
    time += food[i];
    if (food[i] % 10 != 0) {
      time += 10 - (food[i] % 10);
    }
  }
  
  time += food[saigo];
  
  cout << time << endl;
}


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

int main(){
	int n; cin >> n;
	vector<string> s(n);
	for(int i=0;i<n;i++) cin >> s[i];
	vector<int> marchnum(5,0);
	for(int i=0;i<n;i++){
		if(s[i].front()=='M') marchnum[0]++;
		if(s[i].front()=='A') marchnum[1]++;
		if(s[i].front()=='R') marchnum[2]++;
		if(s[i].front()=='C') marchnum[3]++;
		if(s[i].front()=='H') marchnum[4]++;
	}
	long long ans=0;
	for(int i=0;i<3;i++){	
		for(int j=i+1;j<4;j++){
			long long temp=0;
			for(int k=j+1;k<5;k++) temp+=marchnum[k];
			ans+=marchnum[i]*marchnum[j]*temp;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 6144
/**
     *    author:  shashank_hire
    **/
#include <bits/stdc++.h>
using namespace std;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define ll long long
#define ld long double
#define MOD 1000000007

int main()
{
    IOS;
    ll n, W, i, j, sum;
    cin>>n>>W;
    vector<ll> v(n), w(n);

    for(i=0;i<n;i++)
        cin>>w[i]>>v[i];
	sum = accumulate(v.begin(), v.end(), 0);
    vector<vector<ll>> dp(n, vector<ll>(sum+1, 1e18));
	for(i=0;i<n;i++)
		dp[i][0] = 0;
    for(j=1;j<=sum;j++)
		if(j<=v[0])
            dp[0][j] = w[0];
    for(i=1;i<n;i++)
        for(j=1;j<=sum;j++)
			if(j>=v[i])
				dp[i][j] = min(dp[i-1][j], w[i] + dp[i-1][j-v[i]]);
			else
				dp[i][j] = dp[i-1][j];
    // for(j=0;j<=sum;j++)
	// 	cout<<j<<"\t\n"[j==sum];
	// cout<<"----------------------------------------------------------------------------------------------------------------------------------------\n";
    // for(i=0;i<n;i++)
    //     for(j=0;j<=sum;j++)
	// 		cout<<dp[i][j]<<"\t\n"[j==sum];
	for(j=sum;j>=0 and dp[n-1][j]>W;j--)
			;
	cout<<j<<"\n";
	// cout<<dp[n-1].end() - upper_bound(dp[n-1].begin(), dp[n-1].end(), W)-1<<"\n";
}

Measured memory_bytes: 79488
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

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

    int counter=n;
    for(int i=1;i<n;i++){
        if(s.at(i-1)==s.at(i)) counter--;
    }

    cout << counter << endl;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  int N,R;
  cin >> N >> R;
  if(N >= 10){
    cout << R << endl;
    return 0;
  }
  else{
    cout << R + 100*(10-N) << endl;
    return 0;
  }
}

Measured memory_bytes: 3604
import math

pi=math.pi

def Koch(n,p0,p1):
        if n==0:
           return False

        s=[0 for i in range(2)]
        t=[0 for i in range(2)]
        u=[0 for i in range(2)]
        
        s =[(2*p0[0]+1*p1[0])/3.0,(2*p0[1]+1*p1[1])/3.0]
        t =[(1*p0[0]+2*p1[0])/3.0,(1*p0[1]+2*p1[1])/3.0]
        u =[(t[0]-s[0]) * math.cos (pi / 3) - (t[1]-s[1])* math.sin (pi / 3)+s[0],(t[0]-s[0]) * math.sin (pi / 3) + (t[1]-s[1])* math.cos (pi / 3)+s[1]]
        Koch(n-1,p0,s)
        print("{0:.8f} {1:.8f}".format(s[0],s[1]))
        Koch(n-1,s,u)
        print("{0:.8f} {1:.8f}".format(u[0],u[1]))
        Koch(n-1,u,t)
        print("{0:.8f} {1:.8f}".format(t[0],t[1]))
        Koch(n-1,t,p1)

p0=[0, 0]
p1=[100,0]
n=int(input())

print("{0:.8f} {1:.8f}".format(p0[0],p0[1]))
Koch(n,p0,p1)
print("{0:.8f} {1:.8f}".format(p1[0],p1[1]))



Measured memory_bytes: 5776
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int gcd(int a, int b)
{
  if(a < b){
    int tmp = a;
    a = b;
    b = tmp;
  }
  if(b == 0) return a;
  gcd(b, a%b);
}
int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  vector<int> l(n), r(n);
  l[0] = 0;
  r[n-1] = 0;
  for(int i = 1; i < n; i++){
    l[i] = gcd(l[i-1], a[i-1]);
  }
  for(int i = n-1; i > 0; i--){
    r[i-1] = gcd(r[i], a[i]);
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    int m;
    m = gcd(l[i], r[i]);
    ans = max(ans, m);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
N,Q=gets.split.map(&:to_i)

tree = {}
(N-1).times do
  a,b = gets.split.map(&:to_i)
  tree[a] ||= []
  tree[a] << b
  tree[b] ||= []
  tree[b] << a
end

score = Array.new(N+1,0)
Q.times do
  p,x = gets.split.map(&:to_i)
  score[p] += x
end

ret = Array.new(N+1,0)
check = Array.new(N+1,0)
q = [[1, score[1]]]
# n = node, s = score
until q.empty?
  n, s = q.shift
  next if check[n] != 0
  check[n] = 1
  ret[n] = s
  (tree[n]||[]).each do |child|
    q << [child,s+score[child]]
  end
end
# p ret, tree, score

ret.shift
puts ret.join(' ')


Measured memory_bytes: 50684
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func scanInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = scanInt()
	}
	return sl
}

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

func main() {
	n, m := scanInt(), scanInt()
	g := make([][]int, n)
	for i := 0; i < m; i++ {
		a := scanInt()
		b := scanInt()
		a--
		b--
		g[a] = append(g[a], b)
		g[b] = append(g[b], a)
	}

	dist := make([]int, n)
	prev := make([]int, n)
	for i := range dist {
		dist[i] = -1
		prev[i] = -1
	}
	dist[0] = 0
	var q []int
	q = append(q, 0)

	for len(q) > 0 {
		v := q[0]
		q = q[1:]

		for _, nv := range g[v] {
			if dist[nv] != -1 {
				continue
			}

			dist[nv] = dist[v] + 1
			prev[nv] = v
			q = append(q, nv)
		}
	}

	for _, d := range dist {
		if d == -1 {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
	for i := 1; i < n; i++ {
		fmt.Println(prev[i] + 1)
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 18704
#include <bits/stdc++.h>
typedef long long int lli;
using namespace std;
#define MOD 1000000007
#define MAX 500005
lli p[MAX];
lli arr[MAX];
lli n;
lli a,b;
void DFS1(lli s,  lli dist, unordered_set <lli> &color){
    if(dist %a == 0){
        color.insert(s);
    }
    if(s == 1)
        return;
    DFS1(p[s], dist+1, color);
}
void DFS2(lli s,  lli dist, unordered_set <lli> &color){
    if(dist %b == 0)
        color.insert(s);
    if(s == 1)
        return;
    DFS2(p[s], dist+1, color);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli l,r;
    cin>>l>>r;
    lli d;
    cin>>d;
    lli curr = 0;
    lli c = 0;
    while(curr <= r){
        if(curr >=l)
            c++;
        curr +=d;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7;
ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}
ll LCM(ll x, ll y) { 
  return x / GCD(x, y) * y;
}

int main(){
  string s; cin >> s;
  for(int i=0; i<=s.size()-1; i += 2) {
    if(s[i] == 'L' || s[i+1] == 'R') {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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


		if (N.charAt(N.length() - 1) == '3') {
			System.out.println("bon");
		} else if (N.charAt(N.length() - 1) == '0' || N.charAt(N.length() - 1) == '1' || N.charAt(N.length() - 1) == '6'
				|| N.charAt(N.length() - 1) == '8') {
			System.out.println("pon");
		} else {
			System.out.println("hon");
		}

		scan.close();

	}
}


Measured memory_bytes: 35728
N=int(input())
A=list(map(int,input().split()))
key=max(A)+1 #最大値もrange(a,key,a)で計算させるため
B=[0]*key #0~Aの最大値までのlistを作成
for a in A:
    for b in range(a,key,a):
        B[b]+=1 #aの倍数を全てにBリストで1を足す
ans=0
for a in A:
    if B[a]==1: #自身しか倍数にならなかった物
        ans+=1
print(ans)

Measured memory_bytes: 32380
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F();
		var b = G().Select(x => -x).ToList();
		var g = new Dinic(N + 2);
		var s = 0L;
		for (var i = 0; i < N; i++)
			if (b[i] < 0)
			{
				s -= b[i];
				g.AddEdge(0, i + 1, 0);
				g.AddEdge(i + 1, N + 1, -b[i]);
			}
			else
			{
				g.AddEdge(0, i + 1, b[i]);
				g.AddEdge(i + 1, N + 1, 0);
			}
		for (var i = 1; i <= N; i++) for (var j = 2 * i; j <= N; j += i) g.AddEdge(i, j, Dinic.INF);
		Console.WriteLine(s - g.MaxFlow(0, N + 1));
	}
}
class Dinic
{
	public const long INF = 4011686018427387913L;
	class Edge
	{
		public readonly int To;
		public long Capacity;
		public Edge Reverse;
		public Edge(int to, long cap, Edge rev)
		{
			To = to;
			Capacity = cap;
			Reverse = rev;
		}
	}
	public Dinic(int v)
	{
		V = v;
		es = new List<Edge>[v];
		for (var i = 0; i < V; i++) es[i] = new List<Edge>();
		level = new int[V];
	}
	readonly int V;
	readonly List<Edge>[] es;
	readonly int[] level;
	int[] iter;
	public void AddEdge(int f, int t, long c)
	{
		var e1 = new Edge(t, c, null);
		var e2 = new Edge(f, 0, e1);
		e1.Reverse = e2;
		es[f].Add(e1);
		es[t].Add(e2);
	}
	long DFS(int v, int t, long f)
	{
		if (v == t) return f;
		for (; iter[v] < es[v].Count; iter[v]++)
		{
			var e = es[v][iter[v]];
			if (level[v] >= level[e.To] || e.Capacity <= 0) continue;
			var g = DFS(e.To, t, Math.Min(e.Capacity, f));
			if (g > 0)
			{
				e.Capacity -= g;
				e.Reverse.Capacity += g;
				return g;
			}
		}
		return 0;
	}
	void BFS(int s)
	{
		for (var i = 0; i < V; i++) level[i] = -1;
		var queue = new Queue<int>();
		level[s] = 0;
		queue.Enqueue(s);
		while (queue.Count > 0)
		{
			var v = queue.Dequeue();
			foreach (var e in es[v])
				if (e.Capacity > 0 && level[e.To] < 0)
				{
					level[e.To] = level[v] + 1;
					queue.Enqueue(e.To);
				}
		}
	}
	public long MaxFlow(int s, int t)
	{
		var flow = 0L;
		while (true)
		{
			BFS(s);
			if (level[t] < 0) return flow;
			iter = new int[V];
			while (true)
			{
				var f = DFS(s, t, INF);
				if (f <= 0) break;
				flow += f;
			}
		}
	}
}


Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  double r;
  cin >> r;
  cout << fixed << setprecision(10);
  cout << 2*r*PI << endl;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) ((a>b)?a:b);
#define min(a,b) ((b>a)?a:b);
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)                                 //g++ template.cpp -o template.exe
//#define all(x) (x).begin(), (x).end()
typedef long long int ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn=100000;







bool sortbysec(const pair<int,int> &a,                         //sorting of elements wrt second
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
void primeFactors(long long int n)  
{  
	//vector<int> v
	long long int sum=0,j=0,cnt=0;
    
    while (n % 2 == 0)  
    {  
        //cout << 2 << " "; 
        cnt++;
        if(cnt>j)
        {
        	j++;
        	sum++;
        	cnt=0;
        	//cout<<sum<<endl;
        	
        }


        n = n/2;  
    }  


   
    for (long long int i = 3; i <= sqrt(n); i = i + 2)  
    {  
    	j=0;
    	cnt=0;
        
        while (n % i == 0)  
        {  
            cnt++;
             if(cnt>j)
           {
        	  j++;
        	  sum++;
        	  cnt=0;
        	 // cout<<sum<<" "<<i<<endl;
        	
           } 
            n = n/i;  
        }  
    }  
  
    
    if (n > 2)  
        sum++;

        cout<<sum<<endl; 
}  



int main()
{
	
	unsigned long long int n;
	//long long int k=1;
	cin>>n;
	//unsigned long long int a[n];
	primeFactors(n);
	

	return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>

using namespace std;

char a[100010];

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	scanf("%s",a);int n=strlen(a);
	int k;scanf("%d",&k);
	for (int i=0;i<n-1;i++)
	{
		int x=(26-(a[i]-'a'))%26;
		if (x<=k) {k-=x;a[i]='a';}
	}
	a[n-1]=(a[n-1]-'a'+k)%26+'a';
	for (int i=0;i<n;i++) putchar(a[i]);
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		//標準入力オブジェクトを生成
		Scanner sc = new Scanner(System.in);
		//標準入力で以下の変数を初期化
		int numberA = sc.nextInt();
		int numberB = sc.nextInt();
		//正整数を判定
		if(0 < numberA && 0 < numberB) {
			//積を求める
			int multipl = numberA * numberB;
			//奇数文字列・偶数文字列　変数宣言
			String strNum;
			//偶数・奇数を判定　文字列に代入
			if(multipl % 2 == 0) {
				strNum = "Even";
			}else {
				strNum = "Odd";
			}
			//標準出力
			System.out.print(strNum);
		}
	}
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
   ll k,x;cin >>k>>x;
    for (int i = -k+1; i <k; ++i) {
        cout <<x+i<<" ";
    }
    cout <<endl;
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>


int main(void)
{
	char s[100000+2];

	while(scanf("%100000[a-z]\n", s)==1)
	{
		int l=strlen(s);
		char *p=s;

		for(int i=0;i<l;i++)
		{
			if(!(i&1)) *p++=s[i];
		}
		*p='\0';
		printf("%s\n", s);
	}

	return 0;
}


Measured memory_bytes: 256
//
//  B - Time Limit Exceeded.cpp
//  Atcoder(Oct.6ABC)
//
//  Created by Hajime Sakamoto on 2018/10/06.
//  Copyright © 2018 Hajime Sakamoto. All rights reserved.
//

#include <stdio.h>
#include <iostream>
using namespace std;

int N;
int T;
int c[1010];
int t[1010];

int J=2000;
int main(){
    
    cin>>N>>T;
    
    for (int i=0;i<N;i++){
        cin>>c[i]>>t[i];
    }
    
    for(int i=0;i<N;i++){
        if(t[i]<=T && c[i]<J){
            J=c[i];
        }
    }
    
    if (J==2000){
        cout <<"TLE"<<endl;
    }
    else{
        cout <<J;
    }
    
    
    return 0;
    
}



Measured memory_bytes: 256
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

h,w = MI()
maze = LS(h)
sy = 1
sx = 1
gy = h
gx = w
sy -= 1
sx -= 1
gy -= 1
gx -= 1

d = [ [INF]*w for _ in range(h) ]

def bfs(sy,sx,gy,gx):
    q = deque()
    q.append([sy,sx])
    d[sy][sx] = 0
    while q:
        y,x = q.popleft()
        if y==gy and x==gx:
            break
        else:
            for j,i in ([1,0],[0,-1],[-1,0],[0,1]):
                ny = y + j
                nx = x + i
                if nx==-1 or ny==-1 or nx==w or ny==h:
                    pass
                elif maze[ny][nx]=="#":
                    pass
                elif d[ny][nx]!=INF:
                    pass
                else:
                    q.append([ny,nx])
                    d[ny][nx] = d[y][x] + 1
    return d[gy][gx]

count = 0
for i in range(h):
    c = maze[i].count('.')
    count += c

d = bfs(sy,sx,gy,gx) 
# print(f'd={d}')  
if d==INF:
    print('-1')
else:
    print(count-2-(d-1)) 

Measured memory_bytes: 77680
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
using ll = long long;

int main() {
	int n, m;
	cin >> n;
	map <ll, ll>mp;
	for (int i = 0;i < n;i++) {
		ll a;
		cin >> a;
		mp[a]++;
	}
	cin >> m;
	int flag = 0;
	for (int i = 0;i < m;i++) {
		ll b;
		cin >> b;
		if (mp[b] == 0)flag = 1;
		else mp[b]--;
	}
	cout << (flag ? "NO" : "YES") << endl;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

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

    ll int ans = 0;

    for(int b = K + 1; b <= N; ++b)
    {
        ans = ans + (N / b) * (b - K);
        if( (N % b - K + 1) > 0)
        {
            ans = ans + (N % b - K + 1);
            if(K == 0)
            {
                --ans;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define SIZE 2000000

int heap[SIZE];
int n;

void up(int i){
	if( i/2 <= 0 ){ return; }
	if( heap[i/2] > heap[i] ){ return; }
	int temp = heap[i/2];
	heap[i/2] = heap[i];
	heap[i] = temp;
	up(i/2);
	return;
}

void add(int key){
	heap[++n] = key;
	up(n);
	return;
}

void down(int i){
	if( 2*i > n ){
		return;
	}else if( 2*i+1 > n ){
		if( heap[2*i] > heap[i] ){
			int temp = heap[2*i];
			heap[2*i] = heap[i];
			heap[i] = temp;
		}
	}else{
		int j = (heap[i]>heap[2*i]?i:2*i);
		j = (heap[j]>heap[2*i+1]?j:2*i+1);
		if( j == i ){ return; }
		int temp = heap[j];
		heap[j] = heap[i];
		heap[i] = temp;
		down(j);
	}
	return;
}

int extract(){
	int re = heap[1];
	heap[1] = heap[n--];
	down(1);
	return re;
}

int main(){
	int i;
	char com[256];
	while( 1 ){
		scanf("%s", com);
		if( strcmp(com, "end") == 0 ){
			break;
		}else if( strcmp(com, "insert") == 0 ){
			scanf("%d", &i);
			add(i);
		}else if( strcmp(com, "extract") == 0 ){
			printf("%d\n", extract());
		}
	}
	return 0;
}

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

#define ll long long

ll n,k;
ll ans=0;
const ll mod=1e9+7;

int main(void){
	scanf("%d %d",&n,&k);
	while(k<=n+1){
		ans=(ans+k*(n-k+1)+1)%mod;
		k++;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 1732
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {

	char okada[55][55];
	int a = 0, b = 0, h = 0, w = 0;
	std::string str;
	char c;
	std::cin >> str;
	int k = 0;

	for (int i = 0; i < 4; i++) {
		char c = str[i];
		if (c == '+') {
			k++;
	
		}
		else {
			k--;
	
		}
	}
	std::cout<<k<<std::endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        String N = sc.next();
        char[] W = new char[N.length()+1];
        W[0]='0';
        for(int i=0;i<N.length();i++){
            W[i+1] = N.charAt(i);
        }
        System.out.println(sum(W, W.length-1));
    }

    private static void print(char[] N){
        for(int i=0;i<N.length;i++){
            System.out.print(N[i]);
        }
        System.out.println();
    }
    private static long sum(char[] N, int to){
        int keta = N[to]-'0';
//        int keta = N.charAt(N.length()-1)-'0';
        if(to == 0){
            if(keta <= 5){return keta;}
            else{return 11-keta;}
        }
        if(keta < 5) {
            return keta + sum(N, to-1);
        }else if(keta == 5){
            if(N[to-1] >= '5'){
                add(N, to-1);
                return (10-keta) + sum(N, to-1);
            }else{
                return keta + sum(N, to-1);
            }
        }else{
            add(N, to-1);
            return (10-keta) + sum(N, to-1);
        }
    }
    private static void add(char[] N, int ind){
        //if(N.length() == 0){return "1";}
        int i=ind;
        if(N[i] <= '8'){
            N[i]++;
            return;
        }
        while(i >= 0 && N[i] == '9'){
            N[i] = '0';
            i--;
        }
        N[i]++;
    }
}


Measured memory_bytes: 131076
#include <bits/stdc++.h>
using namespace std;
int dp[3001][3001];
void printLCS(string &s,string &t) {
  int sp=0,tp=0;
  while(sp < s.size() and tp < t.size()) {
    if (s[sp] == t[tp]) {
      cout << s[sp];
      sp++;
      tp++;
    } else {
      if (dp[sp][tp] == dp[sp][tp+1]) {
        tp++;
      } else {
        sp++;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  string s,t;
  cin >> s >> t;
  memset(dp,0,sizeof dp[0][0] * 3001 * 3001);
  for(int i=s.size()-1;i>=0;i--) {
    for(int j=t.size()-1;j>=0;j--) {
      if (s[i] == t[j]) {
        dp[i][j] = 1 + dp[i+1][j+1];
      } else {
        dp[i][j] = max(dp[i+1][j],dp[i][j+1]);
      }
    }
  }
  printLCS(s,t);
  return 0;
}

Measured memory_bytes: 35456
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint x;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> x;
	cout << 1-x << endl;
	
	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>

int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    if(a>b){
        printf("a > b\n");
    }else if(a<b){
        printf("a < b\n");
    }else{
        printf("a == b\n");
    }
    return 0;
}

Measured memory_bytes: 580
w,h,n=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
a1=[0];a2=[w];a3=[0];a4=[h]
for i in a:
  if i[2]==1:a1.append(i[0])
  else:pass
for i in a:
  if i[2]==2:a2.append(i[0])
  else:pass
for i in a:
  if i[2]==3:a3.append(i[1])
  else:pass
for i in a:
  if i[2]==4:a4.append(i[1])
  else:pass
if max(a1)-min(a2)<0:x=max(a1)-min(a2)
else:x=0
if max(a3)-min(a4)<0:y=max(a3)-min(a4)
else:y=0
print(x*y)

Measured memory_bytes: 3064
N = int(input())
B = list(map(int, input().split()))

ans = []

for k in range(N):
    flag = True
    for i, b in enumerate(reversed(B)):
        if N - k - i == b:
            ans.append(B.pop(b-1))
            flag = False
            break
    if flag:
        print(-1)
        exit()

for n in reversed(ans):
    print(n)

Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.HashMap;
import java.util.ArrayList;

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

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int n = in.nextInt();
            HashMap<Integer, Integer> ev = new HashMap<>();
            HashMap<Integer, Integer> od = new HashMap<>();

            int ev1 = -1;
            int ev2 = -1;
            int od1 = -1;
            int od2 = -1;

            for (int i = 0; i < n / 2; i++) {
                ev.merge(in.nextInt(), 1, Integer::sum);
                od.merge(in.nextInt(), 1, Integer::sum);
            }

            ArrayList<Integer> ale = new ArrayList<>(ev.keySet());
            ArrayList<Integer> alo = new ArrayList<>(od.keySet());

            for (Integer k : ale) {
                if (ev1 == -1) {
                    ev1 = k;
                } else {
                    if (ev.get(ev1) <= ev.get(k)) {
                        ev2 = ev1;
                        ev1 = k;
                    } else {
                        if (ev2 == -1) {
                            ev2 = k;
                        } else if (ev.get(ev2) <= ev.get(k)) {
                            ev2 = k;
                        }
                    }
                }
            }

            for (Integer k : alo) {
                if (od1 == -1) {
                    od1 = k;
                } else {
                    if (od.get(od1) <= od.get(k)) {
                        od2 = od1;
                        od1 = k;
                    } else {
                        if (od2 == -1) {
                            od2 = k;
                        } else if (od.get(od2) <= od.get(k)) {
                            od2 = k;
                        }
                    }
                }
            }
            if (ev1 != od1) {
                out.println((n / 2 - ev.get(ev1)) + (n / 2 - od.get(od1)));
            } else {

                if (ev2 == -1 && od2 == -1) {
                    out.println(n / 2);
                } else {
                    out.println(Math.min((n / 2 - ev.get(ev1)) + (n / 2 - od.get(od2)),
                            (n / 2 - ev.get(ev2)) + (n / 2 - od.get(od1))));
                }
            }


        }

    }
}



Measured memory_bytes: 66596
n = gets.chomp.to_i
hs = gets.chomp.split(" ").map(&:to_i)

max_step = 0
now_step = 0
now_height = hs.shift

hs.each do |h|
  if h > now_height
    max_step = [max_step, now_step].max
    now_step = 0
  else
    now_step += 1
  end
  
  now_height = h
end

puts [max_step, now_step].max


Measured memory_bytes: 12036
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int gcd(int m,int n)
 {
    return n==0 ? m: gcd(n,m%n);    
 }
 
 int main()
 {
   int m,n;
   while(cin>>m>>n)
   {
     int result=gcd(m,n);
     cout<<result<<endl;                  
   }
   //while(1);
   return 0;
 }

Measured memory_bytes: 3088
N = int(input())
ARR = list(map(int,input().split()))
def calculate(n, arr):
    result = 0
    right = 0
    sum = arr[0]
    for left in range(0, n):
        while right+1 < n:
            if sum ^ arr[right+1] == (sum + arr[right+1]):
                right = right + 1
                sum = sum + arr[right]
            else:
                break
        result = result + right - left + 1
        sum = sum - arr[left]
    print(result)

calculate(N, ARR)


Measured memory_bytes: 24840
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>
#include <queue>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;
typedef long long ll;


int main(){
        ll N;
        cin >> N;
        if(N >= 64) cout << 64;
        else if(N>=32) cout << 32;
        else if(N>=16) cout << 16;
        else if(N>=8) cout << 8;
        else if(N>=4) cout << 4;
        else if(N>=2) cout << 2;
        else cout << 1;
}


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

int main(void){

  int a, b, c;
  int i;
  int n = 0;

  scanf("%d %d %d", &a, &b, &c);

  for(i = a; i <= b; i++){
    if(c % i == 0){
      n++;
    }
  }

  printf("%d\n", n);
    
  return 0;
}


Measured memory_bytes: 2140
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int N, A; cin >> N >> A; int kosu[202020] = {};
  int s[N], t[N], C[N];
  rep(i, N){
    cin >> s[i] >> t[i] >> C[i];
    C[i]--;
  }
  rep(i, 30){
    int shiyo[202020] = {};
    rep(j, N){
      if(C[j]==i){
        shiyo[2*s[j] - 1]++; shiyo[2*t[j]]--;
      }
    }
    rep(j, 202010){
      shiyo[j+1]+=shiyo[j];
    }
    rep(j, 202010){
      if(shiyo[j]>0) kosu[j]++;
    }
  }
  int ans = 0;
  rep(i, 202010){
    ans = max(ans, kosu[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2944
n = gets.to_i
as = gets.split.map(&:to_i)
rates = 8.times.map { |i| (i * 400...(i + 1) * 400) }

count = 0 # gte 3200
ans = as.each_with_object([]) do |a, arr|
  if a < 3_200
    arr << rates.index { |r| r.include?(a) }
  else
    count += 1
  end
end.uniq

min = ans.count > 0 ? ans.count : 1
max = ans.count + count
puts [min, max].join(" ")


Measured memory_bytes: 1788
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>

using namespace std;

int main()
{
	char a[1005];
//	for(int i=0;i<4;i++)
//	{
//		scanf("%c",&a[i]);
//	}
	scanf("%s",a);
	sort(a,a+4);
	if(a[0]==a[1])
	{
		if(a[2]==a[3])
		{
			if(a[0]!=a[2])
			{
				printf("Yes\n");
			}
			else
			{
				printf("No\n");
			}
		}
		else
		{
			printf("No\n");
		}
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>

typedef  long long ll;
#define mop 1000000007
#define mop2 998244353
using namespace std;

int main() {
    
    ll n;
    cin >> n;
    bool ans = false;
    while(n > 0){
        if(n%10 == 7){
            ans = true;
            break;
        }
        n /= 10;
    }
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll S;
  cin >> S;
  ll X1 = 0;
  ll Y1 = 0;
  ll X2 = 1000000000;
  ll Y2 = 1;
  cout << X1 << " " << Y1 << " " << X2 << " " << Y2;
  ll X3 = (X2 - (S % X2)) % X2;
  ll Y3 = ((S - 1) / X2) + 1;
  cout << " " << X3  << " " << Y3 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {
	int n, d, x;
	int a[101];
	int total = 0;

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

	total += x;

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= d; j += a[i]) {
			total++;
		}
	}

	cout << total << endl;

	return 0;
}

Measured memory_bytes: 256
def W_tips(j):
    global K,g,now,tips
    for i in range(g):
        now[i]+=tips[i][j]
    for i in range(g):
        if now[i] > K:
            return False
    return True

f_inf=float("inf")
H,W,K=map(int,input().split())
S=[list(map(int,list(input()))) for _ in range(H)]
ans = f_inf
for div in range(1 << (H-1)):
    g=0
    tips=[[0]*W]
    tips[g]=[s+b for s, b in zip(S[0],tips[g])]
    for i in range(1,H):
        if div >> (i-1) &1:
            g+=1
            tips.append([0]*W)
        tips[g]=[s + b for s, b in zip(S[i],tips[g])]
    num=g
    g+=1
    now=[0]*g
    for j in range(W):
        if W_tips(j)==False:
            num+=1
            now=[0]*g
            if W_tips(j)==False:
                num=f_inf
                break
    ans=min(ans,num)
print(ans)


Measured memory_bytes: 3188
// https://atcoder.jp/contests/diverta2019/tasks/diverta2019_b
#include <bits/stdc++.h>
using namespace std;

int main(void){
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int count = 0;
  for (int i = 0; i < 3001; i++){
    for (int j = 0; j < 3001; j++){
      if ((N - R*i - G*j)>=0 && (N - R*i - G*j) % B == 0){
        count++;
      }
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 384