akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

const int N=500005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x=(x+y)%mod;}
template<class T> inline void read(T &x){
	x=0;char ch=getchar(),rev=0;
	while(ch>'9'||ch<'0') rev=(ch=='-'),ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	x=rev?-x:x;
}
template<class T> inline void print(T x){
	if(!x){puts("0");return;}
	if(x<0){putchar('-');x=-x;}
	int a[20],m=0;
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');puts("");
}
inline int exp(int x,int y){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,a[N];
char str[N];
set<int> s;

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
#endif
	scanf("%s",str+1);n=strlen(str+1);
	for(int i=1;i<=n;i++)
		a[i]=str[i]-'0';
	int ans=0;
	for(int i=2;i<=n;i++)
		if(a[i]!=a[i-1]) s.insert(i);
	for(int i=1;i<=n;i++){
		int r=i;
		while(1){
			if(s.upper_bound(r)==s.end()){printf("%d\n",ans+1);return 0;}
			int t=*s.upper_bound(r);
			if(a[t]>a[r]) r=t; else break;
		}
		for(int j=i;j<=r;j++)
			a[j]=0;
//		while((*s.begin())<=r) s.erase(s.begin());
		i=r;a[n]++;r=n;
		while(a[r]==10) a[r]=0,a[r-1]++,r--;
		for(int j=r;j<=n;j++)
			if(a[j]!=a[j-1]) s.insert(j); else if(s.find(j)!=s.end()) s.erase(j);
		ans++;
	}
//	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 23808
# Sum of Three Integers
K, S = map(int, input().split())

ans = 0

for x in range(K+1): # xは0からKまで走る
	for y in range(K+1): # yは0からKまで走る
		z = S - x - y # zはこの時点で決まる
		if 0 <= z <= K:
			ans += 1

print(ans) 

Measured memory_bytes: 2940
#include <iostream>
#include <memory>
#include <memory.h>
#include <cmath>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
#define USE_MATH_DEFINES
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

typedef pair<xy_t, bool> dat;

namespace std{
	bool operator < (const xy_t &a, const xy_t &b){
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}

double cross(const xy_t &a, const xy_t &b){
	return imag(conj(a) * b);
}

double dot(const xy_t &a, const xy_t &b){
	return real(conj(a)*b);
}

int ccw(xy_t a, xy_t b, xy_t c){
	b -= a; c -= a;
	if(cross(b, c) > 0) return 1;
	if(cross(b, c) < 0) return -1;
	if(dot(b, c) < 0) return +2;
	if(norm(b) < norm(c) ) return -2;
	return 0;
}

bool intersectSS(const line &s, const line &t){
	return ccw(s.first, s.second, t.first) * ccw(s.first, s.second, t.second) <= 0 &&
		ccw(t.first, t.second, s.first) * ccw(t.first, t.second, s.second) <= 0;
}

xy_t crosspoint(const line &l, const line &m){
	double a = cross(l.second - l.first, m.second - m.first);
	double b = cross(l.second - l.first, l.second - m.first);
	if(abs(a) < EPS && abs(b) < EPS) return m.first;
	if(abs(a) < EPS) assert(false);
	return m.first + b / a * (m.second - m.first);
}

int t[20][20];
int dp[1 << 20];

int main(){
	int n;
	while(cin >> n && n){
		fill(dp, dp + (1 << 20), INF);
		for(int i = 0; i < n; i++){
			for(int j = 0; j <= n; j++){
				cin >> t[i][j];
			}
		}
		dp[0] = 0;
		for(int s = 0; s < (1 << n); s++){
			for(int i = 0; i < n; i++){
				if(!(s & (1 << i))){
					int need = t[i][0];
					for(int j = 0; j < n; j++){
						if(s & (1 << j)){
							need = min(t[i][j+1], need);
						}
					}
					dp[s | 1 << i] = min(dp[s | 1 << i], dp[s] + need);
				}
			}
		}
		
		cout << dp[(1 << n) - 1] << endl;
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

ll lcm(ll a, ll b) {
    return a * b / __gcd(a, b);
}

int main(){
    ll A, B;
    int C, D;
    cin >> A >> B >> C >> D;

    ll count[3];
    count[0] = B / C - (A-1) / C;
    count[1] = B / D - (A-1) / D;
    count[2] = B / lcm(C, D) - (A-1) / lcm(C, D);

    ll N = B - A + 1;
    ll ans = N - (count[0] + count[1] - count[2]);
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	//"math"
	//"strings"
)

func main() {
	var a,b,c,d,e,k int
	fmt.Scan(&a,&b,&c,&d,&e,&k)
	if e-a > k{
		fmt.Print(":(")
	}else{
		fmt.Print("Yay!")
	}
}


Measured memory_bytes: 512
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        int n = inp.nextInt();
        int k = inp.nextInt();
        int ni = 0;
        Set<Integer> a = new TreeSet<Integer>();
        for (int i = 0; i < k; i++) {
            ni = inp.nextInt();
            for (int j = 0; j < ni; j++) {
                a.add(inp.nextInt());
            }
        }
        int tmp[] = new int[n];
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            if (!(a.contains(i))) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 46460
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        v[i] = {x, i};
    }
    sort(v.begin(),v.end());
    for (int i = 0; i < n; ++i) {
        if(i) printf(" ");
        printf("%d", v[i].second+1);
    }
    puts("");
    return 0;
}

Measured memory_bytes: 1536
import java.util.*;
public class Main {
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	long N = sc.nextLong();
 	long A = sc.nextLong();
 	long B = sc.nextLong();
  	long amari = N%(A+B);
  	long ans=0;
  	if(A==0){
      System.out.print("0");
      System.exit(0);
    }
     
  	ans = A * (N/(A+B));
  	if(amari<=A){
     ans += amari; 
    }else{
      ans += A;
    }
  
	System.out.print(ans);
	}
}

Measured memory_bytes: 21972
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

// Returns n divisors ORDER BY ASC.
vector<i64> getDivisors(i64 n) // {{{
{
    vector<i64> ret;
    i64 i = 1;
    for (i = 1; i * i < n; ++i) {
        if (n % i == 0) {
            ret.emplace_back(i);
            ret.emplace_back(n / i);
        }
    }
    if (i * i == n) ret.emplace_back(i);
    sort(begin(ret), end(ret));
    return ret;
} // }}}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    var(i64, N);
    const auto divisors = getDivisors(N);

    i64 ans = 0;
    for (const i64 k : divisors) {
        const i64 m = N / k - 1;
        if (m == 0) continue;
        if (N / m == N % m) ans += m;
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include<string.h>

int main (void){
    int num,lfoot=0,rfoot=0;
    int count=0;
    int i;
    char input[3];
    int ppos=0,pos=0;
    while(1){
        lfoot = rfoot = count = 0;
        ppos=0;
        pos=0;
        scanf("%d",&num);
        if(!num)
            break;
        for(i=0;i<num;i++){
            scanf("%s",input);
            if(!strcmp(input,"lu")){
                lfoot++;
                //printf("%d %d\n", lfoot, rfoot);//debug
            }else if(!strcmp(input,"ru")){
                rfoot++;
                //printf("%d %d\n", lfoot, rfoot);//debug
            }else if(!strcmp(input,"ld")){
                lfoot--;
                //printf("%d %d\n", lfoot, rfoot);//debug
            }else if(!strcmp(input,"rd")){
                rfoot--;
                //printf("%d %d\n", lfoot, rfoot);//debug
            }
            
            if(lfoot == rfoot)
                pos = lfoot;
            
            if(lfoot == rfoot && ppos != pos){
                count++;
                ppos = pos;
            }
        }
        
        printf("%d\n",count);
    }
    
    return 0;
}

Measured memory_bytes: 604
H,W=map(int,input().split())

A=[0]*H
i=0
while i<H:
    A[i]=list(input())
    i+=1

B=[]
for i in A:
    if '#'in i:
        B.append(i)

j=W-1
while j>=0:
    if all(i[j]=='.' for i in B):
        k=0
        while k<len(B):
            B[k].pop(j)
            k+=1
    j-=1




for i in B:
    print(''.join(i))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, A[N], XX[N], fa[N], mn[N], sz[N], id[N], stk[N];
int Find(int x) {
	return x == fa[x] ? x : fa[x] = Find(fa[x]);
}
void Union(int x, int y) {
	x = Find(x), y = Find(y);
	fa[y] = x;
	mn[x] = min(mn[x], mn[y]);
}
set<pair<int, int> > st;
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		A[x] = y;
		XX[i] = x;
		fa[x] = x;
		mn[x] = y;
	}
	for (int i = 1; i <= n; i++) {
		while (st.size() && st.begin() -> first < A[i]) {
			Union(st.begin() -> second, i);
			st.erase(st.begin());
		}
		st.insert(make_pair(mn[Find(i)], i));
	}
	for (int i = 1; i <= n; i++) sz[Find(i)]++;
	for (int i = 1; i <= n; i++) {
		printf("%d\n", sz[Find(XX[i])]);
	}
	return 0;
}

Measured memory_bytes: 11784
#include <bits/stdc++.h>
#define ft first
#define sd second
#define maxn 200005
#define mod 998244353
#define PI 3.14159265
#define MP make_pair
#define PB push_back
#define heap priority_queue
#define Bjerg ""
using namespace std;
long long n;
int a[maxn], m;
int av[maxn];
void read()
{
    cin >> n >> a[0] >> m;
}
long long sum[maxn];
long long get(int l , int r)
{
    if(r<l) return 0;
    if(r<0) return 0;
    long long res=sum[r];
    if(l>0) res-=sum[l-1];
    return res;
}
void solve()
{
    if(n<=1e5)
    {
        long long res= a[0];
        for(int i=1;i<n;++i)
        {
            a[i]= (1ll*a[i-1]*a[i-1])%m;
            res+=a[i];
        }
        cout << res<<endl;
    }
    else
    {
        memset(av,-1,sizeof(av));
        av[a[0]]=0;
        sum[0]=a[0];
        int l , r ;
        for(int i=1;i<n;++i)
        {
            a[i]= (1ll*a[i-1]*a[i-1])%m;
            if(av[a[i]]!=-1)
            {
                r=i-1;
                l=av[a[i]];
                break;
            }
            av[a[i]]=i;
            sum[i] = sum[i-1]+a[i];
        }
        long long res= get(0,l-1);
        n-=l;
        int dis = (r-l+1);
        res += 1ll*get(l,r)*(n/dis);
        res += get(l+0,l+n%dis-1);
        cout << res;
    }
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen(Bjerg".inp","r",stdin);
    read();
    solve();
    return 0;
}


Measured memory_bytes: 5016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int a,b,k,ans;
  cin>>a>>b>>k;
  int c=min(a,b);
  for(int i=c;i>=1;i--){
    if(a%i==0&&b%i==0){
      k--;
    }
    if(k==0){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
x1, y1, x2, y2 = map(int,input().split())
dx, dy = x2-x1, y2-y1

x3, y3 = x1 + dx - dy, y1 + dy + dx
x4, y4 = x1 - dy, y1 + dx

print(x3, y3, x4, y4)

Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

static class CodeJam
{
    static long Solve(long N, int[] L)
    {
        long[] sums1 = new long[2001];
        for (int i = 0; i < N; ++i)
        {
            for (int j = i + 1; j < N; ++j)
            {
                ++sums1[L[i] + L[j]];
            }
        }
        long[] sums2 = new long[2001];
        for (int i = 1; i <= 2000; ++i)
        {
            sums2[i] = sums2[i - 1] + sums1[i];
        }
        return N * (N - 1) * (N - 2) / 6 - L.Sum(l => sums2[l]);
    }

    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int[] L = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        Console.WriteLine(Solve(N, L));
    }
}


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

result = [1] * (N + 1)

for i in range(2, N + 1):
    result[i] += 1
    temp = 2
    while temp * i <= N:
        result[temp * i] += 1
        temp += 1

hoge = 0
for i, v in enumerate(result):
    if (i % 2) == 1 and v == 8:
        hoge += 1

print(hoge)

Measured memory_bytes: 3060
n,m=list(map(int, input().split()))
a=list(map(int, input().split()))
a.sort(reverse=True)
while m>0:
  a[0] //= 2
  m = m - 1
  for i in range(n-1):
    if a[0] < a[i+1] and m > 0:
      a[i+1] //= 2
      m = m - 1
    else:
      a.sort(reverse=True)
      break
print(sum(a))

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



int main(){
    int n;
    cin>>n;
    int a[n+1];
    rep2(i,1,n+1) cin>>a[i];

    int count = 1;
    int idx = 1;

    while(--n){
        if(a[idx] == 2){
            cout<< count <<endl;
            return 0;
        }
        else{
            ++count;
            idx = a[idx];
        }
    }

    cout << -1 <<endl;
    return 0;
}


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

using namespace std;

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(NULL);
   int n,i,j;long int w;
   cin >> n >> w;
   long int wt[n+1];int val[n+1];long int x =0;
   for(i=1;i<=n;i++){
       cin >> wt[i] >> val[i];
       x+= val[i];
   }
    vector <long long int > dp(x+1,1e18);
    dp[0]=0;
    for(i=1;i<=n;i++){
        for(j=x;j>= val[i];j--){
            dp[j]= min(dp[j],dp[j-val[i]]+wt[i]);
        }
    }
   /* for(i=0;i<=x;i++)
    cout << dp[i] <<" ";
    cout << "\n";*/
    for(i=x;i>=0;i--){
        if(dp[i] <= w){
            cout << i;
            break;
        }
    }
   return 0;
}

Measured memory_bytes: 1024
;; -*- coding:utf-8 -*-

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter O3 '(optimize (speed 3) (safety 0) (debug 0)))
  (defparameter O2 '(optimize (speed 3) (safety 1))))

(defmacro print-line (obj &optional (stream '*standard-output*))
  `(prog1 (princ ,obj ,stream) (terpri ,stream)))


;; Hauptteil

(deftype unum nil `(integer 0 ,(expt 10 9)))
(defun main ()
  (print-line (floor (read) 3))
  )

#-swank(main)


;; Für Test
(defun get-clipbrd ()
  (with-output-to-string (out)
    (run-program "C:/msys64/usr/bin/cat.exe" '("/dev/clipboard") :output out)))

(defun test ()
  (with-input-from-string (*standard-input* (delete #\return (get-clipbrd)))
    (main)))


;; Für Benchmark
(defparameter *file-path* *load-pathname*)
(defparameter *dir-path* (pathname (directory-namestring *file-path*)))
(defparameter *dat-path* (merge-pathnames "test.dat" *dir-path*))

#+swank
(defun gendat ()
  (with-open-file (out *dat-path*
		       :direction :output :if-exists :supersede)
    ))

(defun bench ()
  (let ((*standard-output* (make-broadcast-stream)))
    (with-open-file (*standard-input* *dat-path*)
      (time (main)))))



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

using namespace std;

#define int 		long long
#define endl		"\n"
#define mod			1000000007
#define inf			1e12
#define IOS			ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

vector<int> a(3000);
vector<vector<int>> mem(3000, vector<int> (3000, -1));

int dp(int l, int r) {
	if (l == r)
		return a[l];

	if (l + 1 == r)
		return llabs(a[l] - a[r]);

	if (mem[l][r] != -1)
		return mem[l][r];


	int left, right, ans;
	left = min(a[l] - a[l + 1] + dp(l + 2, r), a[l] - a[r] + dp(l + 1, r - 1));

	right = min(a[r] - a[l] + dp(l + 1, r - 1), a[r] - a[r - 1] + dp(l, r - 2));

	ans = max(left, right);

	return mem[l][r] = ans;
}

int32_t main() {

	IOS;

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

	cout << dp(0, n - 1);

	return 0;
}

Measured memory_bytes: 74264
K, N = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

dis = [0]*N
for i in range(N-1):
    dis[i] = A[i+1] - A[i]

dis[N-1] = A[0] + K - A[N-1]

print(K-max(dis))

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

int main(){
    ll a,b,c,d; cin>>a>>b>>c>>d;
    ll e=b/c-a/c;
    ll f=b/d-a/d;
    if(a%c==0){e++;}
  if(a%d==0){f++;}
  ll g = __gcd(c,d);
    ll k= c*(d/g);
    ll h=b/k-a/k;
  if(a%k==0){h++;}
    cout << (b-a+1)-(e+f-h) << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
from math import sin, cos, radians
it = lambda: list(map(int, input().strip().split()))
INF = float('inf')

def solve():
    X = int(input())
    ans = 0
    
    degree = 90
    
    x = y = 0
    while True:
        ans += 1
        x += cos(radians(degree))
        y += sin(radians(degree))
        degree = (degree + X) % 360
        if abs(x) < 1e-7 and abs(y) < 1e-7:
            return ans

if __name__ == '__main__':
    print(solve())

Measured memory_bytes: 9744
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	while(cin>>N) {
		VI A(N);
		REP(i, N) cin>>A[i];
		ll c=0;
		REP(i, N) {
			if(A[i]==c+1) c++;
		}
		ll ans=c==0?-1:N-c;
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1792
/*input
3
1000000000 1000000000 1000000000
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
using namespace std;
#define N  100005
void solve()
{
	lld n;
	cin >> n;
	lld ans=0;
	rep(i,0,n)
	{
		lld x;
		cin >> x;
		ans=__gcd(ans,x);
	} 
	cout << ans << endl ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 100005;

int N;
map<string, int> cnt;

signed main()
{
  cin >> N;
  REP(n,N) {
    string s; cin >> s;
    sort(begin(s), end(s));
    cnt[s]++;
  }

  int ans = 0;
  for(auto it : cnt) {
    ans += it.second*(it.second-1)/2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11136
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn = 1e4;
int a[maxn];

bool cmp(int a, int b){
    return a > b;
}
int main(){
	int n; cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
    sort(a+1, a+n+1, cmp);
	int ans = 0;
	for(int i = 1; i <= n-2; i++){
		for(int j = i+1; j <= n-1; j++){
			for(int k = j+1; k <= n; k++){
				if(a[k] + a[j] > a[i]) ans++;
                else break;
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/arc073/tasks/arc073_a

n,T=map(int,input().split())
t=list(map(int,input().split()))

cnt=T
for i in range(1,n):
    dt=t[i]-t[i-1]
    if dt>=T:
        cnt+=T
    else:
        cnt+=dt
print(cnt)

Measured memory_bytes: 25200
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
using namespace std;
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;
}

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

    int N, K;
    cin >> N >> K;
    double ans = 0;
    REP(i, N) {
        int now = i + 1;
        int cnt = 0;
        while (now < K) {
            now *= 2;
            cnt++;
        }

        ans += (1.0 / N) * pow(0.5, cnt);
    }

    std::cout << setprecision(10) << ans << '\n';

    return 0;
}

Measured memory_bytes: 892
// let coding = begin

#include<bits/stdc++.h>

#define ll long long
#define pb       push_back
#define all(a)   a.begin(), a.end()

using namespace std;
const int MAX = 1e9+9;
const int MIN = -1e9;
const int N= 1e5;
int r;
int main(){

  cin >> r;
  if(r<1200) cout << "ABC" <<endl;
  else if(r>=1200 && r<2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args)throws Exception {
		Scanner scan = new Scanner(System.in);
		long money = scan.nextLong();
		long year = 0;
		for(long num = 100;num < money;num = num + num/100) {
			year ++;
		}
		System.out.println(year);

		scan.close();
	}
}

Measured memory_bytes: 27068
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for l in range(a+1):
    for m in range(b+1):
        for n in range(c+1):
            if 500*l+100*m+50*n == x:
                count += 1
print(count)

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

using namespace std;

#define For(i,a,b) for(int i = a ; i <= b ; ++ i)
#define int long long

const int N = 2e5 + 5 , mod = 1e9 + 7;

int n , m , a , b , ans;
int Pow[N] , pre[N];

int cal(int a ,int b){
	if( b == 0 ) return 1;
	int res = cal(a , b / 2);
	res = (res *res) % mod;
	if(b % 2) res = (res * a) % mod;
	return res % mod;
}
int Ckn(int k ,int n){
	int res = Pow[n];
	res = (res * (pre[k] * pre[n - k] % mod)) %mod;
	return res;
}
signed main(){
	cin >> n >> m >> a >> b;
	Pow[0] = pre[0] = 1;
	For(i,1,N - 1) {
		Pow[i] = Pow[i - 1] * i % mod;
		pre[i] = cal( Pow[i] , mod - 2);
	}
	For(i , b + 1 , m){
		ans += Ckn(n - a - 1, n - a - 1 + i - 1) * Ckn(a - 1 , a - 1+ m - i) % mod;
		ans %= mod;
	}	
	cout << ans;
}

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

typedef long long int ll;

class BIT {
private:
  ll N; // Number of nodes
  vector<ll> tree; // array which represents the tree

public:
  BIT(ll n) {
    N = n;
    tree = vector<ll>(N+1,0);
  }

  void add(ll a, ll v) {
    for (int i=a; i<=N; i += i & -i) tree[i] += v;
  }

  ll sum(ll a) {
    ll ret = 0;
    for (int i=a; i>0; i -= i & -i) ret += tree[i];
    return ret;
  }
};

void convert(ll arr[], ll n) {
  ll temp[n];
  for (int i=0; i<n; ++i) {
    temp[i] = arr[i];
  }
  sort(temp,temp+n);

  for (int i=0; i<n; ++i) {
    arr[i] = lower_bound(temp, temp+n, arr[i]) - temp + 1; //arr[i]をソート値のインデックス(ただし1開始)に置き換え
  }
}

// aの転倒数を計算
ll invCount(ll a[], ll n) {
  ll temp[n];
  for (int i=0; i<n; ++i) temp[i] = a[i];
  convert(temp, n);

  BIT bit = BIT(n);
  ll count = 0;
  for (int i=n-1; i>=0; --i) { //右側から走査
    count += bit.sum(temp[i]-1); //現在値よりも小さい値で，右側（走査済み）にあった値の個数を追加
    bit.add(temp[i],1); //現在値の観測数を追加
  }

  return count;
}

// xが求めるmedianの候補であるか判定
bool check(ll x, ll a[], ll n) {
  int b[n];
  for (int i=0; i<n; ++i) {
    b[i] = (a[i] >= x) ? 1 : -1; //x以上の要素を1，他を-1に変換
  }

  //bの累積和を計算
  ll S[n+1];
  S[0] = 0;
  for (int i=1; i<=n; ++i) {
    S[i] = S[i-1] + b[i-1];
  }

  return (n*(n+1)/2 - invCount(S,n+1)) >= (n*(n+1)/2+1)/2; //左辺はSのS[r]-S[l]>0である(l,r)(l<r)の組み合わせ数
}

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

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

  ll low,high;
  low = *min_element(a,a+N)-1;
  high = *max_element(a,a+N)+1; // 初期値は最小最大の外側に取る

  while(high - low > 1  ) {
    ll mid = (low + high)/2;
    if (check(mid,a,N)) low = mid;
    else high = mid;
  }

  cout << low << endl;

  return 0;
}


Measured memory_bytes: 4592
// C# program to build the smallest number 
// by removing n digits from a given number 
using System;
using System.Collections.Generic;
using System.Linq;
class GFG
{

    public static void Main(String[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var k = int.Parse(Console.ReadLine());
        var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        CollectBalls(n, k, arr);
    }

    public static void CollectBalls(int n, int k, int[] arr)
    {
        int min = 0;
       
        int sum = 0;
        for (int i = 0; i < arr.Length; i++)
        {
            sum = sum + Math.Min(2 * arr[i], 2 * (k - arr[i]));

        }
        Console.Write(sum);
    }
}




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

int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	while (a >= b) {
		k--;
		b *= 2;
	}
	while (b >= c) {
		k--;
		c *= 2;
	}
	if (k < 0) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define N 105
using namespace std;

int main(){
  int n,a,b,c,d[N],sum;
  double ans;
  cin>>n>>a>>b>>c;
  sum=c;
  for(int i=0;i<n;i++)cin>>d[i];
  sort(d,d+n,greater<int>());
  ans=sum/a;
  for(int i=0;i<n;i++){
    sum+=d[i];
    ans=max(ans,1.0*sum/(a+b*(i+1)));
  }
  cout<<(int)ans<<endl;
  return 0;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
#define N 100005
using namespace std;
typedef long long ll;
ll n,sum,a[N],A[2*N];

ll bynary_search(ll b,ll e){
  ll l=b,r=e;
  
  while(l<r){
    ll m=(l+r)/2;
    if(sum/3.0<=A[m]-A[b-1])r=m;
    else l=m+1;
  }
  
  return l;
}

void solve(){
  ll ans=0;
  
  for(int cut1=0;cut1<n;cut1++){
    ll cut2=bynary_search(cut1+1,cut1+n);
    ll cut3=bynary_search(cut2+1,cut1+n);
    
    ans=max(ans,min(A[cut2]-A[cut1],min(A[cut3]-A[cut2],A[cut1+n]-A[cut3])));
    cut3--;
    ans=max(ans,min(A[cut2]-A[cut1],min(A[cut3]-A[cut2],A[cut1+n]-A[cut3])));
    
    cut2--;
    
    cut3=bynary_search(cut2+1,cut1+n);
    ans=max(ans,min(A[cut2]-A[cut1],min(A[cut3]-A[cut2],A[cut1+n]-A[cut3])));
    
    cut3--;
    ans=max(ans,min(A[cut2]-A[cut1],min(A[cut3]-A[cut2],A[cut1+n]-A[cut3])));
    
  }
  
  cout<<ans<<endl;
}

int main(){
  cin>>n;
  
  for(int i=0;i<n;i++)cin>>a[i],sum+=a[i];
  A[0]=a[0];
  for(int i=1;i<2*n;i++)A[i]=a[i%n]+A[i-1];
  
  solve();
  
  return 0;
}

Measured memory_bytes: 5456
n = int(input())
h = input()
str_list = []
ans = "Yes"
str_list = h.split(" ")

for j in range (len(str_list)-1):

  if(int(str_list[j]) < int(str_list[j+1])):
    str_list[j+1] = str(int(str_list[j+1])-1)
  elif(int(str_list[j]) > int(str_list[j+1])):
    ans = "No"
    break

print(ans)

Measured memory_bytes: 11156
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>
#include <stack>

using namespace std;

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    vector<vector<int> > nn;
    nn.resize(n);
    for(int i = 0; i < m; ++i){
        int x, y, z;
        scanf("%d %d %d", &x, &y, &z);
        nn.at(x-1).push_back(y-1);
        nn.at(y-1).push_back(x-1);
    }

    vector<bool> visited(n, false);
    int ans = 0;
    stack<int> s;
    for(int i = 0; i < n; ++i){
        if(visited.at(i)){ continue; }
        visited.at(i) = true;
        s.push(i);
        ans++;
        while(!s.empty()){
            int x = s.top(); s.pop();
            for(int y : nn.at(x)){
                if(visited.at(y)){ continue; }
                visited.at(y) = true;
                s.push(y);
            }
        }
    }

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


Measured memory_bytes: 6520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100],b[100],tr[100],ra[100];
int lowbit(int x){
	return x&-x;
}
void add(int pos,int c,int n){
	while(pos<=n){
		tr[pos]+=c;
		pos+=lowbit(pos);
	}
}
int getsum(int n){
	int ret=0;
	while(n){
		ret+=tr[n];
		n-=lowbit(n);
	}
	return ret;
}
int kt(int a[],int n){
	int ret=0;
	for(int i=n;i>=1;i--){
		ret+=ra[n-i]*getsum(a[i]);
		add(a[i],1,n);
	}
	return ret;
} 
void init(int n){
	ra[0]=1;
	for(int i=1;i<=n;i++) ra[i]=i*ra[i-1];
}
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) cin>>b[i];
	init(30);
	int num1=kt(a,n);
	memset(tr,0,sizeof tr);
	int num2=kt(b,n);
	cout<<abs(num1-num2)<<'\n';
	return 0;
 } 

Measured memory_bytes: 3640
import numpy as np

n,d=list(map(int, input().split()))
lst=[]
for i in range(n):
    lst.append(list(map(int, input().split())))
answer=0
for i in range(n):
    for j in range(n):
        if i==j:
            continue
        if i>=j:
            continue
        a=np.array(lst[i])
        b=np.array(lst[j])
        c=a-b
        d=np.linalg.norm(c)
        if d.is_integer():
            answer+=1
print(answer)

Measured memory_bytes: 12400
#include <stdio.h>
#include <string.h>
char weather[3][10]={"Sunny","Cloudy","Rainy"};
int main()
{
    char Q[10];
    int i;
    scanf("%s",Q);
    for(i=0;i<=2;i++){
            if(strcmp(weather[i],Q)==0) break;
    }
    if(i==2) printf("%s",weather[0]);
    else printf("%s",weather[i+1]);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

void dec(ll key,map<ll,ll> &mp){
    mp[-key]--;
    if(mp[-key]==0){
        mp.erase(-key);
    }
}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
    cin >> N;
    map<ll,ll> mp;
    rep(i,N){
        ll a;
        cin >> a;
        mp[-a]++;
    }
    ll ans = 0;
    for(int i=0;i<N &&mp.size()>0;i++){
        ll now = mp.begin()->first * -1;
        dec(now,mp);
        ll p = 1;
        while(p<=now)p*=2;
        ll want = p - now;
        if(mp.count(-want)){
            dec(want,mp);
            ans++;
        }
    }
    cout << ans << endl;
}

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

long long luca[87];
int main() {
  luca[0] = 2;
  luca[1] = 1;
  for (int i = 2; i < 87; i++) luca[i] = luca[i-1] + luca[i-2];
  int n; cin >> n;
  cout << luca[n] << endl;
}

Measured memory_bytes: 384
#include<stdio.h>

int main (void){

 int n;

 int i;

 int a[10000];

 int max;

 int min;

 long int totall=0;

  scanf("%d",&n);

for(i=0;i<n;i++){

  scanf("%d",&a[i]);

}

max=min=a[0];

  for(i=0;i<n;i++){

if(max<a[i]){

max=a[i];

}

if(min>a[i]){

min=a[i];

}

totall=totall+a[i];

}

printf("%d %d %ld\n",min,max,totall);

return 0;

}

Measured memory_bytes: 636
N = int(input())
A = list(map(int,input().split()))
B = [0]*N
C = [0]*N
for i in range(N):
    B[i] = i + 1 - A[i]
    C[i] = i + 1 + A[i]
for i in range(N):
    if B[i] < 0:
        B[i] = 200001
    if C[i] > N:
        C[i] = 200001
K = [0]*200002
L = [0]*200002
for i in B:
    K[i] += 1
for i in C:
    L[i] += 1
M = [0]*200001
for i in range(200001):
    M[i] = K[i]*L[i]
print(sum(M))

Measured memory_bytes: 37856
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
void _OUT() {}; template<class H, class... T> void _OUT(H &h, T &... t) { cout<<' '<<h; _OUT(t...); };
template<class H, class... T> void _P(H &h, T &... t) { cout<<h; _OUT(t...); };
#define _PN(...) _P(__VA_ARGS__); cout << endl;
#define EXEC(...) void exec() { (__VA_ARGS__ - 1) ? multi() : solve(0); }

void exec();
void solve(int t);
void multi() { int TT; cin>>TT; REP1(t,TT) solve(t); }
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    exec();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 123450
#else
#define SIZE 123450
#endif

int N,M;
vector<int> A(SIZE);

struct UnionFind {
    vector<int> parent;
    int size;
    vector<set<int>> V;
    UnionFind(int size) {
        reset(size);
    }
    void reset(int size) {
        this->size = size;
        parent.resize(size);
        REP(i,size) parent[i]=i;
        V.resize(size);
        REP(i,size) V[i].insert(i);
    }
    int root(int i) {
        if (parent[i] == i) return i;
        return parent[i] = root(parent[i]);
    }
    void merge(int i, int j) {
        int ir = root(i);
        int jr = root(j);
        if (ir == jr) return;
        int next = (V[ir].size() >= V[jr].size()) ? ir : jr;
        int hide = (ir == next) ? jr : ir;
        parent[ir] = parent[jr] = next;
        for (int n:V[hide]) V[next].insert(n);
        V[hide].clear();
    }
    bool same(int i, int j) {
        return root(i) == root(j);
    }
    int vsize(int i) {
        return (int)V[i].size();
    }
};


void solve(int _t) {
    cin>>N;
    auto uf = new UnionFind(SIZE);
    int x,y;
    set<int> ylist[SIZE];
    vector<pair<int,int>> V;
    REP(i,N) {
        cin>>x>>y;
        ylist[x].insert(y);
        V.push_back({x,y});
    }
    REP(i,SIZE)if(ylist[i].size()) {
        int y0 = *ylist[i].begin();
        for (int y:ylist[i]) {
            uf->merge(y0, y);
        }
    }
    vector<set<int>> xlist(SIZE);
    for (auto p:V) {
        xlist[uf->root(p.second)].insert(p.first);
        debug("xlist[%lld].insert(%lld)\n",uf->root(p.second),p.first);
    }
    int ans = -N;
    REP(i,SIZE) {
        ans += xlist[i].size() * uf->vsize(i);
    }
    _PN(ans);
}
EXEC(1)



Measured memory_bytes: 36796
A,B,C,D = map(int,input().split())
Alice=False
Bob=False
time=0
for i in range(101):
    if i==A:
        Alice=True
    if i==B:
        Alice=False
    if i==C:
        Bob=True
    if i==D:
        Bob=False
    if Alice==True and Bob==True:
        time+=1
print(time)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.ABC_102
{
    class ABC_102_C
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            long n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            long[] array = new long[n];
            for (int i = 0; i < n; i++)
            {
                array[i] = long.Parse(input[i]) - (i + 1);
            }

            Array.Sort(array);
            long med;
            if (n % 2 == 0)
            {
                med = (array[n / 2-1] + array[n / 2]) / 2;
            }
            else
            {
                med = array[n / 2];
            }

            long result = 0;
            for (int i = 0; i < n; i++)
            {
                result += Math.Abs(array[i] - med);
            }
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 32732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int i,j;
	string s;
	cin>>s;
	int x=0;
	VI v(2050);
	v[0]++;
	ll ans=0;
	VI r(205050);
	r[0]=1;
	for(i=1;i<205050;i++){
		r[i]=r[i-1]*10%2019;
	}
	for(i=s.size()-1;i>=0;i--){
		x=x+(s[i]-'0')*r[s.size()-1-i];
		x%=2019;
		ans += v[x];
		v[x]++;
		//cout<<x<<endl;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 5212
#include <iostream>
#include <vector>

using namespace std;

vector<long long> ans;
vector<pair<int, int>> bridges;

vector<long long> conected(100010);
vector<int> par(100010);
vector<int> Rrank(100010);

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

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

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) return;

	if (Rrank[x] < Rrank[y]) {
		par[x] = y;
		conected[y] += conected[x];
	}
	else {
		par[y] = x;
		conected[x] += conected[y];
		if (Rrank[x] == Rrank[y]) Rrank[x]++;
	}
}


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

int main() {
	int N, M;
	long long dans;

	cin >> N >> M;
	init(N);

	for (int i = 0; i < M; i++) {
		int x, y;
		cin >> x >> y;
		bridges.push_back(make_pair(x, y));
	}

	dans = ((long long)N*(N - 1)) / 2;
	ans.insert(ans.begin(), dans);

	for (int i = M - 1; i >= 1; i--) {
		if (same(bridges[i].first, bridges[i].second)) {
			ans.insert(ans.begin(), dans);
		}
		else {
			dans -= conected[find(bridges[i].first)] * conected[find(bridges[i].second)];
			ans.insert(ans.begin(), dans);
			unite(bridges[i].first, bridges[i].second);
		}
	}

	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 4596
import java.util.*;
import java.util.function.*;
import java.lang.*;
import java.io.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] A = new int[N];
        for(int n=0; n<N; n++) A[n]=sc.nextInt();
        Arrays.sort(A);
        int ans = 0;
        for(int n=0; n<K; n++) ans += A[n];
        System.out.println(ans);
        
    }
}


Measured memory_bytes: 38964
#include "bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;
const int INF = 1 << 30;
const long long MOD = 1000000000 + 7;
const double PI = acos(-1);

int main() {
	int A, P; cin >> A >> P;
	cout << (A * 3 + P) / 2;
}

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

#define SEG_LEN (1 << 18)

int seg[SEG_LEN * 2];

void add(int ind, int v){
    ind += SEG_LEN;
    seg[ind] += v;
    while(true){
        ind /= 2;
        if(ind == 0)break;
        seg[ind] = seg[ind * 2] + seg[ind * 2 + 1];
    }
}

int sum(int l, int r){
    l += SEG_LEN;
    r += SEG_LEN;
    int ans = 0;
    while(l < r){
        if(l % 2 == 1){
            ans += seg[l];
            l++;
        }
        l /= 2;
        if(r % 2 == 1){
            ans += seg[r-1];
            r--;
        }
        r /= 2;
    }
    return ans;
}

int main(){
    int n, q, com, ind, v, l, r;
    cin >> n >> q;
    for(int i = 0;i < q;i++){
        cin >> com;
        if(com == 0){//add
            cin >> ind >> v;
            add(ind, v);
        }
        if(com == 1){//get sum
            cin >> l >> r;
            cout << sum(l, r+1) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3864
#include<stdio.h>
int main(){
  int n,a[100],i,j,tmp,flag=1,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  while(flag){
    flag=0;
    for(j=n-1;j>=1;j--){
      if(a[j]<a[j-1]){
	sum++;
        tmp=a[j];
	a[j]=a[j-1];
	a[j-1]=tmp;
	flag=1;
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i==n-1){
      printf("\n");
    }else{
      printf(" ");
    }
  }
  printf("%d\n",sum);
}



Measured memory_bytes: 2104
package main

import (
	"fmt"
	"math"
)

var w string

func main() {
	fmt.Scan(&w)
	ans := make(map[string]int)

	for i := 0; i < len(w); i++ {
		ans[string(w[i])]++
	}

	for _, value := range ans {
		if value%2 != 0 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

/*  ----------------------------------------  */

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}

func pow(x, y int) uint64 { return uint64(math.Pow(float64(x), float64(y))) }
func abs(x int) int       { return int(math.Abs(float64(x))) }
func floor(x int) int     { return int(math.Floor(float64(x))) }

type si struct {
	s int
	i int
}

type SortBy []si

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i].s < a[j].s }


Measured memory_bytes: 512