akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
typedef pair<int,int> pii;
int read(){
	int x=0,f=1; char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1; ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
int f[N];
queue<pii>q;
set<int>b[N],r[N];
int find(int x){
	return (f[x]==x)?x:f[x]=find(f[x]);
}
int main(){
	int n=read();
	for (int i=1;i<=n;i++) f[i]=i;
	for (int i=1;i<n;i++){
		int u=read(),v=read();
		b[u].insert(v); b[v].insert(u);
	}
	for (int i=1;i<n;i++){
		int u=read(),v=read();
		r[u].insert(v); r[v].insert(u);
		if (b[u].find(v)!=b[u].end()) q.push(make_pair(u,v));
	}
	while (!q.empty()){
		int u=q.front().first,v=q.front().second; q.pop();
		if (find(u)==find(v)) continue;
		u=find(u),v=find(v);
		if (r[u].size()+b[u].size()>r[v].size()+b[v].size()) swap(u,v);
		b[u].erase(v); b[v].erase(u);
		r[u].erase(v); r[v].erase(u);
		for (set<int>::iterator it=b[u].begin();it!=b[u].end();it++){
			int x=*it;
			b[x].erase(u); b[x].insert(v);
			b[v].insert(x);
			if (r[x].find(v)!=r[x].end()) q.push(make_pair(x,v));
		}
		for (set<int>::iterator it=r[u].begin();it!=r[u].end();it++){
			int x=*it;
			r[x].erase(u); r[x].insert(v);
			r[v].insert(x);
			if (b[x].find(v)!=b[x].end()) q.push(make_pair(x,v));
		}
		f[find(u)]=find(v);
	}
	int cnt=0;
	for (int i=1;i<=n;i++) if (find(i)==i) cnt++;
	if (cnt==1) printf("YES\n"); else printf("NO\n");
	return 0;
}

Measured memory_bytes: 29056
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define E 1e-6
#define INF 0x3f3f3f3f
void open(){freopen("data.txt","r",stdin);}
void out(){freopen("out.txt","w",stdout);}
const int maxn = 101010;
const int MOD = 1e9 + 7;

int main()
{
    int n;
    set<int> myset;
    set<int>::iterator it;
    scanf("%d",&n);
    rep(i,0,n){
        int x;
        scanf("%d",&x);
        if(myset.find(x)==myset.end()) myset.insert(x);
        else myset.erase(x);
    }
    printf("%d\n",(int)myset.size());
}


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

int main() {
    int A;
    int B;
    int C;
    int ichi;
    int ni;
    int san;
    int count = 0;
    bool a;
    bool b;

    scanf("%d%d%d", &A, &B, &C);
    ichi = max({A, B, C});
    san = min({A, B, C});
    ni = A + B + C - ichi - san;
    
    count += (ichi - ni)/2;
    a = (ichi - ni)%2 == 1;
    count += (ichi - san)/2;
    b = (ichi - san)%2 == 1;

    if(a && b) {
        count += 1;
    }else if((!a && b) || (a && !b)) {
        count += 2;
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int N; scanf("%d",&N);
  double x[N],sum=0;
  char y[N][4];
  for(int i=0;i<N;i++){
    scanf("%lf%s",&x[i],y[i]);
    if(y[i][0]=='B'){
      sum+=x[i]*380000;
    }else{
      sum+=x[i];
    }
  }
  printf("%lf\n",sum);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using vi = vector<ll>;
using vv = vector<vi>;
//const int MOD = 1000000007;
//const int MOD = 998244353;
const ll INF = 1001001001001;

int main(){
    int n,k;
    cin>>n>>k;
    
    vi a(n);
    ll sum = 0;
    ll maxans = 0;
    rep(i,n){
        cin>>a[i];
        sum += a[i];
        
        maxans = max(maxans, a[i]);
    }
    
    ll minans = (sum + n+k -1)/(n+k);
    //cout << minans <<" "<< maxans << endl;
    
    ll ans = (maxans+minans)/2;
    
    while(maxans-minans>=2){
        ll count = 0;
        rep(i,n){
            count += (a[i] + ans- 1)/ans;
        }
        
        if(count<=n+k){
            maxans = ans;
            ans = (maxans+minans)/2;
        }else{
            minans = ans;
            ans = (maxans+minans)/2;
        }
    }
    
    
    {
        ll count = 0;
        rep(i,n){
            count += (a[i] + minans- 1)/minans;
        }
        
        if(count<=n+k){
            cout << minans << endl;
        }else{
            cout << minans+1 << endl;
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 4792
n=int(input())
a=[0]*n
a[:]=map(int,input().split())
r=0
import copy
for ii in range(n-2):
  b=copy.copy(a[ii:ii+3])
  c=copy.copy(b)
  b.sort()
  if b[1]==c[1]:
    r+=1
print(r)

Measured memory_bytes: 3444
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    H = il()
    print(H[0] ^ H[1] ^ H[2])



if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
# include <iostream>
# include <stdint.h>
# include <stdio.h>
# include <math.h>
using namespace std;


int main(){
	string s, p;
	cin >>s >>p;
	bool yy = false;
	int x = (int)p.size() , z;
	
	for(int i=0;i<(int)s.size();i++){
		if(s[i] == p[0]){
			z =i;
			for(int j =0;j< (int)p.size();j++){
				if(s[z] != p[j]) break;
				else if(j == (int)p.size() -1){
					yy =true; 
				}
				z++;
				if(z == (int)s.size()){
					z =0;
				}


			}
		}
	}
	if(yy ==true){
		cout <<"Yes\n";
	}
	else{
		cout <<"No\n";
	}
	return 0;
}



Measured memory_bytes: 3220
#include<stdio.h>
int main(void)
{
    double a,b,sum=0;
    long long c;
    scanf("%lf %lf",&a,&b);
    if(b<2||a<1)
        sum=0;
    else
    if(a>=b/2)
    {
        sum=b/2;
    }
    else if(a<b/2)
    {
        sum=a+(b-2*a)/4;
    }
    c=sum;
    if(sum-c>=0.5)
        sum=sum-1;
    printf("%.0f\n",sum);
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<stack>
using namespace std;
typedef long long ll;
#define MAX 200000

int dp[200][10][10][10];

int main(){
  int N;
  cin>>N;
  dp[0][3][3][3]=1;

  for(int i=1;i<=N;i++){
    for(int c3=0;c3<4;c3++){
      for(int c2=0;c2<4;c2++){
        for(int c1=0;c1<4;c1++){
          for(int c0=0;c0<4;c0++){
            if(c0==1 && c1==2 && c2==0) continue;
            if(c0==2 && c1==1 && c2==0) continue;
            if(c0==1 && c1==0 && c2==2) continue;
            if(c0==1 && c1==2 && c3==0) continue;
            if(c0==1 && c2==2 && c3==0) continue;

            dp[i][c2][c1][c0]+=dp[i-1][c3][c2][c1];
            dp[i][c2][c1][c0]%=1000000007;
            
          }
        }
      }
    }
  }
  ll ans=0;
  for(int c2=0;c2<4;c2++){
    for(int c1=0;c1<4;c1++){
      for(int c0=0;c0<4;c0++){
        ans+=dp[N][c2][c1][c0];
        ans%=1000000007;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
int main() {
	
	char a[20], b[20], c[20];
	scanf("%s %s %s", &a, &b, &c);
	
	int lenA = strlen(a);
	int lenB = strlen(b);
	
	if (a[lenA-1] == b[0] && b[lenB-1] == c[0]){
		printf("YES\n");
	}
	else printf("NO\n");
	
	return 0;
}

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

int main(void)
{
  char s1[4],s2[4];
  scanf("%s%s",s1,s2);
  if((s1[0]==s2[2] && s1[2]==s2[0])&&s1[1]==s2[1])
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}


Measured memory_bytes: 128
a,b,c,d = map(int, list(input()))

if a + b + c + d == 7:
    print('{}+{}+{}+{}=7'.format(a,b,c,d))
elif a + b + c - d == 7:
    print('{}+{}+{}-{}=7'.format(a,b,c,d))
elif a + b - c + d == 7:
    print('{}+{}-{}+{}=7'.format(a,b,c,d))
elif a + b - c - d == 7:
    print('{}+{}-{}-{}=7'.format(a,b,c,d))
elif a - b + c + d == 7:    
    print('{}-{}+{}+{}=7'.format(a,b,c,d))
elif a - b + c - d == 7:       
    print('{}-{}+{}-{}=7'.format(a,b,c,d))
elif a - b - c + d == 7:     
    print('{}-{}-{}+{}=7'.format(a,b,c,d))
elif a - b - c - d == 7:    
    print('{}-{}-{}-{}=7'.format(a,b,c,d))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P; typedef unsigned long long int ull;
const ll mod = 1e9 + 7;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr) {
	if (firstItr < 0 || secondItr>int(str.size() - 1))return str;
	while (firstItr < secondItr) {
		swap(str[firstItr], str[secondItr]);
		firstItr++; secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str) {
	int itr = 0; std::string res;
	while (itr < int(str.size())) {
		char tmp = str[itr++];
		int length = 1;
		while (itr <int(str.size()) && str[itr] == tmp) { ++itr; ++length; }
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
std::string split(std::string str, size_t first_itr, bool isFront) {
	if (first_itr < 0 || first_itr > str.size()) {
		return str;
	}
	else {
		if (isFront) {
			std::string tmp;
			for (size_t i = 0; i < first_itr; i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
		else {
			std::string tmp;
			for (size_t i = first_itr; i < str.size(); i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
	}
}


bool dfs(int depth, str s) {
	/*if (depth == n) {
		ans.push_back(s);
		return false;
	}
	for (int i = 0; i < n; i++) {
		if (dfs(depth + 1, s + dic.at(i))) {
			return true;
		}
	}*/
	return false;
}


int main() {
	int a, b; cin >> a >> b;
	vec v; v.push_back(a + b);
	v.push_back(a * b);
	v.push_back(a - b);
	cout << *max_element(all(v)) << endl;



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

int x;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> x;
	cout << (x >= 30 ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

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

    ll N;
    cin >> N;
    multiset<ll> s;
    Rep (i, 1<<N) {
        ll S;
        cin >> S;
        s.insert(S);
    }

    vec exist;
    auto itr = s.end();
    itr--;
    exist.push_back(*itr);
    Rep (i, N) {
        Rep (j, 1<<i) {
            itr = s.lower_bound(exist[j]);
            if (itr == s.begin()) {
                cout << "No\n";
                return 0;
            }
            itr--;
            exist.push_back(*itr);
            s.erase(itr);
        }
    }

    cout << "Yes\n";
    return 0;
}

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

using namespace std;
typedef long long ll;

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

int main() {
  ll n;
  cin >> n;
  ll a[n];
  rep(i,0,n){
    cin >> a[i];
  }
  ll now = a[0];
  ll ans = 0;
  rep(i,1,n){
    if(now>a[i]){
      ans += now-a[i];
    }
    else if(now<a[i]){
      now = a[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 5152
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,time=0
    integer(int32), allocatable:: a(:),b(:)

    read*, n
    allocate(a(n),b(n))
    do i = 1, n
        read*, a(i),b(i)
    end do
    call double_sort(b,a,1,n)

    do i=1,n
        if (time+a(i) > b(i)) then
            print'(a)','No'
            stop
        else
            time=time+a(i)
        end if
    end do
    print'(a)', 'Yes'
contains
    recursive subroutine double_sort(ar1, ar2, fst, lst)
        integer(int32),intent(inout):: ar1(:),ar2(:)
        integer(int32),intent(in):: fst,lst
        integer(int32):: mdl

        if (lst - fst < 2) then
            if (ar1(fst) > ar1(lst)) then
                call swap(ar1(fst), ar1(lst))
                call swap(ar2(fst), ar2(lst))
            end if
            return
        end if

        mdl = (fst+lst)/2

        call double_sort(ar1,ar2,fst,mdl)
        call double_sort(ar1,ar2,mdl+1,lst)
        call double_merge_(ar1,ar2,fst,mdl,lst)
    end subroutine


    subroutine double_merge_(ar1,ar2,fst,mdl,lst)
        integer(int32),intent(inout):: ar1(:),ar2(:)
        integer(int32),intent(in):: fst,mdl,lst
        integer(int32),allocatable:: t1(:),t2(:)
        integer(int32):: li,ri,ti

        allocate(t1(lst-fst+1), t2(lst-fst+1))

        li=fst
        ri=mdl+1
        ti=1

        do while(li <= mdl .and. ri <= lst)
            if (ar1(li) <= ar1(ri)) then
                t1(ti) = ar1(li) 
                t2(ti) = ar2(li)
                li=li+1
            else
                t1(ti) = ar1(ri)
                t2(ti) = ar2(ri)
                ri=ri+1
            end if
            ti=ti+1
        end do

        if (li <= mdl) then
            t1(ti:) = ar1(li:mdl)
            t2(ti:) = ar2(li:mdl)
        else
            t1(ti:) = ar1(ri:lst)
            t2(ti:) = ar2(ri:lst)
        end if

        ar1(fst:lst) = t1(:)
        ar2(fst:lst) = t2(:)

        deallocate(t1,t2)
    end subroutine

    
    subroutine swap(x,y)
        integer(int32),intent(inout):: x,y
        integer(int32):: tmp
        tmp = x
        x = y
        y = tmp
    end subroutine
end program name

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

typedef long long ll;

ll a, b,c;
ll res = 0;

int main(){
	cin >> a >> b >> c;
	if(a + b < c){
		res = a + b * 2 + 1;
	}
	else{
		res = b + c;
	}
	cout << res << endl;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  ll n;cin>>n;
  vector<ll>num(n);
  ll ans=0;
  ll minuspo=0;
  ll pluspo=0;
  ll zeropo=0;
  for(ll i=0;i<n;i++){
    cin>>num[i];
    num[i]-=(i+1);
    if(num[i]==0)zeropo++;
    else if(num[i]<0)minuspo++;
    else pluspo++;
    ans+=abs(num[i]);
    // cout<<num[i]<<" ";
  }
  ll cnt=0;

  if(minuspo<pluspo){
    sort(num.begin(),num.end());
    ll minuspo2=minuspo+zeropo;
    if(minuspo2>=pluspo){
      cout<<ans<<endl;
      //  cerr<<"!"<<endl;
      return 0;
    }
    ll i=0;
    while(pluspo>minuspo2){
      if(i==0)
	ans-=(ll)abs((pluspo-minuspo2))*abs(num[minuspo2]);
      else
	ans-=(ll)abs((pluspo-minuspo2))*abs((num[minuspo2]-num[minuspo2-1]));
      pluspo--;minuspo2++;
      i++;
    }
    cout<<ans<<endl;
    return 0;
  }else if(minuspo>pluspo){
    sort(num.begin(),num.end());
    ll pluspo2=(ll)pluspo+zeropo;
    if(pluspo2>=minuspo){
      cout<<ans<<endl;
      return 0;
    }
    ll i=0;
    while(pluspo2<minuspo){
      if(i==0)
	ans-=abs(pluspo2-minuspo)*abs(num[minuspo-1]);
      else
	ans-=abs(pluspo2-minuspo)*abs(num[minuspo-1]-num[minuspo]);
      pluspo2++;minuspo--;
      i++;
    }
    cout<<ans<<endl;
  }else{
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 1792
INF = 2 * 10 ** 5
MOD = 10 ** 9 + 7
n = gets.to_i
colors = []
n.times { colors << gets.to_i }
places = Array.new(INF + 1) { [] }
colors.each_with_index do |color, index|
  places[color] << index
end
dp = [1]
previous = colors.shift
colors.each.with_index(1) do |color, index|
  place_index = places[color].bsearch_index { |place| place >= index }
  if previous == color || place_index == 0
    dp[index] = dp[index - 1]
  else
    dp[index] = dp[index - 1] + dp[places[color][place_index - 1]]
  end
  previous = color
end
puts dp.last % MOD


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

using namespace std;

int main(){
 string s; 
  cin >> s;
 
 int cnt=0;
  long res=0;
  for(int i=0;i<s.length();i++){ 
    if(s[i]=='B') cnt++;
    else {res+=cnt;
         }
  }
  
  cout << res << endl;
  
}


Measured memory_bytes: 640
import _heapq
inf=float("inf")


def prim():
    color=["white" for _ in range(n+1)]
    D=[inf for _ in range(n+1)]
    M=[[] for _ in range(n+1)]

    for u,v,w in UVW:
        M[u].append([w,v])
        M[v].append([w,u])

    queue=[[0,1]]
    _heapq.heapify(queue)
    color[1]="gray"
    D[1]=1

    while len(queue)>0:
        num=_heapq.heappop(queue)[1]
        if color[num]=="black":continue
        color[num]="black"

        for i,j in M[num]:
            if D[j]>i and color[j]!="black":
                if i%2==0:D[j]=D[num]
                else:D[j]=-D[num]
                color[j]="gray"
                _heapq.heappush(queue,[i,j])

    return D[1:]


n=int(input())
UVW=[list(map(int,input().split())) for _ in range(n-1)]
for i in prim():
    if i==1:print(i)
    else:print(0)

Measured memory_bytes: 58996
#include <bits/stdc++.h>
    
using namespace std;
typedef long long ll;
    
int main()
{
    string S;
    cin >> S;

    if (S[0] != S[1] || S[1] != S[2]) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <vector>
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uit;
typedef double f2;
typedef long double f3;
#define N 100050
#define mod 1000000007
char w[N];int n,cnt[26];
int main() {
	scanf("%d%s",&n,w+1);
	int i;
	for(i=1;i<=n;i++) cnt[w[i]-'a']++;
	ll ans=1;
	for(i=0;i<26;i++) ans=ans*(cnt[i]+1)%mod;
	printf("%lld\n",(ans-1+mod)%mod);
}


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

int gcd(int a, int b)
{
  return b == 0 ? a : gcd(b,a%b);
}

int main()
{
  int p, q;
  cin >> p >> q;
  q /= gcd(p,q);
  long long int x = 1;
  for(int i = 2; i * i <= q; i++){
    if(q % i == 0){
      x *= i;
      while(q % i == 0) q /= i;
    }
  }
  cout << x * q << endl;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h,w;cin>>h>>w;
  vector<string> G(h);rep(i,h) cin>>G[i];
  vector<lvector> V(h,lvector(w,0)),W(w,lvector(h,0));
  rep(i,h) {
    ll v=0,pos=0;
    rep(j,w) {
      if(G[i][j]=='.') v++;
      else {
        fill(V[i].begin()+pos,V[i].begin()+pos+v,v);
        pos=j+1,v=0;
      }
    }
    if(v>0) fill(V[i].begin()+pos,V[i].end(),v);
  }
  rep(i,w) {
    ll v=0,pos=0;
    rep(j,h) {
      if(G[j][i]=='.') v++;
      else {
        fill(W[i].begin()+pos,W[i].begin()+pos+v,v);
        pos=j+1,v=0;
      }
    }
    if(v>0) fill(W[i].begin()+pos,W[i].end(),v);
  }
  ll ans=-1;
  rep(i,h)rep(j,w) ans=max(ans,V[i][j]+W[j][i]);
  print(ans-1);
  return 0;
}

Measured memory_bytes: 70252
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S, T;
    cin >> S >> T;
    int Q;
    cin >> Q;
    vector<int> cusumS(S.length() + 1, 0), cusumT(T.length() + 1, 0);
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == 'A')
            cusumS[i + 1] = cusumS[i] + 2;
        else
            cusumS[i + 1] = cusumS[i] + 1;
    }
    for (int i = 0; i < T.length(); i++) {
        if (T[i] == 'A')
            cusumT[i + 1] = cusumT[i] + 2;
        else
            cusumT[i + 1] = cusumT[i] + 1;
    }
    while (Q--) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        if (abs((cusumS[b] - cusumS[a - 1]) - (cusumT[d] - cusumT[c - 1])) % 3 == 0)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    //system("pause");
}

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

#define ll long long int
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0);
#define eb(x) emplace_back(x)
#define mp(a,b) make_pair(a,b)
#define sz(a) int((a).size())
#define mod 1000000007
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)


int main()
{
	FASTIO;

	    ll n,m;
	     cin>>n>>m;
	     ll ans=0;

	     if(n>=1)
            ans=(n*(n-1))/2;
	     if(m>=1)
            ans+=(m*(m-1))/2;

	     cout<<ans<<"\n";


	return 0;
}





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

 using namespace std;

 int main() {
   int N, X, i;

   cin >> N;

   vector<int> d(N);
   for(i = 0; i < N; i++) cin >> d.at(i);

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

   X = 1;
   for (i = 0; i < N - 1; i++) {
     if (d.at(i) != d.at(i + 1)) X++;
   }

   cout << X << endl;
}


Measured memory_bytes: 256
def include3?(i)
  if i % 10 == 3
    true
  elsif (i / 10) != 0
    include3?(i / 10)
  else
    false
  end
end

for i in 1..gets.to_i
  if i % 3 == 0 or include3?(i)
    printf " #{i}"
  end
end
puts


Measured memory_bytes: 6868
N, K = map(int, input().split())
A = [0] * N

for i in range(K):
    d = int(input())
    targets = list(map(int, input().split()))
    for j in range(d):
        index = targets[j] -1
        A[index] = 1

count = 0
for i in range(N):
    if A[i] == 0:
        count += 1

print(count)


Measured memory_bytes: 9076
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, M, C;
  cin >> N >> M >> C;
  int count = 0, solve = 0;
  vector<int> bdata(M);
  for(int i = 0; i < M; i++) {
    cin >> bdata.at(i);
  }
  int a;
  for(int i = 0; i < N; i++) {
    solve = C;
    for(int j = 0; j < M; j++) {
      cin >> a;
      solve += a * bdata.at(j);
    }
    if (solve > 0) count++;
  }
  cout << count << endl;
  return 0;
}

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

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

    int odd = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        if (a % 2 == 1) odd++;
    }

    if (odd % 2 == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
#include<cstring>
#include <cstdlib>
#include <cstdio>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <memory>
#include <numeric>
#include <type_traits>

using namespace std;

#define rep(i,n) for (int (i)=0;(i)<(n);i++)
typedef long long ll;
const int MAXV = 1e6;


int main(){
  int n; cin >> n;
  map<string, int> m;
  string s;
  rep(i,n){
    cin >> s;
    m[s]++;
  }
  cout << "AC x " << m["AC"] << endl;
  cout << "WA x " << m["WA"] << endl;
  cout << "TLE x " << m["TLE"] << endl;
  cout << "RE x " << m["RE"] << endl;
  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	int N;
	while (cin >> N, N) {
		bool na = true;
		int k, res = 1;
		while (N--) {
			cin >> k;
			if (0 < k) ++res;
			if (2 <= k) na = false;
		}
		if (na) {
			cout << "NA\n";
		} else {
			cout << res << endl;
		}
	}
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;


int main(){
    long long n;
    cin >> n;
    vector<vector<long long> > g(n, vector<long long>(n));
    for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j) cin >> g[i][j];
    vector<vector<bool> > used(n, vector<bool>(n, false));
    for(int x = 0; x < n; ++x)
        for(int i = 0; i < n; ++i)
            for(int j = 0; j < n; ++j){
                if(x == i || x == j || i == j) continue;
                if(g[i][j] > g[i][x] + g[x][j]){
                    cout << -1;
                    return 0;
                }
                if(g[i][j] == g[i][x] + g[x][j]){
                    used[i][j] = used[j][i] = true;
                }
            }
    long long ans = 0;
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j){
            if(i == j) continue;
            if(!used[i][j]) ans += g[i][j];
        }
    cout << ans / 2;
}

Measured memory_bytes: 1024
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

MIN = min(A,B,C,D,E)
if N % MIN ==0:
    print(N // MIN + 4)
else:
    print( (N // MIN) + 5 )

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <map>
 
#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))
 
using namespace std;
 
using ll = long long;
 
typedef stack<int> IntStack;
typedef queue<int> IntQueue;
typedef vector<int> IntVector;
typedef list<int> IntList;
 
typedef struct S{
  int a;
  int b;
} Object;

int main(){
  map<string, int> mp;
  ll N;
  cin >> N;
  string S;
  for(int i=0;i<N;i++){
    cin >> S;
    mp[S] = 1;
  }
  
  cout << mp.size() << endl;   
}

Measured memory_bytes: 19224
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;

ll decode(string s){
    ll ret=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='1') ret+=pow(2,i);
    }
    return ret;
}

string encode(ll n,int size){
    string ret(size,'0');
    int i=0;
    while(n>0){
        if(n%2==0) ret[i]='0';
        else ret[i]='1';
        i++;
        n/=2;
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N,M;
    cin>>N>>M;
    vll a(M),b(M);
    vvll c(M);
    for(int i=0;i<M;i++){
        cin>>a[i]>>b[i];
        c[i].resize(b[i]);
        for(int j=0;j<b[i];j++) {
            cin>>c[i][j];
            c[i][j]--;
        }
    }
    
    vvll dp(M+1,vll(pow(2,N),INTMAX));//i番目までの鍵を使って、j番目の箱を開ける時の値段の最小値
    dp[0][0]=0;
    
    for(int i=0;i<M;i++){
        for(int j=0;j<dp[i].size();j++) dp[i+1][j]=dp[i][j];
        for(int j=0;j<dp[i].size();j++){
            if(dp[i][j]==INTMAX) continue;
            string s=encode(j,N);
            for(int k=0;k<b[i];k++){
                s[c[i][k]]='1';
            }
            ll de=decode(s);
            dp[i+1][de]=min(dp[i][j]+a[i],dp[i+1][de]);
        }
    }
    
    /*for(int j=0;j<dp[0].size();j++) printf("%s|",encode(j,N).c_str());
    printf("\n");
    for(int i=0;i<=M;i++){
        for(int j=0;j<dp[i].size();j++){
            if(dp[i][j]==INTMAX) printf("M|");
            else printf("%lld|",dp[i][j]);
        }
        printf("\n");
    }*/
    
    if(dp[M][pow(2,N)-1]==INTMAX) cout<<-1<<endl;
    else cout<<dp[M][pow(2,N)-1]<<endl;
        
    return 0;
}


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

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n)  FOR(i,0,(n))


class BHinaArare {
public:
	void solve(std::istream& in, std::ostream& out) {
    set<char> set;
    int n;
    in >> n;
    REP(i,n){
      char s;
      in >> s;
      set.insert(s);
    }
    out << (set.size() == 3 ? "Three" : "Four") << endl;
	}
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
	BHinaArare solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3568
N = int(input())
A = [int(i) for i in input().split()]
res = 1
for i in range(N):
    if A[i] == 0:
        res = 0
    if res < 0:
        continue
    res *= A[i];
    if res > 1e+18:
        res = -1

print(res)

Measured memory_bytes: 88160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

int main()
{
    string s;
    cin >> s;
    if (s == "Sunny")
    {
        puts("Cloudy");
    }
    else if (s == "Rainy")
    {
        puts("Sunny");
    }
    else if (s == "Cloudy")
    {
        puts("Rainy");
    }
    return 0;
}

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

using namespace std;

using int64 = long long;

int main() {
  int N, K, X[100000];
  cin >> N >> K;
  vector< int > pos, neg;
  for(int i = 0; i < N; i++) {
    cin >> X[i];
  }
  int ret = 1 << 30;
  for(int i = 0; i <= N - K; i++) {
    int L = X[i], R = X[i + K - 1];
    if(R < 0) ret = min(ret, -L);
    else if(L >= 0) ret = min(ret, R);
    else ret = min(ret, min(2 * -L + R, 2 * R - L));
  }
  cout << ret << endl;
}

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

int main ()
{
	string s, t;
	bool idx = 1;
	cin >> s >> t;
	int i = 0;
	while (idx == 1 and i < (int) s.size()) 
	{
		if (s[i] != t[i])
			idx = 0;			
		i++;
	}

	if (idx == 0)
		cout << "No" << "\n";
	else
		cout << "Yes" << "\n";


}

Measured memory_bytes: 3636
#include <iostream>
#include <map>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
using namespace std;
using ll = long long;

int main() {
    int n;
    ll m;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    vector<ll> s(n + 1, 0);
    rep(i, n) s[i + 1] = s[i] + a[i];

    map<ll, ll> cnt; 
    rep(i, n + 1) cnt[s[i] % m]++;

    ll ans = 0;
    for (auto e: cnt) {
        if (e.second % 2 == 0) ans += e.second / 2 * (e.second - 1);
        else ans += (e.second - 1) / 2 * e.second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5760
#!/usr/local/bin/ruby
n,m = gets.to_i,gets.to_i
arr = (1..n).to_a
m.times do
 rec = gets.split(",")
 x,y = rec[0].to_i,rec[1].to_i
 arr[x-1],arr[y-1] = arr[y-1],arr[x-1]
end
puts arr

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

int main()
{
  int n, ans = 0;
  cin >> n;
  vector<int> v(n), c(n);
  for(int i=0; i<n; i++)
    cin >> v[i];
  for(int i=0; i<n; i++)
    cin >> c[i];
  
  for(int i=0; i<n; i++)
    ans += max(v[i] - c[i], 0);
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int k = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		int[] h = new int[n + 1];
		for (int i = 0; i < n; i++) {
			h[i + 1] = Integer.parseInt(sa[i]);
		}
		br.close();

		long[][] dp = new long[n + 1][n - k + 1];
		for (int i = 1; i <= n; i++) {
			for (int i2 = 1; i2 <= n - k && i2 <= i; i2++) {
				if (i2 == 1) {
					dp[i][i2] = 10000000000000L;
					if (i - i2 <= k) {
						dp[i][i2] = h[i];
					}
				} else {
					long min = 10000000000000L;
					for (int j = i2 - 1; j < i; j++) {
						if (i - i2 <= k) {
							long val = dp[j][i2 - 1] + Math.max(h[i] - h[j], 0);
							min = Math.min(min, val);
						}
					}
					dp[i][i2] = min;
				}
			}
		}
		long ans = 10000000000000L;
		for (int i = n - k; i <= n; i++) {
			ans = Math.min(ans, dp[i][n - k]);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	long  MOD = 1000000007L;

	public void run() {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		int K=sc.nextInt();

		long NM= (N*M)%MOD;
		long ans = f(NM, N, M, K);
		ans += f(NM, M, N, K);
		ans %= MOD;
		long cnt = choose(NM-2, K-2);
		ans *= cnt;
		ans %= MOD;

		System.out.println(ans);
		sc.close();
	}

	public long f(long nm, int n, int m, int k) {
		long ans = 0;
		for(long i=1; i<n; i++) {
			long tmp = i * (n-i) % MOD;
			tmp %= MOD;
			ans += tmp;
			ans %= MOD;
			//System.out.println(ans);
		}
		ans = ans*m*m;
		ans %= MOD;
		return ans;
	}

	public long choose(long n, int k) {
		return fact(n) * inv(fact(n-k)) % MOD * inv(fact(k)) % MOD;
	}

	public long fact(long x) {
		long ans = 1;
		for(long i=x; i>0; i--) {
			ans *= i;
			ans %= MOD;
		}
		return ans;
	}

	public long pow(long n, long x) {
		if(x==0) return 1;
		long tmp = pow(n, x/2);
		long ans = 0;
		if(x%2==0) {
			ans = tmp * tmp % MOD;
		}else {
			ans = tmp * tmp % MOD * n % MOD;
		}
		return ans;
	}

	public long inv(long x) {
		return pow(x, MOD-2);
	}
}


Measured memory_bytes: 23892
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 2e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

ll arr[maxN], dp[maxN][2];
int n;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	cin >> n;
	for(int i = 1; i <= n; i++) cin >> arr[i];
	dp[1][0] = LLONG_MIN / 3;
	dp[1][1] = arr[1];
	for(int i = 2; i <= n; i++) {
		if(i & 1) {
			dp[i][0] = arr[i] + max(dp[i - 2][0], (i > 2? dp[i - 3][0]: LLONG_MIN / 3));
			dp[i][1] = arr[i] + dp[i - 2][1];
		} else {
			dp[i][0] = arr[i] + max(dp[i - 2][0], (i > 2? dp[i - 3][1]: LLONG_MIN / 3));
		}
	}
	//for(int i = 0; i < n; i++) LOG << dp[i][0] << ' ' << dp[i][1] << '\n';
	ll ans = dp[n][0];
	int x = 0;
	if(n % 2 == 0) x = 1;
	ans = max(ans, dp[n - 1][x]);
	cout << ans << '\n';
}



Measured memory_bytes: 8304
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstdio>
#include<cmath>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int read(){
	int f=1,x=0;
	char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();}
	return f*x;
}
#define MAXN 200000
#define MAXC 1000000
#define INF 0x3f3f3f3f
struct node{//虚虚连边
	int u,v,f;
	node(){}
	node(int U,int V,int F){u=U,v=V,f=F;}
};
struct node1{//真虚连边
	int num,u,f;
	node1(){}
	node1(int U,int F){u=U,f=F;}
	friend bool operator < (node1 a,node1 b){return a.u==b.u?a.f<b.f:a.u<b.u;}
};
struct edge{
	int v,w;
	edge(){}
	edge(int V,int W){v=V,w=W;}
};
vector<node> xx;
vector<node1> zx;
vector<edge> G[3*MAXC+5];
int n,m,cnt;
inline void Addedge(int u,int v,int w){
	G[u].push_back(edge(v,w));
	G[v].push_back(edge(u,w));
	return ;
}
queue<int>Q;
int dis[MAXC+5];
bool vis[MAXC+5];
int SPFA(int S,int T){
	memset(vis,0,sizeof(vis));
	memset(dis,0x3f,sizeof(dis));
	vis[S]=1,dis[S]=0,Q.push(S);
	while(!Q.empty()){
		int u=Q.front();
		Q.pop();
		vis[u]=0;
		int siz=G[u].size();
		for(int i=0;i<siz;i++){
			int v=G[u][i].v,w=G[u][i].w;
			if(dis[v]>dis[u]+w){
				dis[v]=dis[u]+w;
				if(!vis[v]){
					vis[v]=1;
					Q.push(v);
				}
			}
		}
	}
	return (dis[T]==INF?-1:dis[T]/2);
}
int main(){
	//freopen("trip.in","r",stdin);
	//freopen("trip.out","w",stdout);
	n=read(),m=read(),cnt=n;
	for(int i=1;i<=m;i++){
		int u=read(),v=read(),f=read();
		xx.push_back(node(u,v,f));
		zx.push_back(node1(u,f)),zx.push_back(node1(v,f));
	}
	//puts("\n");
	sort(zx.begin(),zx.end());
	for(int i=0;i<int(zx.size());i++){
		int u=zx[i].u,f=zx[i].f;
		if(i==0||(u==zx[i-1].u&&f!=zx[i-1].f)||(u!=zx[i-1].u)){
			zx[i].num=++cnt;
			//printf("%d %d %d\n",u,f,zx[i].num);
			Addedge(u,cnt,1);
		}
	}
	for(int i=0;i<int(xx.size());i++){
		node1 l1=*lower_bound(zx.begin(),zx.end(),node1(xx[i].u,xx[i].f));
		node1 l2=*lower_bound(zx.begin(),zx.end(),node1(xx[i].v,xx[i].f));
		//printf("%d %d\n",l1.num,l2.num);
		Addedge(l1.num,l2.num,0);
	}
	printf("%d\n",SPFA(1,n));
	return 0;
}

Measured memory_bytes: 101660
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long N = input[0], K = input[1];

        var bigArray = new long[100000 + 1];

        for(var i = 0; i < N; ++i)
        {
            var num_times = Console.ReadLine().Split();
            long num = long.Parse(num_times[0]), times = long.Parse(num_times[1]);
            bigArray[num] += times;
        }

        for(var i = 1; i <= 100000; i++)
        {
            K -= bigArray[i];
            if (K > 0) continue;
            Console.WriteLine(i);
            return;
        }
    }
}

Measured memory_bytes: 18016
#include <bits/stdc++.h>
using namespace std;
const int N=100005;
int n,a[N],tot=0;
char s[N];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	if (s[1]=='0'||s[n]=='1')
		return puts("-1"),0;
	for (int i=1;i<n;i++){
		if (s[i]!='1')
			continue;
		if (s[n-i]!='1')
			return puts("-1"),0;
		a[++tot]=i;
	}
	int x=1;
	for (int i=1;i<=tot;i++){
		int y=x;
		for (int j=a[i-1]+1;j<=a[i];j++)
			printf("%d %d\n",y,++x);
	}
	return 0;
}

Measured memory_bytes: 1920
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int N; cin >> N;
    vector<int> A(N+2);
    int cost = 0;
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        cost += abs(A[i] - A[i-1]);
    }
    cost += abs(A[N+1] - A[N]);
    
    for (int i = 1; i <= N; i++) {
        int ans = cost;
        ans -= abs(A[i] - A[i-1]) + abs(A[i+1] - A[i]);
        ans += abs(A[i+1] - A[i-1]);
        cout << ans << '\n';
    }
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3736
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <cstring>
#include <string>
#include <queue>
#include <cmath>
#include <map>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define rev(v) (v).rbegin(), (v).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

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


bool visit[1000001];

int check(int n, int cnt = 0){
	if(cnt == 0){
		memset(visit, false, sizeof(visit));
	}
	if(n < 10) return cnt;
	if(visit[n]) return -1;
	visit[n] = 1;

	int	next = 0;
	int k, m = n;
	for(int i = 10; m > 0; i*=10){
		k = n%i;
		m = n/i;
		next = max(next, k*m);
	}
	return check(next, cnt+1);
}

int main(){
	int Q;
	cin >> Q;
	while(Q--){
		int n;
		cin >> n;
		cout << check(n) << endl;
	}


	return 0;
}

Measured memory_bytes: 2148
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n,k; string s;
char maze[60][60];
int dis[101][101];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll dp[100010][2]; int x[509][509]; int c[509][509];
int gcd(int x, int y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
int main() {
	string a, b;
	cin >> a >> b;
	if (a.size() == b.size()) {
		for (int i = 0; i <a.size(); i++) {
			if ((int)a[i] > (int)b[i]) {
				cout << "GREATER" << endl;
				return 0;
			}
			else if ((int)a[i] < (int)b[i]) {
				cout << "LESS" << endl;
				return 0;
			}
		}
		cout << "EQUAL" << endl;
	}
	else if (a.size() > b.size()) {
		cout << "GREATER" << endl;
		return 0;
	}
	else {
		cout << "LESS" << endl;
		return 0;
	}
}




Measured memory_bytes: 256
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <queue>
#include <functional>
#include <iostream>
using namespace std;
int main(){
	long long int n, a[100010] = {}, cnt = 1, ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++) {
		if (a[i] == a[i + 1]) {
			cnt++;
		}
		else {
			ans += cnt % 2;
			cnt = 1;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

template<class T>
T read()
{
    T value;
    std::cin >> value;
    return value;
}
 
template<class F>
void times_do(size_t n, F func)
{
    for(size_t i = 0; i < n; ++i) func();
}
 
template<class T>
vector<T> reads(size_t n)
{
    vector<T> a;
    a.reserve(n);
    times_do(n, [&](){
        a.push_back(read<T>());
    });
    return a;
}

int main(){
    const size_t H = read<size_t>();
    const size_t W = read<size_t>();
    const size_t N = read<size_t>();

    const auto a = reads<size_t>(N);
    
    vector<size_t> colors;
    colors.reserve(H*W);
    
    for(size_t i = 0; i < a.size(); ++i){
        times_do(a[i], [&](){
            colors.push_back(i+1);
        });
    }
    
    for(size_t y = 0; y < H; ++y){
        const bool even_line = (y % 2 == 0);
        for(size_t x = 0; x < W; ++x){
            if(even_line){
                cout << colors[y*W + x] << ' ';
            }else{
                cout << colors[y*W + (W - 1 - x)] << ' ';
            }
        }
        cout << '\n';
    }

    return 0;
}


Measured memory_bytes: 384
#include <iostream>

int main(){
    int i, j, ii, jj;
    int h, w, a, b;
    std::cin >> h >> w >> a >> b;
    for (j = 1; j <= h; j++) {
        for (i = 1; i <= w; i++) {
            std::cout << ((i <= a && j <= b) || (i > a && j > b) ? 1 : 0);
        }
        std::cout << std::endl;
    }

    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N;
  cin >> N;
  long flag = 0, a, b, count = 1;
  cin >> b;
  for(int i = 1; i < N; i++){
    cin >> a;
    if(a == b)continue;
    else if(flag == 0){
      if(a > b)flag = -1;
      else flag = 1;
    } else if((flag == 1 && a > b) || (flag == -1 && a < b)){
      flag = 0;
      count++;
    }
    b = a;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
import math
n,m = map(int,input().split())
if abs(n-m) != 0 and abs(n-m) != 1 :
    print(0)
else:
    x = math.factorial(min(m,n))

    if abs(n-m) == 0:
        print((2 * x * x)%(10**9+7))
    else:
        print((x * x * max(n,m))%(10**9+7))

Measured memory_bytes: 5188
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n,k;cin>>n>>k;
  k*=n;
  VV<int> pos(200010,V<int>());
  V<ll> v(n);
  rep(i,0,n){
    cin>>v[i];
    pos[v[i]].pb(i);
  }
  rep(i,0,n){
    pos[v[i]].pb(i+n);
  }

  V<PL> op(1,{0,0});
  ll now=pos[v[0]][1]%n,cnt=pos[v[0]][1]-pos[v[0]][0];

  while(1){
    now++;
    now%=n;
    cnt++;
    op.eb(now,cnt);
    if(now==0)break;

    cnt+=*ub(all(pos[v[now]]),now)-now;
    now=*ub(all(pos[v[now]]),now);
    now%=n;
    //op.eb(now,cnt);
  }

  k%=cnt;
  now=0;
  cnt=0;
  rep(i,0,siz(op)){
    if(k<op[i].sc)break;
    now=op[i].fs;
    cnt=op[i].sc;
  }

  V<int> ans(0);
  unordered_set<int> se;
  while(cnt<k){
    assert(k-cnt<1000010);
    if(se.count(v[now])){
      while(ans.back()!=v[now]){
        se.erase(ans.back());
        ans.pop_back();
      }        
      se.erase(v[now]);
      ans.pop_back();
    }else{
      ans.pb(v[now]);
      se.insert(v[now]);
    }
    now++;
    now%=n;
    cnt++;
  }

  rep(i,0,siz(ans)){
    cout<<ans[i]<<" ";
  }

}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

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

int main(){
	int a,b;
	for(int i = 0;i < 7;i++){
		cin >> a >> b;
		if(a - b > 0) cout << a - b << endl;
		else cout << b - a << endl;
	}
	return 0;
}

Measured memory_bytes: 1160