akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 
typedef long long ll;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define DBGV(v,n) forn(i,n) cout << v[i] << " "; cout << endl
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl
#define MAXN 2005
#define INF 1000000007
 
vector <int> divisores(int n)
{
	vector <int> ans;
	forr(i,1,sqrt(n)+1)
	{
		if(n%i == 0) 
		{
			ans.pb(i);
			if(i*i != n) ans.pb(n/i);
		}
		
	}
	sort(all(ans));
	return ans;
}
 
int main()
{ 
	FIN;
	
	#ifdef input
		//freopen("test1.txt", "r", stdin);
	#endif
	
	vector <int> visto(1000005,0);
	int n;
	cin >> n;
	vector <int> v(n);
	forn(i,n) cin >> v[i];
	forn(i,n) visto[v[i]]++;
	int ans = 0;
	forn(i,n)
	{
		vector <int> div = divisores(v[i]);
		bool d=false;
		visto[v[i]]--;
		for(auto u : div)
		{
			if(visto[u]>0) d=true;
		}
		if(d==true) ans++;
		visto[v[i]]++;
	}
	cout << n-ans << endl;
	return 0;
}

Measured memory_bytes: 7964
import numpy as np
import math

n = int(input())
lst = list(map(int, input().split()))

mn = np.mean(lst)
avg = np.ceil(mn)
avg2 = np.floor(mn)

ans = 0
ans2 = 0
for _ in lst:
    ans2 += (_ - avg2) ** 2
    ans += (_ - avg) ** 2
print(int(min(ans, ans2)))

Measured memory_bytes: 12508
n,m=gets.chomp.split(" ").map{|s| s.to_i}
a=Array.new
ans=0
for i in 0..n-1
  a[i]=gets.chomp.split(" ").map{|s| s.to_i}
end
a.sort!
for i in 0..n-1
  if m>=a[i][1]
    ans+=a[i][0]*a[i][1]
    m-=a[i][1]
  else
    ans+=m*a[i][0]
    break
  end
end
puts ans


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long ans = 1;
  const long long mod = 1e9 + 7;
  for (int i = 1; i <= n; i++) {
    ans *= i;
    ans %= mod;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod 1000000007
#define int long long int

int32_t main() {
  FASTIO;
  int n; cin >> n;
  cout << 2*n*3.1415926535 << endl;
  return 0;
}

Measured memory_bytes: 3804
#!/usr/bin/env ruby

n  = STDIN.gets.chomp
x  = STDIN.gets.chomp.split(/\s/).map { |e| e.to_i }

ans = 1000000000
for p in x.min .. x.max do
	cost = 0
	for i in x do
		cost = cost + (p - i)**2
	end
	if ans > cost
		ans = cost
	end
end

puts ans


Measured memory_bytes: 1916
def dudge(k):
    for i in range(n):
        p = (k >> i) % 2
        if p == 0: continue

        for claim in xy[i]:
            x = claim[0]
            y = claim[1]

            truth = (k >> x-1) % 2
            if truth == 1 and y == 0:
                return False
            elif truth == 0 and y == 1:
                return False
    return True


n = int(input())

xy = []
for i1 in range(n):
    ai = int(input())
    xy.append([])

    for i2 in range(ai):
        xi,yi = map(int, input().split())
        xy[i1].append((xi, yi))

result = 0
for k in range(1 << n):
    if dudge(k):
        l = [i for i in range(n) if (k >> i) % 2 == 1]
        cnt = 0
        result = max(result, len(l))

print(result)


Measured memory_bytes: 3064
from collections import deque

N = int(input())
S = input()

new_s = []
flag = True
while flag:

    if len(S) == 1:
        new_s = [1]
        break

    new_s = []
    flag = False
    for i in range(len(S)-1):
        current_char = S[i]

        if current_char == S[i+1]:
            flag = True
            continue
            
        else:
            new_s.append(current_char)

    new_s.append(S[-1])
    S = new_s



print(len(new_s))


Measured memory_bytes: 4564
#include<bits/stdc++.h>
#define ll long long
int M=1e9+7;
using namespace std;
int main()
{
	ll n,cnt=0,ans=0;
	cin>>n;
	ll lim=sqrt(n);
	for(ll i=1;i<=lim;i++ )
	{
		for(ll j=i;j<n;j++)
		{
			ll temp=i*j;
			if(temp<n)
			{
				if(i==j)
				ans++;
				else
				ans+=2;
			}
			else
			break;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
        #define int long long
        //#define endl '\n'
        #define modulo 1000000007
        ///I am the backupguy!
        using namespace std;
        int32_t main()
        {
        iostream::sync_with_stdio(0);
        cin.tie(0);
        vector<pair<pair<string,int>,int>>lolz;
        int n;
        cin>>n;
        for(int i=0;i<n;i++){
        string s;
        int d;
        cin>>s>>d;
        lolz.push_back({{s,-d},i});
        }
        sort(lolz.begin(),lolz.end());
        for(int i=0;i<n;i++){
        cout<<lolz[i].second+1<<endl;
        }
        return 0;
    }


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

using namespace std;

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

    int n, k;
    cin >> n >> k;
    set<int> s;
    while (k--) {
        int d;
        cin >> d;
        while (d--) {
            int x;
            cin >> x;
            s.insert(x);
        }
    }
    cout << n - s.size() << '\n';

    return 0;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		if (a == 1){a += 13;}
		if (b == 1){b += 13;}
		if (a > b){
			System.out.println("Alice");
		}else if (a < b){
			System.out.println("Bob");
		}else{
			System.out.println("Draw");
		}
		scanner.close();
	}
}


Measured memory_bytes: 9804
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int count = 0;
    while(A >= B){
        B *= 2;
        count++;
    }
    while(B >= C){
        C *= 2;
        count++;
    }
    if(count <= K) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

class card
{
public:
    char c, suit;
    int value;
    card();
    void input();
};

card::card(){}

void card::input(){
    cin >> suit >> c;
    value = c - '0';
}

void show(card* a, int n)
{
    for(int i = 0; i < n - 1; i++) cout << a[i].suit << a[i].value << " ";
    cout << a[n - 1].suit << a[n - 1].value << endl;
}

void BubbleSort(card* a, int n)
{
    int i;
    card z;
    bool inv = true;

    while(inv){
        inv = false;
        for(i = n - 1; i > 0; i--){
            if(a[i].value < a[i - 1].value){
                z = a[i];
                a[i] = a[i - 1];
                a[i - 1] = z;
                inv = true;
            }
        }
    };
    show(a, n);
    cout << "Stable" << endl;
}

void SelectionSort(card* a, int n)
{
    int i, j, minj;
    card z;

    for(i = 0; i < n; i++){
        minj = i;
        for(j = i; j < n; j++){
            if(a[minj].value > a[j].value) minj = j;
        }
        if(i < minj){
            z = a[minj];
            a[minj] = a[i];
            a[i] = z;
        }
    }
    show(a, n);
}

bool IsStable(card* a, card* b, int n)
{
    for(int i = 0; i < n; i++){
        if(a[i].suit != b[i].suit) return false;
    }
    return true;
}

int main()
{
    card A[36], B[36];
    int i, N;
    cin >> N;
    for(i = 0; i < N; i++){
        A[i].input();
        B[i] = A[i];
    }

    BubbleSort(A, N);
    SelectionSort(B, N);
    if(IsStable(A, B, N)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }

    return 0;
}

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

using namespace std;

int main(){
	int water;
	while(cin >> water){
		int ans = 1150;
		if(water == -1) break;
		int i = 10;
		while(water != i){
			if(water < 10) break;
			if(i < 20){
				ans += 125;
				++i;
			}
			else if(i >= 20 && i < 30){
				ans += 140;
				++i;
			}
			else if(i >= 30){
				ans += 160;
				++i;
			}
		}
		cout << 4280 - ans << endl;
 	}
	return 0;
}

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

using namespace std;
#define rep(i,n) for (int i =0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;

int main() {
    int N,a;
    cin >>N;
    
    vector<ll> L(N);
    int ans=0;

    rep(i,N)cin >>L[i];
    if(N<3){
        cout <<0;
        return 0;}
    sort(L.begin(),L.end());
    rep(i,N-2){
        rep(j,N-i-2){
            rep(k,N-i-j-2){
                a=0;
                if(L[i]==L[i+j+1]||L[i]==L[i+j+k+2]||L[i+j+k+2]==L[i+j+1])a=1;
                if(L[i]+L[i+j+1]<=L[i+j+k+2])a=1;
                
                if(a==0){ans++;
                //cout <<L[i]<<" "<<L[i+j+1]<<" "<<L[i+j+k+2]<<endl;
                }
            }
        }
    }
    
cout <<ans;
return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll gcd(ll a, ll b) {
	if (a < b) return gcd(b, a);
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

int main(int argc, char **argv) {
	ll x;
	cin >> x;
	cout << (360/gcd(x, 360)) << endl;
	return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#include<queue>
#include<map>
#include<vector>
typedef long long ll;
using namespace std;
int n,tt;
int t[200008];
int main() {
	scanf("%d%d",&n,&tt);
	for(int i=0;i<n;i++)scanf("%d",t+i);
	int sum=tt;
	for(int i=0;i<n-1;i++){
		sum+=min(tt,t[i+1]-t[i]);
	}
	printf("%d\n",sum);
}


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

string a,b;

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>a>>b;

string s=a+b;
int num=stoi(s);

for(int i=1; i<=2000; i++){
	for(int j=1; j<=2000; j++){
		if(i==j){
			if(i*j==num){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
}

cout<<"No"<<endl;

}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
typedef long long ll;

using namespace std;

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

    if (a < 10) {
        b = b + (100*(10-a));
    }

    cout << b << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


ll cnting(vector<int> &a){
  int n = a.size();
  ll res = 0;
  for (int i=0; i<n; i++) for (int j=i+1; j<n; j++) if (a[i] > a[j]) res++;
  return res;
}

int main() {
  int N; cin >>N;
  ll K; cin >>K;
  vector<int> A(N); rep(i, N) cin >>A[i]; rep(i, N) A[i]--;
  ll res = cnting(A) % MOD;
  res = (res * K) % MOD;
  vector<ll> nums(2000); rep(i, N) nums[A[i]]++;
  ll tmp = 0;
  for (int i=0; i<2000; i++){
    // () * (K-1) + () * (K-2) + ...
    // = () * K(K-1)/2
    res += K*(K-1)/2 % MOD * nums[i] % MOD * tmp % MOD;
    res %= MOD;
    tmp += nums[i];
    tmp %= MOD;
  }
  cout <<res <<endl;

}

Measured memory_bytes: 384
import io
import math

n,m=map(int,input().split())
L=[]
x=m/n

for i in range(1,min(int(x)+1,int(m**0.5)+1)):
    if m%i==0:
        if i<=x:
            L.append(i)
        if m//i<=x:
            L.append(m//i)
print(max(L))

Measured memory_bytes: 3188
#include <stdio.h>
 
int main() {

    int r, c;
    scanf("%d %d", &r, &c);
    int matrix[r+1][c] = {};

    int last[c] = {};

    for (int i=0; i<r; i++)
    {
        for (int j=0; j<c; j++)
        {
            scanf("%d", &matrix[i][j]);
            last[j] += matrix[i][j];
        }
    }

    // 合計行
    for (int j=0; j<c; j++)
    {
        matrix[r][j] = last[j];
    }

    // 合計列
    for (int i=0; i<(r+1); i++)
    {
        int tmp = 0;
        for (int j=0; j<c; j++)
        {
            printf("%d ", matrix[i][j]);
            tmp += matrix[i][j];
        }
        printf("%d\n", tmp);
    }
    return 0;
}


Measured memory_bytes: 2712
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
#include <omp.h>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}



void solve(long long K){
    long long cnt = 0;
    for(int i = 1;i <= K;i += 2){
        for(int q = 2;q <= K;q += 2){
            cnt++;
        }
    }
    cout << cnt << endl;
    return;
}

// Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	int sum = A + B + C;
	int max_num = max(A, max(B, C));
	if (sum % 2 == max_num % 2) {
		cout << (max_num * 3 - sum) / 2;
	}
	else {
		cout << ((max_num+1) * 3 - sum) / 2;
	}

	system("pause");
	return 0;
}

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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int K;
  string S;
  cin >> K >> S;
  if(S.size() <= K){
    cout << S <<endl;
  } else{
    cout << S.substr(0, K) << "..." <<endl;
  }
}


Measured memory_bytes: 3664
using System;

namespace ConsoleApp18
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            switch (n % 10)
            {
                case 1:
                    Console.WriteLine("pon");
                    break;
                case 2:
                    Console.WriteLine("hon");
                    break;
                case 3:
                    Console.WriteLine("bon");
                    break;
                case 4:
                    Console.WriteLine("hon");
                    break;
                case 5:
                    Console.WriteLine("hon");
                    break;
                case 6:
                    Console.WriteLine("pon");
                    break;
                case 7:
                    Console.WriteLine("hon");
                    break;
                case 8:
                    Console.WriteLine("pon");
                    break;
                case 9:
                    Console.WriteLine("hon");
                    break;
                case 0:
                    Console.WriteLine("pon");
                    break;
            }
        }
    }
}

Measured memory_bytes: 27392
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll mod = 1e9+7;
ll INF = 1e17;
/*ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}*/
/*ll power(ll a,ll b,ll p)
{
	ll res=1;
	a%=p;
	while(b>0)
	{
		if(b&1)
		res=res*a%p;
		a=a*a%p;
		b>>=1;
	}
	return(res);
}*/
/*void dfs(ll x)
{
	vis[x]=true;
	for(ll i=0;i<v[x].size();i++)
	{
		if(vis[v[x][i]]==false)
		dfs(v[x][i]);
	}
}*/
/*ll b_search(ll arr[],ll n,ll s)
{
	ll l=0,r=n-1;
	while(l<=r)
	{
		ll mid=l+(r-l)/2;
		if(arr[mid]==s)
		return(mid);
		if(arr[mid]<s)
		l=mid+1;
		else
		r=mid-1;
	}
	return(-1);
}*/
 
void solve()
{
	ll n,k;
	cin>>n>>k;
	cout<<min(n%k,abs(n%k-k))<<endl;
}
 
int main()
{
	IOS
	ll t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
    return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

string s;

int main(){
  cin >> s;

  int l = s.size();
  REP(i, 8) {
    if(s.substr(0, i) + s.substr(l - (7 - i), 7 - i) == "keyence") {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;

  return 0;
}


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

int main() {
  int n, x, t, ko, koko;
  cin >> n >> x >> t;
  ko = n / x;
  koko = n % x;
  if(koko > 0){
    ko++;
  }
  cout << ko * t << endl;
}


Measured memory_bytes: 3624
m, f, r = map(int, input().split())
while m >= 0 or f >= 0 or r >= 0:
	if m < 0 or f < 0 or m + f < 30:
		print("F")
	elif m + f >= 80:
		print("A")
	elif m + f >= 65:
		print("B")
	elif m + f >= 50:
		print("C")
	elif m + f >= 30:
		if r >= 50:
			print("C")
		else:
			print("D")
	m, f, r = map(int, input().split())



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

using namespace std;

int main(){

    long long a,b,c,d;
    long long ans;

    cin >> a >> b >> c >> d;

    long long tmp1 = a * c;
    long long tmp2 = a * d;
    long long tmp3 = b * c;
    long long tmp4 = b * d;
    
    ans = tmp1;

    if(ans < tmp2){
        ans = tmp2;
    }

    if(ans < tmp3){
        ans = tmp3;
    }

    if(ans < tmp4){
        ans = tmp4;
    }

    cout << ans << endl;

}

Measured memory_bytes: 3632
#include <stdio.h>
#include <functional>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
using namespace std;

const int N = 2e5 + 10;

pair<int, pair<int,int>> roadworks[N];
set<int> start_time;
map<int, int> ans;
int d[N];

int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d", &roadworks[i].second.first, &roadworks[i].second.second, &roadworks[i].first);
    roadworks[i].second.first -= roadworks[i].first;
    roadworks[i].second.second -= roadworks[i].first;
  }
  sort(roadworks, roadworks + n);
  for (int i = 0; i < q; i++) {
    scanf("%d", d + i);
    start_time.insert(d[i]);
    ans[d[i]] = -1;
  }
  for (int i = 0; i < n; i++) {
    int s = roadworks[i].second.first;
    int f = roadworks[i].second.second;
    int x = roadworks[i].first;
    if (start_time.empty()) {
      break;
    }
    auto it = start_time.lower_bound(s);
    vector<set<int>::iterator> removed;
    while (it != start_time.end() && *it < f) {
      ans[*it] = x;
      removed.push_back(it);
      it++;
    }
    for (int i = 0; i < (int) removed.size(); i++) {
      start_time.erase(removed[i]);
    }
  }
  for (int i = 0; i < q; i++) {
    printf("%d\n", ans[d[i]]);
  }
  return 0;
}

Measured memory_bytes: 24324
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>

using std::cin;
using std::cout;
using std::sqrt;
using std::pow;
using std::vector;
using std::pair;

typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
typedef unsigned long ul;

double solve(vpii &v);
double solverHelper(vpii &v, vpii &s);
double distance(int x1, int y1, int x2, int y2);
int factorial(int n);

int main() {
    int N, x, y;
    vpii v;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> x >> y;
        v.push_back(std::make_pair(x, y));
    }

    double ans = solve(v);
    cout << std::setprecision(12) << ans / factorial(N) <<  "\n";
    return 0;
}

double  solve(vpii &v) {
    vpii s;
    return solverHelper(v, s);
}

double solverHelper(vpii &v, vpii &s) {
    static double ans = 0.0;
    if (v.empty()) {
        double dis = 0.0;
        for (ul i = 0; i < s.size() - 1; ++i) {
            dis += distance(s[i].first, s[i].second, s[i+1].first, s[i+1].second);
        }
        ans += dis;
    } else {
        for (ul i = 0; i < v.size(); ++i) {
            pii t = v.at(i);
            s.push_back(t);
            v.erase(v.begin() + i);

            solverHelper(v, s);

            s.pop_back();
            v.insert(v.begin() + i, t);
        }
    }
    return ans;
}

double distance(int x1, int y1, int x2, int y2) {
    return sqrt(pow((x1 - x2), 2) + pow(y1 - y2, 2));
}

int factorial(int x) {
    int ans = 1;
    for (int i = 1; i <= x; ++i) {
        ans *= i;
    }
    return ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;vector<int>v(N);
  for(int i=0;i<N;i++)cin>>v.at(i);
  sort(v.begin(),v.end());
  double x=v.at(0);
  for(int i=1;i<N;i++)x=(x+v.at(i))/2;
  printf("%lf\n",x);
}

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

int main(void){
  bool memo[101] = {0};
  int in, count = 0;
  for(int i = 0; i < 3; i++){
    cin >> in;
    if(memo[in])continue;
    memo[in] = true;
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import math
from functools import reduce
L = 10**6 + 1
n = int(input())
a_list = list(map(int, input().split()))
memo = [0] * L

for a in a_list:
    memo[a] += 1

for i in range(2, L):
    if sum(memo[i::i]) > 1:
        if reduce(math.gcd, a_list) == 1:
            print("setwise coprime")
            exit()
        else:
            print("not coprime")
            exit()

print("pairwise coprime")


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

using namespace std;

int ps[3][4005];
char s[4005];

int f(char c) {
	if (c == 'R') return 0;
	else if (c == 'G') return 1;
	return 2;
}

int main() {
	int n;
	scanf("%d", &n);
	scanf("%s", s);
	
	for (int i = 0; i < n; i++) {
		ps[f(s[i])][i]++;
		
		if (i - 1 >= 0) {
			for (int j = 0; j < 3; j++) {
				ps[j][i] += ps[j][i - 1];
			}
		}
	}
	
	long long res = 0;
	
	for (int i = 1; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			if (s[i] == s[j]) continue;
			int idx = 3;
			idx -= f(s[i]) + f(s[j]);
			long long add = ps[idx][i - 1];
			int diff = j - i;
			if (i - diff >= 0 && f(s[i - diff]) == idx) add--;
			
			res += add;
		}
	}
	
	printf("%lld\n", res);
}


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

int main() {
  
  long long N;
  N = 5;
  vector<long long> A(N);
  
  for (int i=0; i<N; i++) {
    cin >> A[i];
    
    if (A[i] == 0) {
      cout << i+1 << endl;
      return 0;
    }
  }
  
  
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
#define PER(i,n) for(int i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int a, p;
  cin >> a >> p;
  int ans = (a*3+p) / 2;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#define ll long long
#define INF 1000000000
#define mod 1000000007
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=true;

set<string>se;

void divide(string s){
  string a;
  a=s[0];
  s.erase(s.begin());
  while(s.size()){
    se.insert(a+s);
    se.insert(s+a);
    reverse(all(a));
    //if(debug)cout<<s<<"+"<<a<<endl;
    se.insert(s+a);
    se.insert(a+s);
    reverse(all(s));
    se.insert(s+a);
    se.insert(a+s);
    reverse(all(a));
    //if(debug)cout<<s<<"+"<<a<<endl;
    se.insert(s+a);
    se.insert(a+s);
    reverse(all(s));
    a=a+s[0];
    s.erase(s.begin());
    //cout<<s<<endl;
  }
}


int main(){
  int m;
  string s;
  cin>>m;
  rep(i,m){
    cin>>s;
    divide(s);
    cout<<se.size()<<endl;
    se.clear();
  }

  return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int>  t(n+1),x(n+1),y(n+1);

    t.at(0) = x.at(0) = y.at(0) = 0;
    
    for(int i=0;i<n;i++){
        cin >> t.at(i+1) >> x.at(i+1) >> y.at(i+1);
    }

    bool can = true;
    for(int i=0;i<n;i++){
        int dt = t.at(i+1) - t.at(i);
        int dist = abs(x.at(i+1)-x.at(i)) + abs(y.at(i+1)-y.at(i));
        if(dt < dist) can = false;
        if(dt%2 != dist%2) can = false;
    }
    if(can) cout<<"Yes"<< endl;
    if(!can) cout<<"No"<<endl;
}

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

using namespace std;

#ifdef WIN32
	#define I64 "%I64d"
#else
	#define I64 "%lld"
#endif

typedef long long ll;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
#define sz(s) (int(s.size()))
#define fname "a"
#define MAXN 20002

int n;
int a[2][MAXN];
int d[2][MAXN];


int main()
{
	#ifdef LOCAL
	freopen(fname".in", "r", stdin);
	freopen(fname".out", "w", stdout);
	#endif

	scanf("%d", &n);
	for (int i = 0; i < 2; ++i)
		for (int j = 0; j < n; ++j) {
			scanf("%d", &a[i][j]);
			if (i) d[i][j] = max(d[i][j], d[i - 1][j]);
			if (j) d[i][j] = max(d[i][j], d[i][j - 1]);
			d[i][j] += a[i][j];
		}

	cout << d[1][n - 1] << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, temp;
  string s;
  cin >> n;
  
  temp = 0;
  while (n > 0) {
    cin >> s;
    if (s == "Y")
      temp = 1;
    n--;
  }
  if (temp == 1)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}

Measured memory_bytes: 256
import sys, math, collections, heapq, itertools
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b
  
def solve():
    file = sys.stdin.readline #single: int(file()), line: map(int, file().split())
    INF = 10 ** 25
    mod = 7 + 10 ** 9
    P, Q, R = map(int, file().split())
    print(P + Q + R - max(P, Q, R))
    return 0
  
if __name__ == "__main__":
    solve()

Measured memory_bytes: 3700
def main():
    n = map(int, input().split())
    inlis = list(map(int, input().split()))
    sortlis = sorted(inlis)

    tmp = 0
    for i in range(len(inlis)):
        if inlis[i] != sortlis[i]:
            tmp += 1
    if tmp == 0 or tmp == 2:
        print("YES")
    else:
        print("NO")

    
if __name__ == "__main__":
    main()


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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

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

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

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

signed main(){
	int n=read(),k=read();
	string s=readString();
	int g=0,q;
	{
		REP(i,n){
			bool w=((s[i]=='A')^(i&1));
			if(w){
				if(k>=2){
					g++;
					k-=2;
					if(k==0)q=0;
				}else{
					k--;
					q=1;
				}
			}else{
				k--;
				g++;
				if(k==0)q=0;
			}
			if(k==0)
				break;
		}
		if(k){
			if(n^1){
				g+=k/2;
				q=k&1;
			}
			else{
				g+=k;
				q=0;
			}
		}
	}
	string t;
	REP(i,n)
		if(i+g<n)
			t+=((g&1)^(s[i+g]=='A'))?'A':'B';
		else
			t+=((n-1-i)&1)?'B':'A';
	if(q){
		if(t[0]=='A')
			t[0]='B';
		else{
			REP(i,n-1)
				t[i]=t[i+1]=='A'?'B':'A';
			t[n-1]='A';
		}
	}
	cout<<t<<endl;
}


Measured memory_bytes: 2948
import sys
INF = 10 ** 10
MOD = 10 ** 9 + 7
from functools import lru_cache
sys.setrecursionlimit(100000000)

def f(x):
    if x%2 == 0:
        return x//2
    else:
        return 3 * x + 1

def main():
    s = int(input())
    a = set()
    a.add(s)
    x = s
    i = 2
    while True:
        y = f(x)
        if y in a:
            break
        a.add(y)
        x = y
        i += 1
    
    print(i)

if __name__ =='__main__':
    main()    

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
typedef long long ll;
 
int main()
{
	int n, k;
	cin >> n >> k;
	if (n < 2*k-1) cout << "NO" << endl;
	else cout<< "YES" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;

// #define DEBUG

class Unionfind
{
    vector<int> p;

public:
    Unionfind(int n);
    int find(int x);
    void unite(int x, int y);
    bool match(int x, int y);
};

Unionfind::Unionfind(int n)
{
    for (int i = 0; i < n; i++)
    {
        p.push_back(i);
    }
}

int Unionfind::find(int x)
{
    while (p[x] != x)
    {
        p[x] = p[p[x]];
        x = p[x];
    }
    return x;
}

bool Unionfind::match(int x, int y)
{
    return (find(x) == find(y)) ? true : false;
}

void Unionfind::unite(int x, int y)
{
    x = Unionfind::find(x);
    y = Unionfind::find(y);
    if (x != y)
    {
        p[x] = y;
    }
}

int main()
{
#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif
    int n, m, x;
    set<int> a, b, c;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        a.insert(x);
    }
    cin >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> x;
        b.insert(x);
    }

    for (int i = 0; i < m; i++)
    {
        cin >> x;
        c.insert(x);
    }
    for (auto itr = a.begin(); itr != a.end(); itr++)
    {
        c.insert(*itr);
    }
    for (auto itr = b.begin(); itr != b.end(); itr++)
    {
        c.insert(*itr);
    }
    for (auto itr = c.begin(); itr != c.end(); itr++)
    {
        cout << *itr << endl;
    }

    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)


Measured memory_bytes: 40588
#include <bits/stdc++.h>
#define int long long
#define N 2010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
typedef pair<int,int> P;
int n,Z,W;
int A[N];

int mem[N][N][2];
bool used[N][N][2];
int dfs(int idx1,int idx2,int cnt,int turn,int X,int Y){
  //cout<<idx1<<" "<<idx2<<" "<<cnt<<" "<<turn<<" "<<X<<" "<<Y<<endl;
  if(idx1 == n || idx2 == n) return abs(X - Y);
  if(used[idx1][idx2][cnt]) return mem[idx1][idx2][cnt];
  used[idx1][idx2][cnt] = 1;

  int res = 0;  
  int idx = max(idx1,idx2);
  if(turn == 0){
    res = -INF;    
    Max(res,dfs(idx+1,idx2,1,turn,A[idx],Y));
    if(cnt) Max(res,dfs(idx1,idx2,0,!turn,X,Y));
  }
  else if(turn == 1) {
    res = INF;
    Min(res,dfs(idx,idx+1,1,turn,X,A[idx]));
    if(cnt) Min(res,dfs(idx1,idx2,0,!turn,X,Y));
  }
  else assert(0);
  return mem[idx1][idx2][cnt] = res;
}

signed main(){
  cin>>n>>Z>>W;
  for(int i=0;i<n;i++) {
    cin>>A[i];
  }  

  cout<<dfs(0,0,0,0,Z,W)<<endl;
  return 0;
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,K,T,U,V,L;
int D[222];
signed main(){
    cin>>N>>K>>T>>U>>V>>L;
    rep(i,N)cin>>D[i];

    int cur=0;
    double en=0.0,ans=0.0;
    rep(i,L){
        if(D[cur]==i){
            cur++;
            en+=T;
            chmin(en,1.0*(K+1)*T);
        }
        if(en*V>=1){
            en-=1.0/V;
            ans+=1.0/V;
        }
        else{
            ans+=en+(1.0-en*V)/U;
            en=0.0;
        }
    }
    printf("%.20f\n",ans);
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int n, m;
  cin >> n >> m;
  vi a(m);
  rep(i,m) cin >> a[i];
  sort(all(a));
  int tot = 0;
  rep(i,m) tot += a[i];
  if(tot > n) {
    cout << -1 << endl;
  }
  else {
    cout << n-tot << endl;
  }
}

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

int main() {
	
	double N, M;
	double A, B, C;
	cin >> N >> M;
	A = N + M;
	B = N - M;
	C = N * M;
	vector<double> v;
	v = {A,B,C};
	

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

	cout << v.at(2) << endl;
	
	}

Measured memory_bytes: 256
import math
from collections import deque
from collections import defaultdict

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq

s = readChar()
d = defaultdict(int)

for i in s:
	d[i]+=1

for i in d.values():
	if i!=1:
		print("no")
		exit()
print("yes")

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  int N;
  cin >> N;
  vi A(N), dA(N, 0), sdA(N+1, 0);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
    if(i == 0) dA.at(i) = abs(A.at(i));
    else{
      dA.at(i) = abs(A.at(i) - A.at(i-1));
    }
  }
  for(int i = 0; i < N; i++){
    sdA.at(i+1) = sdA.at(i) + dA.at(i);
  }
  
  //cout << sdA.at(N) - sdA.at(0) << endl;
  
  for(int i = 0; i < N; i++){
    int ans = 0;
    if(i != 0){
      ans += sdA.at(i) - sdA.at(0);
    }

    if(i != 0 && i != N-1){
      ans += abs(A.at(i+1) - A.at(i-1));
    }
    else if(i == 0) ans += abs(A.at(i+1));
    
    if(i != N-1){
      ans += sdA.at(N) - sdA.at(i+2);
      ans += abs(A.at(N-1));
    }
    else ans += abs(A.at(N-2));

    cout << ans << endl;

  } 
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main (){
    int N,M;
    cin >> N >> M;
    vector<int> A(M);
    rep(i, M){
        cin >>A.at(i);
    }
    int sum =0 ;
    rep(i,M){
        sum+=A.at(i);
    }
    int ans = N-sum;
    if(ans >=0){
        cout << ans ;
    }else{
        cout <<"-1"<<endl;
    }

    
}


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

#define FOR(i,a,b) for (ll i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (ll i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
ll INF = LLONG_MAX;
 
using vc = vector<char>;
using vi = vector<ll>;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll H, N;
    cin >> H >> N;
    vi AS (N);
    vi BS (N);
    F0R(i, N) {
        cin >> AS[i] >> BS[i];
    }

    vi dp (H+1);
    F0R(i, H+1) dp[i] = -1;
    dp[0] = 0;
    FOR(i, 0, H) {
        F0R(j, N) {
            if (AS[j] < i) continue;
            if (dp[i] == -1) dp[i] = BS[j];
            else dp[i] = min(BS[j], dp[i]);
        }
        if (dp[i] == -1) continue;
        F0R(j, N) {
            if (i + AS[j] > H) continue;
            if (dp[i+AS[j]] == -1) dp[i+AS[j]] = dp[i] + BS[j];
            else dp[i+AS[j]] = min(dp[i+AS[j]], dp[i] + BS[j]);
        }
    
    }

    F0R(j, N) {
        if (AS[j] < H) continue;
        if (dp[H] == -1) dp[H] = BS[j];
        else dp[H] = min(BS[j], dp[H]);
    }

    cout << dp[H] << endl;
}

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

#define pb push_back
#define ff first
#define ss second

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

const int MAXN = 2 * 100 * 1000 + 17;

int n, a[MAXN], dp[MAXN][2], p[MAXN];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i], p[a[i]] = i;
	for (int i = 1; i <= n; i++) {
		dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]);
		dp[i][1] = dp[p[a[i] - 1]][1] + 1;
	}
	cout << n - max(dp[n][0], dp[n][1]) << endl;
	return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

int main(){
  fastIO();
  char a;
  cin>>a;
  if(a>='a'&&a<='z'){
    cout<<"a"<<endl;
  }else{
    cout<<"A"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=405;

int n, m, ct=0, ans=0, bb=0, w=0;
int vis[N][N];
char a[N][N];
int b[N][N];

void dfs(int x, int y, int c)
{
	if(x<1 || y<1 || x>n || y>m)
		return;
	if(vis[x][y])
		return;
	if(b[x][y]!=c)
		return;
	bb+=(b[x][y]);
	w+=(!b[x][y]);
	vis[x][y]=1;
	ct++;
	dfs(x+1, y, c^1);
	dfs(x-1, y, c^1);
	dfs(x, y+1, c^1);
	dfs(x, y-1, c^1);
}

int32_t main()
{
	IOS;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
			b[i][j]=(a[i][j]=='#');
		}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(vis[i][j])
				continue;
			ct=0;
			bb=0;
			w=0;
			dfs(i, j, b[i][j]);
			ans+=bb*w;
		}
	}
	cout<<ans;
	return 0;
}

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

int main () {
  int k, x; cin >> k >> x;
  vector<int> ans(2*k-1);
  for (int i=0;i<2*k-1;i++) {
    ans.at(i) = x-k+1 + i;
  cout << ans.at(i) << " ";
  }
}

Measured memory_bytes: 256
#include <stdio.h>
char line[9]="01235789";

void spe(int num){
    if(num){
        spe(num/8);
        printf("%c",line[num%8]);
    }
}

int main(void){
    int num;
    for(;scanf("%d",&num),num;){
        spe(num);
        printf("\n");
    }
    return 0;
}

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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (a>=b)
    cout << "delicious\n";
  else if (b-a <= x)
    cout << "safe\n";
  else
    cout << "dangerous\n";
  return 0;
}

Measured memory_bytes: 256