akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

std::string S;
ll K;

int main()
{
  std::cin >> K >> S;

  if( S.size() <= K )
    std::cout << S << std::endl;
  else
    std::cout << S.substr(0,K) << "..." << std::endl;

  return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(long i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
int main(){
    int n,m;
    cin >> n >> m;
    UnionFind tree(n);
    int a,b,c;
    rep(i,m){
        cin >> a >> b >> c;
        tree.unite(a-1,b-1);
    }
    set<int> st;
    rep(i,n){
        st.insert(tree.root(i));
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 5376
#include <iostream>

using namespace std;

int main(void)
{
	int a, b, c;
	cin >> a >> b >> c;
	if ((a - b == 0 && a - c != 0) || (a - b != 0 && a-c == 0) || (a - b == a - c && a - b != 0))
		cout << "Yes" << endl;
	else
		cout << "No";
	return (0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

ll  a[110];
map< pair< int,pair<int,int>> , int>mp;
int main()
{
    ll n, cnt=0; cin>>n;
    for(int i=0; i<n; i++)
        cin>>a[i];
    sort(a, a+n);

    if(n<3) cout<<0;
    else
    {for(int i=0; i<n-2; i++)
    {
        for(int j=i+1; j<n-1; j++)
        {
            for(int k=j+1; k<n; k++)
            {
                if(a[i]+a[j]>a[k] && a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k])
                {
                    if(mp[{i,{j,k}}]==0 ) cnt++,mp[{i,{j,k}}]=1;
                }
            }
        }
    }
    cout<<cnt;}
}


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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int A[200000];
int bits[200000][20];
int sum[20];

int main()
{
	int N, from = 0, len = 0;
	ll ans = 0;

	cin >> N;
	rep(i, N) cin >> A[i];

	int SHIFT = 0;
	rep(j, 20) {
		rep(i, N) {
			bits[i][j] = (A[i] >> SHIFT) & 1;
		}
		SHIFT++;
	}

	rep(to, N) {
		rep(loop, 20) sum[loop] += bits[to][loop];
		len++;

		repc(i, from, to - 1) {
			bool f = true;
			rep(loop, 20) if (sum[loop] > 1) f = false;
			if (f) break;

			rep(loop, 20) sum[loop] -= bits[i][loop];
			len--;
			from++;
		}

		ans += len;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 16640
#include<cstdio>
#include<cmath>
#include<math.h> 
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
double t,tang,pans,ans,pi=3.141592654;
int a,b,x,v;
int main()
{
	scanf("%d%d%d",&a,&b,&x);
	v=a*a*b;
	if(x>=v/2)
	{
		t=(double)(2*v-2*x)/(a*a);
		tang=(double)t/a;
		pans=atan(tang);
		ans=(double)pans*180/pi;
	}
	else if(x<v/2)
	{
		t=(double)2*x/(a*b);
		tang=(double)b/t;
		pans=atan(tang);
		ans=(double)pans*180/pi;
	}
	printf("%.7f\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int num_p,num_q,cnt=0;
  vector<int> p(n),q(n),c(n);
  for(int i=0;i<n;i++)cin>>p[i];
  for(int i=0;i<n;i++)cin>>q[i];
  for(int i=1;i<=n;i++)c[i-1]=i;
  do{
    cnt++;
    if(c==p) num_p=cnt;    
    if(c==q) num_q=cnt;
  }while(next_permutation(c.begin(),c.end()));
  cout<<abs(num_p-num_q)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
ll GCD(ll a,ll b){
	return (b==0)?(a):(GCD(b,a%b));
}
ll LCM(ll a,ll b){
	return a/GCD(a,b)*b;
}
//
vector<int> aa,bb,cc;
int main(){
  int l;
  cin>>l;
  int n=1,c=0;
  while(n<l){
    c++;
    n*=3;
  }
  if(2*n/3>=l){
    int m=1;
    for(int i=1;i<=c-1;i++){
      aa.push_back(i);bb.push_back(i+1);cc.push_back(0);
      aa.push_back(i);bb.push_back(i+1);cc.push_back(m);
      aa.push_back(i);bb.push_back(i+1);cc.push_back(2*m);
      m*=3;
      if(i==c-1){
        aa.push_back(c);bb.push_back(c+1);cc.push_back(0);
      }
    }
    m/=3;m*=2+1;
    while(m<l){
      int h=1;
      int cn=0;
      while(m+h*3<l){
        h*=3;
        cn++;
      }
      aa.push_back(cn+1);bb.push_back(c+1);cc.push_back(m);
      m+=h;
    }
  }else{
    int m=1;
    for(int i=1;i<=c-1;i++){
      aa.push_back(i);bb.push_back(i+1);cc.push_back(0);
      aa.push_back(i);bb.push_back(i+1);cc.push_back(m);
      aa.push_back(i);bb.push_back(i+1);cc.push_back(2*m);
      m*=3;
      if(i==c-1){
        aa.push_back(c);bb.push_back(c+1);cc.push_back(0);
      }
    }
    m/=3;m*=2+1;
    while(m<l){
      int h=1;
      int cn=0;
      while(m+h*3<l){
        h*=3;
        cn++;
      }
      aa.push_back(cn+1);bb.push_back(c+1);cc.push_back(m);
      m+=h;
    }
  }
  cout<<c+1<<" "<<(int)aa.size()<<endl;
  for(int j=0;j<(int)aa.size();j++){
    cout<<aa[j]<<" "<<bb[j]<<" "<<cc[j]<<endl;
  }
	return 0;
}

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

int main()
{
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif*/
	int n;
	cin>>n;
	vector<pair<pair<string,int>,int>>p;
	for(int i=0;i<n;i++)
	{
		string s;
		int a;
		cin>>s>>a;
		p.push_back({{s,-a},i+1});
	}
	sort(p.begin(),p.end());
	for(auto x: p)
	{
		cout<<x.second<<endl;
	}
}

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

int main(){
    int n;cin>>n;
    vector<int> P(n),Q(n);
    for(int i = 0; i < n; i++) cin>>P[i];
    for(int i = 0; i < n; i++) cin>>Q[i];
    
    int a=0,b=0;
    vector<int> pr(n);
    for(int i = 0; i < n; i++) pr[i] = i+1;
    int cnt = 1;
    do{
        bool ok = 1;
        for(int i=0; i < n; i++){
            if(pr[i] != P[i]) ok = 0; 
        }
        if(ok) a = cnt;
        ok = 1;
        for(int i = 0; i < n ;i++){
            if(pr[i]!=Q[i]) ok = 0;
        }
        if(ok) b = cnt;
        cnt++;
    }while(next_permutation(pr.begin(),pr.end()));
    
    cout<<abs(a-b);

}


Measured memory_bytes: 256
package main

import (
    "fmt"
)

func bsearch(needle int, haystack []int) int {
    i, j := 0, len(haystack)
    for i < j {
        h := i + (j - i) / 2
        if haystack[h] < needle {
            i = h + 1
        } else {
            j = h
        }
    }
    return i
}

func main() {
    
    // fmt.Println(bsearch(0, []int{0, 2, 5}))

    scanInt()
    Q := scanInt()
    S := scanString()
    ac_positions := []int{}
    for i := 0; i < len(S) - 1; i++ {
        if S[i] == 'A' && S[i + 1] == 'C' {
            ac_positions = append(ac_positions, i)
        }
    }
    // fmt.Println(ac_positions)
    ac_positions = append(ac_positions, 100000)
    for i := 0; i < Q; i++ {
        l, r := scanInt(), scanInt()
        l_pos := bsearch(l - 1, ac_positions)
        r_pos := bsearch(r - 2, ac_positions)
        // fmt.Println(l_pos, r_pos)
        if ac_positions[r_pos] == r - 2 {
            fmt.Println(r_pos - l_pos + 1)
        } else {
            fmt.Println(r_pos - l_pos)
        }
    }
}

func scanInt() (num int) {
    fmt.Scan(&num)
    return
}

func scanInts(len int) (nums []int) {
    var num int
    for i := 0; i < len; i++ {
        fmt.Scan(&num)
        nums = append(nums, num)
    }
    return
}

func scanString() (str string) {
    fmt.Scan(&str)
    return
}

func scanStrings(len int) (strs []string) {
    var str string
    for i := 0; i < len; i++ {
        fmt.Scan(&str)
        strs = append(strs, str)
    }
    return
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
long long N;
long long x[200001];
int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> x[i];
    x[i] -= i+1;
  }

  sort(x,x+N);

  long long cost=0,midian;
  if(N%2==1){
    midian = x[N/2];
    for(int i=0;i<N;i++){
      cost += abs(x[i]-midian);
    }
  }
  else if(N%2==0){
    midian = (x[N/2-1]+x[N/2])/2;
    for(int i=0;i<N;i++){
      cost += abs(x[i]-midian);
    }
  }
  cout << cost << endl;
  return 0;
}


Measured memory_bytes: 1792
'use strict'
const main = (input: string) => {
    const std: string[] = input.trim().split('\n');
    const n: number = Number(std.shift());
    const p: number[] = std[0].split(' ').map(Number);
    const sp: number[] = Array.from(p).sort((a,b) => a-b);
    const r = p.filter((v, i) => v !== sp[i]);
    if (r.length > 2) {
        return console.log('NO');
    }
    console.log('YES');
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  


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

class P
{
    static void Main()
    {
        int[] HW = Console.ReadLine().Split().Select(int.Parse).ToArray();
        bool[][] map = new bool[HW[0] + 2][];
        map[0] = new bool[HW[1] + 2];
        map[map.Length - 1] = new bool[HW[1] + 2];
        for (int i = 1; i < HW[0] + 1; i++)
        {
            string s = $".{Console.ReadLine()}.";
            map[i] = s.Select(x => x == '#').ToArray();
        }
       
        for (int i = 0; i < HW[0]; i++)
        {
            string smap = "";
            for (int j = 0; j < HW[1]; j++)
            {
                if (map[i + 1][j + 1])
                {
                    smap += "#";
                }
                else
                {
                    int count = new bool[] { map[i][j], map[i][j + 1], map[i][j + 2], map[i + 1][j], map[i + 1][j + 1], map[i + 1][j + 2], map[i + 2][j], map[i + 2][j + 1], map[i + 2][j + 2] }.Count(x => x);
                    smap += count;
                }
            }
            Console.WriteLine(smap);
        }
    }
}

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

int n;

std::string ans = "";
int main() {
    std::cin >> n;
    if (n == 0) {
        std::cout << "0" << std::endl;
        return 0;
    }
    
    while (n != 0) {
        if (n % 2 == 0) {
            ans = "0" + ans;
        }
        else if (n % 2 != 0) {
            n--;
            ans = "1" + ans;
        }
        n /= -2;

    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
int main()
{
	long long a, b;
	char str;
	while (~scanf ("%lld %c %lld", &a, &str, &b)){
	if (str == '+')
		printf ("%lld\n", a + b);
	else
		printf ("%lld\n", a - b);}
	return 0;
}

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

char s[100005];

int main(){

	scanf("%s",s);

	int len=strlen(s);

	int i;

	int ans=0;

	for(i=0;i<len;i++){
		if(s[i]=='g'&&i%2==1){
		ans++;
		}
		else if(s[i]=='p'&&i%2==0){
		ans--;
		}
	}
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 256
import bisect
N = int(input())
seven53 = []
def dfs(s):
    if all(s.count(c) > 0 for c in "753"):
        seven53.append(s)
    if len(s) > 8:
        return
    else:
        for i in "753":
            dfs(s+i)
dfs("")
seven53 = list(map(int, seven53))
seven53.sort()
print(bisect.bisect_right(seven53, N))

Measured memory_bytes: 6004
function Main(inp) {
    var input = inp.split("\n");
    var n = Number(input[0]);
    var nums = input[1].split(' ').map(function(n) {return Number(n);});
    var i, len = nums.length, max = 0, min = Number.MAX_VALUE;
    nums.forEach(function(n) {
        if (n > max) {
            max = n;
        }
        if (n < min) {
            min = n;
        }
    })
    console.log(max - min);
}

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

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

def a2(num):
	t=num
	c=0
	while t %2==0:
		c += 1
		t=t/2
	return c
		


# 整数の入力
a = int(raw_input())

ary= map(int, raw_input().split())
ret=sum([a2(x) for x in ary])
print  ret



Measured memory_bytes: 3460
#include <iostream>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
stack<int> S1;
stack<pair<int,int> > S2;
char ch;
int sum = 0;

int main() {
  for(int i = 0;cin >> ch;i++){
    if(ch == '\\') S1.push(i);
    else if(ch == '/' && S1.size() > 0){
      int j = S1.top(); S1.pop();
      sum += i - j;
      int a = i - j;
      while(S2.size() > 0 && S2.top().first > j){
        a += S2.top().second; S2.pop();
      }
      S2.push(make_pair(j,a));
    }
  }

  vector<int> ans;
  while(S2.size() > 0) {
    ans.push_back(S2.top().second);
    S2.pop();
  }
  reverse(ans.begin(),ans.end());
  cout << sum << endl;
  cout << ans.size();
  for(int i = 0;i < ans.size();i++){
    cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3252
/**
>>> In The Name Of GOD
**/
#include <bits/stdc++.h>

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

#define pb push_back
#define pp pop_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define bs binary_search
#define smin(x,y) (x) = min((x) ,(y))
#define smax(x,y) (x) = max((x) ,(y))
#define sz(x) (int)(x).size()
#define ssz(x) (int)(x).length()
#define all(x) (x).begin(),(x).end()

//freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

///ifstream fin("input.txt");
///ofstream fout("output.txt");


/*bool cmp_pair_F_2(pair <int,int> x, pair <int,int> y)
{
    return x.F>y.F;
}
bool cmp_pair_S_2(pair <int,int> x, pair <int,int> y)
{
    return x.S>y.S;
}
bool cmp_pair_S_1(pair <int,int> x, pair <int,int> y)
{
    return x.S<y.S;
}*/

bool cmp(int x, int y)
{
	return x>y;
}



int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //int i,j;
    int x,a;
    cin >> x >> a;
    if (x<a)
        cout << 0;
    else
        cout << 10;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  cin>>N>>M;
  int H[N];
  for(int i=0;i<N;++i) cin>>H[i];
  vector<vector<int> > edge(N);
  int A, B;
  for(int i=0;i<M;++i) {
    cin>>A>>B;
    A--;
    B--;
    edge[A].push_back(B);
    edge[B].push_back(A);
  }
  int ans = 0;
  bool ok;
  for(int i=0;i<N;++i) {
    ok = true;
    for(int j=0;j<edge[i].size();++j) {
      if(H[i]<=H[edge[i][j]]) ok = false;
    }
    if(ok) ans++;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 8744
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from fractions import gcd

def readln(ch):
    _res = list(map(int,str(input()).split(ch)))
    return _res

def count(a):
    odd, even = 0,0
    for x in a:
        if x % 2 == 1: odd = odd + 1
        else: even = even + 1
    return odd,even

def deal(n,a):
    odd,even = count(a)
    if even == 0:
        return False
    if even % 2 == 1:
        return True
    if odd > 1:
        return False
    if a[0] % 2 == 0:
        res = a[0]
    else:
        res = a[1]
    for i in range(0,n):
        if a[i] % 2 == 1:
            if a[i] == 1: return False
            a[i] = a[i] - 1
        res = gcd(a[i],res)
    return not deal(n,list(map(lambda x: x//res,a)))

n = int(input())
a = readln(' ')
if deal(n,a):
    print('First')
else:
    print('Second')


Measured memory_bytes: 90600
import java.util.*;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for(int i = 0; i < N; i++)
            A[i] = sc.nextInt();
        int[] dp = new int[N];
        dp[0] = A[0];
        for(int i = 1; i < N; i++){
            dp[i] = gcd(dp[i-1], A[i]);
        }

        System.out.println(dp[N-1]);
    }
    static int gcd(int a, int b) {
        if(b > a)
            return gcd(b, a);
        else{
            if(b == 0)
                return a;
            else
                return gcd(b, a%b);
        }
    }
    
}


Measured memory_bytes: 50584
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <deque>
using namespace std;

int main() {
    string S;
    int Q;
    cin >> S >> Q;
    int t, f;
    char c;
    int t_cnt = 0;
    bool reversed = false;
    deque<char> out;
    for (int i = 0; i < S.length(); i++) {
        out.push_back(S[i]);
    }
    for (int i = 0; i < Q; i++) {
        cin >> t;
        if (t == 1) {
            reversed = !reversed;
            continue;
        } else {
            cin >> f >> c;
            if ((f == 1 && !reversed) || (f == 2 && reversed)) {
                out.push_front(c);
            } else {
                out.push_back(c);
            }
        }
    }
    if (reversed)
        reverse(out.begin(), out.end());
    for (int i = 0; i < out.size(); i++) {
        cout << out[i];
    }
    cout << "\n";
    return 0;
}

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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int>a(n);
    vector<ll>sum(n);
    rep(i,n)cin>>a[i];
    sum[0]=a[0];
    for(int i=1; i<n; ++i)sum[i]=sum[i-1]+a[i];
    vector<ll>v;
    for(int l=0; l<n; ++l){
        for(int r=l; r<n; ++r){
            ll x=sum[r];
            if(l!=0)x-=sum[l-1];
            v.push_back(x);
        }
    }
    int N=v.size(),bit=60;
    ll ans=0;
    vector<bool>ok(N,true);
    for(int bit=60; bit>=0; --bit){
        ll judge=1LL<<bit;
        int cnt=0;
        rep(i,N){
            if(ok[i]){
                if(v[i]&(1LL<<bit))cnt++;
            }
        }
        if(cnt>=k){
            ans+=judge;
            rep(i,N){
                if(!(v[i]&(1LL<<bit)))ok[i]=false;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7480
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int n,i;
    long long a,min = 1000000,max = -1000000,sum = 0;
    cin >> n;
    for (i=0;i<n;i++){
        cin >> a;
        if (a<min) min = a;
        if (a>max) max = a;
        sum += a;
    }
    cout << min << " " << max << " " << sum << endl; 
    return 0;
}


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

const int DIM = 2e3 + 5;

char mat[DIM][DIM]; int c[DIM][DIM];
int equ[DIM][DIM], dif[DIM][DIM];
int lef[DIM], rig[DIM], arr[DIM];

vector<int> stk;

inline void solve(int i, int n, int m, int &ans) {
    for (int j = 1; j < m; ++j) {
        if (mat[i][j] == mat[i][j + 1])
            arr[j] = dif[i - 1][j];
        else
            arr[j] = equ[i - 1][j];
    }
    
    stk.assign(1, 0);
    for (int j = 1; j < m; ++j) {
        while (arr[stk.back()] >= arr[j])
            stk.pop_back();
        
        lef[j] = stk.back() + 1;
        stk.push_back(j);
    }
    
    stk.assign(1, m);
    for (int j = m - 1; j > 0; --j) {
        while (arr[stk.back()] >= arr[j])
            stk.pop_back();
        
        rig[j] = stk.back() - 1;
        stk.push_back(j);
    }
    
    for (int j = 1; j < m; ++j)
        ans = max(ans, (rig[j] - lef[j] + 2) * (arr[j] + 1));
    
    return;
}

inline void solve(int n, int m, int &ans) {
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j < m; ++j) {
            equ[i][j] = equ[i - 1][j] + 1;
            dif[i][j] = dif[i - 1][j] + 1;
            
            if (mat[i][j] != mat[i][j + 1])
                dif[i][j] = 0;
            else
                equ[i][j] = 0;
        }
    }
    
    arr[0] = arr[m] = -1;
    
    for (int i = 2; i <= n; ++i) {
        solve(i, n, m, ans);
        for (int j = 1; j <= m; ++j)
            mat[i][j] = 1 - mat[i][j];
        
        solve(i, n, m, ans);
        for (int j = 1; j <= m; ++j)
            mat[i][j] = 1 - mat[i][j];
    }
    
    return;
}

int main( void ) {
    
    int n, m;
    cin >> n >> m;
    
    int ans = max(n, m);
    
    for (int i = 1; i <= n; ++i) {
        cin >> (mat[i] + 1);
        
        for (int j = 1; j <= m; ++j)
            mat[i][j] = (mat[i][j] == '#' ? 1 : 0);
    }
    
    for (int i = 0; i <= 3; ++i) {
        solve(n, m, ans);
        
        for (int i = 1; i <= n; ++i)
            for (int j = 1; j <= m; ++j)
                c[j][n - i + 1] = mat[i][j];
        
        swap(n, m);
        for (int i = 1; i <= n; ++i)
            for (int j = 1; j <= m; ++j)
                mat[i][j] = c[i][j];
    }
    
    cout << ans;
    return 0;
}

Measured memory_bytes: 51328
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int[][] a = new int[N][N];
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) a[i][j] = scanner.nextInt();

    System.out.println(solve(N, a));
  }

  public static long solve(int N, int[][] a) {
    long dist = 0;
    for (int i = 0; i < N; i++) for (int j = i + 1; j < N; j++) dist += a[i][j];

    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        for (int k = 0; k < N; k++) {
          if (k == i || k == j) continue;
          if (a[i][j] > a[i][k] + a[k][j]) return -1;
          if (a[i][j] == a[i][k] + a[k][j]) {
            dist -= a[i][j];
            break;
          }
        }
      }
    }
    return dist;
  }
}


Measured memory_bytes: 50316
#include <iostream>
#include <string.h>
using namespace std;

const int N = 1e5 + 1;

#define int long long

int dp[101][N], a[101], c[101];

main()
{
	int n, w;
	cin >> n >> w;
	
	for(int i = 1; i <= n; i++)
		cin >> a[i] >> c[i];
	
	memset(dp, 0x3f3f3f3f, sizeof(dp));
	
	int ans = 0;
	dp[0][0] = 0;
	for(int v = 0; v < N; v++)
	{
		for(int i = 1; i <= n; i++)
		{
			dp[i][v] = dp[i - 1][v];
			if(v >= c[i]) dp[i][v] = min(dp[i][v], dp[i - 1][v - c[i]] + a[i]);
			
			if(dp[i][v] <= w) ans = max(ans, v);
		}
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 79104
N, D = map(int, input().split())
X = [[int(j) for j in input().split()] for i in range(N)]
ans = 0
print(
    sum(
        [
            (
                sum([(X[j][k] - X[i][k]) ** 2 for k in range(D)]) ** 0.5
            ).is_integer()
            for i in range(N) for j in range(i + 1, N)
        ]
    )
)


Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

#define Len 10001

int main()
{
    char s[10];
    char a[10];
    int l = 0;

    scanf("%s", s);
    int strl = strlen(s);
    

    for (int i = 0; i < strl; i++){
        switch (s[i]){
            case '0' : 
                a[l++] = '0';
                
                break;

                

            case '1' :
                a[l++] = '1';
               
                break;

                
            case 'B' :
                if(l == 0) break;
                l--;
                
                break;
        }
    }
    
    for(int i = 0; i < l; i++){
        putchar(a[i]);
    }
    putchar('\n');
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define M 100

void selectionSort(int *A,int N){

  int i,j,k,mini,count=0;

  for(i=0;i<N;i++){
    mini=i;
    for(j=i;j<N;j++){
      if(A[j] < A[mini]) {
	mini = j;
      }
    }
    if(mini != i) count ++;
    k = A[i];
    A[i] = A[mini];
    A[mini] = k;

  }
  for(i=0;i<N;i++){
    if(i==N-1) printf("%d",A[i]);
    else printf("%d ",A[i]);
  }
  printf("\n");
  printf("%d\n",count);

}

int main(){

  int i,j,k,A[M];

  scanf("%d",&k);

  for(i=0;i<k;i++){
    scanf("%d",&A[i]);
  }

  selectionSort(A,k);

  return 0;
}



Measured memory_bytes: 2068
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "tmp.cpp"

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

  int n;
  cin >> n;
  vl a(n);
  map<ll, int> mp;
  REP(i, n) {
    cin >> a[i];
    mp[a[i]]++;
  }

  sort(a.rbegin(), a.rend());
  int ans = 0;
  REP(i, n) {
    if (mp[a[i]] == 0)
      continue;
    mp[a[i]]--;
    ll t = 1;
    while (t <= a[i]) {
      t <<= 1;
    }
    if (mp[t - a[i]]) {
      ans++;
      mp[t - a[i]]--;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 26880
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
  }
  sort(x.begin(), x.end());
  int ans = 1e9;
  for (int p = x[0]; p <= x[n - 1]; ++p) {
    int res = 0;
    for (int i = 0; i < n; ++i) {
      res += abs(x[i] - p) * abs(x[i] - p);
    }
    ans = min(ans, res);
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;

typedef pair<int, int> p;

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

    int N;
    cin >> N;

    vector<int> a(N);

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

    vector<bool> b(N);

    int pos = 0;
    int count = 0;

    while(!b[pos]) {
        b[pos] = true;
        pos = a[pos];
        count++;
        if(pos == 1) {
            cout << count << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}

Measured memory_bytes: 640
#!/usr/bin/python3
# -*- coding: utf-8 -*-
x = int(input())
flag = 0
for a in range(-200, 201):
    if flag == 1:
        break
    for b in range(-200, 201):
        if a**5 - b**5 == x:
            print(a, b)
            flag = 1
            break

Measured memory_bytes: 9180
#include <iostream>
#include <cmath>
#include <string>

int main(void){
             
        std::string a, b;

        std::cin >> a >> b;

        std::string c = a + b;
        int c_int = std::stoi(c);

        int c_sqrt = std::sqrt(c_int);

        if( c_sqrt*c_sqrt == c_int){
                std::cout << "Yes" << std::endl;
        }else{
                std::cout << "No" << std::endl;
        }   

        return 0;

}

Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int n, s;
    cin >> n >> s;
    if (n < s) {
        cout << -1 << endl;
        return 0;
    } else if (n == s) {
        cout << n + 1 << endl;
        return 0;
    }

    for (int b = 2; b < sqrt(n) + 1; b++) {
        int sm = 0;
        int val = n;
        while (val > 0) {
            sm += val % b;
            val /= b;
        }
        if (sm == s) {
            cout << b << endl;
            return 0;
        }
    }

    for (auto d1 = (int) floor(sqrt(n)); d1 >= 1; d1--) {
        if ((n - s) % d1 == 0) {
            int b = 1 + ((n - s) / d1);

            int sm = 0;
            int val = n;
            while (val > 0) {
                sm += val % b;
                val /= b;
            }
            if (sm == s) {
                cout << b << endl;
                return 0;
            }
        }
    }

    cout << -1 << endl;

    return 0;
}

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

int main()
{
    ll n,k;
    cin >> n >> k;
    if( n % k != 0 )
    {
        ll a = n / k;
        n = n - k*a;
    }
    else if( n % k == 0 ){
        cout << 0 << endl;
        return 0;
    }
    ll b = n - k;
    if( abs(n) >= abs(b) ){
        cout << abs(b) << endl;
    }
    else if( abs(b) > abs(n)  ){
        cout << abs(n) << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
using namespace std;
double dp[3000][3000];
void fun(double arr[],ll n)
{
	vector<double> dp(n+1,0);
	dp[0]=1-arr[1];
	dp[1]=arr[1];
	for(int a=2;a<=n;a++)
	{
		vector<double> ddp=dp;
		dp[0]=dp[0]*(1-arr[a]);
		for(int b=1;b<=a;b++)
		{
			dp[b]=ddp[b]*(1-arr[a])+ddp[b-1]*arr[a];	
		}	
	}
	ll k=(n+1)/2;
	double ans=0;
	for(int a=k;a<=n;a++)
	{
		ans=ans+dp[a];
	}
	cout<<fixed<<setprecision(10);
	cout<<ans<<endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll n;
	cin>>n;
	double arr[n+1];
	for(int a=1;a<=n;a++)
	cin>>arr[a];
	fun(arr,n);
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
using ll = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;};

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

  Int m,n;
  cin>>m>>n;
  vector<Int> ws(m),ts(m);
  for(Int i=0;i<m;i++) cin>>ws[i]>>ts[i];

  vector<Int> cs(n),bs(n);
  for(Int i=0;i<n;i++) cin>>cs[i]>>bs[i];

  vector<Int> sw(m+1,0),st(m+1,0);
  for(Int i=0;i<m;i++){
    sw[i+1]=sw[i]+ws[i];
    st[i+1]=st[i]+ts[i];
  }
  
  Int s=1<<n;
  const Int INF = 1e9;
  vector<Int> dp(s,-INF);
  dp[0]=0;
  for(Int b=0;b<s;b++){
    for(Int i=0;i<n;i++){
      if((b>>i)&1) continue;
      Int nb=b|(1<<i);
      Int x=upper_bound(sw.begin(),sw.end(),sw[dp[b]]+cs[i])-sw.begin();
      Int y=upper_bound(st.begin(),st.end(),st[dp[b]]+bs[i])-st.begin();
      chmax(dp[nb],min(x,y)-1);
    }
  }  
  cout<<dp[s-1]<<endl;
  return 0;
}




Measured memory_bytes: 9248
import java.util.*;
public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int [] H = new int[N];
        int [] DP = new int[N];
        for(int i=0;i<N;i++){
            H[i] = sc.nextInt();
            DP[i]=999999999;
        }
        DP[0]=0;
        for(int i=1;i<N;i++){
            int num;
            if(i+1-K<=0) num = 0;
            else num = i-K;
            for(int j=i-1;j>=num;j--) {
                int now = Math.abs(H[i] - H[j]);
                if (now + DP[j] < DP[i]) DP[i] = DP[j] + now;
            }
        }
        System.out.println(DP[N-1]);
    }
}

Measured memory_bytes: 64352
#include <bits/stdc++.h>
using namespace std;
int a[200005],ans;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i],ans^=a[i];
	for(int i=1;i<=n;i++) cout<<(ans^a[i])<<" ";
}

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

#define times(n, i)      uptil(0, n, i)
#define upto(f, t, i)    for(decltype(t) _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(decltype(t) _##i = (t), i = (f); i < _##i; i++)
#define downto(f, t, i)  for(decltype(t) _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(decltype(t) _##i = (t), i = (f); i > _##i; i--)
#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define all(v) v.begin(), v.end()
#define ln << "\n"

struct line{};

template<class T> istream& operator>>(istream& in, vector<T>& v) {
    times(v.capacity(), i) in >> v[i];
    return in;
}

template<class T> const ostream& operator<<(ostream& out, const vector<T>& v) {
    times(v.size(), i) out << (i ? " " : "") << v[i];
    return out;
}

template<class T, class...U> typename enable_if<is_same<T, line>::value, string>::type next(istream& in, const U&... args) {
    string s;
    getline(in, s, args...);
    return move(s);
}

template<class T, class...U> typename enable_if<!is_same<T, line>::value, T>::type next(istream& in, const U&... args) {
    T t(args...);
    in >> t;
    return move(t);
}
template<class T, class...U> auto next(const U&... args) -> decltype(next<T>(cin)) {
    return next<T>(cin, args...);
}

template<class T> T sum(const vector<T>& v) {
    T ans = T();
    for(const T& t : v) ans += t;
    return ans;
}

template<class T> T sum(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    T ans = T();
    for(typename vector<T>::iterator t = begin; t != end; t++) ans += *t;
    return ans;
}

template<class T> T min(const vector<T>& v) {
    return *min_element(v.begin(), v.end());
}

template<class T> T min(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *min_element(begin, end);
}

template<class T> T max(const vector<T>& v) {
    return *max_element(v.begin(), v.end());
}

template<class T> T max(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *max_element(begin, end);
}

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

    int N = next<int>();

    times(next<int>(), i) {
        int A = next<int>(), B = next<int>();
        if(N % 2) {
            cout << (N / 2 - max(abs(N + 1 - A * 2), abs(N + 1 - B * 2)) / 2) % 3 + 1 ln;
        } else {
            cout << (N / 2 - max(abs(N + 1 - A * 2), abs(N + 1 - B * 2)) / 2 - 1) % 3 + 1 ln;
        }
    }

    return 0;
}

Measured memory_bytes: 1196
#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<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define int ll
#define endl "\n"
#define all( x ) x.begin(), x.end()
#define fast ios::sync_with_stdio(0);cin.tie(0);

typedef unsigned long long ull;

const int inf = 1e9 + 5;
const long double PI = 3.141592653589793;

void solve(){
  int a;
  cin >> a;
  cout << a + a*a + a*a*a << endl;
  return;
}  
signed main(){
  fast;
  int t;
  t = 1;
  //cin>>t;
  while(t--){
    solve();
  }
}



Measured memory_bytes: 3648
import java.util.Arrays;
import java.util.Scanner;

//All Numbers Lead to 6174
public class Main{

	int next(int n){
		String r = n+"";
		while(r.length()<4)r+="0";
		char[] s = r.toCharArray(), l = new char[4];
		Arrays.sort(s);
		for(int i=0;i<4;i++)l[i]=s[3-i];
		return Integer.parseInt(new String(l))-Integer.parseInt(new String(s));
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			if(n%1111==0){
				System.out.println("NA"); continue;
			}
			int res = 0;
			while(n!=6174){
				n = next(n); res++;
			}
			System.out.println(res);
		}
	}
	
	void debug(Object...o){
		System.out.println(Arrays.deepToString(o));
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main(){
    int N;
    cin >> N;
    vector<int> h(N+1);
    for(int i = 1;i <= N;i++)   cin >> h[i];
    h[0] = h[1];
    vector<int> dp(N+1);
    dp[0] = 0;
    dp[1] = 0;
    for(int i = 2;i <= N;i++){
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[N] << endl;
}

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

int main(void) {
	string s;
	int alpha[3] = { 0 };
	cin >> s;
	for (int i = 0;i < 3;i++)
		alpha[s[i] - 'a']++;
	if (alpha[0] == 1 && alpha[1] == 1 && alpha[2] == 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
import itertools 

n = int(input())

d = defaultdict(int)

for i in range(n):
    s = input()
    d[s[0]] += 1

l = ["M", "A", "R", "C", "H"]

c = itertools.combinations(l, 3)

s = 0

for x in c:
    s += d[x[0]] * d[x[1]] * d[x[2]]

print(s)


Measured memory_bytes: 9508
N,K=map(int,input().split())
S=[0]*N
for i in range(0,N):
    if i+1>=K:
        S[i]=1
    else:
        for j in range(100):
            if (i+1)*(2**(j-1))>=K:
                S[i]=1/(2**(j-1))
                break
goukei=sum(S)
print(goukei/N)

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

typedef long long ll;
int dp[201][201][201];

int gcd(int a,int b)
{
  if (a%b==0)
    return b;
  else
    return gcd(b,a%b);
}

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

  int tmp;
  ll ans = 0L;
  for(int i=1;i<=l;i++){
    for(int j=i;j<=l;j++){
      for(int k=j;k<=l;k++){
        tmp = gcd(i, gcd(j,k));
        dp[i][j][k] = tmp;
        dp[i][k][j] = tmp;
        dp[j][i][k] = tmp;
        dp[j][k][i] = tmp;
        dp[k][i][j] = tmp;
        dp[k][j][i] = tmp;
      }
    }
  }

  for(int i=1;i<=l;i++){
    for(int j=1;j<=l;j++){
      for(int k=1;k<=l;k++){
        ans += dp[i][j][k];
      }
    }
  }

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


Measured memory_bytes: 34728
#include<stdio.h>
#include<iostream>

using namespace std;

int main(){


int S;
int h,m,s;

cin>>S;

h=S/3600;
S-=h*3600;

m=S/60;
s=S-(m*60);

cout<<h<<':'<<m<<':'<<s<<endl;

return 0;

}

Measured memory_bytes: 1160
use proconio::input;
// use proconio::marker::{Bytes, Chars};

fn main() {
    input! {
        n: usize,
        a: [i128; n],
    }

    let mut last = a[0];
    let mut result = 0;

    for i in 1..n {
        result += a[i] * last;
        result = result % (1000000007);
        last += a[i];
    }

    println!("{}", result);
}



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

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

	int answer = a;
	if (a == b) answer = c;
	if (a == c) answer = b;
	if (b == c) answer = a;

	cout << answer << endl;

	return 0;
}


Measured memory_bytes: 256
N = gets.chomp.to_i
buyable_flag = false

(0..25).each do |a|
  (0..14).each do |b|
    if N - (a*4 + b*7) == 0
	  buyable_flag = true
      break
    end
  end
end

puts buyable_flag ? "Yes" : "No"

Measured memory_bytes: 1788
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;

#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

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

    int n, d;
    cin >> n >> d;

    vvi xy(n, vi(2));
    rep(i, n) {
        cin >> xy[i][0] >> xy[i][1];
    }

    int num = 0;
    rep(i, n) {
        if(sqrt(pow(xy[i][0], 2) + pow(xy[i][1], 2)) <= d) {
            num++;
        }
    }

    cout << num << endl;
}

Measured memory_bytes: 14292
#include<stdio.h>
int main(void){
int a,b,c,d,e;
scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
if(c-e<0 || d-e<0 || c+e>a || d+e>b){
printf("No\n");
}else{
printf("Yes\n");
}
return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <limits.h>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main() {
    int n, a[105], max = 0, min = 1000000000;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        if (a[i] < min) min = a[i];
        if (a[i] > max) max = a[i];
    }
    cout << max - min;
    return 0;
}

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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << unitbuf;
        cout << fixed << setprecision(20);
    };
} init;

int N;
int D[110000], n[110000], d[110000];
unordered_map<int, int> mp;
vint ans;
signed main() {
    cin >> N;
    for (int i = 1; i <= N; i++) {cin >> D[i]; n[i] = 1; mp[D[i]] = i;};
    sort(D + 1, D + N + 1); reverse(D + 1, D + N + 1);
    for (int i = 1; i <= N - 1; i++) {
        int s = mp[D[i]];
        int t = mp[D[i] - N + 2 * n[s]];
        n[t] += n[s];
        d[t] += d[s] + n[s];
        ans.push_back(s); ans.push_back(t);
    }
    if (n[mp[D[N]]] != N || d[mp[D[N]]] != D[N]) {
        cout << -1 << endl;
        return 0;
    }
    for (int i = 0; i < 2 * (N - 1); i += 2) {
        cout << ans[i] << " " << ans[i + 1] << endl;
    }

}

Measured memory_bytes: 11548
#include <iostream>
using namespace std;
int main()
{
	int a[3];
	int i;
	int max=-1;
	for(i=0; i<3; i++)
	{
		cin>>a[i];
		if(a[i]>max) max=a[i];
	}
	int sum=max*3-a[0]-a[1]-a[2];
	if(sum%2==1) sum+=3;
	cout<<sum/2;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int n, q, i, j, k=0;
	int right, left, mid;
	
	scanf("%d", &n);
	int a[n];
	for(i = 0; i < n; i++)scanf("%d", &a[i]);
	scanf("%d", &q);
	int b[q];
	for(j = 0; j < q; j++)scanf("%d", &b[j]);
	
	for(i = 0; i < q; i++){
		left = 0;
		right = n;
		
		while(left < right){
			mid = (left+right)/2;
			if(b[i] == a[mid]){
				k++;
				break;
			}
			if(b[i] < a[mid])right = mid;
			else left = mid+1;
		}
	}
	
	printf("%d\n", k);
	
	return 0;
}


Measured memory_bytes: 2252
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/icl/interval_map.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
namespace icl = boost::icl;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> N;
  vector<ll> r(65536, 0);
  
  REP(x,100)
  REP(y,100)

  REP(z,100) {
    x++;y++;z++;
    auto res = x*x+y*y+z*z+x*y+y*z+z*x;
    if (res < r.size())
      r[res]++;
    x--;y--;z--;
  }



  for (auto i : bst::irange((ll)1, N+1))
    cout << r[i] << endl;
}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}



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

int n, W;
int weight[110], value[110];

int dp[110][10010];

int main() {
    cin >> n >> W;
    for (int i = 0; i < n; i++) {
        cin >> value[i] >> weight[i];
    }

    for (int w = 0; w <= W; w++) {
        dp[0][w] = 0;
    }

    for (int i = 0; i < n; i++) {
        for (int w = 0; w <= W; w++) {
            if (w >= weight[i]) {
                dp[i+1][w] = max(dp[i][w], dp[i+1][w-weight[i]]+value[i]);
            } else {
                dp[i+1][w] = dp[i][w];
            }
        }
    }

    cout << dp[n][W] <<endl;
}


Measured memory_bytes: 7040
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;

#define INF 0x3f3f3f3f

int main() {
    int n, x;
    while (scanf("%d%d", &n, &x) != EOF) {
        int res = INF;
        int tmp; scanf("%d", &tmp);
        res = abs(tmp - x); x = tmp; n--;
        while (n--) {
            scanf("%d", &tmp);
            res = __gcd(res, abs(tmp - x));
            x = tmp;
        }
        printf("%d\n", res);
    }
    return 0;
}


Measured memory_bytes: 128
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,m=map(int,input().split())
    X=[int(_) for _ in input().split()]
    if m<=n:
        print(0)
    else:
        X.sort()
        XX=[0]*(m-1)
        for i in range(m-1):
            XX[i]=X[i+1]-X[i]
        XX.sort(reverse=True)
        print(X[-1]-X[0]-sum(XX[:n-1]))

if __name__=='__main__':
    main()

Measured memory_bytes: 14344