akhauriyash/Code-Regression huggingface dataset:
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

struct UnionFind
{
	vector<int> parent;
	vector<int> rank;

	UnionFind(int N) :parent(N, 0), rank(N, 0)
	{
		rep(i, 0, N)
		{
			parent[i] = i;
		}
	}

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

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

		if (x == y)
		{
			return;
		}

		if (rank[x] < rank[y])
		{
			parent[x] = y;
		}
		else
		{
			parent[y] = x;
			if (rank[x] == rank[y])
			{
				rank[x]++;
			}
		}
	}

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

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

	int N, M, K;
	cin >> N >> M >> K;
	UnionFind UF(N);
	vector<int> PC(N, 0);
	vector<int> FC(N, 1);
	int a, b;
	rep(i, 0, M)
	{
		cin >> a >> b;
		a--, b--;
		PC[a]++;
		PC[b]++;
		if (UF.find(a) != UF.find(b))
		{
			int res = FC[UF.find(a)] + FC[UF.find(b)];
			UF.unite(a, b);
			FC[UF.find(a)] = res;
		}
	}
	rep(i, 0, K)
	{
		cin >> a >> b;
		a--, b--;
		if (UF.find(a) == UF.find(b))
		{
			PC[a]++;
			PC[b]++;
		}
	}

	rep(i, 0, N)
	{
		cout << FC[UF.find(i)] - PC[i] - 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 3968
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int num = Integer.parseInt(in.nextLine());
        List<String> words = new ArrayList<String>();
        boolean isRight = true;
        while(in.hasNextLine()) {
        	String cache = in.nextLine();
            if (words.contains(cache)) {
            	isRight = false;
            	break;
            }
            words.add(cache);
        }
        in.close();
        if (isRight) {
        	char a = ' ';
        	for(String word : words) {
        		if (a == ' ' || a == word.charAt(0)) {
        		a = word.charAt(word.length() - 1);
        		} else {
        			isRight = false;
        		}
        	}
        }
        String ans = isRight ? "Yes" : "No";
        System.out.println(ans);
    }
}

Measured memory_bytes: 21588
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	n = n % 10
	if n == 3 {
		fmt.Println("bon")
	} else if n <= 1 || n == 6 || n == 8 {
		fmt.Println("pon")
	} else {
		fmt.Println("hon")
	}
}


Measured memory_bytes: 1816
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))

M = [(1+p)/2 for p in P]
result = [0, ]

for i in range(1, N-K+1):
    result.append(result[-1] + M[i+K-1] - M[i-1])

print(sum(M[:K]) + max(result))

Measured memory_bytes: 25060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 998244353;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int Pow(int a) {
    ll ret = 1;
    for(int i = 0;i < a;i++) {
        ret *= 2;
    }
    return ret;
}

int main() {
    int N,K;
    cin >> N >> K;
    if(N == 1) {
        if(K == 0) {
            cout << "0 0 1 1" << endl;
        }
        else {
            cout << -1 << endl;
        }
    }
    else if(K > Pow(N) - 1) {
        cout << -1 << endl;
    }
    else {
        for(int i = Pow(N) - 1;i >= 0;i--) {
            if(i != K) {
                cout << i << " ";
            }
        }
        cout << K << " ";
        for(int i = 0;i <= Pow(N) - 1;i++) {
            if(i != K) {
                cout << i << " ";
            }
        }
        cout << K << endl;
    }
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

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

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<int>A(N);
  REP(i,N){
    cin>>A[i];
  }
  map<int,int>mp;
  ll ans=0;
  FOR(i,1,N){
    mp[A[i-1]+i-1]++;
    ans+=mp[i-A[i]];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 21084
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int h = scanner.nextInt();
		int w = scanner.nextInt();
		String s[][] = new String[h][w];

		for (int i = 0; i < h; i++) {
			s[i] = scanner.next().split("");
		}

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (s[i][j].equals("#")) {
					for (int k = -1; k <= 1; k++) {
						for (int v = -1; v <= 1; v++) {
							try {
								if (!((k == 0 && v == 0) || s[i + k][j + v].equals("#"))) {
									s[i + k][j + v] += ".";
								}
							} catch (Exception e) {

							}
						}
					}
				}

			}
		}

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (s[i][j].equals("#")) {
					System.out.print("#");
				} else {
					System.out.print(s[i][j].length() - 1);
				}
			}
			System.out.println("");
		}

	}
}


Measured memory_bytes: 23252
n = gets.to_i
vs = gets.split.map(&:to_i)
even_table = Hash.new { 0 }
odd_table = Hash.new { 0 }
vs.each.with_index do |v, i|
  if i.even?
    even_table[v] += 1
  else
    odd_table[v] += 1
  end
end
ans = 1 << 60
sorted_even = even_table.sort_by { |_, v| -v }
sorted_odd = odd_table.sort_by { |_, v| -v }
[sorted_even.size, 2].min.times do |i|
  [sorted_odd.size, 2].min.times do |j|
    if sorted_even[i][0] == sorted_odd[j][0]
      count = n - [sorted_even[i][1], sorted_odd[j][1]].max
      ans = count if count < ans
    else
      count = n - (sorted_even[i][1] + sorted_odd[j][1])
      ans = count if count < ans
    end
  end
end
puts ans


Measured memory_bytes: 20472
#include <cstdio>
#include <algorithm>
using namespace std;
#define ri register int
typedef long long ll;
const int N=2000005,MAXBUF=5000005;
int n,m,a[N],b[N];
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, c;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (c = gc(); c < '0' || c > '9'; c = gc()) ;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15);
	}
}
using io :: gi;
inline int calc(ri mid){
	ri i,x,y;
	for(i=1;i<=n;++i) b[i]=a[i]<mid?0:1;
	for(x=m-1;x&&b[x]^b[x+1];--x);
	for(y=m+1;y<=n&&b[y]^b[y-1];++y);
	return !x&&y>n?b[1]:(m-x+1<y-m+1?b[x]:b[y]);
}
int main(){
	ri l,r,mid,i;
	gi(n);
	m=n;
	n=(n<<1)-1;
	for(i=1;i<=n;i++) gi(a[i]);
	l=1;r=n;
	while(l<=r) calc(mid=l+r>>1)?l=mid+1:r=mid-1;
	printf("%d",l-1);
	return 0;
}

Measured memory_bytes: 7552
#include <cstdio>
#include <algorithm>
#include <queue>
#include <map> 
#include <cstring>
using namespace std;
#define LL long long
const int N = 100010;
LL d[N];
queue<int>q;
int n;
int dist[N],sz[N];
map<LL,int>mp;
vector<int>g[N];
pair<int,int> edge[N];
int main(){
	scanf("%d",&n);
	for(register int i = 1;i <= n;++i){
		scanf("%lld",&d[i]);
		mp[d[i]] = i;
		sz[i] = 1;
	}
	for(register int i = 1;i < n;++i){
		auto it = mp.rbegin();
		int x = it -> second;
		LL dy = d[x] - n + 2*sz[x];
		if(mp.find(dy) == mp.end() || mp[dy] == x)
			return puts("-1"),0;
		int y = mp[dy];
		edge[i] = make_pair(x,y);
		g[x].push_back(y);
		g[y].push_back(x);
		sz[y] += sz[x];
		mp.erase(--mp.end());
	}
	memset(dist,-1,sizeof(dist));
	dist[1] = 0;
	LL tot = 0;
	q.push(1);
	while(q.size()){
		int x = q.front();
		tot += dist[x];
		q.pop();
		for(auto y : g[x])
		if(dist[y] == -1){
			dist[y] = dist[x] + 1;
			q.push(y);
		}
	}
	if(tot != d[1])
		return puts("-1"),0;
	for(int i = 1;i < n;++i)
		printf("%d %d\n",edge[i].first,edge[i].second);
	return 0;
}

Measured memory_bytes: 12416
int main(void){
  char stat[4];
  gets(stat);
  if(stat[0] == 'A' & stat[1] == 'A' & stat[2] == 'A'){
    printf("No\n");
  } else if(stat[0] == 'B' & stat[1] == 'B' & stat[2] =='B'){
    printf("No\n");
  } else {
    printf("Yes\n");
  }
  return 0;
}

Measured memory_bytes: 128
A,B,C,X,Y=map(int,input().split())
if A+B<=2*C:
  print(A*X+B*Y)
else:
  if X>=Y:
    print(min(2*Y*C+A*(X-Y),2*C*X))
  else:
    print(min(2*X*C+B*(Y-X),2*C*Y))

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

int main(){
  int X,f,x2;
  cin >> X;
  x2 = X;
  while(X>0){
    f += X%10;
      X /=10;
  }
  if(x2 % f == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;

	
	public static void Main(string[] args)
	{
		var s = Console.ReadLine();
		Console.WriteLine(s.StartsWith("YAKI")?"Yes":"No");
	}
	
	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;
	}
}

Measured memory_bytes: 13396
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        String[] s = br.readLine().split(" ");
        int[] a = new int[6];
 
        for(int i = 0; i < s.length; i++){
            a[i] = Integer.parseInt(s[i]);    
        }
 
        Dice dice = new Dice(a);
 
        int num = Integer.parseInt(br.readLine());
 
        for(int i = 0; i < num; i++){
            String[] input = br.readLine().split(" ");
            int top = Integer.parseInt(input[0]);
            int front = Integer.parseInt(input[1]);
            dice.setTop(top);
            dice.setFront(front);
            System.out.println(dice.RIGHT);
        }
         
    }
}
 
class Dice{
    int TOP,BOTTOM,LEFT,RIGHT,FRONT,BACK;
 
    Dice(int[] a){
        this.TOP = a[0];
        this.FRONT = a[1];
        this.RIGHT = a[2];
        this.LEFT = a[3];
        this.BACK = a[4];
        this.BOTTOM = a[5];
    }
 
    void setTop(int top){
        if(this.FRONT == top)           this.turnN();
        else if(this.RIGHT == top)      this.turnW();
        else if(this.LEFT == top)       this.turnE();
        else if(this.BACK == top)       this.turnS();
        else if(this.BOTTOM == top)    {this.turnN(); this.turnN();}
    }
 
    void setFront(int front){
        if(this.RIGHT == front)         this.turnL();
        else if(this.LEFT == front)     this.turnR();
        else if(this.BACK == front)    {this.turnR(); this.turnR();}
    }
 
    void turnS(){
        int tmp = this.TOP;
        this.TOP = this.BACK;
        this.BACK = this.BOTTOM;
        this.BOTTOM = this.FRONT;
        this.FRONT = tmp;
    }
 
    void turnN(){
        int tmp = this.TOP;
        this.TOP = this.FRONT;
        this.FRONT = this.BOTTOM;
        this.BOTTOM = this.BACK;
        this.BACK = tmp;
    }
 
    void turnW(){
        int tmp = this.TOP;
        this.TOP = this.RIGHT;
        this.RIGHT = this.BOTTOM;
        this.BOTTOM = this.LEFT;
        this.LEFT = tmp;
    }
 
    void turnE(){
        int tmp = this.TOP;
        this.TOP = this.LEFT;
        this.LEFT = this.BOTTOM;
        this.BOTTOM = this.RIGHT;
        this.RIGHT = tmp;
    }
 
    void turnL(){
        int tmp = this.FRONT;
        this.FRONT = this.RIGHT;
        this.RIGHT = this.BACK;
        this.BACK = this.LEFT;
        this.LEFT = tmp;
    }
 
    void turnR(){
        int tmp = this.FRONT;
        this.FRONT = this.LEFT;
        this.LEFT = this.BACK;
        this.BACK = this.RIGHT;
        this.RIGHT = tmp;
    }
 
}


Measured memory_bytes: 24472
#300
N = int(input())
S = [input() for _ in range(N)]
L = [0 for _ in range(N)]
L1 = ["" for _ in range(N)]
S.sort()
k = 0


for i in range(N):
    if i == 0:
        L[k] = 1 
        L1[k] = S[i]
    else:
        if S[i-1] == S[i]:
            L[k] = L[k] + 1
        else:
            L[k+1] = 1
            L1[k+1] = S[i]
            k += 1

m = max(L)
for i in range(N):
    if L[i] == m:
        print(L1[i])


Measured memory_bytes: 21752
#include <stdio.h>

int main(){
	int a,b,c;
	if(scanf("%d %d %d",&a,&b,&c)!=3)return 1;
	if((a<c && c<b)||(b<c && c<a)){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
mod=998244353
def modpow(a,p):
    res=1
    for i in range(p):
        res*=a
        res%=mod
    return res

n=int(input())
d=input().split(" ")
a={}
for i in range(0,n):
    a.setdefault(i,0)
for i in d:
    a[int(i)]+=1
ans=1
if d[0]!='0' or a[0]!=1:
    ans=0
else:
    for i in range(n-1):
        ans*=modpow(a[i],a[i+1])
        ans%=mod

print(ans)

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

using namespace std;

int main() {
   int n;
   cin >> n;
   char a[n],b[n],c[n];
   scanf("%s",a);
   scanf("%s",b);
   scanf("%s",c);

   int count = 0;
   for(int i=0;i<n;i++){
      if((a[i] == b[i]) && (b[i] == c[i]) && (c[i] == a[i])){
         continue;
      }else if((a[i] != b[i]) && (b[i] != c[i]) && (c[i] != a[i])){
         count += 2;
      }else{
         count += 1;
      }
   }

   cout << count << endl;
   return 0;
}

Measured memory_bytes: 256
//By Tushar Gautam
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln "\n"
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
// template <template <class...> class TT, class ...T>
// ostream& operator<<(ostream& out,TT<T...>& c){
//     out<<"{ ";
//     forstl(x,c) out<<x<<" ";
//     out<<"}"; return out;
// }
typedef long long int  ll;
typedef long double  ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM = 1e5+5, MOD = 1e9+7;
int t,n,m,k,x,y;
string p,q;
vv32 dp;
vvp32 par;
int solve(int x,int y){
	if(x==n || y==m) return 0;
	if(dp[x][y]!=-1) return dp[x][y];
	if(p[x]==q[y]){
		par[x][y]=mp(x+1,y+1);
		return dp[x][y]=1+solve(x+1,y+1);
	}
	int ans1=solve(x+1,y),ans2=solve(x,y+1);
	if(ans1>ans2){
		par[x][y]=mp(x+1,y);
		return dp[x][y]=ans1;
	}else{
		par[x][y]=mp(x,y+1);
		return dp[x][y]=ans2;
	}
}
int main(){
	fastio;
	cin>>p>>q;
	n=p.size(),m=q.size();
	dp.assign(n,v32(m,-1));
	par.assign(n,vp32(m,mp(0,0)));
	solve(0,0);
	string ans;
	int a1=0,a2=0;
	while(a1<n && a2<m){
		tie(x,y)=par[a1][a2];
		if(x<n && y<m && dp[x][y]!=dp[a1][a2]) ans+=p[a1];
		else if( (x==n || y==m) && dp[a1][a2]>0) ans+=p[a1];
		a1=x,a2=y;
	}
	cout<<ans<<ln;
	return 0;
}

Measured memory_bytes: 106496
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	int ans=0;
	cin>>s;
	for(int i=0;i<s.size();i++){
		int u=s[i]-'0';
		ans+=u;
		ans%=9;
	}
	if(ans==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

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

constexpr int INF = 1e9;

class union_find {
public:
    union_find(int N)
        : par(N, -1), w(N)
    {}

    pair<int, int> root(int x) {
        if(par[x] < 0) {
            return make_pair(x, 0);
        }
        pair<int, int> p = root(par[x]);
        w[x] += p.second;
        p.second = w[x];
        par[x] = p.first;
        return p;
    }

    void unite(int x, int y, int v) {
        int rx = root(x).first, ry = root(y).first;
        if(rx == ry) {
            return;
        }
        if(par[rx] < par[ry]) { // size(x) > size(y)
            par[rx] += par[ry];
            par[ry] = rx;
            w[ry] = v - w[y] + w[x];
        } else {
            par[ry] += par[rx];
            par[rx] = ry;
            w[rx] = -v + w[y] - w[x];
        }
    }

    int calc(int x, int y) {
        if(root(x).first != root(y).first) {
            return INF;
        }
        return w[y] - w[x];
    }
        
private:
    vector<int> par;
    vector<int> w;
};

int main() {
    int N, M;
    while(cin >> N >> M, N) {
        union_find uf(N);
        for(int i=0; i<M; ++i) {
            char op; cin >> op;
            if(op == '!') {
                int a, b, v;
                cin >> a >> b >> v;
                a--; b--;
                uf.unite(a, b, v);
            } else {
                int a, b;
                cin >> a >> b;
                a--; b--;
                if(uf.calc(a, b) == INF) {
                    cout << "UNKNOWN" << endl;
                } else {
                    cout << uf.calc(a, b) << endl;
                }
            }
        }
    }
}


Measured memory_bytes: 3508
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

ll ans = 0;

int main(void){
	int n; cin >> n;
	vint a(n);
	vint counts(n+10, 0);
	vint comb(n+10, 0);
	ll combSum = 0;
	rep(i, n){
		cin >> a[i];
		counts[a[i]]++;
	}
	rep(i, n+1){
		ll count = counts[i];
		comb[i] = (count*(count-1)) / 2;
		combSum += comb[i];
	}
	rep(i, n){
		ll count = counts[a[i]];
		ll ans = combSum - comb[a[i]] + ((count-1)*(count-2)) / 2;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <vector>
#include <iomanip>
#include <utility>
using namespace std;
#define ll long long

int main(void){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll dx, dy;
    dx = abs(c-a); dy = abs(d-b);
    for(ll i = 0; i < dy; i++)
        cout << 'U';
    for(ll i = 0; i < dx; i++)
        cout << 'R';
    for(ll i = 0; i < dy; i++)
        cout << 'D';
    for(ll i = 0; i < dx+1; i++)
        cout << 'L';    
    for(ll i = 0; i < dy+1; i++)
        cout << 'U';
    for(ll i = 0; i < dx+1; i++)
        cout << 'R';
    cout << "DR";
    for(ll i = 0; i < dy+1; i++)
        cout << 'D';
    for(ll i = 0; i < dx+1; i++)
        cout << 'L';
    cout << 'U';  
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9 + 7;
const int INT_MOD=1e9+7;
#define rep(i, N) for(int i = 0; i < N; i++)
#define REP(i, n) for(int i = 0; i <= n; i++)
#define rrep(i,n) for(int i=n;i>0;i--)
#define RREP(i,n) for(int i=n;i>=0;i--)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
signed main(){
    int n;cin>>n;
    int a[16][16];
    rep(i,16)rep(j,16) a[i][j]=-1;
    rep(i,n){
        int x;cin>>x;
        rep(j,x){
            int p,q;cin>>p>>q;
            a[i][p-1]=q;
        }
    }
    int maxn=0;
    for(int i=0;i<(1<<n);i++){
        int com=0;
        rep(k,n){
            if((i>>k)&1){
                int flag=1;
                rep(j,n){
                    if(a[k][j]!=-1){
                        if(((i>>j)&1)!=a[k][j]){
                            flag=-1;
                            break;
                        }
                    }
                }
                if(flag>0) com++;
                else {
                    com=0;
                    break;
                }
            }
        }
        maxn=max(com,maxn);
    }
    cout<<maxn<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
n,m=map(int,input().split())
INF=10**15
li1=set()
lin=set()
for i in range(m):
  a,b=map(int,input().split())
  if(a==1):li1.add(b)
  elif(b==1):li1.add(a)
  elif(a==n):lin.add(b)
  elif(b==n):lin.add(a)
for i in li1:
  if(i in lin):
    print("POSSIBLE")
    sys.exit()
    
print("IMPOSSIBLE")

Measured memory_bytes: 18892
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define CLR(a) memset(a, 0, sizeof(a))
#define DBG(x) cout<<(#x)<<"="<<x<<endl
#define FOR(i, a, b)  for(int i=(a); i<(b); i++)
#define REP(i, a, b)  for(int i=(a); i<=(b); i++)
#define DOWN(i, a, b) for(int i=(a); i>=(b); i--)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1000000009;
const int N= 1e3 + 10;

int match[N];
int n;
int vis[N];
vector<int> v[N];

struct Point {
	int x,y;
	bool operator < (const Point &rhs) const {
		return x<rhs.x;
	}
}a[N], b[N];

bool solve(int cur) {
	FOR(i, 0, v[cur].size()) {
		int u=v[cur][i];
		if (vis[u]) continue;
		vis[u]=1;
		int t=match[u];
		match[u]=cur;
		if (!t||solve(t)) return true;
		match[u]=t;
	}
	return false;
}

int main() {
	cin>>n;
	REP(i, 1, n) {
		cin>>a[i].x>>a[i].y;
	}
	REP(i, 1, n) {
		cin>>b[i].x>>b[i].y;
	}
	REP(i, 1, n) {
		REP(j, 1, n) {
			if (a[i].x<b[j].x&&a[i].y<b[j].y) {
				v[i].pb(n+j);
			}
		}
	}
	int ans=0;
	REP(i, 1, n) {
		CLR(vis);
		if (solve(i)) ans++;
	}
	cout<<ans<<endl;
	//cout<<1.*clock()/CLOCKS_PER_SEC<<"ms"<<"\n";
	return 0;
}

Measured memory_bytes: 256
def selection_sort(A):
    a = list(A)
    swap_count = 0

    for i in range(0, len(A)-1):
        i_min = i
        for j in range(i+1, len(A)):
            if a[j] < a[i_min]:
                i_min = j
        if i is not i_min:
            a[i], a[i_min] = a[i_min], a[i]
            swap_count += 1
    
    print(' '.join(map(str, a)))
    print(swap_count)

input()
selection_sort(list(map(int, input().split())))


Measured memory_bytes: 5600
import java.util.*;
import java.lang.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		b=b/1000;
		int ok=0;
		int k;
	    for(int i=0;i<=a;i++) {
	    	if(ok==1)break;
	    	    for(int j=0;j<=a;j++) {
	    	    	    k=b-(10*i+5*j);
	    	    	    	    if(k>=0&&k<=b&&a==i+j+k) {
	    	    	    	    	   ok=1;
	    	    	    	    	   System.out.println(i+" "+j+" "+k);
	    	    	    	    }
	    	    	}
	    	}
		if(ok==0)System.out.println(-1+" "+-1+" "+-1);
	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string s;
  R s;
  int ans=MAX;
  rep(i,s.size()-2) {
    int x=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
    ans=min(ans,abs(753-x));
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

using namespace std;

int main() {

	int X;
	cin >> X;

	for (int i = -120; i <= 120; ++i)
	{
		for (int j = -120; j <= 120; ++j)
		{
			if (pow(i, 5) - pow(j, 5) == X) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 4032
#include <stdio.h>

int main (){
	int a;
	int p;
	int x;
	int total;
	int pie;
	scanf ("%d %d", &a, &p);
	
	x = a * 3;
	total = x + p;
	pie = total / 2;
	
	printf ("%d\n", pie);
	
	return 0;
}

Measured memory_bytes: 1700
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a!=1&&b!=1)
        cout<<1<<endl;
    else if(a!=2&&b!=2)
        cout<<2<<endl;
    else
        cout<<3<<endl;
    return 0;
}


Measured memory_bytes: 256
using namespace std;

#include <stdio.h>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#include <bitset>

typedef pair<int, int> ii;
typedef vector<int> vi;

int n;
int a[101], b[101], c[101], d[101];
vi adj[201];

bitset<1000> vis;
array<int, 1000> match;

bool augment(int u) {
  if (vis[u]) return false;
  vis[u] = true;
  for (int v : adj[u]) {
    if (match[v] == -1 || augment(match[v])) {
      match[v] = u; return true;
    }
  }
  return false;
}

signed main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a[i], &b[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &c[i], &d[i]);
  }
  
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (a[i] < c[j] && b[i] < d[j]) {
        adj[i].push_back(j + 100);
        adj[j + 100].push_back(i);
      }
    }
  }
  
  int mcbm = 0;
  vi no_match;
  match.fill(-1);
  for (int u = 0; u < n; u++) {
    vis.reset();
    if (augment(u)) mcbm++;
    else no_match.push_back(u);
  }
  printf("%d\n", mcbm);
  

}


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

template <class Abel>
class BinaryIndexedTree
{
  const int size_;
  std::vector<Abel> data_;

public:
  // 0-indexed
  BinaryIndexedTree(int size) : size_(size), data_(size + 1, 0) {}

  // data[target] += num
  void Add(int target, Abel num)
  {
    for (int index = target + 1; index <= size_; index += index & -index)
      data_[index] += num;
  }

  // sum of [0, right)
  Abel Sum(int right)
  {
    Abel sum = 0;
    for (int index = right; index > 0; index -= index & -index)
      sum += data_[index];
    return sum;
  }

  // sum of [left, right)
  Abel Sum(int left, int right) { return Sum(right) - Sum(left); }
};


int main()
{
  int n, q;
  std::cin >> n >> q;
  BinaryIndexedTree<int> binary_indexed_tree(n);
  for (int i = 0; i < q; ++i)
  {
    int com, x, y;
    std::cin >> com >> x >> y;
    x--;
    if (com)
    {
      std::cout << binary_indexed_tree.Sum(x, y) << std::endl;
    }
    else
    {
      binary_indexed_tree.Add(x, y);
    }
  }
}
// be checkd by AOJ(DSL-2-B).


Measured memory_bytes: 3128
#include <iostream>
using namespace std;
   
int F[102][102];
int xg,yg,w,h;
   
   
void DFS(int Y,int X,int c){
  //if(Y < 1 || X < 1)
    //return;
  if(F[Y][X] != c){
    return;
  }
   
  F[Y][X] = -1;
  DFS(Y+1,X  ,c);
  DFS(Y-1  ,X,c);
  DFS(Y,X+1  ,c);
  DFS(Y  ,X-1,c);
}
   
   
int main(){
  int xs,ys,n;
  while(1){
    cin >> w >> h;
    if(w == 0 && h == 0)
      break;
for(int i=0; i<102; i++){
      for(int j=0; j<102; j++){
        F[i][j] = 10;
      }
    }
       F[0][-100] = 0;
    cin >> xs >> ys >> xg >> yg >> n;
   
   
    for(int i=0;i<n;i++){
      int c,d,x,y;
      cin >> c >> d >> x >> y;
      if(c == 0)
         c = 1919810;
      if(d == 0){
        for(int j=0;j<4;j++){
          F[x+j][y] = c;
          F[x+j][y+1] = c;
        }
      } else {
        for(int j=0;j<4;j++){
          F[x][y+j] = c;
          F[x+1][y+j] = c;
        }
      }
    }
  DFS(xs,ys,F[xs][ys]);
   
  if(F[xg][yg] == -1){
    cout << "OK" << endl;
  } else {
    cout << "NG" <<endl;
  }
  }
}


Measured memory_bytes: 3628
n,m=list(map(int,input().split()))
a=[]
b=[]
for i in range(m):
    a1, b1=[int(i) for i in input().split()]
    a.append(a1)
    b.append(b1)

city=[]
for i in range(n):
    city.append(0)

for aa in a:
    city[aa-1]=(city[aa-1]+1)

for bb in b:
    city[bb-1]=(city[bb-1]+1)

for cc in city:
    print(cc)


Measured memory_bytes: 3064
#include <algorithm>　　　 //STL 通用算法
#include <bitset>　　　　　//STL 位集容器
#include <cctype>         //字符处理
#include <cerrno> 　　　　 //定义错误码
#include <cfloat>　　　　 //浮点数处理
#include <ciso646>         //对应各种运算符的宏
#include <climits> 　　　　//定义各种数据类型最值的常量
#include <clocale> 　　　　//定义本地化函数
#include <cmath> 　　　　　//定义数学函数
#include <complex>　　　　 //复数类
#include <csignal>         //信号机制支持
#include <csetjmp>         //异常处理支持
#include <cstdarg>         //不定参数列表支持
#include <cstddef>         //常用常量
#include <cstdio> 　　　　 //定义输入／输出函数
#include <cstdlib> 　　　　//定义杂项函数及内存分配函数
#include <cstring> 　　　　//字符串处理
#include <ctime> 　　　　　//定义关于时间的函数
#include <cwchar> 　　　　 //宽字符处理及输入／输出
#include <cwctype> 　　　　//宽字符分类
#include <deque>　　　　　 //STL 双端队列容器
#include <exception>　　　 //异常处理类
#include <fstream> 　　　 //文件输入／输出
#include <functional>　　　//STL 定义运算函数（代替运算符）
#include <limits> 　　　　 //定义各种数据类型最值常量
#include <list>　　　　　　//STL 线性列表容器
#include <locale>         //本地化特定信息
#include <map>　　　　　　 //STL 映射容器
#include <memory>         //STL通过分配器进行的内存分配
#include<new>            //动态内存分配
#include <numeric>         //STL常用的数字操作
#include <iomanip> 　　　 //参数化输入／输出
#include <ios>　　　　　　 //基本输入／输出支持
#include <iosfwd>　　　　　//输入／输出系统使用的前置声明
#include <iostream> 　　　//数据流输入／输出
#include <istream>　　　　 //基本输入流
#include <iterator>        //STL迭代器
#include <ostream>　　　　 //基本输出流
#include <queue>　　　　　 //STL 队列容器
#include <set>　　　　　　 //STL 集合容器
#include <sstream>　　　　 //基于字符串的流
#include <stack>　　　　　 //STL 堆栈容器
#include <stdexcept>　　　 //标准异常类
#include <streambuf>　　　 //底层输入／输出支持
#include <string>　　　　　//字符串类
#include <typeinfo>        //运行期间类型信息
#include <utility>　　　　 //STL 通用模板类
#include <valarray>        //对包含值的数组的操作
#include <vector>　　　　　//STL 动态数组容器
using namespace std;

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

const int MAXN=2e5+10;
const ll MOD=1e9+7;

inline int read(){
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))x=(x<<3)+(x<<1)+c-'0',c=getchar();
	return x*f;
}
inline ll readll(){
	ll x=0;int f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-') f=-1;c=getchar();}
	while(isdigit(c)) x=(x<<3ll)+(x<<1ll)+1ll*(c-'0'),c=getchar();
	return x*f;
}
int gcd(int x,int y){
	return y?gcd(y,x%y):x;
}
ll gcd(ll x,ll y){
	return y?gcd(y,x%y):x;
}
ll a[MAXN];
int n,k;
int main(){
	n=read(),k=read();
	for(int i=0;i<n;i++) a[i]=readll();
	sort(a,a+n);
	int l=0,r=n-1,w=1; 
	ll ans=1;
	if(k&1) ans=a[r--],k--,w=(ans<0?-1:1);
	while(k){
		ll x=a[l]*a[l+1],y=a[r]*a[r-1];
		if(x*w>y*w) ans=(ans*(x%MOD))%MOD,l+=2;
		else ans=(ans*(y%MOD))%MOD,r-=2;
		k-=2;
	}
	printf("%lld\n",(ans%MOD+MOD)%MOD);
	return 0;
}

Measured memory_bytes: 5304
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

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

struct Mod {
    static uint64_t PRIME;
    uint64_t value = 0;
    Mod() : value(0) {}
    Mod(ll v) {
        if (v >= 0) {
            value = v % PRIME;
        } else {
            value = PRIME - (-v) % PRIME;
        }
    }
    Mod operator+(const Mod& rhs) const {
        return Mod(*this) += rhs;
    }
    Mod& operator+=(const Mod& rhs) {
        value += rhs.value;
        if (value >= PRIME) {
            value -= PRIME;
        }
        return *this;
    }
    Mod operator-(const Mod& rhs) const {
        return Mod(*this) -= rhs;
    }
    Mod& operator-=(const Mod& rhs) {
        if (value < rhs.value) {
            value += PRIME;
        }
        value -= rhs.value;
        return *this;
    }
    Mod operator*(const Mod& rhs) const {
        return Mod(*this) *= rhs;
    }
    Mod& operator*=(const Mod& rhs) {
        value = (value * rhs.value) % PRIME;
        return *this;
    }
    Mod inv() const {
        return power(*this, PRIME - 2);
    }
    Mod operator/(const Mod& rhs) const {
        return Mod(*this) /= rhs;
    }
    Mod& operator/=(const Mod& rhs) {
        *this *= rhs.inv();
        return *this;
    }
    static Mod power(Mod rhs, ll exp) {
        Mod ans = 1;
        while (exp > 0) {
            if (exp % 2) {
                ans *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return ans;
    }
};
uint64_t Mod::PRIME = 1000000007;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<Mod> fact(N+1);
    fact[0] = 1;
    vector<Mod> fact_inv(N+1);
    fact_inv[0] = 1;
    rep(n,1,N+1) {
        fact[n] = fact[n-1] * n;
        fact_inv[n] = fact_inv[n-1] / n;
    }
    Mod ans = 0;
    rep(a,0,min(K,N-1)+1) {
        ans += fact[N] * fact_inv[a] * fact_inv[N-a] * fact[N-1] * fact_inv[a] * fact_inv[N-1-a];
    }
    cout << ans.value << endl;
}


Measured memory_bytes: 3328
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int x;
	cin >> x;
	int answer = 1;
	for(int i = 2; i * i <= x; ++i)
	{
		int j = i * i;
		while(j <= x)
		{
			answer = max(answer, j);
			j *= i;
		}
	}
	cout << answer << '\n';
}

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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

bool search(int sum, int target, int* w, int n, int index) {
    if (sum == target) { // found
        return true;
    } else if (sum > target) {  // beyond
        return false;
    }

    if (index >= n) return false;

    return search(sum + w[index], target, w, n, index + 1) || search(sum, target, w, n, index + 1);
}

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

    int n;
    cin >> n;

    int A[n];
    REP(i, n) cin >> A[i];

    int q;
    cin >> q;

    int m;
    REP(i, q) {
        cin >> m;

        if (search(0, m, A, n, 0)) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }

}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "YES" : "NO");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

struct UnionFind
{
  vector<int> d;
  UnionFind(int n = 0) : d(n, -1) {}
  int find(int x)
  {
    if (d[x] < 0)
      return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y)
  {
    x = find(x);
    y = find(y);
    if (x == y)
      return false;
    if (d[x] > d[y])
      swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d[find(x)]; }
};

int main()
{
  int N, M;
  cin >> N >> M;
  UnionFind uf(N + M);
  rep(i, N)
  {
    int K;
    cin >> K;
    rep(j, K)
    {
      int L;
      cin >> L;
      int m = N + L - 1;
      uf.unite(i, m);
    }
  }

  bool is_ok = true;
  rep(i, N)
  {
    if (uf.find(i) != uf.find(0))
      is_ok = false;
  }
  printYesNo(is_ok);
  return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
    int main(){
        int a, b;
        cin >> a >> b;
        if(abs(a - b) % 2 == 0)
        cout << (a + b) / 2 << endl;
        else 
        cout << "IMPOSSIBLE" << endl;
    return 0;
}


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

int main()
{
  int a[3];
  rep(i, 3) cin >> a[i];
  int ans = 0;
  if(a[0] == a[1] && a[1] == a[2]) cout << 0 << endl;
  else{
    sort(a, a + 3);
    if((a[2] - a[1]) % 2 == 0 && (a[2] - a[0]) % 2 == 0) {
      ans += (a[2] - a[1]) / 2;
      ans += (a[2] - a[0]) / 2;
    }
    else if((a[2] - a[1]) % 2 == 1 && (a[2] - a[0]) % 2 == 1) {
      ans++;
      a[1]++;
      a[0]++;
      ans += (a[2] - a[1]) / 2;
      ans += (a[2] - a[0]) / 2;
    }
    else if((a[2] - a[1]) % 2 == 0 ) {
      ans++;
      a[2]++;
      a[1]++;
      ans += (a[2] - a[1]) / 2;
      ans += (a[2] - a[0]) / 2;
    }
    else{
      ans++;
      a[2]++;
      a[0]++;
      ans += (a[2] - a[1]) / 2;
      ans += (a[2] - a[0]) / 2;
    }
    cout << ans << endl;
  }
    
  return 0;
}


Measured memory_bytes: 3560
function Main(input) {
    var idata = input.split(" ").map(Number);
    // var idata = input.split(/\s/);
    var a = idata[0];
    var b = idata[1];
    var c = idata[2];
    var ans = Math.max(0, c - (a - b));
    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <queue>

using namespace std;
const int64_t INF=10000000000000000;
template<class T>
void read_1d(std::vector<T>& a,int64_t num){
	a.reserve(num);
	for(int64_t i1=0;i1<num;i1++){
		T temp;
		cin>>temp;
		a.push_back(temp);
	}
}
template<class T>
void read_2d(std::vector<std::vector<T> >&a,int64_t x,int64_t y ){
	a.resize(x);
	for(int64_t i1=0;i1<x;i1++){
		a[i1].reserve(y);
		for(int64_t i2=0;i2<y;i2++){
			T temp;
			cin>>temp;
			a[i1].push_back(temp);
		}
	}
}
template<class InputIterator>
void debug(InputIterator first,InputIterator last){
	for(auto i1=first;i1!=last;i1++){
		cout<<(*i1)<<endl;
	}
}
struct Point{
	int64_t x;
	int64_t y;
	int64_t c_cost;
};
bool operator<(const Point& a,const Point& b){
	return a.c_cost>b.c_cost;
}
int main(){
	int64_t H,W,K;
	cin>>H>>W>>K;
	vector<vector<char> > map;
	read_2d(map,H,W);
	bool used[H][W];
	for(int64_t i1=0;i1<H;i1++){
		for(int64_t i2=0;i2<W;i2++){
			used[i1][i2]=false;
		}
	}
	int64_t x1,y1;
	for(int64_t i1=0;i1<H;i1++){
		for(int64_t i2=0;i2<W;i2++){
			if(map[i1][i2]=='S'){
				x1=i1;
				y1=i2;
				break;
			}
		}
	}
	priority_queue<Point> que;
	int64_t ans=INF;
	que.push(Point{x1,y1,0});

	while(!que.empty()){
		Point p=que.top();
		que.pop();
		if(used[p.x][p.y]){
			continue;
		}

		if(p.x==0||p.x==H-1||p.y==0||p.y==W-1){
			ans=0;
			break;
		}else{
			used[p.x][p.y]=true;
			ans=min(ans,(p.x-1)/K+1);
			ans=min(ans,(p.y-1)/K+1);
			ans=min(ans,(H-2-p.x)/K+1);
			ans=min(ans,(W-2-p.y)/K+1);
			if(p.c_cost<K){
				if(!used[p.x-1][p.y]&&map[p.x-1][p.y]=='.'){
					que.push(Point{p.x-1,p.y,p.c_cost+1});
				}
				if(!used[p.x][p.y-1]&&map[p.x][p.y-1]=='.'){
					que.push(Point{p.x,p.y-1,p.c_cost+1});
				}
				if(!used[p.x+1][p.y]&&map[p.x+1][p.y]=='.'){
					que.push(Point{p.x+1,p.y,p.c_cost+1});
				}
				if(!used[p.x][p.y+1]&&map[p.x][p.y+1]=='.'){
					que.push(Point{p.x,p.y+1,p.c_cost+1});
				}
			}

		}
	}
	cout<<ans+1<<endl;





}


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

string a,b; int n,m; int dp[4000][4000]={0};

int main()
{
    cin>>a>>b; vector<char> v;
    m=a.length(),n=b.length();
    for(int i=1;i<=m;i++)
        for(int j=1;j<=n;j++)
        {
            if(a[i-1]==b[j-1]) dp[i][j]=1+dp[i-1][j-1];
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    // for(int i=1;i<=m;i++)
    // {    for(int j=1;j<=n;j++) cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }   
    
    
    int i=m,j=n;
    // cout<<ans<<endl;
    while(dp[i][j]!=0)
    {
        //cout<<i<<" "<<j<<endl;
        if(dp[i][j]==1+dp[i-1][j-1] and a[i-1]==b[j-1])
        {
            v.push_back(a[i-1]);
            i--,j--;
        }
        else
        {
            if(dp[i-1][j]>dp[i][j-1]){i--;}
            else j--;
        }
    }
    
    for(i=v.size()-1;i>=0;i--) cout<<v[i];
}





Measured memory_bytes: 47488
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] lines = sc.nextLine().split(" ");
        long num1 = Integer.parseInt(lines[0]);
        long num2 = Integer.parseInt(lines[1]);

        long ans1 = num1 / num2;
        long ans2 = num1 % num2;
        double ans3 = (double)num1 / (double)num2;

        System.out.println(ans1 + " " + ans2 + " " + String.format("%.9f", ans3));


    }
}

Measured memory_bytes: 26468