akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文

int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	dump(a[2] - a[0]);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int n;
	cin >> n;
	if(n==0)break;
	REP(i,n){
	    int d[8];
	    int ans[4];
	    REP(i,8) cin >> d[i];
	    ans[0] = d[0]*d[4] - d[1]*d[5] - d[2]*d[6] - d[3]*d[7];
	    ans[1] = d[0]*d[5] + d[1]*d[4] + d[2]*d[7] - d[3]*d[6];
	    ans[2] = d[0]*d[6] - d[1]*d[7] + d[2]*d[4] + d[3]*d[5];
	    ans[3] = d[0]*d[7] + d[1]*d[6] - d[2]*d[5] + d[3]*d[4];
	    printf("%d %d %d %d\n",ans[0],ans[1],ans[2],ans[3]);
	}
    }
    return 0;
}

Measured memory_bytes: 1144
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import defaultdict

def judge(cnts, h, w):
    odd_cnt = 0
    mod4_2_cnt = 0
    mod4_0_cnt = 0

    for key, val in cnts.items():
        if val % 2 == 1:
            odd_cnt += 1

        elif val % 4 == 2:
            mod4_2_cnt += 1

        else:
            mod4_0_cnt += 1


    if h == 1 and w == 1:
        return True

    elif h == 1:
        if w % 2 == 1:
            return True if odd_cnt == 1 else False
        else:
            return True if odd_cnt == 0 else False

    elif w == 1:
        if h % 2 == 1:
            return True if odd_cnt == 1 else False
        else:
            return True if odd_cnt == 0 else False

    elif h % 2 == 1 and w % 2 == 1:
        return True if mod4_2_cnt == (w//2 + h//2) and odd_cnt == 1 else False

    elif h%2 == 1:
        return True if mod4_2_cnt == (w//2) and odd_cnt == 0 else False

    elif w%2 == 1:
        return True if mod4_2_cnt == (h//2) and odd_cnt == 0 else False

    else:
        return True if mod4_2_cnt == 0 and odd_cnt == 0 else False


h, w = li()
a = [ns() for _ in range(h)]

char_cnt = defaultdict(int)

for ai in a:
    for aij in ai:
        char_cnt[aij] += 1

print("Yes" if judge(char_cnt, h, w) else "No")

Measured memory_bytes: 3316
#!/usr/bin/env python3
import sys

def sum_dig(n):
    ret = 0
    while n > 0:
        ret += n % 10
        n //= 10
    return ret

def solve(N: int, A: int, B: int):
    ret = 0
    for i in range(1, N + 1):
        if A <= sum_dig(i) <= B:
            ret += i
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()


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

int main() {
  long long int a,b;
  cin>>a;
  b=2;
  for(int i=0;i<100000;i++){
  	b=i*i;
    if(b>a){
      b=(i-1)*(i-1);
      break;
    }
  }
  
  if(a==1){b=1;}
  
  cout<<b<<endl;
  
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int k;
    cin>>k;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];



    int dp[n];

    dp[0]=0;
    dp[1]=abs(arr[0]-arr[1]);

    for(int i=2;i<n;i++)
    {
        dp[i]=INT_MAX;
        for(int j=1;j<=k;j++)
            if(i-j>=0)
                dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
    }

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


}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MOD1 1000000007
#define MOD2 1000000009
#define fi first
#define se second
typedef long long int ll;
int main() 
{
	#ifndef ONLINE_JUDGE
	freopen("G:/coding/CPP/input.txt", "r", stdin);
	freopen("G:/coding/CPP/output.txt", "w", stdout);
	#else
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	#endif
	int n;
	cin>>n;
	vector<int> v(n+1);
	int d=0;
	for(int i=1;i<=n;i++) {
		cin>>v[i];
		if(i%2!=0 && v[i]%2!=0) d++;
	}
	cout<<d;

}


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

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class BRowToColumn {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<vector<bool>> mat(n, vector<bool>(n));
      rep(i, n) {
        rep(j, n) {
          char c; cin >> c;
          mat[i][j] = (c == '#');
        }
      }

      int num = 0;
      rep(j, n) {
        bool flag = true;
        rep(i, n) {
          if (!mat[i][j]) {
            flag = false;
            break;
          }
        }
        if (flag) {
          num++;
        }
      }

      if (num==n) {
        cout << 0 << endl;
        return;
      }

      vector<bool> hasj(n);
      vector<int> cnti(n);
      rep(i, n) {
        rep(j, n) {
          if (mat[i][j]) {
            hasj[j] = true;
            cnti[i]++;
          }
        }
      }

      int mi = INT_MAX/2;
      rep(i, n) {
        if (hasj[i]) {
          chmin(mi, n-cnti[i]);
        } else {
          chmin(mi, n-cnti[i]+1);
        }
      }
      if (mi > n) {
        cout << -1 << endl;
        return;
      }

      cout << mi + (n-num) << endl;

    }
};

signed main() {
  BRowToColumn solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef	long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef set<int> si;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef pair<ll, pll> plll;
typedef vector<pair<int, pii>> viii;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define tc int tt;cin>>tt;while(tt--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fio ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#define RED "\033[31m"
#define GREEN "\033[32m"
#define RESET "\033[0m"
#define sleep for (int i = 1, a;i < 100000000;i++, a = a * a)
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ranked_pairset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ranked_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ranked_map;

int main() {
	fio;
	string s;
	cin >> s;
	ll a = 0;
	for (auto c : s)
		a += (c - '0');
	(a % 9 == 0 && cout << "Yes\n") || cout << "No\n";
}


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

int main() {
  string s;
  cin >> s;
  
  int a,b,c,d;
  a=stoi(s.substr(0,1));
  b=stoi(s.substr(1,1));
  c=stoi(s.substr(2,1));
  d=stoi(s.substr(3,1));
  
  cout << a;
  if(a+b+c+d==7){cout << "+" << b << "+" << c << "+" << d << "=7";}else
  if(a+b+c-d==7){cout << "+" << b << "+" << c << "-" << d << "=7";}else
  if(a+b-c+d==7){cout << "+" << b << "-" << c << "+" << d << "=7";}else
  if(a-b+c+d==7){cout << "-" << b << "+" << c << "+" << d << "=7";}else
  if(a+b-c-d==7){cout << "+" << b << "-" << c << "-" << d << "=7";}else
  if(a-b+c-d==7){cout << "-" << b << "+" << c << "-" << d << "=7";}else
  if(a-b-c+d==7){cout << "-" << b << "-" << c << "+" << d << "=7";}else
  if(a-b-c-d==7){cout << "-" << b << "-" << c << "-" << d << "=7";}
  
  return 0;
}

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

int main(){
	int n,k;
	cin>>n>>k;

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

	int b[200010] = {0};
	sort(a,a+n);
	/*for(int i=0;i<n;++i){
		cout<<a[i]<<" ";
	}
	cout<<endl;*/
	int rec=0;
	for(int i=0;i<n-1;++i){
		if(a[i] == a[i+1]) ++b[rec];
		else{
			++b[rec];
			++rec;
		}
	}
	if(a[n-1] != a[n]) ++b[rec];

	/*for(int i=0;i<n;++i){
		cout<<b[i]<<" ";
	}
	cout<<endl;*/

	++rec;
	sort(b,b+rec);
	/*for(int i=0;i<n;++i){
		cout<<b[i]<<" ";
	}
	cout<<endl;*/

	int x = 0,var = 0;
	while(true){
		if(rec <= k)break;
		var += b[x];
		--rec;
		++x;
	}
	cout<<var<<endl;
}

Measured memory_bytes: 1792
#include <stdio.h> 
#include<stdbool.h>
#include<math.h>
  
bool isprime (int a){
	int j;
	
	if (a == 2)
		return true;
	
	if (a < 2 || (a%2==0))
		return false;
	
	j=3;	
	while(j<=sqrt(a)){
		if (a%j == 0)
			return false;
		j+=2;
	}
	return true;
}


int main() 
{ 
    int n,i,test,count=0;
    scanf("%d", &n);
    
    for (i=0; i<n; i++){
    	scanf("%d", &test);
    	if (isprime(test))
    		count++;
	}
    	
    printf("%d\n", count);
    
    return 0; 
} 



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

int main(void){
  int n, m;
  int h[100000]={0};
  int ma[100000]={0};
  
  cin >> n >> m;
  
  for(int i=0; i<n; i++){
    cin >> h[i];
    ma[i] = 0;
  }

  for(int i=0; i<m; i++){
    int a, b;
    cin >> a >> b;
    ma[a-1] = max(ma[a-1], h[b-1]);
    ma[b-1] = max(ma[b-1], h[a-1]);
  }

  int ans;
  for(int i=0; i<n; i++){
    if(h[i] > ma[i]) ans++;
  }
  
  cout << ans;
  
  return 0;
}
  

Measured memory_bytes: 4384
#include <iostream>
using namespace std;
using ll = long long;

int main() {
    int n, a[200005], cnt[200005];
    long long ans = 0;

    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        ans += cnt[a[i]];
        cnt[a[i]]++;
    }
    for (int i = 1; i <= n; i++) {
        cout << ans - cnt[a[i]] + 1 << endl;
    }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
#define MOD 1000000007
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define RER(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin() v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n;
string s;
bool d[2*MAX_N];

signed main(){
	cin >> n >> s;
	d[0] = 1;
	for(ll i=1; i<2*n; i++){
		if(s[i] == s[i-1]) d[i] = 1 - d[i-1];
		else d[i] = d[i-1];
	}
	// for(ll i=0; i<2*n; i++){
	// 	if(d[i]) cout << 'L';
	// 	else cout << 'R';
	// }
	ll ret = 1;
	ll num_l = 1;
	for(ll i=1; i<2*n; i++){
		if(d[i]) num_l++;
		else{
			ret *= num_l--;
			ret %= MOD;
		}
	}
	if(num_l != 0) ret = 0;
	if(s[0] == 'W') ret = 0;
	// cout << ret << endl;
	ret %= MOD;
	for(ll i=1; i<=n; i++){
		ret *= i;
		ret %= MOD;
	}
	cout << ret << endl;
    return 0;
}

Measured memory_bytes: 772
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
    string s, s1;
    cin >> s >> s1;
    sort(s.begin(), s.end());
    sort(s1.begin(), s1.end());
    reverse(s1.begin(), s1.end());
    if(s < s1)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::Usize1;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: u64 = 1000000007;
const INF: usize = std::usize::MAX / 4;

fn main() {
    input! {
        N: usize,
        S: [String; N],
    }

    let mut V = HashSet::new();
    for s in S {
        V.insert(s);
    }

    println!("{}", V.len());
}


Measured memory_bytes: 24856
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

int main(){
  int a,b,m;
  int ma=INF,mb=INF;
  cin>>a>>b>>m;
  int na[100009],nb[100009];
  rep(i,a){
    cin>>na[i];
    ma=min(ma,na[i]);
  }
  rep(i,b){
    cin>>nb[i];
    mb=min(mb,nb[i]);
  }
  int ans=ma+mb;
  rep(i,m){
    int x,y,c;
    cin>>x>>y>>c;
    x--;y--;
    ans=min(ans,na[x]+nb[y]-c);
  }
  cout<<ans<<endl;
  return(0);
}



Measured memory_bytes: 1024
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

int main() {
  //input
  long N;
  cin >> N;
  
  //main
  
  //output
  long ans = ((1+N-1)*(N-1))/2;
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
#define MAXN 3001
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
void setIO(string s) {
    ios_base::sync_with_stdio(0); cin.tie(0); 
    freopen((s+".in").c_str(),"r",stdin);
    freopen((s+".out").c_str(),"w",stdout);
}
ve sieve()
{
    ll arr[MAXN+1]={0};
    ve primes;

    memset(arr,-1,sizeof arr); 
    for (ll i = 2; i <= MAXN; i++)
    {
        if(arr[i]==-1)
        {
            arr[i]=1;
            primes.pb(i);
            for (ll j = i*i; j <= MAXN; j+=i)
            {
                arr[j]=1;
            }
        }
    }
    return primes;
}
map<vedos,ll>gg;
ve primes;
vedos getfact(ll yo)
{
    vedos kali;
    for(auto it:primes)
    {
        ll index=0;
        while((yo%it)==0)
        {
            yo=(yo/it);
            index++;
        }
        if(index%3!=0)kali.pb({it,index%3});
        if(yo==1)return kali;
    }
    if(yo!=1)
    {
        ll ko = sqrt(yo);
        if(pow(ko,2)==yo)
        {
            kali.pb({ko,2});
        }
        else kali.pb({yo,1});
    }
    return kali;
}
int main()
{
    flash;
    ll n;
    cin>>n;
    primes=sieve();
    for (ll i = 0; i < n; ++i)
    {
        ll yo;
        cin>>yo;
        vedos nowi = getfact(yo);
        nowi.pb({1,0});
        gg[nowi]++;
    }
    ll ans=0; 
    map<vedos,ll>klo=gg;
    for(auto it:gg)
    {
        if(klo.find(it.first)!=klo.end())
        {
        vedos complement;
        for(auto it1:it.first)
        {
            if(it1.second==1)complement.pb({it1.first,2});
            if(it1.second==2)complement.pb({it1.first,1});
        }
        complement.pb({1,0});
        if(complement==it.first)
        {
            ans++;
        }
        else if(klo.find(complement)!=klo.end())
        {
            ans+=max(klo[it.first],klo[complement]);
            klo.erase(complement);
        }
        else
        {
            ans+=klo[it.first];
        }
        klo.erase(it.first);
        }
    }
    cout<<ans;
  return 0;
}
//code the AC sol !
// BS/queue/map

Measured memory_bytes: 32256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <iterator>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ff first
#define ss second
#define END "\n"
#define pb push_back
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef vector<ii> vii;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////
vector<vector<ll>> adj;
vector<ll> sum;
vector<bool> visited;
void dfs(ll v)
{
    visited[v] = true;
    for (auto u: adj[v])
    {
        if (visited[u])
        sum[v] = max(sum[u] + 1, sum[v]);
        else
        {
            dfs(u);
            sum[v] = max(sum[u] + 1, sum[v]);
        }
    }
}


int main()
{
    ll n, m, i, j, x, y, ans = -1;
    cin >> n >> m;
    sum = vector<ll>(n + 1, 0);
    adj = vector<vector<ll>>(n + 1);
    visited = vector<bool>(n + 1, false);
    for (i = 0; i < m; i++)
    {
        cin >> x >> y;
        adj[x].pb(y);
    }
    for (i = 1; i <= n; i++)
    {
        if (!visited[i])
        dfs(i);
    }
    for (i = 1; i <= n; i++)
    ans = max(ans, sum[i]);
    cout << endl;
    cout << ans << endl;
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
#define PINT pair<int,int>
#define f1 first
#define s2 second
const int INF = 1e9 + 7;

using namespace std;

int main(){
    cin.tie(0), ios::sync_with_stdio(false);
    int n,m;
    cin >> n;
    map<string,int> br;
    string s;
    REP(i,n){
        cin >> s;
        ++br[s];
    }
    cin >> m;
    REP(i,m){
        cin >> s;
        --br[s];
    }
    int max=0;
    for(auto itr=br.begin();itr!=br.end();++itr){
        if(itr->second>max) max=itr->second;
    }
    cout << max << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <functional>
#include <string>
#include <queue>
using namespace std;

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

struct pairs{ long long int a, b; };
bool compare(const pairs& p1, const pairs& p2)
{
  return p1.b < p2.b;
}

int main(){
  int N; cin >> N;
  vector<pairs> input(N);
  REP(i,N){ cin >> input[i].a >> input[i].b; }
  sort( input.begin(), input.end(), compare);

  long long int total_cost = 0;
  int jud = 1;
  REP(i, N){
    total_cost += input[i].a;
    if( total_cost > input[i].b){ 
      cout << "No" << endl;
      jud = 0;
      break; 
    } 
  }
  if(jud==1){ cout << "Yes" << endl; }
  return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> p2;
ll dp[3005][6005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,t;
    cin>>n>>t;
    vector<p2> v(n);
    for(ll i=0;i<n;i++)
    cin>>v[i].first>>v[i].second;
    sort(v.begin(),v.end());
    for(ll i=1;i<=n;i++)
    for(ll j=1;j<6005;j++){
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        if(j-v[i-1].first>=1&&j-v[i-1].first<=t)
        dp[i][j]=max(dp[i][j],v[i-1].second+dp[i-1][j-v[i-1].first]);
    }
    cout<<dp[n][6004];
}

Measured memory_bytes: 141056
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)
 
 
int main()
{
    int n;cin>>n;
    vector<int> l(n);
    for(int i = 0; i < n; i++) cin>>l[i];
    sort(l.begin(), l.end());
    int sum = 0;
    for(int i = 0; i < n - 1; i++) sum += l[i];
    sum -= l[n-1];
    cout << (sum > 0?"Yes":"No")<<endl;

    return 0;
    
}



Measured memory_bytes: 256
n, m = map(int,input().split())
X = list(map(int,input().split()))
Y = list(map(int,input().split()))

XX = [X[i+1]-X[i] for i in range(n-1)]
YY = [Y[i+1]-Y[i] for i in range(m-1)]

mod = 10**9 + 7

ans = 0
ans0 = 0
for i in range(1, n):
    ans1 = (i * (n-i)) % mod
    ans1 = (ans1 * XX[i-1]) % mod
    ans0 = (ans0 + ans1) % mod

for i in range(1, m):
    ans1 = (i * (m-i)) % mod
    ans1 = (ans1 * YY[i-1]) % mod
    ans1 = (ans1 * ans0) % mod
    ans = (ans + ans1) % mod

print(ans)


Measured memory_bytes: 87268
#include<cstdio>
#include<vector>
#include<complex>
#include<algorithm>

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

using namespace std;

typedef complex<double> Point;

const double EPS=1e-9;

namespace std{
	bool operator <(const Point &a,const Point &b){
		return abs(a.real()-b.real())<EPS?(a.imag()+EPS<b.imag()):(a.real()+EPS<b.real());
	}
}

class Line:public vector<Point>{
public:
	Line(){}
	Line(const Point &a,const Point &b){ push_back(a), push_back(b); }
};

class Segment:public Line{
public:
	Segment(){}
	Segment(const Point &a,const Point &b):Line(a,b){}
};

inline double dot(const Point &a,const Point &b){
	return a.real()*b.real()+a.imag()*b.imag();
}

inline double cross(const Point &a,const Point &b){
	return a.real()*b.imag()-a.imag()*b.real();
}

enum {CCW=1,CW=-1,ON=0};
int ccw(const Point &a,Point b,Point c){
	b-=a, c-=a;
	double rotdir=cross(b,c);
	if(rotdir>EPS)  return CCW;
	if(rotdir<-EPS) return CW;
	return ON;
}

inline void calc_abc(const Line &l,double &a,double &b,double &c){
	a=l[0].imag()-l[1].imag();
	b=l[1].real()-l[0].real();
	c=cross(l[0],l[1]);
}

bool cover(const Segment &s,const Point &p){
	return dot(s[0]-p,s[1]-p)<EPS;
}

bool intersect(const Segment &s,const Segment &t,Point *p){
	bool flg;
	if(abs(cross(s[1]-s[0],t[1]-t[0]))<EPS && abs(cross(s[1]-s[0],t[0]-s[0]))<EPS){
		flg=(cover(s,t[0]) || cover(s,t[1]) || cover(t,s[0]) || cover(t,s[1]));
		if(!flg) return false;
	}

	if(flg || (ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1])<=0
			&& ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1])<=0)){
		double a1,b1,c1,a2,b2,c2;
		calc_abc(s,a1,b1,c1);
		calc_abc(t,a2,b2,c2);
		double det=a1*b2-a2*b1;
		if(abs(det)<EPS){ // s is parallel to t
			Point q[3]={s[0],s[1],t[0]};
			rep(i,3){
				if(cover(s,q[i]) && cover(t,q[i])){
					*p=q[i];
					break;
				}
			}
		}
		else *p=Point(b1*c2-b2*c1,a2*c1-a1*c2)/det;
		return true;
	}
	return false;
}

int n;
Point _f[100],_g[100];

double f(double x){
	if(x<_f[0].real()) return 0;
	rep(i,n-1){
		double x1=_f[i].real(),x2=_f[i+1].real();
		double y1=_f[i].imag(),y2=_f[i+1].imag();
		if(x<x2) return (y2-y1)/(x2-x1)*(x-x1)+y1;
	}
	return 0;
}

double g(double x){
	if(x<_g[0].real()) return 0;
	rep(i,n-1){
		double x1=_g[i].real(),x2=_g[i+1].real();
		double y1=_g[i].imag(),y2=_g[i+1].imag();
		if(x<x2) return (y2-y1)/(x2-x1)*(x-x1)+y1;
	}
	return 0;
}

int main(){
	for(double r;scanf("%d%lf",&n,&r),n;){
		vector<double> ev;
		rep(i,n){
			int x,y; scanf("%d%d",&x,&y);
			_f[i]=Point(x,y);
			_g[i]=Point(x+r,y);
			ev.push_back(x);
			ev.push_back(x+r);
		}

		rep(i,n-1) rep(j,n-1) {
			Point p;
			if(intersect(Segment(_f[i],_f[i+1]),Segment(_g[i],_g[i+1]),&p)){
				ev.push_back(p.real());
			}
		}

		sort(_f,_f+n);
		sort(_g,_g+n);
		sort(ev.begin(),ev.end());

		double ans=0;
		rep(i,ev.size()-1){
			double x1=ev[i],x2=ev[i+1];
			if(x2-x1<EPS) continue;
			double f1=f(x1),f2=f(x2),g1=g(x1),g2=g(x2);
			double af=(f2-f1)/(x2-x1),bf=f1-af*x1;
			double ag=(g2-g1)/(x2-x1),bg=g1-ag*x1;
			ans+=af*ag*(x2*x2*x2-x1*x1*x1)/3+(af*bg+bf*ag)*(x2*x2-x1*x1)/2+bf*bg*(x2-x1);
		}
		printf("%.15f\n",ans);
	}

	return 0;
}

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

int main(){
	int n, m;
	int tmp, sum = 0;

	cin >> n >> m;

	vector<int> a(n, 0);
	for(int i=0; i<m; i++){
		cin >> tmp;
		sum += tmp;
	}

	if(sum > n){
		cout << -1;
	}else{
		cout << n - sum;
	}
}



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

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a*c, a*d, b*c, b*d}) << endl;
    return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    int maxL = -1, minR = 1000000;
    for(int i=1; i<=m; i++){
        int l, r;
        cin >> l >> r;
        maxL = max(l, maxL);
        minR = min(r, minR);
    }
    cout << max(0, minR-maxL+1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N=0;
    int l[1010];
    int r[1010];
    
    cin >> N;
    for(int i=0; i<N;++i) cin >> l[i] >> r[i];
    
    int sum=0;
    int start=0, end=0;
    for(int i=0; i<N;++i){
       sum += r[i] - l[i] + 1;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
	long long x,y,a=0,b=0;
	bool flag;
	scanf("%lld %lld",&x,&y);
	if(abs(x)>abs(y))
	a=abs(x)-abs(y),flag=false;
	else
	a=abs(y)-abs(x),flag=true;
	if(x>=0&&flag){
		if(y<0)
		++b;
		printf("%lld",a+b);
		return 0;
	}
	if(x<0&&flag){
		if(y>0)
		++b;
		else 
		b+=2;
		printf("%lld",a+b);
		return 0;
	}
	if(x>=0){
		if(y>0)
		b+=2;
		else
		++b;
		printf("%lld",a+b);
		return 0;
	}
	if(x<0){
		if(y>0)
		++b;
		printf("%lld",a+b);
		return 0;
	}
	return 0;
}

Measured memory_bytes: 128
# coding:utf-8
N,M=map(int,raw_input().split())
X=[]
Y=[]
Z=[]
for i in range(N):
    x,y,z=map(int,raw_input().split())
    X.append(x)
    Y.append(y)
    Z.append(z)
ans=-1
for xc in [1,-1]:
    for yc in [1,-1]:
        for zc in [1,-1]:
            P=[]
            for i in range(len(X)):
                P.append(xc*X[i]+yc*Y[i]+zc*Z[i])
            P.sort();P=P[::-1]
            ans=max(ans,sum(P[:M]))
print(ans)



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

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
vector<ll> P;
vector<ll> A, B;
vector<ll> garbage;
int main() {
  cin >> N;
  P.resize(N);
  garbage.resize(N);
  int cnt = 1;
  for (auto &val : P) {
    cin >> val;
    val--;
    garbage[val] = cnt++;
  }
  int base_val = 30000;
  A.resize(N);
  B.resize(N);
  for (int i = 0; i < N; i++) {
    A[i] = i * base_val + garbage[i];
    B[i] = (N - i) * base_val;
  }

  for (int i = 0; i < N; i++) {
    cout << A[i];
    if (i == N - 1) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
  for (int i = 0; i < N; i++) {
    cout << B[i];
    if (i == N - 1) {
      cout << endl;
    } else {
      cout << " ";
    }
  }

  return 0;
}


Measured memory_bytes: 1280
import fractions
n,m = map(int,input().split())
l = input().split()
lcm = 1
sum = 0
for i in range(len(l)):
    lcm = (int(l[i]) * lcm) // fractions.gcd(int(l[i]), lcm)
for i in range(len(l)):
    if (lcm // int(l[i])) % 2 == 1:
        sum += 1
if sum == len(l):
    x = m // (int(lcm) // 2)
    y = m // lcm
    print(int(x - y))
else:
    print(0)

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

using namespace std;
using ll = long long;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long a, long long b, long long x){
  double c = a*a*b;
  double y;
  double ans;
  if(c/2.0 < x) {
    y = 2.0*(c-(double)x) / (double)(a*a);
    ans = atan((double)y/a)*((double)180/M_PI);
  } else {
    y = (2.0*(double)x) / (double)(a*b);
    ans = atan((double)b/(double)y)*((double)180/M_PI);
  }
  std::cout << setprecision(10) <<ans << std::endl;
}

int main(){
  long long a;
  scanf("%lld",&a);
  long long b;
  scanf("%lld",&b);
  long long x;
  scanf("%lld",&x);
  solve(a, b, x);
  return 0;
}


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

int a,b,llo,lo;
bool x[100][10000],y[100],dp[100][10000],sdp[100][10000];

int yoko(int oop){
    for(int e=0;e<b;e++){
            int ddf=0;
        for(int g=0;g<a;g++){
            if(dp[g][e]==1){ddf++;}
        }
        if(ddf>a/2){
                        for(int g=0;g<a;g++){
            if(dp[g][e]==0){dp[g][e]=1;}else
            if(dp[g][e]==1){dp[g][e]=0;}
        }

        }
    }

}


int cou(){
    llo=0;
    for(int m=0;m<a;m++){
        for(int c=0;c<b;c++){
            dp[m][c]=x[m][c];
        }
    }

    for(int m=0;m<a;m++){
        if(y[m]==1){
            for(int c=0;c<b;c++){
                if(x[m][c]==0){dp[m][c]=1;}else
                if(x[m][c]==1){dp[m][c]=0;}
            }
        }
    }

    yoko(0);

    for(int m=0;m<a;m++){
        for(int c=0;c<b;c++){
            if(dp[m][c]==0){llo++;}
        }
    }
    if(lo<=llo){lo=llo;
        for(int m=0;m<a;m++){
            for(int c=0;c<b;c++){
                sdp[m][c]=dp[m][c];
            }
        }
    }


}

int gyou(int f){
    if(f>=a){ cou(); return 0;}
    y[f]=0;
    gyou(f+1);
    y[f]=1;
    gyou(f+1);
}


int main(){
    while(1){
        cin>>a>>b;
        if(a+b==0){break;}
        if(a==10&&b==0){break;}
    for(int q=0;q<a;q++){
        for(int g=0;g<b;g++){
            cin>>x[q][g];
        }
    }
    gyou(0);

    cout<<lo<<endl;
    }




}

Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b,c;
	cin>>a>>b>>c;
	ll s=c-a-b;
	if(s<0)
		cout<<"No";
	else
	{
		s*=s;
		if(s>4*a*b)
			cout<<"Yes";
		else
			cout<<"No";
	}
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N,K; cin >> N >> K;
    vector<int> H(N);
    for(int i=0;i<N;i++){
        cin >> H[i];
    }
    ll out = 0;
    sort(H.begin(),H.end());
    for(int i=0;i<N-K;i++){
        out += H[i];
    }
    cout << out << endl;
    
    return 0;
}


Measured memory_bytes: 4040
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 1e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n, m;
int dp[maxn], in[maxn];
vector<int>adj[maxn];
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin >> n >> m;
    for(int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        ++in[b];
    }
    queue<int>Q;
    for(int i = 1; i <= n; i++) if(!in[i]) Q.push(i);
    while(sz(Q))
    {
        int v = Q.front(); Q.pop();
        for(int to : adj[v])
        {
            if(--in[to] == 0)
                Q.push(to);
            dp[to] = max(dp[to], dp[v] + 1);
        }
    }
    cout << *max_element(dp + 1, dp + n + 1) << "\n";
    return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
 
int main()
{
	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll x;
    cin>>x;
    ll n=100;
    ll count=0;
    
    while(n<x)
    {
    	
    	n=n+(n/100);
    	count++;
    	
	}
	

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

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; i++)
  {
    cin >> A[i];
  }
  vector<int> a = A;
  sort(a.rbegin(), a.rend());
  for (int i = 0; i < n; i++)
  {
    int ans = a[0];
    if (A[i] == a[0])
    {
      ans = a[1];
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3200
#include<stdio.h>
#define INFTY 2000000000;
int cnt = 0;

int merge(int S[],int left,int mid,int right){
  int n1,n2;
  int i,j,k;
  n1 = mid - left;
  n2 = right - mid;
  int L[n1+1],R[n2+1];
  for(i = 0;i<=n1-1;i++){
    L[i] = S[left + i];
    
  }
  for(i = 0;i<=n2 - 1;i++){
    R[i] = S[mid + i];
  }
  L[n1] = INFTY;
  R[n2] = INFTY;
  i = 0;
  j = 0;
  for(k = left;k<=right-1;k++){
    if(L[i] <= R[j]){
      S[k] = L[i];
      i = i+1;
      cnt++;
    }
    else{
      S[k] = R[j];
      j = j+1;
      cnt++;
    }
  }
  
  return *S;
}
void mergeSort(int S[],int left,int right){
  int mid;
  if((left+1) < right){
    mid = (left+right)/2;
    mergeSort(S,left,mid);
    mergeSort(S,mid,right);
    merge(S,left,mid,right);
   
  }
}

int main(){
  int n,s[500000];
  int i;

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

 
    mergeSort(s,0,n);
   for(i = 0;i<n;i++){
     if(i>0)printf(" ");
    printf("%d",s[i]);
      
  }
  printf("\n%d\n",cnt);
  
  

  return 0;
}



Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];
const int INF = 1e9;
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

vector<ll> dp(100010, INF);

void solve(long long N, long long K, std::vector<long long> h)
{
    dp[0] = 0;
    for (int i = 1; i < N; i++)
    {
        for (int j = i - K; j <= i; j++)
        {
            if (j >= 0)
            {
                dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
            }
        }
    }
    cout << dp[N - 1] << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> h(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &h[i]);
    }
    solve(N, K, std::move(h));
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
//typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
//define
#define PI acos(-1)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

int main(){
    double a,b,h,m;
    double kakudo_a,kakudo_b,kakudo_sa,r ;
    cin >> a >> b >> h >> m;
    
   kakudo_a=30*h + m/2;
   kakudo_b=6*m;
   kakudo_sa=kakudo_b - kakudo_a;
   r=sqrt(a*a + b*b - 2*a*b*cos(kakudo_sa * PI / 180));
   printf("%.20f",r);
   
 return 0;
}

Measured memory_bytes: 4288
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m, d;
    cin >> n >> m >> d;
    double mul = 2;
    if (d == 0) mul = 1;
    double t = double(n - d) * mul;

    double ans = t * double(m - 1)/double(n * n);
    printf("%30.15f\n", ans);
    return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
c=[list(map(int,input().split())) for i in range(10)]
a=[list(map(int,input().split())) for i in range(h)]
 
for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j]=min(c[i][j],c[i][k]+c[k][j])

ans=0
for i in range(h):
    for j in range(w):
        if a[i][j]!=-1:
            ans+=c[a[i][j]][1]
print(ans)

Measured memory_bytes: 3444
#include<stdio.h>
#include<string.h>
int main()
{
	char a[100];
	scanf("%s",a);
	int len=strlen(a);
	if(len%2) printf("No\n");
	else
	{
		for(int i=0;i<len;i++)
		{
			if(i%2)
			{
				if(a[i]!='i')
				{ 
				printf("No\n");
				return 0;
		    	}
			}
			else
			{
				if(a[i]!='h')
				{
					printf("No\n");
					return 0;
				}
			}	
		}
		printf("Yes\n");
	}
	return 0;
 } 

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

int main()
{
    // 入力
    int A, B;
    cin >> A >> B;

    // 出力
    cout << max(max(A + B, A - B ), A * B) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define lli long long int
#define all(x) x.begin(),x.end()
#define siz(x) x.size()
#define prs(x,y) x.find(y)!=x.end()
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res;}
inline int level(int n){int ans=0;while(n%2==0){n/=2;ans++;}return ans;}
int main()
{

	double r;
	cin>>r;
	cout<<2.0*M_PI*r;
}



Measured memory_bytes: 3760
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if((a<c && c<b) || (b<c && c<a)) cout << "Yes\n";
    else cout << "No\n";
	return 0;
}

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

int main()
{
	int A,B,K;
	int dai;
	int syo;
	int i;
	vector<int> D;
	cin >> A;
	cin >> B;
	cin >> K;
	
	dai = max(A, B);
	syo = min(A, B);

	for (i = syo; 0<i; --i) 
	{
		if (syo%i == 0 && dai%i == 0)
		{
			D.push_back(i);
		}
	}

	cout << D[K - 1] << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;



int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << ketasitei;

	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll ans = 0;
	ans = min(a, k);
	k -= a;
	if (k > 0)
	{
		k -= b;
		if (k > 0)
		{
			ans -= k;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3636