akhauriyash/Code-Regression huggingface dataset:
import java.util.*;


public class Main {

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

        int N = sc.nextInt();

        Map<Integer,Integer> map = new TreeMap<Integer, Integer>();
        for(int i=0;i<N;i++){
            int X = sc.nextInt();
            int L = sc.nextInt();
            map.put(X,L);
        }
        int compareX =-1000000010;
        int compareL =0;
        int removeNum=0;

        for(Integer key : map.keySet()){

            if(compareX+compareL > key - map.get(key)){
                removeNum++;
                if(compareX+compareL > key + map.get(key)){
                    compareX = key;
                    compareL = map.get(key);
                }
            } else {
                compareX = key;
                compareL = map.get(key);
            }

        }
        int ansA = N -removeNum;

        System.out.println(ansA);




    }
}






Measured memory_bytes: 98316
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll a,b,c,d,e,f,g,ans=0;
const ll INF=99999999999999999;
ll n,q;
ll par[110000];//親の頂点
ll size[110000];
ll root(ll x){
    if(par[x]==x)return x;
    return par[x]=root(par[x]);
}
bool same(ll x,ll y){
    return root(x)==root(y);
}
void unite(ll x,ll y){
    if(same(x,y))return;
    size[root(y)]+=size[root(x)];
  par[root(x)]=y;
}
int main(){
  ll k[100000][2];
  stack<ll> s;
    cin>>n>>q;
  
  for(int i=0;i<q;i++){
    cin>>k[i][0]>>k[i][1];
  }
  ans=n*(n-1)/2;
  
    for(int i=0;i<n;i++){//初期化
        par[i]=i;
        size[i]=1;
    }

    for(int i=q-1;i>-1;i--){
      if(!same(k[i][0],k[i][1])){
        s.push(ans);
        ans-=size[root(k[i][0])]*size[root(k[i][1])];
        unite(k[i][0],k[i][1]);
      }
      else s.push(ans);
    }
      
      while(!s.empty()){
        cout<<s.top()<<endl;
        s.pop();
      }
}

Measured memory_bytes: 5020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll MOD=1e9+7;
const ll N=2e5+5;
const ld pi=3.14159265359;
const ll INF=(1LL<<63);
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(a) (ll)a.size()

ll n,x,cnt[65],ans;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n;
	REP1(i,n){cin>>x;REP(j,61)if(x&(1LL<<j))cnt[j]++;}
	REP(j,61){
		ans+=(1LL<<j)%MOD*(cnt[j]*(n-cnt[j])%MOD)%MOD;
		ans%=MOD;
	}
	cout<<ans<<"\n";
	return 0;
}




Measured memory_bytes: 384
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    cout<<setprecision(16);
double x;
cin>>x;
ll a=100;
int i=0;

while(true){
    i++;
    a*=1.01;

  //  cout<<a<<endl;

    if(a>=x){
        cout<<i<<endl;
        return 0;
    }
}


    
return 0;
}


Measured memory_bytes: 3720
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define all(v) v.begin(),v.end()
#define itr(r,v) for(auto r=v.begin();r!=v.end();r++)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffo(i,a,b) for(ll i=a;i<=b;i++)
#define rfr(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl "\n"
#define pqmx priority_queue<ll>
#define pqmn priority_queue<ll,vll,greater<ll>>
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define ctime auto sttart = high_resolution_clock::now()
#define etime auto sttop = high_resolution_clock::now()
#define go_t ll testcases; cin>>testcases; for(ll caseno= 1 ;caseno <= testcases; caseno++)
#define ptime auto z1z = duration_cast<microseconds>(sttop-sttart); cout<<"\nTime taken : "<<z1z.count()<<" microseconds\n"
#define dbg1(x)             cout <<#x<<": "<<x<<'\n';
#define dbg2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define dbg3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define dbg4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';
#define dbg5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<'\n';

using namespace std;
using namespace std::chrono;

const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
const ll maxN = 400 + 5;
const ll MAX_SIZE = 2e6 + 6;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;

ll powerM(ll x, ll y, ll M = MOD) { // default argument
	ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;
}

ll power(ll x, ll y) {
	ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;
}

int n;
int a[maxN];
ll dp[maxN][maxN];
ll pref[maxN];

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	FIO
	cin >> n;
	FOR(i, n) cin >> a[i + 1];
	for (int i = 1; i <= n; ++i)
		pref[i] = pref[i - 1] + a[i];
	// memoized version of previous recursive code
	// dp[i][j] -> represents the min cost if the range [i, r] is to be merged
	for (int i = 1; i <= n; ++i) {
		// i corresponds to r
		for (int j = i; j >= 1; -- j) {
			// j corresponds to l
			ll ans = INF;
			if (i == j) {
				dp[i][j] = 0;
				continue;
			}
			for (int k = j; k <= i - 1; ++k) {
				ans = min(ans, dp[j][k] + dp[k + 1][i] + pref[i] - pref[j - 1]);
			}
			dp[j][i] = ans;
		}
	}
	cout << dp[1][n];
	return 0;
}


Measured memory_bytes: 4896
import java.util.Scanner;
class Main{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    int debt=100;
    
    
    
    for(int i=1; i<=n; i++){
    
    debt=(int)Math.ceil(debt*1.05);
    
    }
    
    System.out.println(debt*1000);
    
   }
   }
    

Measured memory_bytes: 25996
#include<iostream>
#include<algorithm>

int const MAXN = 2e5;
int N;

int main() {
  int N; std::cin >> N;
  int ans = 1, mP, P;
  std::cin >> P; mP = P;
  for(int i = 1; i < N; ++i) {
    std::cin >> P;
    if(P <= mP){ ++ans; mP = P; }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
//セグ木区間和的な
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>;
using vvi = vector<vi>;

ll n,d,a;

//区間和とかのための
class SegTree_r
{
  public:
  ll n2,ln2;//2のべき乗になる数でn以上の数//n2のlog2値
  vector<ll> data;//●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
  SegTree_r(ll logn)
  {
    ln2=logn;
    n2=1<<logn;
    data.resize(n2*2);
    for(ll i=0;i<n2*2;i++)
      data[i]=0;//●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
  }
  //ある要素の値を取得、今まで加算した区間和 O(logn)
  ll GetVal(ll posi)
  {
    ll v=0;//●●●●●●●●●●●●●●●●●●●
    ll myi=posi+n2;
    v+=data[myi];//葉
    for(ll i=0;i<ln2;i++){//中間要素
      myi/=2;
      v+=data[myi];
    }
    return v;
  }
  //lを含むrを含まないところまでの区間にv値を加算
  void AddRange(ll l,ll r,ll v)
  {
    ll ret=data[l];
    ll l_=l;
    ll r_=r;
    for(ll i=0;(l_+r_)>0;i++){
      ll offset=1<<(ln2-i);
      if (r_%2==1){
          if (r_-1>=l_){
            data[offset+r_-1]+=v;
            r_--;
          }
      }
      if (l_%2==1){
          if (l_<r_){
            data[offset+l_]+=v;
            l_++;
          }
      }
      r_>>=1;
      l_>>=1;
    }
  }
};







//2つの要素をまとめてソート、前の変数が優先。flag=0で小さい順、1で大きい順
void mysort2(vi &a,vi &b,ll flag){
  vector<pair<ll, ll>> p(a.size());
  REP(i,n){
    p[i].first=a[i];
    p[i].second=b[i];
  }
  sort(p.begin(),p.end());
  if (flag==1){
    reverse(p.begin(),p.end());
  }
  REP(i,n){
    a[i]=p[i].first;
    b[i]=p[i].second;
  }
  return;
}








int main(){
  ll ans=0;
  cin>>n>>d>>a;
  vi x(n),h(n);
  REP(i,n){
    cin>>x[i]>>h[i];
  }
  mysort2(x,h,0);

  SegTree_r segtree_r(18);//nが200000なら18をいれる
  ll ir=0;
  REP(i,n){
    for(;ir<n;ir++){
      if ((x[i]+2*d)<x[ir]){
        break;
      }
    }

    h[i]-=segtree_r.GetVal(i);
    if (h[i]<0)continue;
    ll dmg=h[i]/a+(h[i]%a!=0);
    segtree_r.AddRange(i,ir,dmg*a);
    ans+=dmg;
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 7496
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)

inline int read()
{
	int data = 0, w = 1; char ch = getchar();
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') w = -1, ch = getchar();
	while (ch >= '0' && ch <= '9') data = data * 10 + (ch ^ 48), ch = getchar();
	return data * w;
}

const int N(1e5 + 10);
int n, m, a[N], sum[N], b[N], c[N];
void Add(int x) { for (; x <= m; x += x & -x) ++c[x]; }
int Sum(int x) { int s = 0; for (; x; x -= x & -x) s += c[x]; return s; }
int check(int mid)
{
	sum[0] = 0;
	for (int i = 1; i <= n; i++) sum[i] = (a[i] <= mid ? -1 : 1);
	for (int i = 1; i <= n; i++) sum[i] += sum[i - 1]; m = 0;
	for (int i = 0; i <= n; i++) b[++m] = sum[i];
	std::sort(b + 1, b + m + 1), m = std::unique(b + 1, b + m + 1) - b - 1;
	for (int i = 0; i <= n; i++)
		sum[i] = std::lower_bound(b + 1, b + m + 1, sum[i]) - b;
	long long ans = 0, all = 1ll * n * (n + 1) / 2; memset(c, 0, (m + 1) << 2);
	for (int i = 0; i <= n; i++) ans += Sum(sum[i]), Add(sum[i]);
	return ans >= all - ans;
}

int main()
{
	n = read();
	for (int i = 1; i <= n; i++) a[i] = read();
	int l = 1, r = 1e9, ans;
	while (l <= r)
	{
		int mid = (l + r) >> 1;
		if (check(mid)) l = mid + 1;
		else ans = mid, r = mid - 1;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1664
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull;

void IO(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("test.txt","r",stdin);
    #endif
}

const int N=2e6+3,M=1e4+5,mod=1e9+7,dx[]={1,-1,0,0},
                                    dy[]={0,0,1,-1};
const double eps=1e-9;

int n,m,tc,a[N],c[N],u,v,s[N][26],last[26];

ll sum(int idx){
    ll score = 0;
    for(int i = 0 ; i < n ; i++)
        score += s[i][idx];
    return score;
}

ll calc(int day,int idx){
    ll score = 0;
    for(int i = 0 ; i < 26 ; i++)
        if (i != idx)
            score -= (ll)c[i] * (day - last[i]);
        else
            score += sum(day);
    return score;
}

int main(){
    //IO();
    cin >> n;
    for(int i = 0 ; i < 26 ; i++)
        cin >> c[i];
    for(int i = 0 ; i < n ; i++)
        for(int j = 0 ; j < 26 ; j++)
            cin >> s[i][j];
    for(int day = 1 ; day <= n ; day++){
        ll mx_score = -1e18;
        int ans = 0;
        for(int contest = 0 ; contest < 26 ; contest++){
            ll score = calc(day,contest);
            if (score > mx_score){
                mx_score = score;
                ans = contest + 1;
            }
        }
        last[ans - 1] = day;
        cout << ans << "\n";
    }
}

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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

class dsu {
private:
	int *id;
	int* sz;

	int root(int i) {
		while (i != id[i]) {
			id[i] = id[id[i]];
			i = id[i];
		}
		return i;
	}
public:
	int n;
	dsu(int v) {
		n = v;
		id = new int[n];
		sz = new int[n];

		for (int i = 0; i < n; i++) {
			id[i] = i;
			sz[i] = 0;
		}
	}

	bool find(int p , int q) {
		return root(p) == root(q);
	}

	void join(int p , int q) {
		int i = root(p);
		int j = root(q);
		if (i == j) {
			return;
		}
		if (sz[i] < sz[j]) {
			id[i] = j ;
			sz[j] += sz[i];
		}
		else {
			id[j] = i;
			sz[i] += sz[j];
		}
	}
};

class BIT {
private:
	int* FT;
	int n;
public:
	void updateBIT(int index , int val) {
		index += 1;
		while (index <= n) {
			FT[index] += val;
			index += (index & (-index));
		}
	}

	int getSum(int index) {
		index += 1;
		int sum = 0 ;
		while (index > 0) {
			sum += FT[index];
			index -= (index & (-index));
		}
		return sum;
	}


	BIT(int* a , int v) {
		n = v ;
		FT = new int[n + 1];
		for (int i = 1 ; i <= n ; i++) {
			FT[i] = 0 ;
		}
		for (int i = 0 ; i < n ; i++) {
			updateBIT(i, a[i]);
		}
	}
};

int nCr(int n , int r ) {
	int p = 1, k = 1;

	if (n - r < r ) {
		r = n - r;
	}
	if (r != 0) {
		while (r != 0) {
			p *= n ;
			k *= r ;
			int m = __gcd(p, k);
			p /= m;
			k /= m;
			n--;
			r--;
		}
	}
	else {
		p = 1;
	}
	return p ;
}

int modPower(int x, int y , int p) {
	//Used to calculate (x^y)%p
	int res = 1;
	if (y == 0) {
		return 1;
	}

	x = x % p;
	if (x == 0) {
		return 0  ;
	}

	while (y > 0) {
		if (y & 1) {
			res = (res * x) % p;
		}

		y >>= 1;
		x = (x * x) % p;
	}
	return res ;

}



int32_t main() {
	FIO;

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

	int d = INT_MIN;
	for (int i = 0 ; i < n ; i++) {
		for (int j = i + 1 ; j < n ; j++) {
			int v = abs(a[i] - a[j]);
			d = max(d, v);
		}
	}
	cout << d;




	return 0;
}


Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), k = scanner.nextInt();
			long count = n / k;
			long answer = count * count * count;
			if (0 == (k & 1)) {
				// kが2の倍数のとき
				long count2 = n / k + ((n % k >= k / 2) ? 1 : 0);
				answer += count2 * count2 * count2;
			}
			System.out.println(answer);
		}
	}
}


Measured memory_bytes: 35680
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int main(){
    string s;
    cin>>s;
    s[5] = ' ';
    s[13] = ' ';
    cout<<s<<endl;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    n,m = map(int,input().split())
    uf = UnionFind(n)
    for _ in range(m):
        a,b = map(lambda x:int(x)-1,input().split())
        uf.union(a,b)
    ans = 0
    for i in range(n):
        ans = max(uf.size(i),ans)
    print(ans)
    return 

if __name__ == "__main__":
    main()

Measured memory_bytes: 80240
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()

if N < 105:
    print(0)
    exit()

ans = 0
for i in range(105,N+1,2):
    cnt = 0
    for q in range(1,int(i**0.5)+1):
        if i % q == 0:
            cnt += 2
    if cnt == 8:
        ans += 1
print(ans)



Measured memory_bytes: 9208
// Try CADDi 2018 for Beginners
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let mut even = 0;
    for _ in 0..n {
    	let x = get!();
        if x % 2 == 0 {
        	even += 1;
		}
    }
    if even != n {
    	println!("first");
    } else {
    	println!("second");
    }
}

Measured memory_bytes: 6396
def gcd(a, b):
    while b:
            a,b = b,a%b
    return a

def lcm(x,y):
    return (x * y) // gcd(x, y)

def atwo(n,m,s,t):
    l=lcm(n,m)
    gc=gcd(n,m)
    if s[0::n//gc]==t[0::m//gc]:
        print(l)
        exit()
    else:
        print(-1)
        exit()

n,m=map(int,input().split())
print(atwo(n,m,input(),input()))

Measured memory_bytes: 3316
###
### atcorder test program
###

### math class
class math:
    ### pi
    pi = 3.14159265358979323846264338

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

math = math()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#A, B, C = [x for x in input().split()]
#inlist = [int(w) for w in input().split()]
#R = float(input())
#A = [int(x) for x in input().split()]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

A = [[0,0,0,0,0,0,0,0,0,0] for i in range(3)]
B = [[0,0,0,0,0,0,0,0,0,0] for i in range(3)]
C = [[0,0,0,0,0,0,0,0,0,0] for i in range(3)]
D = [[0,0,0,0,0,0,0,0,0,0] for i in range(3)]

N = int(input())

for i in range(N):
    inlist = [int(w) for w in input().split()]
    if inlist[0] == 1:
        A[inlist[1]-1][inlist[2]-1] += inlist[3]
    elif inlist[0] == 2:
        B[inlist[1]-1][inlist[2]-1] += inlist[3]
    elif inlist[0] == 3:
        C[inlist[1]-1][inlist[2]-1] += inlist[3]
    elif inlist[0] == 4:
        D[inlist[1]-1][inlist[2]-1] += inlist[3]

for i, array in enumerate([A, B, C, D]):
    for j in array:
        output.list(j)
    if i != 3:
        print("####################")



Measured memory_bytes: 5660
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: i64 = read();
    let y: i64 = read();
    for i in 0..n + 1 {
        for j in 0..n - i + 1 {
            let k = n - i - j;
            if i * 10000 + j * 5000 + k * 1000 == y {
                println!("{} {} {}", i, j, k);
                return;
            }
        }
    }

    println!("{} {} {}", -1, -1, -1)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  bool Z=false;
  cin >> N;
  vector<int>vec(N);
  set<int>sett;
  for(int X=0; X<N; X++){
    cin >> vec.at(X);
    sett.insert(vec.at(X));
  }
  if(sett.size()<vec.size()){
    cout << "NO" << endl;
  }
  else{
    cout << "YES" << endl;
  }
}

Measured memory_bytes: 10368
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007
#define MEM_SIZE = 1e5+5;

template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}




//-----CODE------//
class DisjointSet{
  public:
  vector<int> rank,p;
  DisjointSet(){}
  DisjointSet(int size)
  {
    rank.resize(size,0);
    p.resize(size,0);
    for (int i = 0; i < size; i++)
    {
      makeSet(i);
    }
  }
void makeSet(int x)
{
  p[x] = x;
  rank[x] = 0;
}

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

void unite(int x, int y)
{
  link(findSet(x),findSet(y));
}
void link(int x, int y)
{
  if(rank[x] > rank[y])
  {
    p[y] = p[x];
  }
  else
  {
    p[x] = p[y];
  }
  if(rank[x] == rank[y])
  {
    rank[y]++;
  }
}
  int findSet(int x)
  {
    if(x != p[x])
    {
      p[x] = findSet(p[x]);
    }
    return p[x];
  }
};

void solve(void)
{
  int N;
  cin>>N;
  int Q;
  cin>>Q;
  DisjointSet ds = DisjointSet(N);
  for (int i = 0; i < Q; i++)
  {
    int T,A,B;
    cin>>T>>A>>B;
    if(T == 0)
    {
      ds.unite(A,B);
    }
    else if(T == 1)
    {
      if(ds.same(A,B))
      {
        cout<<1<<endl;
      }
      else
      {
        cout<<0<<endl;
      }
      
    }
  }
  
  return; 
}


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

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

 
  return 0;
}


Measured memory_bytes: 3324
#!/usr/bin/env python3


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    # Failed to predict input format
    N, K = list(map(int, input().split()))
    A = [x-1 for x in list(map(int, input().split()))]

    len_cycle = 0
    start = 0
    already_visit = set([0])

    loop_node = -1
    if K > N:
        while True:
            start = A[start]
            len_cycle += 1
            if start in already_visit:
                loop_node = start
                break
            else:
                already_visit.add(start)

        dist_loop_node = 0
        if loop_node != 0:
            start = 0
            while True:
                start = A[start]
                dist_loop_node += 1
                if start == loop_node:
                    break
            len_cycle -= dist_loop_node

        len_move = (K - dist_loop_node) % len_cycle
        start = loop_node
        for _ in range(len_move):
            start = A[start]
        print(start+1)
    else:
        start = 0
        for _ in range(K):
            start = A[start]
        print(start+1)
    pass

if __name__ == '__main__':
    main()


Measured memory_bytes: 32384
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(b / a, c) << endl;
    return 0;
}


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

int main() {
  intmax_t X, Y;
  scanf("%jd %jd", &X, &Y);

  int res = 0;
  while (X <= Y) {
    ++res;
    X *= 2;
  }
  printf("%d\n", res);
}


Measured memory_bytes: 256
fun main(args: Array<String>) = IO().exec {
    val n = int()
    val a = int()
    val b = int()
    val p = IntArray(n){int()}
    val cnt = IntArray(3)
    for (i in n) {
        if (p[i] <= a) cnt[0]++
        else if (p[i] <= b) cnt[1]++
        else cnt[2]++
    }
    println(cnt.min()!!)
}

// region template
operator fun Int.iterator() = 0.until(this).iterator()

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = java.io.PrintWriter(System.out)
    fun hasNextByte(): Boolean = if (ptr < buflen) true else {
        ptr = 0
        buflen = System.`in`.read(buffer)
        buflen > 0
    }

    fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }

    fun string(): String {
        if (!hasNext()) throw java.util.NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun long(): Long {
        if (!hasNext()) throw java.util.NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }

    fun double(): Double = string().toDouble()
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}
// endregion

Measured memory_bytes: 33992
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int X, N; cin >> X >> N;
    vector<int> A(110);
    for (int i = 0; i < N; i++) {
        int p; cin >> p; A[p] = 1;
    }
    int diff = 1e9;
    int ans = -1;
    for (int i = 0; i <= 101; i++) {
        if (A[i] == 0 && diff > abs(i - X)) {
            diff = abs(i - X);
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

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

  bool ok = false;
  while (n) {
    if (n % 10 == 9) ok = true;
    n /= 10;
  }

  cout << (ok ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;

namespace ABC155
{
    class Program
    {
        static void Main(string[] args)
        {

            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            int N = int.Parse(Console.ReadLine());
            string[] str = new string[N];

            int[] kazu = new int[N];
            int point=0;
            string nstr;

            int max;

            int i;


            for (i = 0; i < N; i++)
            {
                str[i] = Console.ReadLine();
                kazu[i] = 0;
            }


            Array.Sort(str, StringComparer.OrdinalIgnoreCase);
            
            //出た回数の保存
            nstr = str[0];
            kazu[0] = 1;
            max = 0;
            for (i = 1; i < N; i++)
            {
                if(nstr != str[i])
                {
                    point = i;
                }
                kazu[point]++;

                if (kazu[point] > max)
                {
                    max = kazu[point];
                }

                nstr = str[i];
            }

            for (i = 0; i < N; i++)
            {
                if (kazu[i] == max)
                {
                    Console.WriteLine(str[i]);
                }
            }
            Console.Out.Flush();
            

        }
    }
}


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

#define f(i,x,y)			for(int i=x; i<y; i++)
#define mp 					make_pair
#define F 					first
#define S 					second

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

	int a[n+1];
	f(i,1,n+1)
		cin>>a[i];
	vector <int> dp(n+1,0);
	dp[1] = 0;

	f(i,2,n+1)
	{
		int x = min(i-1,k);
		int v = INT_MAX;
		for(int j=1; j<=x; j++)
			v = min(v,dp[i-j]+abs(a[i]-a[i-j]) );
		dp[i] = v;
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class AAtCoderCrackers {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int a, b;
    int ans = 1;
    cin >> a >> b;
    if (a%b == 0){
        ans = 0;
    }
    cout << ans << endl;
}
};

int main() {
	AAtCoderCrackers solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N, A, B, C;
    cin >> N >> A >> B >> C;
    vector<int> l(N);
    int ans = INT_MAX;
    for (int i = 0; i < N; i++) cin >> l[i];
    for (int x = 1; x < (1 << N); x++) {
        for (int y = 1; y < (1 << N); y++) {
            for (int z = 1; z < (1 << N); z++) {
                if ((x & y) == 0 && (y & z) == 0 && (z & x) == 0) {
                    int aa = 0, bb = 0, cc = 0;
                    int res = 0, c = 0;
                    for (int i = 0; i < N; i++) {
                        if ((1 << i) & x) {
                            aa += l[i];
                            c++;
                        }
                        if ((1 << i) & y) {
                            bb += l[i];
                            c++;
                        }
                        if ((1 << i) & z) {
                            cc += l[i];
                            c++;
                        }
                    }
                    res = (c-3) * 10 + abs(aa-A) + abs(bb-B) + abs(cc-C);
                    ans = min(ans, res);
                }
            }
        }
    }
    cout << ans << endl;
}

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

int main(){
    string ans;
    for(int i = 0; i < 3; i++){
        string tmp;
        cin >> tmp;
        if(i == 0){
            ans.push_back(tmp[0]);
        }
        else if(i == 1){
            ans.push_back(tmp[1]);
        }
        else{
            ans.push_back(tmp[2]);
        }
    }

    cout << ans << endl;

    return 0;
}

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

if N % 2:
  print(0)
else:
  
  num_five = 0
  cursor = 10
  while N // cursor != 0:
    num_five += N // cursor
    cursor *= 5

  num_two = 0
  cursor = 2
  while N // cursor != 0:
    num_two += N // cursor
    cursor *= 2

  print(min(num_five, num_two))

Measured memory_bytes: 38256
import core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
  auto a = readln.chomp.split.map!(to!int);
  writeln = max(0, a[0] - a[1]);
}


Measured memory_bytes: 256
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use List::Util qw(min);

my ($n, $m, $x) = split /\s+/, <STDIN>;
my @a = split /\s+/, <STDIN>;
my ($left, $right) = (0, 0);

foreach (@a) {
    if ($x < $_) {
        ++$right;
    } else {
        ++$left;
    }
}

my $min = min($right, $left);
print "$min\n";


Measured memory_bytes: 896
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

ll k, n;
vector<ll> x, y;
vector<pair<ll, ll>> xy;
vector<ll> dpx, dpy;

void solve() {
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    ll ans = (x.back() - x.front()) * (y.back() - y.front());
    rep(i, n) { // left x
        repr(j, n) { // right x
            rep(t, n) { // under y
                repr(l, n) { // top y
                    ll l_x = x[i], r_x = x[j], u_y = y[t], t_y = y[l];
                    int c = 0;
                    rep(s, n) {
                        if (l_x <= xy[s].first && xy[s].first <= r_x && u_y <= xy[s].second &&
                            xy[s].second <= t_y) {
                            c++;
                        }
                    }
                    if (c >= k) ans = min((r_x - l_x) * (t_y - u_y), ans);
                }
            }
        }
    }

    cout << ans << endl;
}

int main() {
    cin >> n >> k;
    x.resize(n), y.resize(n);
    dpx.resize(n), dpy.resize(n);
    xy.resize(n);
    rep(i, n) {
        cin >> x[i] >> y[i];
        xy[i] = make_pair(x[i], y[i]);
    }
    solve();
    return 0;
}

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

using namespace std;

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

#define rep(i, a, N) for(int i = a; i < N; i++)
#define rrep(i, a, N) for(int i = a; i >= N; i--)

int main() {
    int N;
    cin >> N;
    rep(i, 0, N) {
        int t, x, y;
        cin >> t >> x >> y;
        if (t % 2 != (x + y) % 2 || t < (x + y)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/

	coding: utf-8
	lang: C (GCC 5.4.1)
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	TLong n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	if(a > b)	puts("0");
	else if(n == 1){
		if(a != b)	puts("0");
		else puts("1");
	}
	else printf("%lld\n", (b - a) * (n - 2) + 1);
	return 0;
}


Measured memory_bytes: 128
//out of contest
//saw

#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,ans=0,ma;
  cin>>A>>B>>C;
  ma=max(A,max(B,C));
  ans=((ma*3)-(A+B+C));
  if(ans%2==0)cout<<ans/2<<endl;
  else cout<<(ans+3)/2<<endl;
  return 0 ;
}


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

int k, s;
int main()
{
  // 入力
  cin >> k >> s;

  int ans = 0;

  for (int x = 0; x <= k; x++)
  {
    for (int y = 0; y <= k; y++)
    {
      if (0 <= s - x - y && k >= s - x - y)
      {
        ans++;
      }
    }
  }

  printf("%d\n", ans);

  return 0;
}

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

int c[100009];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        c[a]++;
    }
    int p = 0;
    for (int i = 1; i <= 100000; i++)
        if (c[i] > 1)
            p += c[i] - 1;
    if (p % 2) p++;
    cout << n - p << '\n';
    return 0;
}


Measured memory_bytes: 640
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        String s = sc.next();
        s += sc.next();
        s += sc.next();
        
        out.println(s.equals("575") || s.equals("557") || s.equals("755") ? "YES" : "NO");
        
        out.flush();
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s[] = {"AC","WA","TLE","RE"};
    int n;
    cin >> n;
    map<string,int>cnt;
    for(int i=0; i<n; i++)
    {
        string s;
        cin >> s;
        cnt[s]++;
    }
    for(int i=0; i<4; i++)
    {
        cout << s[i] << " x " << cnt[s[i]]<<endl;
    }
}


Measured memory_bytes: 3616
#include<stdio.h>
int main(){
    int i,j,l,r,a[100][100],b[1][100],c[100];
    scanf("%d %d",&l,&r);
    for(i=0;i<l;i++){
        for(j=0;j<r;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<r;i++){
        scanf("%d",&b[0][i]);
    }
    for(i=0;i<l;i++){
        for(j=0;j<r;j++){
            c[i] = a[i][j]*b[0][j] +c[i];
        }
    }
    for(i=0;i<l;i++){
        printf("%d\n",c[i]);
    }
}

Measured memory_bytes: 1888
N,Q=map(int,input().split())
S=input()
LR=[list(map(int,input().split())) for _ in range(Q)]

F=[0]*len(S)
for i in range(N-1):
    F[i+1]+=F[i]+(1 if S[i:i+2]=='AC' else 0)
    #print(i,F,S[i:i+2])
for l,r in LR:
    print(F[r-1]-F[l-1])

Measured memory_bytes: 31476
/*氏名：保坂優介, 学籍番号：200441141
  概要：最小 最大 合計を求める*/

#include<stdio.h>

int main(void)
{
    int i, n, a, max = -1000000, min = 1000000;     //変数の宣言
    long total=0;
    
    scanf("%d", &n);        //入力

    for (i = 0; i < n; i++)     //n回繰り返し
    {
        scanf("%d", &a);        //入力

        if (max < a)        //最大を求める
        {
            max = a;
        }

        if (min > a)        //最小を求める
        {
            min = a;
        }
        total = total + a;        //合計を求める
    }

    printf("%d %d %ld\n", min, max, total);     //表示
   

    return 0;
}


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

using namespace std;
typedef long long LL;

#define MAXN 101
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz size
#define FAIL {cout <<-1 << endl; return 0;}

int main(int argc, char** argv) {
#ifdef OJ
    freopen("input.txt", "r", stdin);
    //    freopen("output.txt", "w", stdout);
#endif
    std::ios::sync_with_stdio(false);

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

    cout << s - n << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long min = 100000000000000l;
        for (int i = 1 ; i <= Math.sqrt(n) ; i ++) {
            if (n % i == 0) {
                min = Math.min(min, (long) (i - 1) + (n / i - 1));
            }
        }

        System.out.println(min);
    }

}


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

#define INF (INT64_MAX)
#define MOD (1000000000+7)
#define MAX 200000

class UnionFind{
private:
  std::vector<int> data_array;
public:
 const int root(int id){
    if(data_array[id] >= 0)
      return data_array[id] = root(data_array[id]);
    else
      return id;
  }
  UnionFind(size_t size) : data_array(size,-1){}
  // unionは予約語
  bool union_(int lhs, int rhs){
    lhs = root(lhs);
    rhs = root(rhs);
    bool is_union = (lhs != rhs);
    if(is_union){
      if( data_array[lhs] > data_array[rhs]){  std::swap(lhs,rhs);  }
      data_array[lhs] += data_array[rhs];
      data_array[rhs] = lhs;
    }
    return is_union;
  }
  bool find(int lhs, int rhs){
    return ( root(lhs) == root(rhs) );
  }
};

int N, K, L;
pair<int, int> p[MAX];

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

	UnionFind ufR( N );
	UnionFind ufT( N );

	for( int i = 0; i < K; i++ ) {
		int p, q;
		cin >> p >> q;
		p--;
		q--;
		ufR.union_( p, q );
	}
	for( int i = 0; i < L; i++ ) {
		int r, s;
		cin >> r >> s;
		r--;
		s--;
		ufT.union_( r, s );
	}

	for( int i = 0; i < N; i++ ) {
		p[i] = make_pair( ufR.root( i ), ufT.root( i ) );
	}
	sort( p, p + N );

	for( int i = 0; i < N; i++ ) {
		pair<int, int> pa = make_pair( ufR.root( i ), ufT.root( i ) );
		cout << upper_bound( p, p + N, pa ) - lower_bound( p, p + N, pa );
		if( i < N - 1 ) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3840
n = int(input())
a = input().split()

b = []
c = []
for i in range(len(a)):
    if (i+1) % 2 !=  0:
        b.append(a[i])
    else:
        c.append(a[i])
if (i + 1) % 2 != 0:
    d = " ".join(reversed(b)) + " " + " ".join(c)
else:
    d = " ".join(reversed(c)) + " " + " ".join(b)

print(d)


Measured memory_bytes: 26772
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1)
	{
		cerr << name << " = " << arg1 << endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args)
	{
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
		__f(comma+1, args...);
	}
#else
#define debug(...)
#endif

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

#define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"

// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;  // Min Heap

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth (1 based indexing) smallest: " << *A.find_by_order(k - 1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

ll pp[15];

ll power(ll a, ll b)
{
	ll ans = 1;
	while(b > 0)
	{
		if(b & 1ll) ans = (ans * a);
		a = (a * a);
		b >>= 1ll;
	}
	return ans;
}

bool check(ll n)
{
	vector<ll>x;
	while(n)
	{
		x.pb(n % 10);
		n /= 10;
	}
	for(int i=0;i<sz(x) - 1;i++)
		if(abs(x[i] - x[i + 1]) > 1) 
			return false;
	return true;
}

ll nex(ll n)
{
	vector<ll>x;
	while(n)
	{
		x.pb(n % 10);
		n /= 10;
	}
	ll ans = 0, ind = -1;
	for(int i=0;i<sz(x)-1;i++)
		if(abs(x[i] - x[i + 1]) > 1)
			ind = i;
	x[ind] += 1;
	for(ll i=ind;i<sz(x);i++)
	{
		ans += pp[i] * (x[i] % 10);
		if(x[i] >= 10)
		{
			x[i] = (x[i] % 10);
			if(i == sz(x) - 1) ans += pp[sz(x)];
			else x[i + 1] += 1;
		}
	}
	ll q = x[ind];
	for(ll i=ind-1;i>=0;i--)
	{
		if(q > 1) ans += pp[i] * (q - 1);
		q--;
	}
	return ans;
}

int main()
{
	FAST_IO;

	ll k, curr = 1;
	cin >> k;
	pp[0] = 1;
	for(ll i=1;i<15;i++) pp[i] = (pp[i - 1] * 10);
 	vector<ll>v;
 	while(sz(v) < k)
 	{
 		bool f1 = check(curr);
 		if(f1) v.pb(curr), curr += 1;
 		else curr = nex(curr);
 	}   
 	cout << v.back() << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)

ll n,m;
ll p[10001],c[500],e[500];
ll dp[10002];
const ll INF =0xffffffffffffff;
int main()
{
	cin>>m>>n;
	rep(i,m) cin>>p[i];
	sort(p,p+m,[](ll a,ll b){return a>b;});
	fill(dp,dp+10002,INF);
	dp[0]=0;
	rep(i,n) cin>>c[i]>>e[i];
	rep(i,n){
		rrep(j,10001){
			dp[j]=min(dp[j],min(dp[j+1],j-c[i]>=0?dp[j-c[i]]+e[i]:INF));
		}
		//rrep(j,m+1-c[i]){
		//	dp[j+c[i]]=min(dp[j+c[i]],dp[j]+e[i]);
		//}
	}
	ll ans=0,sum=0;
	rep(i,m){
		//cout<<dp[i]<<endl;
		sum+=p[i];
		ans=max(ans,sum-dp[i+1]);
	}
	//cout<<dp[m]<<endl;
	cout<<ans<<endl;
}

Measured memory_bytes: 3292
import collections

p = int(input())


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

l = prime_factorize(p)
sl = set(l)
lsl = list(set(l))
c = collections.Counter(l)
ans = 0
#print(c)
#print(lsl)
for i in range(len(lsl)):
    cnt = 0
    #print(c[lsl[i]])
    #print(i)
    if c[lsl[i]] == 1:
        ans += 1
    else:
        for j in range(1, c[lsl[i]]):
            cnt += j

            #print(c[lsl[i]])
            if cnt <= c[lsl[i]]:
                ans += 1
print(ans)

Measured memory_bytes: 9456
#include <algorithm>
#include <string>
#include <array>
#include <vector>
#include <iostream>

using namespace std;

int main() {

  string str;
  int cnt0 = 0;
  int cnt1 = 0;

  cin >> str;
  
  for (int i = 0; i < str.size(); i++) {
    if (str[i] == '0') cnt0 ++;
    if (str[i] == '1') cnt1 ++;
  }

  cout << min(cnt0, cnt1) * 2 << endl;
}


Measured memory_bytes: 512