akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
struct pair_hash {
    template <class T1, class T2>
    size_t operator () (const pair<T1,T2> &p) const {
        auto h1 = hash<T1>{}(p.first);
        auto h2 = hash<T2>{}(p.second);
        return h1 ^ h2;  
    }
};
using Vote = pair<ll,ll>;
using Unordered_map = unordered_map<Vote, int, pair_hash>;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define showvec(arr,a,b) for(ll i=a;i<b;i++) cout<<arr[i]<<" ";
#define read_input(arr,a,b) for(ll i=a;i<b;i++) cin>>arr[i];
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define SmooothOperatorrrrr()                 \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                    \
    cout.tie(0);                   
#define deci(n) cout<<fixed<<setprecision(n)
const int mod=998244353;
const int mod2=1000000007;
#define M_PI 3.14159265358979323846
#define LL_MAX 9223372036854775807
#define MAXN 2000001
/**************************************************************************************************/
int main()
{
    SmooothOperatorrrrr();
    int n;cin>>n;
    ll l[n];
    read_input(l,0,n);
    ll count=0;
    FOR(i,0,n-2)
    {
        FOR(j,i+1,n-1)
        {
            if(l[i]!=l[j])
            {
                FOR(k,j+1,n)
                {
                    if(l[j]!=l[k]&&l[i]!=l[k])
                    {
                        vll v;
                        v.pb(l[i]);
                        v.pb(l[j]);
                        v.pb(l[k]);
                        sort(v.begin(),v.end());
                        if(v[0]+v[1]>v[2])
                            count++;
                    }
                }
            }
        }
    }
    cout<<count<<endl;
}       

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

int main(){
    string s;
    long long k;
    cin >> s;
    cin >> k;
    char ans='1';
    for(long long i=0;i<k;i++){
        if(s[i]!='1'){
            ans=s[i];
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const double pi=acos(-1);
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
//cout << fixed << setprecision(12);
ll h,w,p;
cin>>h>>w>>p;
ll f=0,g=0;
string a[h]={};
ll ca=0,cb=0;
rep(i,h){
cin>>a[i];}
ll cc=0;
for(ll i=0; i<h; i++){
for(ll k=0; k<w; k++){
if(a[i].at(k)=='#')cb++;}}
//縦
for (ll x = 0; x < (1 << w); x++) {
    bitset<6> s(x);
    //cout << s << " ";
for (ll y = 0; y < (1 << h); y++) {
    bitset<6> t(y);
    //cout << t << endl;
for(ll i=0; i<h; i++){
if(t.test(i)) f=1;
for(ll k=0; k<w; k++){
if(s.test(k)) g=1;
if(a[i].at(k)=='#'&&(f==1||g==1)){
cc++;}
g=0;
}
f=0;
}if(cb-cc==p) {ca++;}
cc=0;
}}
cout << ca << endl;}


Measured memory_bytes: 3624
import math

def pow(p,n):
    bin_n=bin(n)[2:][::-1]
    tmp=p;pn=1
    for i in range(len(bin_n)):
        if bin_n[i]=="1": pn=(pn*tmp)%mod
        tmp=tmp*tmp%mod
    return pn


mod=10**9+7
n,k=map(int,input().split())

ans=[0]*(k+1)
for i in range(k,0,-1):
    div=set()
    for x in range(1,int(i**0.5)+1):
        if i%x==0: div.add(x);div.add(i//x)
    ans[i]=pow(k//i,n)-sum([ans[j*i] for j in range(k//i,1,-1)])
    ans[i]%=mod
print(sum(ans[i]*i for i in range(k+1))%mod)

Measured memory_bytes: 87164
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))


A, B, C, D = MAP()


while True:
    C -= B
    if C <= 0:
        print("Yes")
        break
    A -= D
    if A <= 0:
        print("No")
        break


Measured memory_bytes: 61704
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
int MOD = 1e9 + 7;

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

    int n;
    cin >> n;
    vi as(n);
    map<int, int> mp;
    for(int i = 0; i < n; i++){
        cin >> as[i];
        mp[as[i]]++;
    }
    sort(as.begin(), as.end(), greater<int>());

    int ans = 0;
    for(int i = 0; i < n; i++){
        if(mp[as[i]] < 1){
            continue;
        }

        int expo = 1;
        while(expo <= as[i]) expo *= 2;
        mp[as[i]]--;

        if(mp[expo - as[i]] > 0){
            ans++;
            mp[expo - as[i]]--;
        }
    }

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


Measured memory_bytes: 19840
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))
#define MAX(x,y) ((x)<(y)?(y):(x))

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

#define INF 1000000000

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}

ll twoRow(ll a, ll b, ll mod)
{
	ll ret = 1;
	for(ll i = 1 ;i <= a+b;++i)
	{
		ret *= i;
		ret %= mod;
	}
	for(ll i = 1 ;i <= a;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	for(ll i = 1 ;i <= b;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	return ret;
}

struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return (ret);
}

int first[32] = {0};
int nx[100010][32] = {0};
int main()
{
	string S,T,Q;
	ll i,j,k;
	cin >> S >> T;
	for(i=0;i<32;++i)
		first[i] = -1;
	int s_len = S.size();
	Q = S+S;
	for(i=Q.size()-1;i>=0;--i)
	{
		for(j=0;j<32;++j)
		{
			nx[i%s_len][j] = first[j]-i;
		}
		first[Q[i]-'a'] = i;
	}
	/*
	for(i=0;i<s_len;++i)
	{
		for(j=0;j<32;++j)
		{
			cout << nx[i][j] << " ";
		}
		cout << endl;
	}*/
	int t_len = T.size();
	ll pos = first[T[0]-'a'];
	if(pos<0)
	{
		cout << -1 << endl;
		return 0;
	}
	for(i=1;i<t_len;++i)
	{
		if(nx[pos%s_len][T[i]-'a'] < 0)
		{
			cout << -1 << endl;
			return 0;
		}
		pos += nx[pos%s_len][T[i]-'a'];
	}
	cout << pos+1 << endl;
	return 0;
}




















Measured memory_bytes: 13312
import java.util.Scanner;
public class Main {
	static final int BALL_NUM = 10;
	int[] ball;
	void run(){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		for(int i = 0;i < n;i++){
			//????????????????????????
			ball = new int[BALL_NUM];
			for(int j = 0;j < BALL_NUM;j++)
				ball[j] = scan.nextInt();
			if(solve()){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}
	boolean solve(){
		int b = 0,c = 0;
		for(int i = 0;i < BALL_NUM;i++){
			//??????b>c??¨??????b??????????????????
			//b > ball[i]?????´??????c???ball[i]?????£??\?????????????????¢?????????????????????
			if(b < ball[i]){
				b = ball[i];
			}else{
				if(c < ball[i]){
					c = ball[i];
				}else{
					return false;
				}
			}
			/*
			if(b >= c){
				if(b < ball[i]){
					b = ball[i];
				}else{
					if(c < ball[i]){
						c = ball[i];
					}else{
						return false;
					}
					
				}
			}else{
				if(c < ball[i]){
					c = ball[i];
				}else{
					if(b < ball[i]){
						b = ball[i];
					}else{
						return false;
					}
				}
			}
			*/
		}
		return true;
	}

	public static void main(String args[]){
		new Main().run();
	}
}

Measured memory_bytes: 26120
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define zoom ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define precise cout.precision(8); cout << fixed;
#define seed srand(chrono::steady_clock::now().time_since_epoch().count());
const double PI = acos(-1);
using namespace std;

void solve() {
    ll N, i, ans = 0; cin >> N;
    for(i = 1; i <= N; i += 1) {
        ll temp = N / i;
        ans += (((temp * (temp + 1)) / 2) * i);
    }
    cout << ans;
}

int main() {
    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
using namespace std;
int w[101],l[101],visited[101],ans;


void saiki(int m){
  if(visited[m])ans=1;
  if(!w[m] || ans)return;
  visited[m]=1;
  saiki(l[w[m]]);
}


int main(){
  int n;
  cin>> n;
  for(int i=0;i<101;i++) l[i]=w[i]=visited[i]=0;

  for(int i=0;i<n;i++){
    string str;
    int u,d;
    cin>>u>>str>>d;
    if(str=="lock")l[d]=u;
    else w[u]=d;
  }

  ans=0;
  for(int i=0;i<101;i++){
    for(int j=0;j<101;j++) visited[j]=0;
    saiki(i);
  }
  cout << ans<<endl;
  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
 
}

int p[N];
int get(int v){
	return v == p[v] ? v : p[v] = get(p[v]);
}
void solve()
{
	int n;
	cin >> n;
	vector<pii> x(n), y(n);
	set<pair<int, pii> > px, py;
	rep(i, n) p[i] = i;
	rep(i, n){
		cin >> x[i].F >> y[i].F;
		x[i].S = y[i].S = i;
	}
	sort(all(x));
	sort(all(y));
	rep(i, n){
		if(i){
			px.insert({x[i].F - x[i - 1].F, {x[i].S, x[i - 1].S}});
			py.insert({y[i].F - y[i - 1].F, {y[i].S, y[i - 1].S}});
		}
	}
	ll res = 0;
	while(!px.empty() && !py.empty()){
		pair<int, pii> u = *px.begin();
		pair<int, pii> v = *py.begin();
		if(u.F <= v.F){
			res += 1ll * u.F;
			int x = get(u.S.F), y = get(u.S.S);
			p[y] = x;
			px.erase(px.begin());
		}
		else{
			res += 1ll * v.F;
			int x = get(v.S.F), y = get(v.S.S);
			p[y] = x;
			py.erase(py.begin());	
		}
		while(!px.empty()){
			pair<int, pii> x = *px.begin();
			if(get(x.S.F) == get(x.S.S)) px.erase(px.begin());
			else break;
		}
		while(!py.empty()){
			pair<int, pii> x = *py.begin();
			if(get(x.S.F) == get(x.S.S)) py.erase(py.begin());
			else break;
		}
	}
	cout << res;


}	 

 
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}


Measured memory_bytes: 19084
K = int(input())
A = list(map(int, input().split()))

mina = maxa = 2

for a in A[::-1]:
  mina = -(-mina // a) * a
  maxa = maxa // a * a + a - 1
  if mina > maxa:
    print(-1)
    break
else:
  print(mina, maxa)

Measured memory_bytes: 14252
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);
	    int x=gi();
	    int y=gi();
	    int z=gi();
	     
	    int n=Math.floorDiv(x, y+z);
	    int m=x%(y+z);
	    if (m<z)n--;

	    System.out.print(n);
//	    if (s.contains("AC")) {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35756
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 111111;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    bool can=false;
    for(int i=0;i<s.size()-1;i++){
        if(s[i]=='A'&&s[i+1]=='C')can=true;
    }
    if(can)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int[] a = new int[3];
		for (int i = 0; i < 3; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int k = sc.nextInt();
		for (int i = 0; i < k; i++) {
			a[2] = a[2] * 2;
		}
		System.out.println(a[0] + a[1] + a[2]);
	}
}


Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAx = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
long long min_value = MAx, min_index = -1;

typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
    bool a[3] = {false};
    rep(i, 2) {
        cin >> N;
        a[N-1] = true;
    }
    rep(i, 3){
        if(a[i] == false) cout << i+1;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> H(n); rep(i, n) cin >> H[i];
  bool ok = true;
  ll mn = 0;
  rep(i, n) {
    if(H[i]<mn) ok = false;
    if(H[i]-1>=mn) mn = H[i]-1;
  }
  cout << (ok ? "Yes" : "No") << "\n";
  return 0;
}


Measured memory_bytes: 3984
# coding: utf-8
def getLnInputs():
    return input().split()


def getLnIntInputs():
    return list(map(int, getLnInputs()))


def main():
    N, C, K = getLnIntInputs()

    a_queue = []
    bus_count = 0
    for _ in range(N):
        a_queue.append(int(input()))

    a_queue = sorted(a_queue)
    p_queue = []

    for i in range(N):
        t = a_queue[i]
        if len(p_queue) != 0 and t - p_queue[0] > K:
            p_queue = [t]
            bus_count += 1
            continue

        p_queue.append(t)

        if len(p_queue) == C:
            p_queue = []
            bus_count += 1

    if len(p_queue):
        bus_count += 1

    print(bus_count)
    return


main()


Measured memory_bytes: 8280
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s; cin >> s;
  set<int> u;
  for(auto i : s) u.insert(i);
  if(u.size() == s.size()) cout << "yes" << endl;
  else cout << "no" << endl;
  return 0;
}

Measured memory_bytes: 256
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    q, h, s, d = [int(x) for x in input().rstrip().split(" ")]
    n = int(input().rstrip())

    h = h if h < 2 * q else 2 * q
    s = s if s < 2 * h else 2 * h
    d = d if d < 2 * s else 2 * s

    ans = 0

    ans += (n // 2) * d
    n = n % 2

    ans += n * s

    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 61868
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 510000;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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


bool is_prime[MAX];
bool is_prime_small[MAX];

//[a, b)に対して古いを行う。is_prime[i - a] = true = iが素数
ll segment_sieve(ll a, ll b){
    for(int i = 0; (ll)i * i < b; i ++) is_prime_small[i] = true;
    rep(i, b - a) is_prime[i] = true;
    ll p = 0;
    for(int i = 2; (ll)i * i < b; i ++){
        if(is_prime_small[i]){
           for(int j = 2 * i; (ll)j * j < b; j += i) is_prime_small[j] = false; //[2, sqrt(b))の篩
           for(ll j = max(2LL, (a + i - 1) / i); j < b; j += i){
               if(is_prime[j - a]) p ++;
               is_prime[j - a] = false; //[a, b)の篩
           }
        }
    }
    return b - a - p;
}

//x^nをMODで割った値を求めたいとき(繰り返し二乗法）
const int MOD = 1000000007;
ll mod_pow(ll x, ll n){
    ll res = 1;
    while(n > 0){
        if(n & 1)res = res * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int a[n];
    rep(i, n)cin >> a[i];
    sort(a, a + n);
    reverse(a, a + n);
    cout << a[0] << " ";
    P b[n];
    rep(i, n){
        if(i == 0) {
            b[i].first = -100;
            b[i].second = -100;
        }
        else{
        b[i].second = a[i];
        if(a[0] / 2 < a[i]) b[i].first = a[0] - a[i];
        else b[i].first = a[i];
    }}

    sort(b, b + n);
    cout << b[n - 1].second << endl;
   // cout << b[n - 1].first << endl;
}


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

using namespace std;
#define next _next
#define y1 _y1
#define y2 _y2
#define lowbit(x) (x&(-x))
#define lc ((rt)<<1)
#define rc ((rt)<<1|1)
#define mid  ((l+r)>>1)
#define clr(a, b) memset(a,b,sizeof(a))

#ifdef __LOCAL_DEBUG__
# define _debug(fmt, ...) fprintf(stderr, "\033[94m%s: " fmt "\n\033[0m", \
    __func__, ##__VA_ARGS__)
#define dg(a) cout <<"\033[94m" <<#a << "\033[0m = "<< a << endl;
#else
#define _debug(...) ((void)0)
#define dg(a)((void)0)
#endif

typedef long long ll;
typedef long double ld;
const ld pi = acos(-1);
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = static_cast<int>(1e6 + 7);


int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int A, B;
    while (cin >> A >> B) {
        cout << A * B - (A + B) + 1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const ll mod=1e18+7;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}




int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<ll>v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    for(int i=0;i<n;i++){
        if(v[i]%2==0){
            if(v[i]%3!=0 && v[i]%5!=0){cout<<"DENIED"<<endl;return 0;}
        }
    }
    cout<<"APPROVED"<<endl;
    return 0;
    }


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

int main(){
    int s,t,n;
    bool flag=false;
    cin >> s >> t >> n;
    int bs,bt;
    for(int i=0;i<n;i++){
        cin >> bs >> bt;
        if(s>bs&&s<bt)
            flag =true;
        if(t>bs&&t<bt)
            flag = true;
        if(s<=bs&&t>=bt)
            flag = true;
        if(s>=bs&&t<=bt)
            flag = true;
    }
    cout << flag << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less

#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define show(x) cerr << #x << " = " << x << "\n"
#define mem( a , b ) memset( a , b , sizeof a )
#define popcnt(x) __builtin_popcount(x)
#define all(x) x.begin() , x.end()
#define mod(x,m) ((x%m + m )%m)
#define SZ(a) (int)a.size()
#define ll  long long
#define ld  long double
#define vii vector  <ll>
#define dqi deque   <ll>
#define sii set     <ll>
#define vpi vector  <pii>
#define mii map     <ll,ll>
#define pii pair    <ll,ll>
#define pi  pair    <int,int>
#define pb  push_back
#define F   first
#define S   second
#define L   length()
#define OO  (ll)1e18
#define EPS 1e-9
using namespace std;
using namespace __gnu_pbds;
void ONLINE__JUDGE();

typedef tree<ll, null_type, less<ll>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
pii swapii( pii pr ){ return { pr.S , pr.F }; }
ll binEXP( ll x , ll pw , ll MOD = LLONG_MAX );
int dx[] = {  0 ,  0 , -1 , +1 , -1 , +1 , -1 , +1 };
int dy[] = { -1 , +1 ,  0 ,  0 , -1 , +1 , +1 , -1 };

const ll MOD = 1e9 + 7;
const ll MAX = 3e3 + 7;

ll x; vector<ld> vec;
ld dp[MAX][MAX];

ld go( ll i , ll rem ){

    if ( i == x ){
        return 1;
    }

    if ( dp[i][rem] != -1 ) return dp[i][rem];
    ld ans = go( i+1 , rem ) * vec[i];
    if ( rem > 0 ){
        ans += go( i+1 , rem - 1 ) * (1.0 - vec[i]);
    }
    return dp[i][rem] = ans;
}
int main()
{
    FASTIO //ONLINE__JUDGE();

    cin >> x; vec.resize(x);
    for ( ld& i : vec ) cin >> i;

    for ( int i = 0; i < MAX; ++i )
        for ( int j = 0; j < MAX; ++j ) dp[i][j] = -1;
    cout << fixed << setprecision(10) << go(0 , x/2);
    return 0;
}

void ONLINE__JUDGE()
{
    #ifndef ONLINE_JUDGE
    freopen( "inp.c"         , "r" , stdin  );
    //freopen( "OutPut.txt"   , "w" , stdout );
    #endif // ONLINE_JUDGE
}

ll binEXP( ll x , ll pw , ll MOD )
{ ll res=1; while(pw>0){ pw%2 ? res *= x : 0; x *= x; x%=MOD; pw /= 2; res%= MOD; } return res%=MOD; }


Measured memory_bytes: 141952
#include <iostream>
using namespace std;
int main(void){
    int n, k;
    cin >> n >> k;
    
    long long i, sum = 0;
    
    for(i = k+1; i <=n; i++){
        sum += (n/i)*(i - k);
        if(!k) sum--;
        if(n%i >= k) sum += n%i - k + 1;
    }
    
    cout << sum <<endl;
    return 0;
}


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

using namespace std;

#define MAX 1000
#define INF 1e9

int V;
struct State{
  int x, y;
};

vector<State> vec;

double check(State a, State b){
  return sqrt(pow((a.x-b.x),2.) + pow(a.y-b.y,2.));
}

double dist[MAX];
bool used[MAX];
int prev[MAX];
double cost[MAX][MAX];

void dijkstra(int s, int t){
  fill(dist, dist+MAX, INF);
  memset(used,false,sizeof(used));
  memset(prev,-1,sizeof(prev));
  dist[s] = 0;

  while(true){
    int v = -1;
    for(int u = 0 ; u < V ; u++){
      if(!used[u] && (v == -1 || 
		      dist[u] < dist[v])){
	v = u;
      }
    }

    if(v == -1){
      break;
    }else{
      used[v] = true;
    }

    for(int u = 0 ; u < V ; u++){
      if(dist[u] > dist[v] + cost[u][v] && cost[u][v] <= 50){
	dist[u] = dist[v] + cost[u][v];
	prev[u] = v;
      }
    }
  }

  if(dist[t] == INF){
    cout << "NA" << endl;
  }else{
    vector<int> path;
    for(int i = t ; i != -1 ; i = prev[i]){
      path.push_back(i);
    }
    reverse(path.begin(), path.end());
    
    int len = path.size();
    for(int i = 0 ; i < len ; i++){
      cout << path[i]+1 << (i == len-1 ? '\n' : ' ');
    }
  }
}

int main(){
  int n, start, goal, num;
  State s;

  while(cin >> V, V){
    State distance[MAX];

    vec.clear();
    fill(cost[0],cost[V],INF);
    for(int i = 0 ; i < V ; i++){
      cin >> num >> s.x >> s.y;
      vec.push_back(s);
      distance[num-1] = s;
    }

    for(int i = 0 ; i < V-1 ; i++){
      for(int j = i+1 ; j < V ; j++){
	cost[i][j] = cost[j][i] = 
	  check(distance[i],distance[j]);
      }
    }
 
    cin >> n;
    for(int i = 0 ; i < n ; i++){
      cin >> start >> goal;
      start--, goal--;
      dijkstra(start, goal);
    }
  }
  
  return 0;
}

Measured memory_bytes: 2020
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdlib.h>
#include <math.h>

using namespace std;

/////////////         qsortのラッピング

int qsort_int_compare_ascend(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int qsort_int_compare_descend(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
void ascendOrder(int size, int *array) {//sho-jun
	qsort(array, size, sizeof(int), qsort_int_compare_ascend);
}
void descendOrder(int size, int *array) {//ko-jun
	qsort(array, size, sizeof(int), qsort_int_compare_descend);
}

int main() {
	int N;
	cin >> N; N *= 2;
	int *L = new int[N];
	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}
	ascendOrder(N, L);
	int sum = 0;
	for (int i = 0; i < N; i += 2) {
		sum += L[i];
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>

using namespace std;

int main()	{
  int a, b, c;
  cin >> a >> b >> c;
  set<int> paint;
  paint.insert(a);
  paint.insert(b);
  paint.insert(c);
  int count;
  for (auto it : paint)
    count++;
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

//ここから編集

const int MAX = 2000010;
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;
}

ll cum[100010];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(5);
  
  int N; cin >> N;
  vector<ll> x(N+1);
  REP(i,N) cin >> x[i+1];

  COMinit();
  ll ans = 0;
  
  for(int i=0; i<=N; i++){
    cum[i+1] = cum[i] + inv[i+1];

    cum[i+1] %= MOD;
  }

  for(int i=1; i<N; i++){

    ans += (x[i+1]-x[i]) * cum[i] % MOD;
    
    ans %= MOD;  
  }
  ans *= fac[N-1];
  cout << ans%MOD << endl;


}

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

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    int ans = 0;
    int n = s.size();
    for(int i = 0; i < n; i++) {
        if (s[i] == 'S') {
            cnt++;
        } else {
            if (cnt > 0) {
                cnt--;
                ans+=2;
            }
        }
    }
    cout << n - ans << endl;
    return 0;
}


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

const ll INF = 1LL << 60;

ll N;
vector<ll> a;
int main() {
    cin >> N;
    a.resize(N + 1);
    rep(i, N) cin >> a[i + 1];

    // 後ろから決めてく
    vector<ll> ans(N + 1, -1);
    // reverse(a.begin(), a.end());

    // 倍数
    for (int i = N; i > 0; i--) {
        //  cout << i << endl;
        int loop_cnt = N / i;
        if (loop_cnt >= 2) {
            // cout << i << " over" << endl;
            // iより上は計算されている
            ll tmp = 0;
            for (int j = i + i; j <= N; j += i) {
                tmp += ans[j];
            }
            tmp = tmp % 2;
            ans[i] = tmp ^ a[i];
            // cout << tmp << endl;
        } else {
            // cout << i << " " << a[i] << endl;
            // 値固定するしかない
            ans[i] = a[i];
        }
    }

    // reverse(ans.begin(), ans.end());

    set<ll> st;
    for (int i = 1; i <= N; i++) {
        if (ans[i] == 1) {
            st.insert(i);
        };
    }

    cout << st.size() << endl;

    for (auto v : st) {
        cout << v << " ";
    }
    cout << endl;

    // for (int i = 0; i <= ans.size() - 1; i++) {
    //     cout << ans[i] << " ";
    // }
    // cout << endl;
}

Measured memory_bytes: 12156
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    
    string s;
    cin >> s;
    string t;
    for (ll i=0;i<s.length();i++){
        if(s[i] != 'x'){
            t += s[i];
        }
    }
    string f = t;
    reverse(t.begin(),t.end());
    ll ans = 0;
    if(f != t){
        cout << -1 << endl;
    }else{
        ll i=0;
        ll j=s.length()-1;
        while(i < j){
            if(s[i] == s[j]){
                i += 1;
                j -= 1;
            }else if(s[i] == 'x'){
                ans += 1;
                i += 1;
            }else if(s[j] == 'x'){
                ans += 1;
                j -= 1;
            }
        }
        cout << ans << endl;
    }

}



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

using namespace std;

struct Bipartite_Matching
{
  vector< vector< int > > graph;
  vector< int > match, alive, used;
  int timestamp;

  Bipartite_Matching(int n)
  {
    timestamp = 0;
    graph.resize(n);
    alive.assign(n, 1);
    used.assign(n, 0);
    match.assign(n, -1);
  }

  void add_edge(int u, int v)
  {
    graph[u].push_back(v);
    graph[v].push_back(u);
  }

  bool dfs(int v)
  {
    used[v] = timestamp;
    for(int i = 0; i < graph[v].size(); i++) {
      int u = graph[v][i], w = match[u];
      if(alive[u] == 0) continue;
      if(w == -1 || (used[w] != timestamp && dfs(w))) {
        match[v] = u;
        match[u] = v;
        return (true);
      }
    }
    return (false);
  }

  int bipartite_matching()
  {
    int ret = 0;
    for(int i = 0; i < graph.size(); i++) {
      if(alive[i] == 0) continue;
      if(match[i] == -1) {
        ++timestamp;
        ret += dfs(i);
      }
    }
    return (ret);
  }
};


const int LIM = (int) 1e7;
bool prime[LIM + 1];

int main()
{
  prime[0] = prime[1] = true;
  for(int i = 2; i * i <= LIM; i++) {
    if(!prime[i]) {
      for(int j = i + i; j <= LIM; j += i) {
        prime[j] = true;
      }
    }
  }

  int N;
  cin >> N;
  vector< int > vs;
  for(int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if(vs.empty() || vs.back() + 1 != x) {
      vs.emplace_back(x - 1);
      vs.emplace_back(x);
    } else {
      ++vs.back();
    }
  }

  vector< int > latte, malta;
  for(auto &p : vs) {
    if(p & 1) latte.emplace_back(p);
    else malta.emplace_back(p);
  }

  int ret = 0;

  if(!latte.empty() && !malta.empty()) {
    Bipartite_Matching flow(latte.size() + malta.size());
    for(int i = 0; i < latte.size(); i++) {
      for(int j = 0; j < malta.size(); j++) {
        if(!prime[abs(latte[i] - malta[j])]) {
          flow.add_edge(i, j + latte.size());
        }
      }
    }
    ret = flow.bipartite_matching();
  }

  int beet1 = latte.size() - ret;
  int beet2 = malta.size() - ret;
  ret += beet1 / 2 * 2;
  ret += beet2 / 2 * 2;
  ret += beet1 % 2 * 3;
  cout << ret << endl;
}

Measured memory_bytes: 10112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define coutif(a,b,c) cout<<(a?b:c)
#define all(x) (x).begin(), (x).end()
#define uint usigned int
typedef vector <pair<ll,ll>> vi;
ll MOD = 1e9+7;
//vi v1[200005],v2;
//bool visit[200005]={false};
/*void bfs(ll n){
    queue<ll> q;
    q.push(n);
    visit[n]=true;
    while(!q.empty()){
        ll t=q.front();
        q.pop();
        v2.pb(t);
        for(ll i=0;i<v1[t].size();i++){
            if(visit[v1[t][i]]==false){
                q.push(v1[t][i]);
                visit[v1[t][i]]=true;
            }
        }
    }
}*/
/*void dfs(ll n){
    for(ll i=0;i<v1[n].size();i++)
    {
        ll y=v1[n][i];
        if(visit[y]==0)
        {
            v2.pb(y);
            visit[y]=1;
            dfs(y);
        }
    }
}*/
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
    ll j,i,n,m,k,x,y,ans=0,c=0,error=0;
    cin>>n>>m;
    vector<ll> a;
    vi v;
    for(i=0;i<n;i++) cin>>x,a.pb(x);
    sort(all(a));
    for(i=0;i<m;i++){
        cin>>x>>y;
        v.pb(mp(y,x));
    } 
    sort(all(v));
	for(i=m-1;i>=0;i--){
	    x=v[i].ss;
	    y=v[i].ff;
	 //   cout<<x<<" "<<y<<endl;
	    for(j=0;j<x;j++){
	        if(j+c>=n){
	            error=2;
	            break;
	        }
	        if(a[j+c]<y){
	            ans+=y;
	        }
	        else{
	            error=1;
	            break;
	        }
	    }
	    if(error==1 || error==2){c+=j; break;}
	    else c+=x;
	}
	if(c<n){
	    for(i=c;i<n;i++) ans+=a[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3188
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

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

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

    int n, d;
    cin >> n >> d;
    d = d * 2 + 1;

    int ans = (n - 1) / d + 1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(void)
{
 
  long long a, b, r, x, tmp;
 
  cin>>a>>b;
  x = a * b;
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  /* 最小公倍数を出力 */
  cout<<x/b<<endl;
}

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

struct cards {
	string suit;
	int val;
};

void bblsort( cards c[], int N )
{
	for( int i = 0; i < N; i++ ) {
		for( int j = N -1; j > i; j-- ) {
			if( c[ j ].val < c[ j - 1 ].val ) {
				swap( c[ j ], c[ j - 1 ] );
			}
		}
	}
	return;
}

void selsort( cards c[], int N )
{
	for( int i = 0; i < N; i++ ) {
		int minj = i;
		for( int j = i; j < N; j++ ) {
			if( c[ j ].val < c[ minj ].val ) {
				minj = j;
			}
		}
		swap( c[ i ], c[ minj ] );
	}
	return;
}

void dump( cards c[], int N )
{
	for( int i = 0; i < N; i++ ) {
		cout << c[ i ].suit << c[ i ].val;
		if( i == N - 1 ) {
			cout << endl;
		}
		else {
			cout << " ";
		}
	}
	return;
}

void copy( cards c[], cards d[], int N )
{
	for( int i = 0; i < N; i++ ) {
		d[ i ] = c[ i ];
	}
}

void mkstable( vector<cards> &v, cards c[], int N )
{
	for( int i = 1; i < 10; i++ ) {
		for( int j = 0; j < N; j++ ) {
			if( i == c[ j ].val ) {
				v.push_back( c[ j ] );
			}
		}
	}

	if( false ) {
		cout << "*";
		for( int i = 0; i < N; i++ ) {
			cout << v[ i ].suit << v[ i ].val << " ";
		}
		cout << endl;
		return;
	}
}

void chkstable( cards c[], cards d[], int N )
{
	vector<cards> sc;
	vector<cards> sd;

	mkstable( sc, c, N );
	mkstable( sd, d, N );

	bool isstable = true;
	for( int i = 0; i < N; i++ ) {
		if( sc[ i ].suit != sd[ i ].suit and sc[ i ].val == sd[ i ].val ) {
			isstable = false;
		}
	}

	if( isstable == true ) {
		cout << "Stable" << endl;
	}
	else {
		cout << "Not stable" << endl;
	}

	return;
}

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

	cards c[ N ];
	for( int i = 0; i < N; i++ ) {
		string tmp;
		cin >> tmp;
		c[ i ].suit = tmp[ 0 ];
		c[ i ].val  = tmp[ 1 ] - '0';
	}

	cards d[ N ];
	copy( c, d, N );
	bblsort( d, N );
	dump( d, N );
	chkstable( c, d, N );

	copy( c, d, N );
	selsort( d, N );
	dump( d, N );
	chkstable( c, d, N );
	
	return 0;
}





Measured memory_bytes: 3168
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	ll n, k;
	cin >> n >> k;
	ll ans = 0;

	for (ll i = k; i <= n; i++){
		ans += (n*(n+1)/2)%MOD - ((n-i)*(n-i+1)/2)%MOD - ((i-1)*i/2)%MOD + 1;
		ans %= MOD;
	}

	if((ans+1)%MOD < 0) cout << (ans+1)%MOD+MOD << endl;
	else cout << (ans+1)%MOD  << endl;
	return 0;
}


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

#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++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int divisor_num(int n)
{
    map<int, int> mp;
    int cnt = 1;
    int m = (int)sqrt(n);
    for (int i = 2; i <= m; i++)
    {
        while (n % i == 0)
        {
            n /= i;
            mp[i]++;
        }
    }
    for (auto x : mp)
    {
        cnt *= (x.second + 1);
    }
    return cnt;
}

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i % 2 == 0)
            continue;
        if (divisor_num(i) == 8)
            ans++;
    }
    OP(ans);
    return 0;
}

Measured memory_bytes: 256
import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort()
b.sort()
c.sort()

count = 0
for i in b:
  count += bisect.bisect_left(a, i) * (len(c) - bisect.bisect(c, i))
print(count)


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

int main(){
	int n,l;
	cin>>n>>l;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	map<int,int>M;
	for(int i=0;i<n;i++){
		M[a[i]]++;
		if(i<l-1) continue;
		cout<<(*(M.begin())).first<<(i==n-1?"":" ");
		M[a[i-l+1]]--;
		if(!M[a[i-l+1]]) M.erase(a[i-l+1]);
	}
	cout<<endl;

}





Measured memory_bytes: 11684
n=gets.chomp.to_i

n.times {
	a,b,c=gets.chomp.split(" ").map{|i| i.to_i}
	
	if 	([a,b,c].max ** 2) *2 == a ** 2 + b ** 2 + c ** 2
		puts "YES"
	else
		puts "NO"
	end
}

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

using namespace std;
bool d[110];

int main()
{
 int x,n,minV=1e9,u,res;
  cin>>x>>n;
  for (int i=1;i<=n;++i){ cin>>u;d[u]=true;}
  for (int i=0;i<=101;++i)
  {
    if (!d[i] && abs(i-x)<minV)
    {
      res=i;
      minV=abs(i-x);
    }
  }
  cout<<res;
  return 0;
}


Measured memory_bytes: 3600
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        char[] O = sc.next().toCharArray();
        char[] E = sc.next().toCharArray();

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < E.length; i++) {
            sb.append(O[i]);
            sb.append(E[i]);
        }

        if (O.length - E.length > 0) sb.append(O[O.length - 1]);
        
        
        System.out.println(sb.toString());

        return;
    }

}

Measured memory_bytes: 22356
#include <stdio.h>
#include <math.h>

int main(void){
 int a[3],tmp,i,j;
  scanf("%d %d %d",&a[0],&a[1],&a[2]);
  for(i=0;i<2;i++){
    for(j=i+1;j<3;j++){
      if(a[i]<a[j]){// 3 5 6 -> 5 3 6
        tmp=a[i];
        a[i]=a[j];
        a[j]=tmp;
      }
    }
  }
  printf("%d",(abs(a[0]-a[1])+abs(a[1]-a[2])));
  return 0;
}


Measured memory_bytes: 128
N,D = map(int,input().split())

a = [list(map(int,input().split())) for _ in range(N)]

def isSquare(x):
  f = 1
  while f * f <= x:
    if f * f == x:
      return True
    else:
      f += 1
  return False
  
def calcSquareOfDistance(p1,p2,dimension):
  s = 0
  for i in range(dimension):
    s += (p1[i] - p2[i])**2
  return s

def judge(p1,p2,dimension):
  return isSquare(calcSquareOfDistance(p1,p2,dimension))

ans = 0
for i in range(N-1):
  for j in range(i+1,N):
    if judge(a[i],a[j],D):
      ans += 1
print(ans)

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

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  
  for( int i = A; i <= B; i++ ){
    if( i < A+K|| i > B-K ){
      cout << i << endl;
    }
  }
  
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

buk = {}
for x in a:
  if x in buk:
    buk[x] += 1
  else:
    buk[x] = 1

c = {}

from operator import mul
from functools import reduce


def cmb(n, r):
  r = min(n - r, r)
  if r == 0:
    return 1
  over = reduce(mul, range(n, n - r, -1))
  under = reduce(mul, range(1, r + 1))
  return over // under


ansall = 0
for _, z in buk.items():
  if z >= 2:
    ansall += cmb(z, 2)

for x in a:
  if buk[x] - 1 >= 2:
    print(ansall - cmb(buk[x], 2) + cmb(buk[x] - 1, 2))
  elif buk[x] == 2:
    print(ansall - 1)
  else:
    print(ansall)


Measured memory_bytes: 26140
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	BufferSize = 100
)

func readLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func scanStr(sc *bufio.Scanner) string {
	if !sc.Scan() {
		panic(nil)
	}
	return sc.Text()
}

func scanInt(sc *bufio.Scanner) int {
	if !sc.Scan() {
		panic(nil)
	}
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, BufferSize)
	sc.Split(bufio.ScanWords)

	s := scanStr(sc)
	switch s {
	case "SUN":
		fmt.Println("7")
	case "MON":
		fmt.Println("6")
	case "TUE":
		fmt.Println("5")
	case "WED":
		fmt.Println("4")
	case "THU":
		fmt.Println("3")
	case "FRI":
		fmt.Println("2")
	case "SAT":
		fmt.Println("1")
	}
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

void f()
{
  string s;
  cin>>s;
  for(int i=0;i<3;i++)
  {
    if(s[i]=='1')
      cout<<9;
    else
      cout<<1;
  }
  cout<<nl;
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <vector>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a[10];
  int k,b;
  for(int i=0;i<5;i++){
    cin>>a[i];
  }
  cin>>k;
  sort(a,a+5);
  b=a[4]-a[0];
  if(k<b){
    cout<<":("<<"\n";
  }
  else{
    cout<<"Yay!"<<"\n";
  }
  return 0;
}

Measured memory_bytes: 3596