akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, m) = scan!(usize, usize);
    let a = scan!(;;n);
    let b = scan!(;;m);

    for i in 0..n - m + 1 {
        for j in 0..n - m + 1 {
            let mut same = true;
            for k in 0..m {
                for l in 0..m {
                    if a[i + k].as_bytes()[j + l] != b[k].as_bytes()[l] {
                        same = false
                    }
                }
            }
            if same {
                println!("Yes");
                return;
            }
        }
    }
    println!("No")
}


Measured memory_bytes: 4352
import java.util.*;

class Main{
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[]){
        Map<Integer,String> map=new HashMap<>();
      	map.put(0,sc.next());
        int Q=sc.nextInt(),sign=1;
        for(int i=1;i<=Q;i++){
            int T=sc.nextInt();
            if(T==1) sign*=-1;
            else{
                int F=sc.nextInt();
                if(F==1){
                    map.put(i*(-1)*sign,sc.next());
                }
                else{
                    map.put(i*sign,sc.next());
                }
            }
        }
        if(sign!=1){
            StringBuffer s=new StringBuffer(map.get(0));
            map.replace(0,s.reverse().toString());
        }
        for(int i=-Q;i<=Q;i++){
            int I=i*sign;
            if(map.containsKey(I)){
                System.out.print(map.get(I));
            }
        }
        System.out.println();
    }
}


Measured memory_bytes: 88288
import sys
from operator import itemgetter

read = sys.stdin.buffer.read
INF = 1 << 60


def main():
    N, M, *AB = map(int, read().split())

    Q = list(zip(*[iter(AB)] * 2))
    Q.sort(key=itemgetter(1))

    ans = 0
    last = 0
    for a, b in Q:
        if last < a:
            last = b - 1
            ans += 1

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 29300
#include<cstdio>
#include<queue>
#include<algorithm>
#include<functional>
#include<vector>
#include<cstring>

using namespace std;
class data{
public:
	int t,c,d;

};

class data2{
public:
	double cost;
	int v,s,p;
	bool operator<(const data2 &d1)const{
		return d1.cost<cost;
	}
};

int n,m,s,g;
double dp[35][35][35];
vector<data> edge[35];

double dijk(){
	for(int i=0;i<35;i++){
		for(int j=0;j<35;j++){
			for(int k=0;k<35;k++){
				dp[i][j][k]=-1.0;
			}
		}
	}
	priority_queue<data2> que;
	data2 ind;
	ind.cost=0.0;
	ind.v=s;
	ind.s=0;
	ind.p=0;
	double res=-1.0;
	dp[s][0][0]=0.0;
	que.push(ind);
	while(que.size()){
		data2 dd=que.top();
		que.pop();
		if(dp[dd.v][dd.s][dd.p]<dd.cost)continue;
		if(dd.v==g && dd.s==1){
			res=min(dd.cost,res);
			if(res==-1.0)res=dd.cost;
			continue;
		}
		dp[dd.v][dd.s][dd.p]=dd.cost;
		for(int i=0;i<edge[dd.v].size();i++){
			data e=edge[dd.v][i];
			if(dd.p==e.t)continue;
			for(int j=-1;j<=1;j++){
				int ns=dd.s+j;
				if(ns<=0 || ns>e.c)continue;
				double nc=dd.cost+(double)e.d/ns;
				if(dp[e.t][ns][dd.v]>nc || dp[e.t][ns][dd.v]==-1.0){
					dp[e.t][ns][dd.v]=nc;
					data2 nd;
					nd.v=e.t;
					nd.cost=nc;
					nd.s=ns;
					nd.p=dd.v;
					que.push(nd);
				}
			}
		}
	}
	return res;
}

int main(void){
	while(1){
		scanf("%d %d",&n,&m);
		if(n+m==0)break;
		for(int i=0;i<=n;i++)edge[i].clear();
		scanf("%d %d",&s,&g);
		for(int i=0;i<m;i++){
			int x,y;
			data dd;
			scanf("%d %d %d %d",&x,&y,&dd.d,&dd.c);
			dd.t=y;
			edge[x].push_back(dd);
			dd.t=x;
			edge[y].push_back(dd);
		}
		double res=dijk();
		if(res!=-1.0)printf("%.9f\n",res);
		else printf("unreachable\n");
	}
	return 0;
}

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

int A[10000000], n;

int binary_search(int key) {
    int left = 0;
    int right = n;
    int mid;

    while(left<right) {
        mid = (left+right)/2;
        if(key==A[mid]) return 1;
        if(key>A[mid]) left = mid + 1;
        else if(key<A[mid]) right = mid;
    }
    return 0;
}

int main()
{
    int i, q, k, sum = 0;
    scanf("%d", &n);
    rep(i,n) scanf("%d", &A[i]);
    scanf("%d", &q);
    rep(i,q) {
        scanf("%d",&k);
        if(binary_search(k)) sum++;
    }
    P(sum);

    return 0;
}

Measured memory_bytes: 3500
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

bool solve(string S, string T) {
  int len = S.length();
  int table[128] = {0};
  REP(i,len) {
    if(table[S[i]] == 0) table[S[i]] = T[i];
    else {
      if(table[S[i]] !=	T[i]) return false;
    }
  }
  return true;
}

int main() {
  string S, T; cin>>S>>T;
  bool ans = solve(S, T) && solve(T, S);
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 1544
import java.util.*;

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

        for(int i=1; i<4; i++) {
            if(s.charAt(i-1) == s.charAt(i)) {
                System.out.println("Bad");
                return;
            }
        }
        System.out.println("Good");


    }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define mes(a,b) memset((a),(b),sizeof((a)))
#define syio std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0);
#define lson l, mid, rt << 1
#define rson mid+1, r, rt << 1 | 1
typedef long long ll;
typedef long double real;
typedef pair<int, int> pii;

const int oo = ~0u >> 2;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mxn = 200033;
inline int read(){
    int x = 0,f = 1;char c = getchar();
    while(!isdigit(c))f = c == '-' ? -1 : 1,c = getchar();
    while(isdigit(c))x = x * 10 + c - '0',c = getchar();
    return x * f;
}
int n, a[mxn];
int main()
{
    syio;
    cin>>n;
    for (int i = 1; i <= n; ++ i) cin>>a[i];
    ll res = 0;
    for (int i = 2; i <= n; ++ i)
    {
        if (a[i] < a[i - 1])
        {
            res += a[i - 1] - a[i];
            a[i] += a[i - 1] - a[i];
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 4380
#include <stdio.h>
#include <string.h>
int main(void)
{
	int i,j,len,flag;
	char s[200],p[100],ss[100];
	scanf("%s",s);
	scanf("%s",p);
	len=strlen(p);
	strcpy(ss,s);
	strcat(s,ss);
	flag=0;
	for(i=0;i<100;i++){
		for(j=0;j<len;j++){
			if(s[i+j] != p[j]) break;
		}
		if(j==len) flag++;
	}
	if(flag==0) printf("No\n");
	else printf("Yes\n");
    return 0;
}

Measured memory_bytes: 532
#include <iostream>
#include <stdio.h>
using namespace std;

char mp[12][13];

void erase(int x,int y) {
	int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1},i;
    mp[y][x]='0';
    for (i=0;i<4;i++) if (y+dy[i]>-1 && y+dy[i]<12 && x+dx[i]>-1 && x+dx[i]<12)
		if (mp[y+dy[i]][x+dx[i]]=='1') erase(x+dx[i],y+dy[i]);
}


int main() {
	int i,x,y,k,cn[21],e=0;
	do {
	for (i=0;i<12;i++) gets(mp[i]);
	k=0;
	for (y=0;y<12;y++) for (x=0;x<12;x++) if (mp[y][x]=='1') { k++; erase(x,y); }
	cn[e]=k; e++;    
	} while(gets(mp[0])!=NULL);
    for (i=0;i<e;i++) cout << cn[i] << endl;
	return 0;
}

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

using namespace std;

const char en = '\n';
using  ll =          long long;
using ull = unsigned long long;

#define REP(i  ,n) for(int i=0;i<n;i++)
#define FOR(i,s,g) for(int i=s;i<g;i++)

const ll INFL = 810000001919114514;
const int INF =         1919114514;



bool graph[8][8];
int  N,M;
bool checked[8];
int checkedcount=0;
int result=0;

int search(int i){
	checked[i]=true;
	checkedcount++;
	//cout<<i<<' '<<checkedcount<<en;
	if(checkedcount==N){
		result++;
	} else{
		REP(r,N){
			if(graph[i][r]&&!checked[r]) search(r);
		}
	}
	checked[i]=false;
	checkedcount--;
	return 0;
}
int main(){
	ios::sync_with_stdio(false);cin.tie();
	
	cin>>N>>M;

	REP(i,8) fill_n(graph[i],8,false);
	         fill_n(checked ,8,false);

	int a,b;

	REP(i,M){
		cin>>a>>b;
		a--;
		b--;
		graph[a][b]=true;
		graph[b][a]=true;
	}

	search(0);

	cout<<result<<en;

	return 0;
}

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

int main()
{
    int N, D, X;
    cin >> N >> D;
    cin >> X;
    vector<int> A;

    for (int i = 0; i < N; i++)
    {
        int temp;
        cin >> temp;
        A.push_back(temp);
    }

    int count = 0;
    for (int i = 0; i < N; i++)
    {
        int day = 0;
        int lp = 0;
        while (day <= D)
        {
            count++;
            lp++;
            day = 1 + A[i] * lp;
        }
    }

    cout << count + X;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<list>
#include<cstring>
#include<algorithm>
#include <utility>

using namespace std;

int main(void){
    list<pair<int,int> > vp,p[800];
    queue<int> v;
    int i,j,k;
    int size[800],s[800][2];
    int n,to[800],cost[800];
    while(true){
        cin >> n;
        if(n == 0) break;
        memset(size,0,sizeof(size));
        for(i = 0;i < n;i++) p[i].clear();
        for(i = 1;i < n;i++){
            cin >> to[i];
            to[i]--;
        }
        for(i = 1;i < n;i++){
            cin >> cost[i];
            p[i].push_back(make_pair(to[i],cost[i]));
            p[to[i]].push_back(make_pair(i,cost[i]));
        }
        int a = 0;
        for(i = 0;i < n;i++) size[i] = p[i].size();
        for(i = 0;i < n;i++){
            if(size[i] == 1){
                a += p[i].front().second;
                p[p[i].front().first].remove(make_pair(i,p[i].front().second));
                if(p[p[i].front().first].size() == 1){
                    v.push(p[i].front().first);
                }
                else if(p[p[i].front().first].size() == 0){
                    v.pop();
                    break;
                    p[i].clear();
                }
                p[i].clear();
            }
        }
        memset(s,0,sizeof(s));
        while(v.size() != 0){
            i = v.front();v.pop();
            k = p[i].front().second;
            a += 3*k;
            j = p[i].front().first;
            if(s[j][1] < k+s[i][0]){
                s[j][1] = k+s[i][0];
                if(s[j][0] < s[j][1])
                    swap(s[j][0],s[j][1]);
            }
            p[j].remove(make_pair(i,p[i].front().second));
            p[i].clear();
            if(p[j].size() == 1) v.push(j);
            else if(p[j].size() == 0){
                j = 0;
                for(i = 0;i < n;i++){
                    j = (j > s[i][0]+s[i][1])?j:s[i][0]+s[i][1];
                }
                a -= j;
                v.pop();
            }
        }
        cout << a << endl;
    }
    return 0;
}

Measured memory_bytes: 1300
#include<stdio.h>
#include<stdlib.h>
#define N 100
#define INF 1000000
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int a[N][N];

typedef struct node{
	int id;
	int cost;
}node;

void swap(node h[],int x,int y){
	node temp=h[x];
	h[x]=h[y];
	h[y]=temp;
	return;
}


void heapsort(node heap[],int num){

	for(int i=num-1;i>0;i--){
		if(i%2==0){
			if(heap[i].cost < heap[i/2-1].cost)swap(heap,i,i/2-1);
		}else {
			if(heap[i].cost < heap[i/2].cost)swap(heap,i,i/2);
		}
	}
	
	return;

}

int update_heap(node heap[],int num){
	int u=heap[0].id;
	swap(heap,0,num-1);
	num--;
	
	for(int i=0;i<num;i++){
		heap[i].cost=MIN(heap[i].cost,a[u][heap[i].id]);
	}
	
	return num;
}




int main(){
	int i,j,n;
	int num=0;/*heapの要素の個数*/
	int ans=0;
	node heap[N];
	
	
	scanf("%d",&n);
	
	
	/*隣接行列の読み込み*/
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			scanf("%d",&a[i][j]);
			if(a[i][j]==-1)a[i][j]=INF;
		}
	}
	
	/*0以外の頂点をinsert*/
	for(i=1;i<n;i++){
		heap[num].cost=a[0][i];
		heap[num++].id=i;
	}
	
	/*heapを昇順にソート*/
	heapsort(heap,num);
	
	while(num!=0){
		ans+=heap[0].cost;
		num=update_heap(heap,num);
		heapsort(heap,num);
	}
	
	printf("%d\n",ans);
	
	return 0;
	
}


Measured memory_bytes: 2044
#import pysnooper
#import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy
setrecursionlimit(10**6)

s=stdin.readline().rstrip()
k=int(stdin.readline().rstrip())
ans=set()
for i in range(len(s)):
    for j in range(len(s)):
        if j>=k:
            break
        ans.add(s[i:i+j+1])
print(sorted(ans)[k-1])

Measured memory_bytes: 4592
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 1000000007 
#define mod2 998244353
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}

int main() {
   fast();
   int n;
   cin>>n;
   int cnt[n+1]={0};
   for(int i=1;i<=n;i++){
    for(int j=i;j<=n;j+=i){
      cnt[j]++;
    }
   }
   for(int i=1;i<=n;i++){
    cnt[i]+=cnt[i-1];
   }
   cout<<cnt[n-1]<<"\n";
   

}


Measured memory_bytes: 7424
#include <iostream>
#define INF 1000000000

using namespace std;

int main()
{
  int N, T;
  cin >> N >> T;
  
  int ans = INF;
  for (int i = 0; i < N; i++) {
    int c, t;
    cin >> c >> t;
    if (t <= T) ans = min(ans, c);
  }
  if (ans == INF) cout << "TLE" << endl;
  else cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

typedef long long LL;

LL gcd(LL a, LL b){
    while(a && b){
        if(a > b)a %= b;
        else b %= a;
    }
    return a + b;
}
 
int main(){
    LL a, b;
    LL ans = 0;
    cin >> a >> b;
 
    const LL C = gcd(a, b);
    LL c = C;
 
    for(int i = 2;i < sqrt(C);i++){
        if(c % i == 0){
            ans++;
            while(c % i == 0){
              c /= i;
            }
        }
    }
    if(c != 1)ans++;
    cout << ans + 1;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int c[21][21];
int w, h;
int sx, sy, gx, gy;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

int dfs(int x, int y, int turn){
		//cout << x << " " << y << endl;
		if(turn > 10)return -1;
		int res = 11;
		for(int i = 0; i < 4; i++){
				int nx = x;
				int ny = y;
				while(true){
						if(nx < 0 || nx >= h || ny < 0 || ny >= w)break;
						if(nx == gx && ny == gy)return turn;
						if(c[nx][ny] == 1)break;
						if((nx != x || ny != y) && nx + dx[i] >= 0 && nx + dx[i] < h && ny + dy[i] >= 0 && ny + dy[i] < w){
								if(c[nx+dx[i]][ny+dy[i]] == 1){
										c[nx+dx[i]][ny+dy[i]] = 0;
										int tmp = dfs(nx, ny, turn+1);
										if(tmp != -1)res = min(res, tmp);
										c[nx+dx[i]][ny+dy[i]] = 1;
										break;
								}
						}
						nx += dx[i];
						ny += dy[i];
				}
		}
		if(res == 11)return -1;
		else return res;
}

int main(int argc, char const* argv[])
{
	while(true){
			cin >> w >> h;
			if(w == 0)break;
			for(int i = 0; i < h; i++){
					for(int j = 0; j < w; j++){
							cin >> c[i][j];
							if(c[i][j] == 2){
									sx = i; sy = j;
							}else if(c[i][j] == 3){
									gx = i; gy = j;
							}
					}
			}
			cout << dfs(sx, sy, 1) << endl;
	}
	return 0;
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
using Graph = vector<vector<ll>>;
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);


template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool unite(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};


int main(){
    ll n, m; cin >> n >> m;
    UnionFind<int> uf(n);
    rep(i, m){
        ll l, r, d; cin >> l >> r >> d; l--, r--;
        if(!uf.issame(l, r)) uf.unite(l, r, d);
        else{
            if(uf.diff(l, r) != d){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 4580
import java.util.Scanner;

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

		if (a <= b && b <= c) {
			System.out.println(a + " " + b + " " + c);
		} else if (a <= c && c <= b) {
			System.out.println(a + " " + c + " " + b);
		} else if (b <= a && a <= c) {
			System.out.println(b + " " + a + " " + c);
		} else if (b <= c && c <= a) {
			System.out.println(b + " " + c + " " + a);
		} else if (c <= a && a <= b) {
			System.out.println(c + " " + a + " " + b);
		} else if (c <= b && b <= a) {
			System.out.println(c + " " + b + " " + a);
		}
	}
}


Measured memory_bytes: 26312
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val a = IntArray(n) { scanner.nextInt() - 1 }
    val b = IntArray(n) { scanner.nextInt() }
    val c = IntArray(n - 1) { scanner.nextInt() }


    val ret =
        b[a[0]] + (1 until n).map { i ->
            val cp = if (a[i - 1] + 1 == a[i]) c[a[i - 1]] else 0
            b[a[i]] + cp
        }.sum()

    println(ret)
}

Measured memory_bytes: 31384
#include <stdio.h>
int main() {
	int a, b, x, y, z;
	int max;

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

	x = a + b;
	y = a - b;
	z = a * b;

	max = x;
	if (max < y) {
		max = y;
	}
	if (max < z) {
		max = z;
	}
	printf("%d\n", max);
	return 0;

}

Measured memory_bytes: 128
#include<stdio.h>

int main()
{
    int a, b;
    scanf("%d %d",&a, &b);

    if(a+b == 15 && a*b == 15)
    {
        printf("x");
    }

    else if(a*b == 15)
    {
        printf("*");
    }
    else if(a+b == 15)
    {
        printf("+");
    }
    else
    {
        printf("x");
    }

    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

class Main {
    public static void main(String[] arg){
        Scanner sc =new Scanner(System.in);
        int n=sc.nextInt(),t=sc.nextInt();
        int cost=10000;
        for(int i=0;i<n;i++){
            int ci=sc.nextInt(),ti=sc.nextInt();
            if(ti<=t && ci<cost)cost=ci;
        }
        System.out.println(cost==10000?"TLE":cost);
    }
}

Measured memory_bytes: 21716
#include<iostream>
#include<cmath>
#include<iomanip>

int main(void){
    int a, b, h, m;
    std::cin >> a >> b >> h >> m;

    double deg0, deg1;

    deg0 = -(30 * h + 0.5 * m);
    deg1 = - 6 * m;

    double ans;
    ans = std::sqrt(std::pow(a * std::cos(deg0 * M_PI / 180) -b * std::cos(deg1 * M_PI / 180), 2.0) +\
	std::pow(a * std::sin(deg0 * M_PI / 180) - b * std::sin(deg1 * M_PI / 180), 2.0));

    std::cout << std::fixed << std::setprecision(100) << ans << std::endl;

    return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
const lint mod=1e9+7;


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

  lint res = 0;
  while(pow(res+1,2) <= n){
    res++;
  }

  cout << res*res << "\n";
  return 0;
}


Measured memory_bytes: 256
a,b,c=input().strip().split(' ')
a,b,c=[int(a),int(b),int(c)]
g=[0]*200000
for i in range(c):
  f=int(input())
  g[f]+=1
for i in range(1,a+1):
  p=b+g[i]
  p-=c
  if p>0:
    print('Yes')
  else:
    print('No')


Measured memory_bytes: 5448
H,W=map(int,input().split())
ans=[["#"]*(W+2) for i in range(H+2)]
for y in range(H):
  a=input()
  for x in range(len(a)):
    ans[y+1][x+1]=a[x]
for y in range(H+2):
  for x in range(W+2):
    print(ans[y][x],end="")
  print()


Measured memory_bytes: 9344
x = [list(map(int, input().split())) for i in range(3)]
rows = int(input())
y = [int(input()) for i in range(rows)]

xx = sum(x, [])

tate1 = xx[0:9:3]
tate2 = xx[1:9:3]
tate3 = xx[2:9:3]
yoko1 = xx[0:3]
yoko2 = xx[3:6]
yoko3 = xx[6:9]
nana1 = xx[0:9:4]
nana2 = xx[2:7:2]

if rows >= 3 and (set(tate1) <= set(y) or set(tate2) <= set(y) or set(tate3) <= set(y) or set(yoko1) <= set(y) or set(yoko2) <= set(y) or set(yoko3) <= set(y) or set(nana1) <= set(y) or set(nana2) <= set(y)):
    print("Yes")
else:
    print("No")

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

int main(){
    int N,M,count = 0;
    typedef pair<int,int> P;
    deque <P> sec;

    cin >> N >> M;
    for(int i = 0; i < M; ++i){
        P p;
        cin >> p.first >> p.second;
        sec.push_back(p);
    }
    sort(sec.begin(),sec.end(),[](const P a, const P b){
        return a.second <b.second;
    });
    while(!sec.empty()){
        deque <P> nsec;
        int right = sec.front().second;
        sec.pop_front();
        for(auto i = sec.begin();i != sec.end(); i++){
            if((*i).first >= right){
                nsec.push_back(*i);
            }
        }
        sec.swap(nsec);
        count++;
    }
    cout << count << endl;
    int k;
    cin >> k;
    
}

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

int main()
{
    int n,i,j,d=0,c=0;
    int ara[101][3];

    cin>>n;
    for(i=0;i<n;i++){
        for(j=0;j<2;j++){
            cin>>ara[i][j];
        }
    }

   for(i=0;i<n;i++){
        d=0;
    if(ara[i][0]==ara[i][1]){
        for(j=i;j<i+3;j++){
            if(ara[j][0]==ara[j][1]){
                d++;
            }
         }
         if(d==3){
                cout<<"Yes"<<endl;
                c++;
                break;
         }
     }
   }
   if(c==0){
    cout<<"No"<<endl;
   }

    return 0;
}


Measured memory_bytes: 3616
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<sstream>
#define INF 999999
using namespace std;
int main(){
    int N;
    cin>>N;
    while(N--){
        stringstream ss;
        int NUM1,NUM2;
        char C[15];
        cin>>NUM1;
        ss<<NUM1;ss>>C;
        sort(C,C+strlen(C));
        NUM1=atoi(&C[0]);
        reverse(C,C+strlen(C));
        NUM2=atoi(&C[0]);
        cout<<max(NUM1,NUM2)-min(NUM1,NUM2)<<endl;
    }
    return 0;
}

Measured memory_bytes: 1244
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#define pb push_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define upmin(ans,ansx) (ans)=min((ans),(ansx))
#define upmax(ans,ansx) (ans)=max((ans),(ansx))
#define INF (1100000099)
#define INFLL (1100000000000000099ll)
#define MOD (1000000009)
#define MAXN (200005)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

int SegTree[MAXN<<2];
int A[MAXN], ReD[MAXN];
int N;

inline void insertSeg(const int& idx, const int& S, const int& E, const int& X, const int& P) {
    if(E < S || E < X || X < S) return; upmin(SegTree[idx], P);
    if(S == E) return;
    const int mid = (S+E)>>1;
    if(X <= mid) insertSeg(idx<<1, S, mid, X, P);
    else insertSeg((idx<<1)+1, mid+1, E, X, P);
}
inline int getSeg(const int& idx, const int& S, const int& E, const int& P, const int& Q) {
    if(E < S || E < P || Q < S) return INF;
    if(S == P && E == Q) return SegTree[idx];
    const int mid = (S+E)>>1;
    return min(getSeg(idx<<1, S, mid, max(S, P), min(mid, Q)), getSeg((idx<<1)+1, mid+1, E, max(mid+1, P), min(E, Q)));
}
ll f(const int& S, const int& E) {
    if(S > E) return 0;
    if(S == E) return A[S];
    ll ret = 0;
    const int idx = ReD[getSeg(1, 1, N, S, E)];
    ret = f(S, idx-1) + f(idx+1, E);
    ret += (ll)(idx-S+1) * (E-idx+1) * A[idx];
    return ret;
}

int main() {
    fill(SegTree, SegTree+(MAXN<<2), INF);
    scanf("%d", &N); for(int i = 1; i <= N; i++) scanf("%d", &A[i]);
    for(int i = 1; i <= N; i++) insertSeg(1, 1, N, i, A[i]);
    for(int i = 1; i <= N; i++) ReD[A[i]] = i;
    printf("%lld\n", f(1, N));
    return 0;
}

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

int main() {
    char c;
    cin >> c;
    
    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
}


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

template<typename T> T In() { T v; cin >> v; return v; }

#define P(s) cout<<s<<endl
#define P2(b,y,f) P(((b)?y:f))
#define REP(i,b,e) for(int i=b;i<e;++i)
#define ALL(con) con.begin(), con.end()

int main() {
    auto s = In<string>();
    auto p = s[0];
    auto cnt = 0;
    
    for (auto c: s) {
        if (p != c) {
            ++cnt;
            p = c;
        }
    }
    
    P(cnt);
    
    return 0;
}

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

int main() {
	char ball = 'A';
	char x, y, z;
	while (cin >> x >> z >> y){
		if (x == ball) {
			ball = y;
		}
		else if (y == ball){
			ball = x;
		}
	}
	cout << ball;
	cout << endl;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// assign avl ncm dijkstra geo2 kruskal graph uf lca BIT
// matrix dinic next_combination topcoder lcm

bool bs(vi &data, int targ)
{
    if (targ < data[0]) return false;
    else if (targ == data[0]) return true;
    if (data[data.size()-1] < targ) return false;
    else if (data[data.size()-1] == targ) return true;
    // ????????§??????????????? targ ????????§?????????
    // ??????????????? targ ???????°???????????¨??????§?????????
    int l = 0, r = data.size()-1;
    while (1 < r - l) {
        int mid = (l + r) / 2;
        if (data[mid] == targ) {
            return true;
        } else if (targ < data[mid]) {
            r = mid;
        } else {
            l = mid;
        }
    }
    return false;
}

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

    Int(n);
    vector<int> data(n);
    for (int i = 0; i < n; i++) {
        cin >> data[i];
    }
    Int(q);
    int ans = 0;
    while (q--) {
        Int(tmp);
        ans += bs(data, tmp) ? 1 : 0;
    }
    cout << ans << endl;

    return 0;
}

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

#define DIV 1000000007

long long N, M;
set<long long>a;
long long dp[100005];

int main(){
	cin >> N >> M;
	for(long long i = 0; i < M; i++){
		long long tmp;
		cin >> tmp;
		a.insert(tmp);
	}

	dp[0] = 1;
	for(long long i = 0; i < N; i++){
		dp[i] %= DIV;
		if(a.find(i+1) == a.end()){
			dp[i+1] += dp[i];
		}
		if(a.find(i+2) == a.end()){
			dp[i+2] += dp[i];
		}
	}
	cout << dp[N] %DIV << endl;
}

Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        System.out.println( solve(N, S) );
    }

    private static int solve(int N, String S) {
        int[] W = new int[N];
        int[] E = new int[N];

        int ws = 0;
        for (int i = 0; i < N; i++) {
            if( S.charAt(i) == 'W' ) {
                ws++;
            }
            W[i] = ws;
        }

        int es = 0;
        for (int i = N-1; i >= 0 ; i--) {
            if( S.charAt(i) == 'E' ) {
                es++;
            }
            E[i] = es;
        }

        int min = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            int w_e;
            if( i == 0 ) {
                w_e = 0;
            } else {
                w_e = W[i-1];
            }

            int e_w;
            if( i == N -1 ) {
                e_w = 0;
            } else {
                e_w = E[i+1];
            }

            min = Math.min(min, w_e + e_w);
        }
        return min;
    }
}

Measured memory_bytes: 31084
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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 int INF = 1e9;
const LL LLINF = 1e16;

/*
!) 0-indexed
!) [a, b)に対する演算
!) m0, merge, updateNodeを書く
*/
template<typename Monoid>
struct Segtree{
    int n;
    vector<Monoid> dat;
    Monoid m0; // データの初期化値
    Segtree(int sz, Monoid m0) : m0(m0){
        n = 1;
        while(n < sz) n *= 2;
        dat.assign(2*n-1, m0);
    }

    Monoid merge(Monoid a, Monoid b){ return min(a,b); }
    void updateNode(int k, Monoid x){ dat[k] = x; }

    void update(int k, Monoid x){
        k += n-1;
        updateNode(k, x);
        while(k > 0) {
            k = (k-1)/2;
            dat[k] = merge(dat[k*2+1], dat[k*2+2]);
        }
    }
    Monoid query(int a, int b){
        Monoid L = m0, R = m0;
        int A = a+n-1;
        int B = b+n-1;
        while(A < B) {
            if((A&1) == 0) L = merge(L, dat[A++]);
            if((B&1) == 0) R = merge(dat[--B], R);
            A >>= 1;
            B >>= 1;
        }
        return merge(L, R);
    }
    Monoid operator[](const int &k) const { return dat[k+n-1]; }
};


int main(){
    int n, Q;
    cin >> n >> Q;
    Segtree<LL> a(n, (1LL<<31)-1);
    rep(i, Q){
        int q, x, y;
        cin >> q >> x >> y;
        if(q == 0){
            a.update(x, y);
        }else{
            cout << a.query(x, y+1) << endl;
        }
    }
}


Measured memory_bytes: 4936
import heapq
N, M = map(int, input().split())
A = list(map(lambda x: int(x) * (-1), input().split()))

heapq.heapify(A)
for _ in range(M):
    a = heapq.heappop(A) * (-1)
    a = a // 2
    heapq.heappush(A, a * (-1))

print(sum(A) * (-1))


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

int main()
{
    int n, i, sat=0;
    cin>>n;

    int arr1[n], arr2[n], arr3[n];

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

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

    sat = sat + arr2[arr1[0]-1];
    for(i=1; i<n; i++){
        sat = sat + arr2[arr1[i]-1];

        if((arr1[i-1]+1) == arr1[i])
            sat = sat + arr3[arr1[i]-1];
    }

    cout<<sat;

}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        long mod = 1000000000+7;
        int n = sc.nextInt();
        int[][] dic = new int[2*n][];
        for(int i=0;i<n;i++){
            int a = sc.nextInt();
            dic[i] = new int[]{a,0};
        }
        for(int i=n;i<2*n;i++){
            int b = sc.nextInt();
            dic[i] = new int[]{b,1};
        }
        Arrays.sort(dic,new myc());
        long ans = 1;
        int[] cnt = new int[2];
        for(int i=0;i<2*n;i++){
            int now = dic[i][1];
            if(cnt[1-now]>0){
                ans = ans*cnt[1-now]%mod;
                cnt[1-now]--;
            }else{
                cnt[now]++;
            }
        }
        System.out.println(ans);
    }
    static class myc implements Comparator<int[]>{
        public int compare(int[] a, int[] b){
            return a[0]-b[0];
        }
    }
}


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

int main(void){
    int N,M,max=0;
    cin>>N;
    string s[N];
    for(int i=0;i<N;i++)
        cin>>s[i];

    cin>>M;
    string t[M];
    for(int i=0;i<M;i++){
        cin>>t[i];
    }

    for(int i=0;i<N;i++){
        int sum=0;
        for(int j=0;j<N;j++){
            if(s[i]==s[j])
                sum++;
        }
        for(int j=0;j<M;j++){
            if(s[i]==t[j])
                sum--;
        }
        if(sum>max)
            max=sum;
    }
    cout<<max<<endl;
    return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
s = [input() for i in range(H)]

def count(x, y):
    c = 0
    if x-1 >= 0 and s[x-1][y] =="#":
        c += 1
    if x+1 <= H-1 and s[x+1][y] =="#":
        c += 1
    if y-1 >= 0 and s[x][y-1] =="#":
        c += 1
    if y+1 <= W-1 and s[x][y+1] =="#":
        c += 1
    if x-1 >= 0 and y-1>=0 and s[x-1][y-1] =="#":
        c += 1
    if x-1 >= 0 and y+1 <= W-1 and s[x-1][y+1] =="#":
        c += 1
    if x+1 <= H-1 and y-1 >=0 and s[x+1][y-1] =="#":
        c += 1
    if x+1 <= H-1 and y+1 <= W-1 and s[x+1][y+1] =="#":
        c += 1
    return c

ans = [["#"] * W for i in range(H)]
for i in range(H):
    for j in range(W):
        ans[i][j] = count(i, j)

for i,line in enumerate(ans):
    for j,num in enumerate(line):
        if s[i][j] == "#":
            print("#", end="")
        else:
            print(num, end="")
    print()

Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>
#include <cctype>
#include <cmath>

using namespace std;

/* typedef */

typedef long long ll;

/* constant */
const int NIL = -1;
const int INF = 1 << 30;
const int MAX = 2000000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
int tree_size = 0;

/* function */
int leftChild(int ind);
int rightChild(int ind);
int parent(int ind);
void maxHeapify(vector<int>& A, int ind);
void buildMaxHeap(vector<int>& A);
int heapExtractMax(vector<int>& A);
void insertHeap(vector<int>& A, int key);
void heapIncreaseKey(vector<int>& A, int ind, int key);

/* main */
int main(){

    vector<int> H(MAX+1);

    string command;
    int key;
    while (1) {
        cin >> command;
        if (command == "end") 
            break;
        else if (command == "extract")
            cout << heapExtractMax(H) << '\n';
        else {
            cin >> key;
            insertHeap(H, key);
        }
    }

    return 0;

}

int heapExtractMax(vector<int>& A) {
    if (tree_size < 1)
        return NIL;

    int max_value = A[1];
    A[1] = A[tree_size];
    tree_size--;
    maxHeapify(A, 1);

    return max_value;
}

void insertHeap(vector<int>& A, int key) {
    tree_size++;
    A[tree_size] = -INF;
    heapIncreaseKey(A, tree_size, key);
}

void heapIncreaseKey(vector<int>& A, int ind, int key) {
    if (key < A[ind]) return;
    A[ind] = key;
    while (ind > 1 && A[parent(ind)] < A[ind]) {
        int p = parent(ind);
        swap(A[ind], A[p]);
        ind = p;
    }
}

void maxHeapify(vector<int> &A, int ind) {
    int l = leftChild(ind);
    int r = rightChild(ind);
    int largest;
    if (l <= tree_size && A[l] > A[ind])
        largest = l;
    else 
        largest = ind;
    if (r <= tree_size && A[r] > A[largest])
        largest = r;
   
    if (largest != ind) {
        swap(A[largest], A[ind]);
        maxHeapify(A, largest);
    }
}

void buildMaxHeap(vector<int>& A) {
    for (int i = tree_size / 2; i >= 1; i--)
        maxHeapify(A, i);
}

int leftChild(int ind) {
    return ind * 2;
}

int rightChild(int ind) {
    return ind * 2 + 1;
}
int parent(int ind) {
    return ind / 2;
}




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

int main() {
  int x, y;
  cin >> x >> y;

  if (x == y || y == 1 || x % y == 0) {
    cout << -1 << endl;
  } else {
    cout << x << endl;
  }
}

Measured memory_bytes: 256
N,X = map(int,input().split())

L_list = list(map(int,input().split()))

cnt = 0
aaa = []
aaa.append(cnt)

for i in L_list:
    cnt += i
    aaa.append(cnt)

cnt_result = 0

for i in aaa:
    if X>= i:
        cnt_result +=1
    else:
        pass

print(cnt_result)




Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define last Last
const int N=1e6+5;
int n,a[N],b[N],s[N];
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
bool cmp(int x,int y)
{
	return x>y;
}
signed main()
{
	n=read();
	for(int i=0;i<(1<<n);i++)a[i]=read();
	sort(a,a+(1<<n),cmp);
	b[0]=1;s[0]=a[0];
	for(int i=0;i<n;i++)
	{
		int size=1<<i,k=0;
		for(int j=0;j<(1<<n);j++)
			if(!b[j]&&k<size&&a[j]<s[k])
			{
				s[size+k]=a[j];
				b[j]=1;
				k++;
			}
		if(k<size){puts("No");return 0;}
		sort(s,s+(size<<1),cmp);
	}
	puts("Yes");
}

Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define For(i,n) rep(i,0,n)
//#define int long long
//const int INF=1e18;
const int MOD=1000000007;
typedef pair<int,int> P;


int c[3]={0,0,0},n;
double mem[305][305][305];
bool f[305][305][305];


double dp(int a,int b,int c){
    if(!a&&!b&&!c){return 0;}
    if(f[a][b][c]){return mem[a][b][c];}
    f[a][b][c]=1;
    double ret = n;
    if(a){ret+=dp(a-1,b,c)*a;}
    if(b){ret+=dp(a+1,b-1,c)*b;}
    if(c){ret+=dp(a,b+1,c-1)*c;}
    return mem[a][b][c]=ret/(a+b+c);
}


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a;
    cin>>n;
    rep(i,0,n){
        int a;
        cin>>a;
        a--;
        c[a]++;
    }
    cout<<setprecision(20)<<dp(c[0],c[1],c[2])<<endl;
    
    return 0;
}

Measured memory_bytes: 246016
N = int(input())
A_list = list(map(int, input().split()))

sum_abs_all = False
minus_count = 0

for i in A_list:
    if i == 0:
        sum_abs_all = True
        break
    if i < 0:
        minus_count += 1

if minus_count % 2 == 0:
    sum_abs_all = True

abs_A_list = [abs(i) for i in A_list]

ans = 0
for i in abs_A_list:
    ans += i

if not sum_abs_all:
    abs_A_list.sort()
    ans -= 2*abs_A_list[0]

print(ans)


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

int main() {
	// your code goes here
    int x;
    cin>>x;
    int flag = 0;
    for(long long i=0;i<10000;i++){
        for(long long j=-10000;j<10000;j++){
            if((pow(i,5) - pow(j,5)) == x){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }
	return 0;
}


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

typedef long long ll;

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

int main() {
  string s;
  cin >> s;
  int N;
  N = s.size();
  int ans;
  rep(i,N-1) {
    if (i%2 == 0) {
      continue;
    } 
    int a = 1;
    rep(j,(i+1)/2) {
      if (s[j] != s[j+(i+1)/2]) {
        a = 0;
      }
    } 
    if (a == 1) {
      ans = i+1;
    }

  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
using System;

class Program
{
	static void Main(string[] args)
	{
	  string[] para = Console.ReadLine().Split(' ');
      int a = int.Parse(para[0]);
      int b = int.Parse(para[1]);
      int t = int.Parse(para[2]);
      
      int bisckets = ( t / a ) * b;
      Console.WriteLine(bisckets);
	}
}

Measured memory_bytes: 13140
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

	int n = s.length() + 1;
	vector<ll> a(n);
	for (int i = 0; i < n; i++)
	{
		if (s[i] == '<')
		{
			a[i + 1] = a[i] + 1;
		}
	}

	for (int i = n - 1; i >= 0; i--)
	{
		if (s[i] == '>')
		{
			a[i] = max(a[i], a[i + 1] + 1);
		}
	}
	ll res = 0;
	for (int i = 0; i < n; i++)
	{
		res += a[i];
	}

	cout << res << endl;
}

Measured memory_bytes: 4740