akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

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

struct b_tree{
	int left;
	int right;
	int sibling;
	int parent;
};

int getDepth(b_tree* array, int index){
	if(index == -1) return 0;
	if(array[index].left == -1 && array[index].right == -1)return 0;

	int right = getDepth(array, array[index].right);
	int left = getDepth(array, array[index].left);

	return (right > left ? right : left) + 1;
}


int main(){
	ios_base::sync_with_stdio(false);

	int numOfNode;
	cin >> numOfNode;
	b_tree* array = new b_tree[numOfNode];

	rep(i,numOfNode){
		int index;
		cin >> index;
		cin >> array[index].left;
		cin >> array[index].right;
		array[index].parent = -1;
		array[index].sibling = -1;
	}
	
	rep(i, numOfNode){
		array[array[i].left].parent = i;
		array[array[i].right].parent = i;
		array[array[i].left].sibling = array[i].right;
		array[array[i].right].sibling = array[i].left;
	}

	rep(i, numOfNode){
		//id
		cout << "node " << i << ": ";
		//parent
		cout << "parent = " << array[i].parent << ", ";
		//sibling
		cout << "sibling = " << array[i].sibling << ", ";
		//degree
		int counter = 0;
		if(array[i].left != -1) counter ++;	
		if(array[i].right != -1) counter ++;	
		cout << "degree = " << counter << ", ";
		//depth
		counter = 0;
		int index = i;
		while(array[index].parent != -1){
			counter++;
			index = array[index].parent;
		}
		cout << "depth = " << counter << ", ";
		//height
		int height = getDepth(array, i);
		cout << "height = " << height << ", "; 
		counter = 0;
		//type
		if(array[i].parent == -1)cout <<  "root";
		else if(height == 0)cout << "leaf";
		else cout << "internal node";
		//end
		if(i+1 != numOfNode)cout << endl;
	}

	cout << endl;




	return 0;
}

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

int main(){
  int N;
  cin >> N;
  if(N == 1){
    cout << "Hello World" << endl;
  } else{
    int A, B;
    cin >> A >> B;
    cout << A + B << endl;
  }
  return 0;
}


Measured memory_bytes: 256
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimze("02")
#define F first
#define S second
#define pb push_back
#define p push
using namespace std;
using ll = long long;
const ll maxn=5e5+5,inf = 1e18+18;
ll n,m,t,d,x,y=7,sum;
long double dis;

string s;
int main(){
	ios::sync_with_stdio(false) , cin.tie(0 ) ,cout.tie(0);
	cin>>n;
	sum=7;
	x=1;
	if(n%2==0){
		cout<<-1;
		return 0;
	}
	if(sum%n==0){
		cout<<1;
		return 0;
	}
	while(sum%n>0 && x<n){
		y=(y*10)%n;
		sum=(sum+y)%n;
		x++;
		if(sum%n==0){
			cout<<x<<endl;
			return 0;
		}
	}
	cout<<-1;
}


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

int city[7][2] = { {0,0}, {2,3}, {0,4}, {2,0}, {5,6} , {6,3}, {3,2} };
string str;

int main(){
	while(cin >> str){
		int p = 1;
		if(str[0] == '#') break;
		for(int i = 0; i < str.size(); i++) p = city[p][str[i]-'0'];
		if(p == 6) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define MAX 100000001
using namespace std;

vector<bool> prime;

void eratosthenes() {
  prime.resize(MAX, true);
  prime[0] = false;
  prime[1] = false;
  int n = sqrt(MAX);
  for (int i = 2; i <= n; i++) {
    if (prime[i]) {
      for (int j = 2 * i; j <= MAX; j += i) {
        prime[j] = false;
      }
    }
  }
  return;
}

int main() {
  eratosthenes();
  int n;
  cin >> n;
  vector<int> a(n);
  int res = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (prime[a[i]]) res++;
  }

  cout << res << endl;
  return 0;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = int.Parse(Console.ReadLine());
            input = input % 1000;

            if (input == 0)
                Console.WriteLine('0');
            else
            Console.WriteLine(1000-input);
        }


}
}


Measured memory_bytes: 27316
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <typeinfo>
#include <cmath>
#include <iomanip>
#include <queue>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
static const double pi = 3.141592653589793;

int main()
{
    ll k, r = 0, base = 1, count = 1;
    bool success = false;

    cin >> k;
    if (k % 7 == 0)
    {
        k /= 7;
    }
    vector<bool> flags(k + 1, false);
    while (!flags[r])
    {
        flags[r] = true;

        if ((10 * r + 1) % k == 0)
        {
            success = true;
            break;
        }
        r = (10 * r + 1) % k;
        // cout << r << endl;

        count++;
    }

    cout << (success ? count : -1) << endl;
}

Measured memory_bytes: 3692
quit() = exit(0)
in_1(ch) = parse(Int, take!(ch))
in_a(ch) = parse.(Int, split(take!(ch)))

quit() = exit(0)
in_1() = parse(Int, readline())
in_a() = parse.(Int, split(readline()))

function main()
  N = in_1()
  S0 = readline()
  @assert length(S0) == N
  S = [(s=='R' ? 1 : s=='G' ? 2 : 4) for s in S0]
  d2 = Dict{Tuple{Int, Int}, Int}()
  for i in 1:N-2
    s1 = S[i]
    for j in i+1:N-1
      s2 = S[j]
      s1 != s2 || continue
      v = get!(d2, (j, s1+s2), 0)
      d2[(j, s1+s2)] = v+1
    end
  end
  
  c = 0
  for k in 3:N
    s3 = S[k]
    c += sum(get(d2, (j, 7-s3), 0) for j in 2:k-1)
  end
  
  jufuku = 0
  for k in 3:N
    s3 = S[k]
    for j in 2:k-1
      i = j - (k-j)
      i > 0 || continue
      S[i] + S[j] + s3 == 7 && (jufuku += 1)
    end
  end
  
  println(c-jufuku)
end

isempty(ARGS) && main()


Measured memory_bytes: 189960
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define forinc(i,a,b) for(int i=a;i<=b;++i)
#define fordec(i,a,b) for(int i=a;i>=b;--i)
#define fi first
#define se second
#define pii pair<int,int>

const int maxn=1e5+5;
int n,id[3*maxn],cnt,ret;
struct edges
{
    int u,v,c;
};
edges E[3*maxn];
edges pos[maxn];
bool dk(edges A,edges B)
{
    return A.u<B.u;
}
bool dk1(edges A,edges B)
{
    return A.v<B.v;
}
bool cmp(edges A,edges B)
{
    return A.c<B.c;
}
int root(int u)
{
    return (id[u]<0?u:id[u]=root(id[u]));
}
void join(int u,int v)
{
    if((u=root(u))==(v=root(v))) return;
    if(id[u]>id[v]) swap(u,v);
    id[u]+=id[v];
    id[v]=u;
}
main()
{
   // freopen("test.inp","r",stdin);
    ios_base::sync_with_stdio(false);
    memset(id,-1,sizeof id);
    cin>>n;
    forinc(i,1,n)
    {
        cin>>pos[i].u>>pos[i].v;
        pos[i].c=i;
    }
    sort(pos+1,pos+n+1,dk);
    forinc(i,1,n-1) E[++cnt]={pos[i].c,pos[i+1].c,min(abs(pos[i].u-pos[i+1].u),abs(pos[i].v-pos[i+1].v))};
    sort(pos+1,pos+n+1,dk1);
    forinc(i,1,n-1) E[++cnt]={pos[i].c,pos[i+1].c,min(abs(pos[i].u-pos[i+1].u),abs(pos[i].v-pos[i+1].v))};
    sort(E+1,E+cnt+1,cmp);

    forinc(i,1,cnt)
    {
        if(root(E[i].u)!=root(E[i].v))
        {
            join(E[i].u,E[i].v);
            ret+=E[i].c;
        }
    }
    cout<<ret;
}


Measured memory_bytes: 12032
N,K = map(int,input().split())
S = list(input())
s = S[K-1]
if s=='A':
    S[K-1] = 'a'
    print(''.join(S))
if s=='B':
    S[K-1] = 'b'
    print(''.join(S))
if s=='C':
    S[K-1] = 'c'
    print(''.join(S))

Measured memory_bytes: 38384
import Control.Monad
import Data.List

main=do
    [n,m]<-map read.words<$>getLine
    aan <- replicateM n getLine
    am <- concat<$>replicateM m getLine
    let aam = map (f aan m) [0..(n-m)]
    let cs = concatMap (\aa -> map (\i-> g m i aa) [0..(n-m)]) aam
    putStrLn $ case find (==am) cs of
        Just _ -> "Yes"
        Nothing -> "No"

f aan m i = take m $ drop i aan
g m i = concatMap (take m . drop i)

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }

const int sz = 2e5+1;

void dfs(int node,int curr,bool vis[],int dis[],map<int,vector<int>>& tree){
  if(vis[node]) return;
  else{
    vis[node] = true;
    dis[node] = curr;

    for(int i=0;i<tree[node].size();i++){
      if(!vis[tree[node][i]]){
        dfs(tree[node][i],curr+1,vis,dis,tree);
      }
    }
  }
}

int32_t main(){
    
  fast;
  int n,x,y; cin >> n >> x >> y;
  map<int,vector<int>> tree;

  for(int i=1;i<=n-1;i++){
    int a,b; cin >> a >> b;
    tree[a].pb(b);
    tree[b].pb(a);
  }

  bool vis1[sz] = {false},vis2[sz]={false};
  int dis1[sz]={0},dis2[sz]={0};
  
  dfs(x,0,vis1,dis1,tree);
  dfs(y,0,vis2,dis2,tree);

  int ans = -1;

  for(int i=1;i<=n;i++){
    if(dis1[i]<dis2[i]){
      ans = max(ans,dis2[i]-1);
    }
  }
  
  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 25216
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 1200031;

int d,n;

int res;

int f(int x){
	if (x%2)
		return 0;
	return f(x/2)+1;
}

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
//	cin.tie(0);

	cin>>n;
	for (int i=1;i<=n;i++){
		int x;
		cin>>x;
		res+=f(x);
	}
	cout<<res<<endl;

//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7


def inp(): return int(sys.stdin.readline())


def inpl(): return list(map(int, sys.stdin.readline().split()))


def inpl_str(): return list(sys.stdin.readline().split())


H, W, K = inpl()
SS = [list(map(int, str(input()))) for _ in range(H)]

ans = INF

for bit in range(1 << H-1):
    tmpSS = []
    nSS = []
    for b in range(H):
        nSS.append(SS[b])
        # print(bin(bit), nSS)
        if bit & (1 << b) != 0:
            tmpSS.append(nSS)
            nSS = []

    tmpSS.append(nSS)
    tmp_ans = len(tmpSS) - 1
    nSS = []

    for tmpS in tmpSS:
        L = len(tmpS)
        nS = [0]*W
        for x in range(W):
            for y in range(L):
                nS[x] += tmpS[y][x]
        nSS.append(nS)

    # print(nSS)

    L = len(nSS)
    tmpl = [0]*L
    for x in range(W):
        for y in range(L):
            tmpl[y] += nSS[y][x]

        if max(tmpl) > K:
            for y in range(L):
                tmpl[y] = nSS[y][x]
            tmp_ans += 1
            if max(tmpl) > K:
                tmp_ans = INF

    ans = min(ans, tmp_ans)

print(ans)


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

int main(){
	vector<int> an(5);
	int k;
	for(int i=0; i<5; i++) cin >> an[i];
	cin >> k;
	cout << (an[4]-an[0]<=k?"Yay!":":(") << endl;
	return 0;
}

Measured memory_bytes: 3596
A,B,C = map(int, input().split())

cnt = 0
while A!=B or B!=C or C!=A:
    A,B,C = sorted([A,B,C])
    
    if A==B:
        A += 1
        B += 1
        cnt += 1
        
    else:
        A += 2
        cnt += 1
        
print(cnt)
        
    

Measured memory_bytes: 3060
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> as(n); cin >> as;
    for(int i = 0; i < n; i++){
        as[i] -= i + 1;
    }
    sort(as.begin(), as.end());
    int piv = as[n / 2];
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += abs(piv - as[i]);
    }
    cout << ans << '\n';
}


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

using namespace std;


#define M_DEBUG if(1)


int main() {
    // 1≦r≦100
	int r = 0;
	cin >> r ;
	assert(1 <= r && r <= 100);
	cout << (long int)(3 *  pow(r, 2)) << endl;
 	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define tam 120004
#define offset 320000
#define se second
#define fi first
#define pitem item*
#define ptr tre*
#define forr(i,p,n) for(ll i=p;i<n;i++)
using namespace std;
typedef long long ll;
const ll MOD=1000000007 ;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;
ll valx[tam],valy[tam];
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);

    ll n,m;
    cin>>n>>m;
    vector<ll> vx,vy;
    forr(i,0,n)
        cin>>valx[i];
    
    forr(i,0,m)
    {
        cin>>valy[i];
    }
    forr(i,1,m)
    {
        vx.pb(valy[i]-valy[i-1]);
    }
    forr(i,1,n)
    {
        vy.pb(valx[i]-valx[i-1]);
    }
    ll C=0;
    ll M=vx.size();
    forr(i,0,vx.size())
    {

        C=add(C,mult(vx[i],mult((M-i),(i+1))));
    }
    ll S=0;
    ll N=vy.size();
    forr(i,0,vy.size())
    {
        S=add(S,mult(N-i,vy[i]));
    }
    ll tot=0;
    forr(i,0,vy.size())
    {
        tot=add(tot,mult(C,S));
        S-=mult(N-i,vy[i]);S+=MOD;S%=MOD;
    }
    cout<<tot<<endl;
}

Measured memory_bytes: 4212
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 1005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    	out(x / 10);
    }
    putchar('0' + x % 10);
}
int64 N,M;
void Solve() {
    read(N);read(M);
    if(N * 2 >= M) {out(M / 2);enter;}
    else {out(N + (M - N * 2) / 4);enter;}
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int w, h;
    cin >> w >> h;
    vector<int> p(w), q(h);
    rep(i, w)
    {
        cin >> p[i];
    }
    rep(i, h)
    {
        cin >> q[i];
    }

    using A = pair<int, int>;
    vector<A> axes;
    rep(i, w)
    {
        axes.push_back(make_pair(p[i], 0));
    }
    rep(i, h)
    {
        axes.push_back(make_pair(q[i], 1));
    }
    sort(axes.begin(), axes.end());

    int64_t result = 0;
    int x = 0, y = 0;
    rep(i, w + h)
    {
        int v;
        int dir;
        tie(v, dir) = axes[i];

        if (dir == 0) {
            result += (int64_t)v * (h + 1 - y);
            x++;
        } else {
            result += (int64_t)v * (w + 1 - x);
            y++;
        }
        //cout << i << " " << v << " " << x << " " << y << " " << result << endl;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3188
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int A[] = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		// i 以前の最小値
		int min[] = new int[N];
		min[0] = A[0];
		for (int i = 1; i < N; i++) {
			if (A[i] < min[i-1]) {
				min[i] = A[i];
			} else {
				min[i] = min[i-1];
			}
		}
		// i 以降のAiの最大値
		int max[] = new int[N];
		max[N-1] = A[N-1];
		for (int i = N - 2; i >=0; i--) {
			if(A[i] > max[i + 1]) {
				max[i] = A[i];
			} else {
				max[i] = max[i + 1];
			}
		}
		// 最大の価格差
		int maxgap = 0;
		for (int i = 0; i < N; i++) {
			if (maxgap < max[i] - min[i]) {
				maxgap = max[i] - min[i];
			}
		}
		// maxgapを作る場所の数を算出
		// 連続したものはカウントしない
		int prevmax = 0;
		int prevmin = 0;
		int count = 0;
		for (int i = 0; i < N; i++) {
			if (max[i] - min[i] == maxgap && (prevmax != max[i] || prevmin != min[i])) {
				count++;
			}
			prevmax = max[i];
			prevmin = min[i];
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 34072
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n;
    string s, t;
    cin >> n >> s >> t;
    for (ll i = 0; i < n; i++)
        cout << s[i] << t[i];
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var n = p[0];
		var m = p[1];
		
		var u = new UnionFind(n);
		
		for(int i = 0; i < m; i++)
		{
			p = Input().ToInt(-1);
			u.Unite(p[0], p[1]);
		}
		
		var h = new Dictionary<int, int>();
		for(int i = 0; i < n; i++)
		{
			int r = u.Root(i);
			if(!h.ContainsKey(r))
			{
				h.Add(r, 0);
			}
			h[r]++;
		}
		int max = 0;
		foreach(var hr in h.Keys)
		{
			max = Math.Max(max, h[hr]);
		}
		Console.WriteLine(max);
	}
	
	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

public class UnionFind
{
	private int[] par;
	public UnionFind(int n)
	{
		par = new int[n];
		for(int i = 0; i < n; i++)
			par[i] = i;
	}
	public int Root(int x)
	{
		if(par[x] == x) return x;
		return par[x] = Root(par[x]);
	}
	public void Unite(int x, int y)
	{
		int rx = Root(x);
		int ry = Root(y);
		if(rx == ry) return;
		par[rx] = ry;
	}
	public bool InSameTree(int x, int y)
	{
		return Root(x) == Root(y);
	}
}



Measured memory_bytes: 47572
#include <iostream>
#include <algorithm>
#include <map>
#include <regex>
#include <string>
#include <cstdlib>
#include <math.h>
#include <vector>
#include <queue>
using namespace std;
using ll = long long;

int main() {
  int N, K;
  cin >> N >> K;
  ll H[N];
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  sort(H, H+N);

  ll cnt = 0;
  for(int i = 0; i < N - K; i++) {
    cnt += H[i];
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1792
n=int(input())
if n<=9:
    print(0)
    exit()
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
ans=[]
l=[]
for i in range(2,n+1):
    c=factorization(i)
    for j in c:
        if not j[0] in l:
            l.append(j[0])
            ans.append(j[1])
        else:
            ans[l.index(j[0])]+=j[1]
kai=0
k24=0
k2=0
k14=0
k4=0
for i in ans:
    if i>=74:
        kai+=1
    if i>=24:
        k24+=1
    if i>=2:
        k2+=1
    if i>=14:
        k14+=1
    if i>=4:
        k4+=1
print(kai+k24*(k2-1)+k14*(k4-1)+(k2-2)*k4*(k4-1)//2)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

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

		int n = sc.nextInt();
		int[] a = sc.nextIntArray(n);

		for (int i = 0; i < n - 1; i++) {
			if (a[i] > a[i + 1]) {
				loop: for (int j = i + 1; j < n; j++) {
					if (a[i] > a[j]) {
						int tmp = a[i];
						a[i] = a[j];
						a[j] = tmp;

						for (int k = 0; k < n - 1; k++) {
							if (a[k] > a[k + 1]) {
								a[j] = a[i];
								a[i] = tmp;
								continue loop;
							}
						}
						System.out.println("YES");
						return;
					}
				}
			}
		}

		for (int i = 0; i < n - 1; i++) {
			if (a[i] > a[i + 1]) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");

	}

	static class FastScanner {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;

		public FastScanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}

		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public String nextLine() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					return reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}

			return tokenizer.nextToken("\n");
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
	}
}

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

int main(){
    ll a,ans;
    double b;
    cin >> a >> b;
    ans = b*100+0.5; //これはdoubleからlong long への型変換（キャスト）をしている
                     //このとき小数点以下は切り捨てなので0.5を足しておかないと
                     //計算結果がおかしくなる.例えば0.999999など
    a *= ans;
    a /= 100;
    printf("%lld\n", a);
    return 0;
}

Measured memory_bytes: 3740
PROGRAM B
      IMPLICIT NONE
      INTEGER :: N, i, ans, f,g, counter, index, s
      INTEGER,ALLOCATABLE :: A(:)
      LOGICAL :: flag1
      
      read*,N
      ALLOCATE( A(N) )
      read*,A(1:N)
      
      ans = 0
      flag1 = .false.

      
      outer:DO s = 1,10**9
      
        inner:DO index=1,N
          IF( .not.MOD(A(index),2)==0 )THEN
            flag1 = .true.
          END IF
        END DO inner
        
        IF(flag1)THEN
          EXIT
        END IF
        A(:) = A(:)/2
        ans = ans + 1
        
      END DO outer
      
      
      
      print'(I0)', ans
      
      
      
      
      END PROGRAM

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v);
#ifndef ONLINE_JUDGE
#define debug(a) cout<<#a<<" --> "<<(a)<<"\n";
#define debug2(a) cout<<#a<<" --> "<<(a)<<" ";
#define HERE cout<<"here - "<<__LINE__<<"\n";
#else
#define debug(a)
#define debug2(a)
#define HERE
#endif
const ll mod = 1e9+7;
const int N = 2e5+5;
typedef pair<int,int> pii;
ll n,m,k;
vector<ll>a,b;
bool check(ll mid)
{
    if(mid-1>=0 && mid-1 < a.size() && a[mid-1] <=k)
        return true;
    if(mid-1>=0 && mid-1 < b.size() && b[mid-1] <=k)
        return true;
    for(ll i=0;i<n;i++)
    {
         if(i==mid)
            break;
        if(mid-i-1-1>=0 && mid-i-1-1<b.size() && a[i] + b[mid-i-1-1]<=k)
            return true;
    }
    for(ll i=0;i<m;i++)
    {
        if(i==mid)
            break;
        if(mid-i-1-1>=0 && mid-i-1-1<a.size() && b[i] + a[mid-i-1-1]<=k)
            return true;
    }
    return false;

}
void TEST_CASES(int cas)
{
    cin>>n>>m>>k;
    a.resize(n);
    b.resize(m);
    for(ll &i:a)
        cin>>i;
    for(ll &i:b)
        cin>>i;
    for(ll i=1;i<a.size();i++)
    {
        a[i]+= a[i-1];
    }
    for(ll i=1;i<b.size();i++)
    {
        b[i]+= b[i-1];
    }
    ll low =1 , high = n+m;
    ll ans =0;
    while(low<=high)
    {
        ll mid= (low+high)/2;
        if(check(mid))
        {
            ans = mid;
            low= mid+1;
        }
        else{
            high = mid-1;
        }
    }
    printf("%lld",ans);
}


/*

*/

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        TEST_CASES(++cas);
    }
    return 0;
}



//os.order_of_key(v): returns how many elements strictly less than v
//os.find_by_order()

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v)
{
    for(auto i:v)
    {
        os<<"Key : "<<i.first<<" , Value : "<<i.second<<endl;
    }
    return os;
}


Measured memory_bytes: 6400
$debug=false
def aux(p,lat)
  puts "p: #{p} lat: #{lat}" if $debug
  q=[]
  p.each {|x|
    p_now=x
    puts "Start: #{p_now}" if $debug
    lat.each{|y|
      if y.index(p_now)
        puts "y: #{y}" if $debug
        p_now=(y.select{|x| x!=p_now})[0]
        puts "p_now: #{p_now}" if $debug
      end
    }
    puts "End: #{p_now}" if $debug
    q << p_now
  }
  r=[]
  p.each{|x| r<< p[q.index(x)]}
  r
end

def main
  if $debug
    fh=File.new("vol0-0011.txt", "r")
  else
    fh=STDIN
  end
  n=fh.gets.chomp.to_i
  m=fh.gets.chomp.to_i
  lat=[]
  m.times {
    lat << fh.gets.chomp.split(/,/)
  }
  p=(1..n).to_a.map(&:to_s)

  p1=aux(p, lat)

  puts p1

end

if $0 == __FILE__ then
  main
end


Measured memory_bytes: 6864
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

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

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

int N,M;
#define MAXN 100002
string S[MAXN];
ll p[MAXN];

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

    rep(i,M){
       cin >> p[i] >> S[i];
    }
    ll data[MAXN];
    ll allwa = 0;
    ll allac = 0;
    rep(i,N+1)data[i] = 0;
    for(int i=0;i<M;i++){
        if(data[p[i]]!=-1 && S[i]=="WA"){
            data[p[i]]++;
        }
        if(data[p[i]]!=-1 && S[i]=="AC"){
            allac++;
            allwa += data[p[i]];
            data[p[i]] = -1;
        }
    }
    cout << allac << " " << allwa << endl;
    return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <string>

using namespace std;

int main(int argc, const char *argv[]) {
  //
  int n, k;
  string s;
  cin >> n >> k >> s;

  int cnt = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == s[i + 1]) {
      cnt++;
    }
  }

  cnt += 2 * k;
  cout << min(n - 1, cnt) << '\n';
  return 0;
}

Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	public static void main (String[] args) {
      Scanner scan = new Scanner(System.in);
      int n = scan.nextInt();
		int k = scan.nextInt();
		long[] nums = new long[n];
		
		for (int i = 0; i < n; i++) {
			nums[i] = scan.nextInt();
		}
		
		Arrays.sort(nums);
		long sum = 0;
		for (int i = 0; i < nums.length - k; i++) {
			sum+= nums[i];
		}
		
		System.out.println(sum);

	}
}

Measured memory_bytes: 90892
# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    A = list(map(int, input().split()))
    """戦略
    長方形の条件は、縦の2辺の長さが等しくて、横の2辺の長さが等しい。
    自分と同じ数字のものを複数持つ数字を、大きいものから2つ取ってくれば、その2つの数字が長方形の2辺になる。   
    """

    A.sort(reverse=True)
    a = A[0]
    for i in range(1, len(A)):
        if a == A[i]:
            break
        a = A[i]

    if i >= len(A)-1:
        print(0)
        return

    b = A[i+1]
    for j in range(i+2, len(A)):
        if b == A[j]:
            break
        b = A[j]

    if j == len(A):
        print(0)
        return
    
    print(a*b)

if __name__ == "__main__":
    solve()


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

int main()
{
  char S[10];
  
  cin >> S;
  
  if(S[0] == 'S'){
    cout << "Cloudy" << endl;
  }else if(S[0] == 'R'){
    cout << "Sunny" << endl;
  }else{
    cout << "Rainy" << endl;
  }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;

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

int main(){
	//input
	ll N; cin>>N;
	vector<ll> D(N);
	rep(i,N) cin>>D[i];
	vector<ll> d(13,0);
	d[0]=1;
	vector<ll> ans(25,0);
	bool right=true;

	//solve
	rep(i,N){
		d[D[i]]++;
	}
	rep(i,13){
		if(((i==0 || i==12) && d[i]>=2) || d[i]>=3){
			cout<<0;
			return 0;
		}
		else if(d[i]==2){
			ans[i]=1;
			ans[24-i]=1;
		}
		else if(d[i]==1){
			if(right){
				right=false;
				ans[i]=1;
			}
			else{
				right=true;
				ans[24-i]=1;
			}
		}
	}
	ans[24]=ans[0];

	ll mem=INF,ANS=24;
	rep(i,25){
		if(ans[i]==1){
			chmin(ANS,abs(mem-i));
			mem=i;
		}
	}

	cout<<ANS;
}

Measured memory_bytes: 256
a,o,b=input().split()
a=int(a)
b=int(b)
while o!='?':
    if o=='+':
        print(a+b)
    elif o=='-':
        print(a-b)
    elif o=='*':
        print(a*b)
    elif o=='/':
        print(int(a/b))
    a,o,b=input().split()
    a=int(a)
    b=int(b)


Measured memory_bytes: 5596
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

h,w=map(int,input().split())

ans=float('inf')
for i in range(1,w):
    tmp1=h*i
    tmp2=h*((w-i)//2)
    tmp3=h*(w-i-(w-i)//2)
    if tmp2!=0:
        ans=min(ans,max(tmp1,tmp2,tmp3)-min(tmp1,tmp2,tmp3))
    tmp2=(w-i)*(h//2)
    tmp3=(w-i)*(h-h//2)
    ans=min(ans,max(tmp1,tmp2,tmp3)-min(tmp1,tmp2,tmp3))

h,w=w,h
for i in range(1,w):
    tmp1=h*i
    tmp2=h*((w-i)//2)
    tmp3=h*(w-i-(w-i)//2)
    if tmp2!=0:
        ans=min(ans,max(tmp1,tmp2,tmp3)-min(tmp1,tmp2,tmp3))
    tmp2=(w-i)*(h//2)
    tmp3=(w-i)*(h-h//2)
    ans=min(ans,max(tmp1,tmp2,tmp3)-min(tmp1,tmp2,tmp3))
print(ans)

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

int main(){
    int a, b;
    cin >> a >> b;

    if(a>0){
        cout << "Positive\n";
    }
    else if(a==0 || b==0){
        cout << "Zero\n";
    }
    else if(a<0 && b>0){
        cout << "Zero\n";
    }
    else if(b<0){
        if((b-a)%2==0){
	    cout << "Negative\n";
	}
	else{
	    cout << "Positive\n";
	}
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<functional>
using namespace std;
int main(void) {
    
    int n,k;
    cin>>n>>k;
    int score=1;

    for(int i=0;i<n;i++){
        if(score<k){
            score = 2*score;
        }else{
            score+=k;
        }
    }
    cout<<score<<endl;
    return 0;
}

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

#define mp make_pair

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef pair<i64,int> pli;
typedef pair<int,i64> pil;
typedef pair<i64,i64> pll;
typedef vector<int> vi;
typedef vector<i64> vl;

template <typename T>
T id(T b) {return b;};
template <class It>
bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It>
bool any(It f,It l){return std::any_of(f,l,id<bool>);}

const int MAX_H = 400, MAX_W = 400;
int h,w;
int s[MAX_H][MAX_W];
int dx[4] = {0,1,0,-1};
int dy[4] = {-1,0,1,0};
int bc[MAX_H*MAX_W] = {};
int wc[MAX_H*MAX_W] = {};

bool is_confined(int i, int j) {
  return 0 <= i && i < h && 0 <= j && j < w;
}

struct union_find {
  typedef vector<int> vi;
  vi parent,rank,cnt;
  int n;

  union_find(int n) : n(n) {
    parent = vi(n); rank = vi(n,0); cnt = vi(n,1);
    for (int i = 0; i < n; i++) parent[i] = i;
  }

  int find(int a) {
    if (parent[a] == a) return a;
    return parent[a] = find(parent[a]);
  }

  void unite(int a, int b) {
    a = find(a); b = find(b);

    if (a == b) return;
    if (rank[a] < rank[b]) {
      parent[a] = b; cnt[b] += cnt[a];
    } else {
      parent[b] = a; cnt[a] = cnt[b];
      if (rank[a] == rank[b])
        rank[a]++;
    }
  }

  int count(int a) { return cnt[find(a)]; }

  bool same(int a, int b) { return find(a) == find(b); }
};


int main()
{
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    string t;
    cin >> t;
    for (int j = 0; j < w; j++)
      s[i][j] = t[j] == '.' ? 0 : 1;
  }

  union_find uf(h*w);

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      for (int k = 0; k < 4; k++) {
        int ni = i+dy[k], nj = j+dx[k];
        if (is_confined(ni,nj) && s[i][j] != s[ni][nj]) {
          uf.unite(i*w+j, ni*w+nj);
        }
      }
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      //cout << uf.find(i*w+j) << endl;
      if (s[i][j] == 0) {
        wc[uf.find(i*w+j)]++;
      } else {
        bc[uf.find(i*w+j)]++;
      }
    }
  }

  i64 res = 0;
  for (int i = 0; i < h*w; i++) {
    //printf("%d %d\n",wc[i],bc[i]);
    res += 1LL * wc[i] * bc[i];
  }

  cout << res << endl;

  return 0;
}


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

int main(){

    int n;

    while(cin>>n,n){
        if(n==1) cout<<1<<endl;
        else{
        int count=0;
        for(int i=n+1;i<=2*n;i++){
            int check=0;
            for(int j=2;j*j<=i;j++){
                if(i%j==0) check=1;
            }
            if(check==0) count++;
        }

        cout<<count<<endl;
        }
    }

    return 0;

}


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

const int MAXN = 555;
int N;
double R[MAXN];
double pos[MAXN];

int main() {
  while (cin >> N) {
    for (int i = 0; i < N; ++i) {
      cin >> R[i];
    }
    for (int i = 0; i < N; ++i) {
      double x = R[i];
      for (int j = 0; j < i; ++j) {
	double c = R[i] + R[j];
	double b = R[i] - R[j];
	double a = sqrt(c * c - b * b);
	x = max(x, pos[j] + a);
      }
      pos[i] = x;
    }
    double res = 0;
    for (int i = 0; i < N; ++i) {
      res = max(res, pos[i] + R[i]);
    }
    printf("%.10f\n", res);
  }
  return 0;
}

Measured memory_bytes: 1256
#include<stdio.h>
int main(){
	int a, b;

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

	if (a < b){
		printf("a < b\n");
	}
	else if (a > b){
		printf("a > b\n");
	}
	else if (a == b){
		printf("a == b\n");
	}

	return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
long long a,b,c,x,lj;
int main()
{
	cin>>a;
	cin>>b;
	cin>>c;
	cin>>x;
	for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++)
			for(int k=0;k<=c;k++)
				if(i*500+j*100+k*50==x) lj++;
	cout<<lj<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;



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

    int h,w;
    cin >> h >> w;

    int sx,sy,gx,gy;
    cin >> sy >> sx >> gy >> gx;
    sx--;sy--;gx--;gy--;

    pair<int,int> s = make_pair(sx,sy), g = make_pair(gx,gy); 
    vector<vector<int>> ans(h,vector<int>(w,mod));
    string sur[h];

    for(int i = 0; i < h; i++) cin >> sur[i];

    auto inout = [&](int x,int y){
        if(0 <= x && x < w && 0 <= y && y < h) return true;
        else return false;
    };

    auto add = [&](pair<int,int> now,int dx,int dy){
        pair<int,int> ret = make_pair(now.first+dx,now.second+dy);
        return ret;
    };

    queue<pair<int,int>> p,q;

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

    p.push(s);
    ans[s.second][s.first] = 0;

    int can = 0;

    while(!p.empty()){
        while(!p.empty()){
            pair<int,int> now = p.front();
            p.pop();
            q.push(now);
            bool first = true;
            for(int i = 0; i < 4; i++){
                pair<int,int> nxt = add(now,dx[i],dy[i]);
                if(inout(nxt.first,nxt.second)){
                    if(sur[nxt.second][nxt.first] == '.'){
                        ans[nxt.second][nxt.first] = can;
                        if(nxt == g){
                            cout << ans[nxt.second][nxt.first] << endl;
                            return 0;
                        }
                        p.push(nxt);
                        sur[nxt.second][nxt.first] = '#';
                    }
                }
            }
        }
        can++;
        while(!q.empty()){
            pair<int,int> now = q.front();
            q.pop();
            for(int i = -2; i < 3; i++){
                for(int j = -2; j < 3; j++){
                    pair<int,int> nxt = make_pair(now.first+i,now.second+j);
                    if(inout(nxt.first,nxt.second)){
                        if(sur[nxt.second][nxt.first] == '.'){
                            ans[nxt.second][nxt.first] = can;
                            p.push(nxt);
                            sur[nxt.second][nxt.first] = '#';
                            if(nxt == g){
                                cout << ans[nxt.second][nxt.first] << endl;
                                return 0;
                            }
                        }
                    }
                }
            }
        }
    }

    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 8764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
const int MOD = 1e9 + 7;
const int INF = 2e9;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int GCD(int x, int y) { return y ? GCD(y, x % y) : x; }
int LCM(int x, int y) { return x * y / GCD(x, y); }

int main(){
    int n;
    cin >> n;
    vi h(n);
    for (int i = 0; i<n; i++){
        cin >> h[i];
    }
    int cnt = 0, ans = 0;
    for (int i = 0; i < n - 1; i++){
        if(h[i] < h[i + 1]){
            chmax(ans, cnt);
            cnt = 0;
        }
        else{
            cnt++;
        }
    }
    chmax(ans, cnt);
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if (d2 < d1)
    cout << 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {

		int a = cin.nextInt();
		int b = cin.nextInt();
		if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
			cout.println("Possible");
		else
			cout.println("Impossible");
	}

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			try {
				while (!st.hasMoreElements())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			} catch (IOException e) {
				throw new AssertionError(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
	}

}


Measured memory_bytes: 22996
import math
a = 0
n = int(input())

def ggcd(i, j, k):
    a = math.gcd(i, j)
    b = math.gcd(k, a)
    return b

for i in range(1, n + 1):
    for j in range(1, n + 1):
        for k in range(1, n + 1):
            a += ggcd(i, j, k)

print(a)

Measured memory_bytes: 70824
import java.util.*;
 
class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        while (true) {
                                int H = sc.nextInt(), W = sc.nextInt();
                                if (H == 0 && W == 0) {
                                        break;
                                }
                                for (int i = 0; i < H; i++) {
                                        for (int j = 0; j < W; j++) {
                                                if (i == 0 || j == 0 || i == H - 1 || j == W - 1) {
                                                        System.out.print("#");
                                                } else {
                                                        System.out.print(".");
                                                }
                                        }
                                        System.out.println("");
                                }
                                System.out.println("");
                        }
                }
        }
}


Measured memory_bytes: 33460
def main():
    while True:
        n = int(input())
        if n == 0: break

        res = []
        for i in range(n):
            row = input().split()
            res.append([row[0], 0])
            s_m = 0
            s_s = 0
            for j in range(1, 9):
                if j % 2 == 0:
                    s_s += int(row[j])
                else:
                    s_m += int(row[j])
            res[i][1] = s_s + s_m * 60

        ans = sorted(res, key=lambda x: x[1])
        print(ans[0][0])
        print(ans[1][0])
        print(ans[-2][0])

if __name__ == "__main__":
    main()




Measured memory_bytes: 6916
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
struct edge { int to, cost; };
char c[10];
signed main() {
	rep(i, 4) {
		cin >> c[i];
	}
	sort(c, c + 4);
	if (c[0] == c[1] && c[1] != c[2] && c[2] == c[3]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}



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

typedef long long ll;
typedef pair<ll,ll> ii;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
const int INF=2012345678;
const ll LLINF=4012345678012345678LL;
const ll MOD=1000000007;
const long double PI=3.1415926535898;
const long double EPS=1e-9;
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(b==0)return a;return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll expo(ll b,ll p,ll m){ll res=1; while(p){if(p&1)res=(res*b)%m; b=(b*b)%m; p>>=1;} return res;}
inline ll modinv(ll a,ll m){return expo(a,m-2,m);}


int main(){
	int A,B,h,m;
	scanf("%d%d%d%d",&A,&B,&h,&m);
	long double a=A,b=B;
	long double t1=(long double)(h)/(long double)(12)*2*PI+(long double)(m)/(long double)(720)*2*PI,t2=(long double)(m)/(long double)(60)*2*PI;
	long double t3=t1-t2;
	printf("%.12Lf",sqrt(a*a+b*b-2*a*b*cos(t3)));
}


Measured memory_bytes: 4216