akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<utility>
#include<algorithm>

using namespace std;

const int MAX_N = 100;
int A[MAX_N];
int N ;


int main(void){
  int count = 1 ;
  cin >> N ;
  for(int i = 0; i < N ; i++){
    cin >> A[i];
    }
  sort(A,A+N);

  for(int i = 1; i < N ; i++){
    if(A[i] > A[i-1]) count++ ;
  }

  cout << count << endl;




  return 0;

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n;
    cin>>n;
    if(n<1200) cout<<"ABC";
   	else cout<<((n<2800)?"ARC":"AGC");
  	return 0;
}

Measured memory_bytes: 3540
import java.util.*;
public class Main {

	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Main() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		Iterator<LinkedList<Integer>> it1 = adjList.iterator();
		
		for(int i = 0; i < adjMatrix.length; i ++) {
			for(int j = 0; j < adjMatrix[i].length; j++) {
				adjMatrix[i][j] = 0;
			}	
		}
		
		
		int row = 0;
		while(it1.hasNext()) {
		LinkedList<Integer> tmp = it1.next();
		Iterator <Integer> it2 = tmp.iterator();
			while(it2.hasNext()) {
				adjMatrix[row][it2.next()] = 1;
			}
			row++;
		}
	
			
			for(int i = 0; i < adjMatrix.length; i++) {
				for(int j  = 0; j < adjMatrix[i].length; j++) {
					if(j == adjMatrix[i].length-1) {
						System.out.print(adjMatrix[i][j]);
					}
					else {
						System.out.print(adjMatrix[i][j]+" ");
					}
				}
				System.out.println();
			}
	       
	       
		}
	


//change class name GraphRepresentation to Main() for submission to AIZU
	public static void main(String args[]) {
		Main g = new Main();
		g.loadAdjList();
		g.printAdjMatrix();
	}
}





Measured memory_bytes: 32888
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    ll a[87] = {2, 1}, n;
    for (int i = 2; i <= 86; i++) a[i] = a[i - 1] + a[i - 2];
    cin >> n;
    cout << a[n];
}


Measured memory_bytes: 256
N = int(input())
S = []
T = []
for i in range(N):
    [stmp,ttmp] = list(input().split())
    S.append(stmp)
    T.append(int(ttmp))
X = input()
output = 0
flag = 0
for i in range(N):
    if flag == 1:
        output += T[i]
    if S[i]==X:
        flag += 1
print(output)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
   ll n;cin>>n;
   ll a[n];bool ok=0;
   f(i,0,n){cin>>a[i];
 
   if(a[i]%2==0){
       if(a[i]%3==0 || a[i]%5==0)continue;
       else {ok=1;break;}
   }
   }
   if(ok)cout<<"DENIED";
   else cout<<"APPROVED";
   
    return 0;  
} 

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

int main() {
  int N;
  cin >> N;
  
  int Yellow = 0;
  
  for(int i=0; i<N; i++){
    string S;
    cin >> S;
    if(S == "Y"){
      Yellow++;
    }
  }
  if(Yellow > 0){
    cout << "Four" << endl;
  }
  else{
    cout << "Three" << endl;
  }
}

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

using namespace std;
typedef long long ll;

const int maxN = 100010;

queue<int> Q;
vector<int> G[maxN];
int pc[maxN], cnt[3];

int bfs(int u){
	Q.push(u);
	++cnt[pc[u] = 1];
	while(Q.size()){
		u = Q.front(); Q.pop();
		for(int i = 0; i < G[u].size(); ++i){
			int v = G[u][i];
			if(!pc[v]){
				++cnt[pc[v] = 3 - pc[u]];
				Q.push(v);
			}
			else if(pc[v] != 3 - pc[u]) return 0;
		}
	}
	return 1;
}

int main (){
	int n, m, i, a, b;
	scanf("%d%d", &n, &m);
	for(i = 0; i < m; ++i){
		scanf("%d%d", &a, &b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	ll ans;
	if(bfs(1)) ans = cnt[1] * 1ll * cnt[2] - m;
	else ans = n * 1ll * (n - 1) / 2 - m;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 9772
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
    long n;
    std::vector<int> dp(100010);
    std::cin >> n; 
    std::vector<int> h_vec;
    int h;
    while (std::cin >> h) {
        h_vec.push_back(h);
    }
    for (int i = 1; i < n; i++) {
        if (i == 1) {
            dp[i] = std::abs(h_vec[i] - h_vec[i - 1]);
        } else {
            dp[i] = std::min(dp[i - 2] + std::abs(h_vec[i - 2] - h_vec[i]), dp[i - 1] + std::abs(h_vec[i - 1] - h_vec[i]));
        }
    }
    std::cout << dp[n - 1] << std::endl;
}


Measured memory_bytes: 1276
#include <vector>
#include <list>
#include <map>
#include <set>
#include "queue"
#include <deque>
#include <stack>
#include <numeric>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <complex>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include "fstream"
using namespace std;
#define PI acos(-1)
#define MOD (ll)1000000007
#define pii pair<long long ,long long >
#define ll  long long int
#define loop(i,n) for(ll i=0;i<n;i++)
#define loop2(i,n) for(ll i = 1;i<=n;i+=1)
#define pb push_back
#define mp make_pair
#define EPS 1e-8
void display(vector<ll> v1){loop(i,v1.size()){cout<<v1[i]<<" ";}cout<<endl;}
ll dx[8] = {0,1,0,-1,1,1,-1,-1};
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
using namespace std;

//JAI SHREE KRISHNA
//Bigger the ocassion better the response
//Pull the rabbit out of the hat again !

string s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    if(n%11==0)
    {
        cout<<n/11*2<<endl;
    }
    else if(n%11<=6){
        cout<<n/11*2+1<<endl;
    }
    else{
        cout<<n/11*2+2<<endl;
    }
    return 0;
}

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

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

	if(n >= m){
		cout << "0\n";
		return 0;
	}
	vector<int> x(m);
	for(int i = 0; i < m; i++){
		cin >> x[i];
	}
	sort(x.begin(), x.end());

	vector<int> dist(m-1);
	for(int i = 0; i < m-1; i++)
		dist[i] = x[i+1] - x[i];

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

	int ans = 0;
	for(int i = 0; i < m-n; i++)
		ans += dist[i];

	cout << ans << "\n";

	return 0;
}


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

#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define setbits(x) __builtin_popcount(x)
#define zerobits(x) __builtin_ctz(x)
#define setbitsll(x) __builtin_popcountll(x)
#define zerobitsll(x) __builtin_ctzll(x)
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x

typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef map<int,int> mii;

const int MOD = 1e9+7;

void solve () {
	int n;
	cin >> n;
	vi arr(n);
	for (int i = 0;i < n;++i) {
		cin >> arr[i];
	}
	sort(all(arr),greater<int>());
	ll ans = arr[0];
	int cnt = 1;
	for (int i = 1;i < n;++i) {
		if (cnt == n-1) {
			break;
		}
		ans += arr[i];
		++cnt;
		if (cnt == n-1) {
			break;
		}
		ans += arr[i];
		++cnt;
	}
	cout << ans << '\n';

}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}

	

Measured memory_bytes: 3988
import java.util.Scanner;

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

        while (sc.hasNext()) {
            double a = Integer.parseInt(sc.next());
            double b = Integer.parseInt(sc.next());
            double c = Integer.parseInt(sc.next());
            double d = Integer.parseInt(sc.next());
            double e = Integer.parseInt(sc.next());
            double f = Integer.parseInt(sc.next());

            double x = (c*e - b*f) / (a*e - b*d);
            double y = (c - a*x) / b;

            if (x == 0.0) {
                x = 0.0;
            }
            if (y == 0.0) {
                y = 0.0;
            }

            System.out.printf("%4.3f %4.3f\n", x, y);
        }
    }
}

Measured memory_bytes: 26236
h, w, k= map(int,input().split())
MOD = 10**9+7
dp, fib = [[0]*10 for i in range(h+1)], [1,1,2,3,5,8,13,21]
dp[0][1] = 1
if w == 1:
    print(1)
else:
    for i in range(1,h+1):
        for j in range(1, w+1):
            fromleft, fromabove, fromright = 0, 0, 0
            if j == 1: # 左端の場合
                fromabove = dp[i-1][j]*fib[w-1]
                fromright = dp[i-1][j+1]*fib[w-2]
            elif j == w: # 右端の場合
                fromleft = dp[i-1][j-1]*fib[w-2]
                fromabove = dp[i-1][j]*fib[w-1]
            else: # 中央当たりの場合
                fromleft = dp[i-1][j-1]*fib[j-2]*fib[w-j]
                fromabove = dp[i-1][j]*fib[j-1]*fib[w-j]
                fromright = dp[i-1][j+1]*fib[j-1]*fib[w-j-1]
            dp[i][j] = (fromleft+fromabove+fromright)%MOD
            #print(i, j, fromleft, fromabove, fromright)
    print(dp[h][k])
# print(dp)

Measured memory_bytes: 3064
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

void solve()
{
    IN(n);
    string* s = new string[n];
    int* m = new int[n];
    rep(i, n)
    {
        cin >> s[i] >> m[i];
    }
    string ss; cin >> ss;
    bool add = false;
    int result = 0;
    rep(i, n)
    {
        if (add) result += m[i];
        if (s[i] == ss) add = true;
    }
    cout << result << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debugF(cout, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

void linearSieve(int n, vi &minP, vi &primeList){
    // minP[i] = minimum prime in i factorization
    // minP[0] = minP[1] = -1
    // O(n) (int) mem
    // O(n) runtime

    minP.clear(); minP.resize(n+1,0);
    primeList.clear();

    minP[0] = minP[1] = -1;
    for(int i=2;i<=n;++i){
        if(minP[i] == 0){
            minP[i] = i;
            primeList.push_back(i);
        }
        ll x;
        for(int j=0;j < primeList.size() && primeList[j] <= minP[i];++j){
            x = ll(i) * primeList[j];
            if(x > n) break;
            minP[x] = primeList[j];
        }
    }
}
const int maxa = 1e6;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    vi minP, primeL;
    linearSieve(maxa, minP, primeL);
    vb used(maxa+1, false);
    int n, i;
    cin >> n;
    int setG = 0;
    bool pairWise = true;
    for(i=0;i<n;i++){
        int a; cin >> a;
        setG = gcd(setG, a);
        if(!pairWise) continue;
        while(a != 1){
            int p = minP[a];
            while(a%p == 0){
                a /= p;
            }
            if(used[p]){
                pairWise = false;
                break;
            }else{
                used[p] = true;
            }
        }
    }
    string ans;
    if(pairWise){
        ans = "pairwise coprime";
    }else if(setG == 1){
        ans = "setwise coprime";
    }else{
        ans = "not coprime";
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 7724
n, m, d = map(int,input().split())
pnt = 0.
if d==0:
    pnt = (1./n)*(m-1)
else:
    a = max(n-2*d,0)
    pnt = ((a*2 +(n-a))/n**2)*(m-1)
print(pnt)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

int R, B, W, G;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> R >> B >> W >> G;
    int ans = R + B + W + G;
    cout << ans << endl;
}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    int ans = 0;
    rep(i,10000){
        if(i*x >= n){
            ans = t * i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3632
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
	cout << "{ ";
	for (const auto &v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

ll power(ll x, ll y)
{
	ll res = 1;
	while (y)
	{
		if (y & 1)
			res = mul(res, x, MOD);
		y /= 2;
		x = mul(x, x, MOD);
	}
	return res;
}

const int N = 1e5 + 5;
ll dp[N];
//gcd is i
ll go(ll n, ll k)
{
	dp[k] = 1;
	for (int i = k - 1; i >= 1; i--)
	{
		ll cnt = k / i;
		ll ans = power(cnt, n);
		for (int j = 2 * i; j <= k; j += i)
			ans = add(ans, MOD - dp[j], MOD);
		dp[i] = ans;
	}
	return dp[k];
}

void solve()
{
	ll n, k;
	cin >> n >> k;
	ll ans = 0;
	memset(dp, -1, sizeof(dp));
	go(n, k);
	for (int i = 1; i < k + 1; i++)
		ans = add(ans, mul(i, dp[i], MOD), MOD);
	cout << ans << ln;
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	clock_t start, stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for (int tc = 1; tc < t + 1; tc++)
		solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 4408
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <vector>
#define   FOR(i,n) for(int i=0;i<n;i++)

using namespace std;
int int_sort(const void*a,const void *b) {
    return *(  int *) b - *(int *) a;
    //qsort(b, a, sizeof(long long int), int_sort);
}

int main() {

    int a,b,c,d;
    cin >>a >>b>>c;
    if(c<=a+b)
        cout<<"Yes";
    else
        cout<<"No";

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

ld _closest_pair_of_points(vector<pair<ld, ld>>& ps, int l, int r){
    constexpr ld INF = 1e15L;
    constexpr ld eps = 1e-10L;
    if (r - l <= 1) return INF;
    const int m = (l + r) / 2;
    ld x_mid = ps[m].first;
    ld left_half = _closest_pair_of_points(ps, l, m);
    ld right_half = _closest_pair_of_points(ps, m, r);
    ld res = min(left_half, right_half);
    inplace_merge(
        ps.begin() + l, ps.begin() + m, ps.begin() + r, 
        [](const pair<ld, ld> a, const pair<ld, ld> b){
            return a.second < b.second;
        }
    );
    vector<int> idx;
    for (int i = l; i < r; ++i){
        if (abs(ps[i].first - x_mid) > res + eps)
            continue;
        for (int j = idx.size() - 1; j >= 0; --j){
            ld dx = ps[i].first - ps[idx[j]].first;
            ld dy = ps[i].second - ps[idx[j]].second;
            if (dy > res + eps) break;
            res = min(res, sqrtl(dx * dx + dy * dy));
        }
        idx.push_back(i);
    }
    return res;
}

ld closest_pair_of_points(vector<pair<ld, ld>> lis){
    sort(lis.begin(), lis.end());
    return _closest_pair_of_points(lis, 0, lis.size());
}

int main(void){
    int n; cin >> n;
    vector<pair<ld, ld>> lis(n);
    for (int i = 0; i < n; ++i)
        cin >> lis[i].first >> lis[i].second;
    cout << fixed << setprecision(15) << closest_pair_of_points(lis) << endl;
    return 0;
}


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

typedef unsigned long long ll;
typedef std::pair<int, int> P;

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define All(i, x) for(typeof(x.begin()) i = x.begin(); i != x.end(); i++)
#define pb push_back

const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int MAX = 100000;
const int INF = 1e9;
const int MOD = 1000000007;

void solve(){
	int n; cin >> n;
	map<int, int> map;
	Rep(i, n){
		int tmp; cin >> tmp;
		map[tmp] += 1;
	}
	int ans = 0;
	All(i, map){
		int x = i -> first;
		int y = i -> second;
		if(x > y) ans += y;
		else ans += (y - x);
	}
	cout << ans << endl;
}

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


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

int main(){

  int n;
  int comb[4][51] = {0};

  for(int i=0; i<10; i++){
    comb[0][i] = 1;
  }

  for(int i=1; i<4; i++){
    for(int j=0; j<9*i+10; j++){
      for(int k=0; k<10; k++){
        if(j-k>=0){
          comb[i][j] += comb[i-1][j-k];
        }
      }
    }
  }

/*  for(int i=0; i<4; i++){
    for(int j=0; j<51; j++){
      cout << comb[i][j] << " ";
    }
    cout << endl;
  }
*/

  while(cin >> n){
    cout << comb[3][n] << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] arr = br.readLine().split(" ");
        double W = Double.parseDouble(arr[0]);
        double H = Double.parseDouble(arr[1]);
        double x = Double.parseDouble(arr[2]);
        double y = Double.parseDouble(arr[3]);
        double ans = 0;
        double half = W * H / 2;
        int flg = 0;
        
        // // 対角線上か半分にする線上か
        // if (y / x == (H - y) / (W - x) 
        //     || (H - y) / x == y / (W - x)
        //     || x == W / 2 || y == H / 2) {
            ans = half;
            if (x == W / 2 && y == H / 2) {
                flg = 1;
            }
        // } else {
        //     double ans1 = W * Math.min(y, H - y);
        //     double ans2 = H * Math.min(x, W - x);
        //     ans = Math.max(ans1, ans2);
        //     if (ans1 == ans2) {
        //         flg = 1;
        //     } 
        // }

        out.println(ans + " " + flg);
        out.close();
    }
}


Measured memory_bytes: 23124
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] nums=new int[n];
        for(int i=0;i<n;i++)nums[i]=sc.nextInt();
        int ans=1;
        for(int i=0;i<n-1;i++){
            if(nums[i]>=nums[i+1])ans++;
        }
        System.out.println(ans);
        System.out.println(n);
    }
    
}


Measured memory_bytes: 69352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll N, K;
  cin >> N >> K;
  ll pat = N / K;
  ll ans = pat * pat * pat;
  if (K % 2 == 0 && N*2 >= K){
    ll pat2 = (N - K/2) / K + 1;
    ans += pat2 * pat2 * pat2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <numeric>

using namespace std;

#define EPS 1e-5
#define PI acos(-1)

int main(){
	int m,n,ret;
	
	while(cin >> m && m){
		double sm=0, sn=0;
		vector<int> ms(m);
		for(int i=0;i<m-1;i++){
			cin >> ms[i];
		}
		ms[m-1] = 360 - accumulate(ms.begin(),ms.end(),0);
		cin >> n;
		vector<int> ns(n);
		for(int i=0;i<n-1;i++){
			cin >> ns[i];
		}
		ns[n-1] = 360 - accumulate(ns.begin(),ns.end(),0);
		for(int i=0;i<m;i++){
			sm += sin((double)ms[i] / 180 * PI);
		}
		for(int i=0;i<n;i++){
			sn += sin((double)ns[i] / 180 * PI);
		}

		if(sm == sn){
			ret = 0;
		}else if(sm > sn){
			ret = 1;
		}else{
			ret = 2;
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 0
import collections
N = int(input())
UVW = [[int(_) for _ in input().split()] for _ in range(N - 1)]
cd = collections.defaultdict
G = cd(lambda: cd(int))
for u, v, w in UVW:
    G[u][v] = G[v][u] = w
ans = [-1] * (N + 1)
ans[1] = 0
stack = [1]
while stack:
    f = stack.pop()
    for t in G[f].keys():
        if ans[t] == -1:
            stack += [t]
            if G[f][t] % 2:
                ans[t] = 1 - ans[f]
            else:
                ans[t] = ans[f]
print(*ans[1:], sep='\n')


Measured memory_bytes: 64792
import math

A,B,H,M=map(int,input().split())

# 時針の初期度数＋分に応じた度数
hour_rad = (30*H)+(0.5*M)

# 分針の度数
minutes_rad = 6*M

# 時針と分針の間の角度
clock_rad = 0
if abs(minutes_rad - hour_rad) <= 180:
    clock_rad = abs(minutes_rad - hour_rad)
else:
    clock_rad = 360 - abs(minutes_rad - hour_rad)

#print('hour : ' + str(hour_rad))
#print('min : ' + str(minutes_rad))
#print('clock : ' + str(clock_rad))

ans=math.sqrt((A**2)+(B**2)-2*A*B*math.cos(math.radians(clock_rad)))
print(ans)

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

typedef long long int ll;

ll spf[1000005];

void sieve () {
	spf[1] = 1;
	
	for (ll i=2 ; i<1000005 ; i++) {
		spf[i] = i;
		
	}
	
	for (ll i=4 ; i<1000005 ; i+=2) {
		spf[i] = 2;
	}
	
	for (ll i=3 ; (i*i)<1000005 ; i++) {
		if (spf[i]==i) {
			for (ll j=(i*i) ; j<1000005 ; j+=i) {
				if (spf[j]==j) spf[j] = i;
			}
		}
	}
}


int main () {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    sieve();
    
    ll n;
    cin >> n;
    
    unordered_map<ll,ll>mp;
    
	ll a[n];
	
	for (ll i=0 ; i<n ; i++) {
		cin >> a[i];
	}
	
	ll gcdAll = a[0];
	
	for (ll i=1 ; i<n ; i++) {
		gcdAll = __gcd(gcdAll, a[i]);
	}
	
	if (gcdAll!=1) {
		cout << "not coprime\n";
		return 0;
	} 
	
	ll flag = 0;
	
	for (ll i=0 ; i<n ; i++) {
		unordered_map<ll,ll>vis;
		while (a[i]!=1) {
			if (vis[spf[a[i]]]==0 && mp[spf[a[i]]]==1) {
				flag = 1;
				break;
			}
			mp[spf[a[i]]] = 1;
			vis[spf[a[i]]] = 1;
			a[i] /= spf[a[i]];
		}
		
		if (flag==1) break;
		
	}
	
	if (flag==1) {
		cout << "setwise coprime\n";
	}
	else {
		cout << "pairwise coprime\n";
	}
	
	
    
    
}


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

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

int main() {
    int n; cin>>n;
    ll a=1, b=1;

    rep(i,n){
        ll s,t; cin>>s>>t;

        ll u = (a-1) / s + 1;
        ll v = (b-1) / t + 1;
        ll w = max(u,v);

        a = w*s; b = w*t;
    }

    cout << a+b << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0

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

ll lcm(ll a, ll b) {
    return a / gcm(a,b) * b;
}

ll solve()
{
    ll N;
    cin >> N;
    ll ans = 0;
    for1(i,N) {
        ll t;
        cin >> t;
        if (i == 0) {
            ans = t;
        } else {
            ans = lcm(ans, t);
        }
    }
    return ans;
}

int main()
{
    do {
        cout << solve() << endl;
    } while (DEBUG);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ulong = unsigned long;
using ull = unsigned long long;

ulong getRepeatPos(const vector<ull> &items){
  const size_t itemSize = items.size();
  ull newestItem = items[itemSize - 1];
  for(ulong i = itemSize - 2; ; i--){
    if(newestItem == items[i]){
      return i;
    }
    if(i == 0){
      break;
    }
  }
  return itemSize;
}

ull getResult(ulong term, const uint initial, const uint mod){
  vector<ull> items(1, initial);
  ull sum = initial;
  ull newestItem = initial;

  size_t itemSize;
  ulong repeatPosMin, repeatPosMax;
  for(ulong i = 1; ; i++){
    if(i >= term){
      return sum;
    }
    items.push_back(newestItem * newestItem % mod);
    itemSize = items.size();
    newestItem = items[itemSize - 1];
	repeatPosMin = getRepeatPos(items);
	if(repeatPosMin < itemSize - 1){
      repeatPosMax = itemSize - 1;
      break;
    }
    sum += newestItem;
  }

  const ulong repeatCount = repeatPosMax - repeatPosMin;
  ull repeatSum = 0;
  for(ulong i = repeatPosMin; i < repeatPosMax; i++){
    repeatSum += items[i];
  }
  
  term -= repeatPosMax;
  sum += term / repeatCount * repeatSum;

  ulong surplus = term % repeatCount;
  if(surplus != 0){
    for(ulong i = 0; i < surplus; i++){
      sum += items[i + repeatPosMin];
    }
  }
  
  return sum;
}
 
int main(){
  ulong N;
  uint X, M;
  cin >> N >> X >> M;
  
  ull result = getResult(N, X, M);  
  cout << result;
  return 0;
}

Measured memory_bytes: 3860
#include <stdio.h>

int main(void){

  long n,q;
  scanf("%ld %ld", &n, &q);
  char s[n+1];
  scanf("%s", s);
  long l[q];
  long r[q];
  for (long i = 0; i < q; i++) {
    scanf("%ld %ld", &l[i], &r[i]);
  }

  long ac_count[n];
  ac_count[0] = 0;
  for (long i = 1; i < n; i++) {
    if (s[i-1] == 'A' && s[i] == 'C') {
      ac_count[i] = ac_count[i-1]+1;
    } else {
      ac_count[i] = ac_count[i-1];
    }
  }

  long answer;
  for (long i = 0; i < q; i++) {
    if (l[i] > 1) {
      answer = ac_count[r[i]-1] - ac_count[l[i]-2];
      if (s[l[i]-2] == 'A' && s[l[i]-1] == 'C') {
        answer--;
      }
    } else {
      answer = ac_count[r[i]-1];
    }
    printf("%ld\n", answer);
  }

  return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define int long long




signed main(){
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    vector<int> m1,m2;
    m2.push_back(0);
    int u=0,p=1;
    for(int i=0;i<n;i++){
        if(p==1){
            if(s[i]!='1'){
                p=0;
                m1.push_back(i);
            }
        }else{
            if(s[i]!='0'){
                p=1;
                m2.push_back(i);
            }
        }
    }
    if(p==1)m1.push_back(n);
    else {
        m2.push_back(n);
        m1.push_back(n);
    }
    if(m1.size()<k+1)cout<<n;
    else{
        int ans=0;
        for(int i=0;i<m2.size()&&i+k<m1.size();i++){
            ans=max(ans,m1[i+k]-m2[i]);
        }
         cout<<ans;
    }
   

    return 0;
}


Measured memory_bytes: 1404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const ll mod=1000000007,MAX=200005,INF=1<<30;

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

ll rui(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return ans;
}



ll comb(ll a,ll b){
    ll ans=1;
    for(ll i=a;i>a-b;i--){
        ans=ans*i%mod;
    }
    for(ll i=1;i<=b;i++){
        ans=(ans*rui(i,mod-2))%mod;
    }
    return ans;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    //make();
    
    int N,A,B;cin>>N>>A>>B;
    
    cout<<(mod+mod+rui(2,N)-comb(N,A)-comb(N,B)-1)%mod<<endl;
    
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;
int main(){
	int H, W;
    cin >> H >> W;
    string s[H];
    for(int i=0;i<H;i++){
        cin >> s[i]; 
    }
    int check = 0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(s[i][j] == '#'){
                int ok = 0;
                if(i > 0){
                    if(s[i-1][j] == '#')ok = 1;
                }
                if(j > 0){
                    if(s[i][j-1] == '#')ok = 1;
                }
                if(i < H - 1){
                    if(s[i+1][j] == '#')ok = 1;
                }
                if(j < W - 1){
                    if(s[i][j+1] == '#')ok = 1;
                }
                if(!ok)check = 1;
            }
        }
    }
    if(check) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int s = 0;
		sc.close();
		if(A>=B && A>=C) {
			s = B+C;
		}else if(B>=A && B>=C) {
			s = A+C;
		}else {
			s = A+B;
		}
		System.out.println(s);
	}

}

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

using namespace std;


#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VC vector<char>
#define VS vector<string>
#define VVS vector<vector<string>>



int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<char>> c(h, vector<char>(w));
	int a = 0;
	REP(i, h) {
		REP(j, w) {
			cin >> c[i][j];
			if (c[i][j] == '.')a++;
		}
	}
	VVI v(h, vector<int>(w, 100000));
	v[0][0] = 1;
	queue<int> q;
	q.push(0);
	vector <int> dx = { 1,-1,0,0 };
	vector<int> dy = { 0,0,1,-1 };
	while (!q.empty()) {
		int d = q.front();
		q.pop();
		int e = d / 100;
		int f = d % 100;
		REP(i, 4) {
			if (0 <= e + dy[i] && e + dy[i] < h && 0 <= f + dx[i] && f + dx[i] < w&&c[e + dy[i]][f + dx[i]] == '.') {
				if (v[e + dy[i]][f + dx[i]] == 100000) {
					v[e + dy[i]][f + dx[i]] = v[e][f] + 1;
					q.push((e + dy[i]) * 100 + f + dx[i]);
				}
			}
		}
	}
	if (v[h - 1][w - 1] == 100000)cout << -1 << endl;
	else cout << a - v[h - 1][w - 1] << endl;
	return 0;
}

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

int main(void){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  int dx = tx-sx;
  int dy = ty-sy;

  for(int i = 1;i <= dy;i++){
    cout << "U";
  }
  for(int i = 1;i <= dx;i++){
    cout << "R";
  }

  for(int i = 1;i <= dy;i++){
    cout << "D";
  }
  for(int i = 1;i <= dx;i++){
    cout << "L";
  }
  dy = dy + 1;
  dx = dx + 1;
  cout << "L";
  for(int i = 1;i <= dy;i++){
    cout << "U";
  }
  for(int i = 1;i <= dx;i++){
    cout << "R";
  }
  cout << "D";

  cout << "R";
  for(int i = 1;i <= dy;i++){
    cout << "D";
  }
  for(int i = 1;i <= dx;i++){
    cout << "L";
  }
  cout << "U" << endl;
}


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

int count(vector<string> vec,string s){
  int x=0;
  for(int i=0;i<vec.size();i++)
    if(vec[i]==s)
      x+=1;
  return x;
}

int main(){
  int N;
  cin>>N;
  vector<string> vecbu(N);
  for(int i=0;i<N;i++)
    cin>>vecbu[i];
  int M;
  cin>>M;
  vector<string> vecre(M);
  for(int i=0;i<M;i++)
    cin>>vecre[i];
  
  int m=0;
  for(int i=0;i<N;i++){
    m=max(count(vecbu,vecbu[i])-count(vecre,vecbu[i]),m);
  }
  cout<<m<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long int64;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int ht, st, ha, sa;
	cin >> ht  >> st >> ha >> sa;
	int turn = 1;
	while (true) {
		if (turn) {
			ha -= st;
			if (ha <= 0) {
				cout << "Yes";
				break;
			}
		}
		else {
			ht -= sa;
			if (ht <= 0) {
				cout << "No";
				break;
			}
		}
		turn ^= 1;
	}
	
}

Measured memory_bytes: 3640
n,m,x = gets.chomp.split.map(&:to_i)
ps = n.times.map{gets.chomp.split.map(&:to_i)}
ans = 10**18
flag = false
(2**n).times do |i|
	array = Array.new(m,0)
	cnt = 0
	n.times do |j|
		if i[j] == 1
			ps[j].each_with_index do |t,k|
				if k == 0
					cnt += t
				else
					array[k-1] += t
				end
			end
		end
	end
	if array.all?{|a| a >= x}
		flag = true
		ans = cnt if ans > cnt
	end
end

puts flag ? ans : -1

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

int main() {
    int X,Y,A,B,C;
    cin >> X >> Y >> A >> B >> C;
    vector<int> p(A);//X個
    vector<int> q(B);//Y個
    vector<int> r(C);
    vector<int> pq(0);
    int i;
    for (i = 0; i < A; i++){
        cin >> p.at(i);
    }
    for (i = 0; i < B; i++){
        cin >> q.at(i);
    }
    for (i = 0; i < C; i++){
        cin >> r.at(i);
    }

    sort(p.begin(), p.end());
    reverse(p.begin(), p.end());
    sort(q.begin(), q.end());
    reverse(q.begin(), q.end());
    sort(r.begin(), r.end());
    reverse(r.begin(), r.end());

    for(i = 0; i < X; i++){
        pq.push_back(p.at(i));
    }
    for(i = 0; i < Y; i++){
        pq.push_back(q.at(i));
    }
    for(i = 0; i < C; i++){
        pq.push_back(r.at(i));
    }
    sort(pq.begin(), pq.end()); //X+Y+C個
    reverse(pq.begin(), pq.end());

    long long cnt = 0;

    for(i = 0;i < X + Y; i++){
        cnt += pq.at(i);
    }

    cout << cnt << endl;
    // int j = 0;
    // long long sum = 0;

    // for(i = 0; i < X + Y; i++){
    //     if(pq.at(i) < r.at(j) && j < C){//代入して後ろに入れる
    //         pq.at(X + Y - 1 - j) = r.at(j);
    //         j++;
    //     }else{
    //     }

    // }
}


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

#define DEBUG(x) cerr << #x << " = " << x << endl

const int swx[9][2] = {
    { 1, 8 },
    { 2, 0 },
    { 3, 1 },
    { 4, 2 },
    { 5, 3 },
    { 6, 4 },
    { 7, 5 },
    { 8, 6 },
    { 0, 7 }
};

const int swy[9][2] = {
    { 6, 3 },
    { 7, 4 },
    { 8, 5 },
    { 0, 6 },
    { 1, 7 },
    { 2, 8 },
    { 3, 0 },
    { 4, 1 },
    { 5, 2 }
};

typedef long long i64;
const int INF = (int)1e9;
typedef pair<int, i64> P;

template <class T, class U>
T lexical_cast(const U& from) {
    T to;
    stringstream ss;
    ss << from; ss >> to;
    return to;
}

// hidarikara
i64 stateChange(i64 S, int i, int j) {
    i = 8 - i;
    j = 8 - j;
    i64 powI = 1LL;
    i64 powJ = 1LL;
    for(int x = 0; x < i; x++) powI *= 10LL;
    for(int x = 0; x < j; x++) powJ *= 10LL;
    i64 mulI = (S / powI) % 10;
    i64 mulJ = (S / powJ) % 10;
    return S - (mulI * powI) + (mulJ * powI) - (mulJ * powJ) + (mulI * powJ);
}

int main() {
    while(true) {
        int costX, costY;
        cin >> costX >> costY;
        if(costX == 0 && costY == 0) break;
        i64 start;
        i64 goal;
        string str;
        str = "";
        for(int i = 0; i < 9; i++) {
            char c; cin >> c;
            str.push_back(c);
        }
        start = lexical_cast<i64>(str);
        str = "";
        for(int i = 0; i < 9; i++) {
            char c; cin >> c;
            str.push_back(c);
        }
        goal = lexical_cast<i64>(str);
        map<i64, int> d;
        priority_queue<P, vector<P>, greater<P> > Q;
        Q.push(P(0, start));
        d[start] = 0;
        while(!Q.empty()) {
            P p = Q.top();
            Q.pop();
            int costNow = p.first;
            i64 curS = p.second;
            if(curS == goal) break;
            if(d.count(curS) && costNow > d[curS]) continue;

            int zero;
            str = lexical_cast<string>(curS);
            if(curS < 100000000LL) zero = 0;
            else zero = find(begin(str), end(str), '0') - begin(str);

            i64 s;
            s = stateChange(curS, zero, swx[zero][0]);
            if(d.count(s) == 0 || d[s] > costNow + costX) {
                d[s] = costNow + costX;
                Q.push(P(d[s], s));
            }

            s = stateChange(curS, zero, swx[zero][1]);
            if(d.count(s) == 0 || d[s] > costNow + costX) {
                d[s] = costNow + costX;
                Q.push(P(d[s], s));
            }

            s = stateChange(curS, zero, swy[zero][0]);
            if(d.count(s) == 0 || d[s] > costNow + costY) {
                d[s] = costNow + costY;
                Q.push(P(d[s], s));
            }

            s = stateChange(curS, zero, swy[zero][1]);
            if(d.count(s) == 0 || d[s] > costNow + costY) {
                d[s] = costNow + costY;
                Q.push(P(d[s], s));
            }
        }
        cout << d[goal] << endl;
    }
}

Measured memory_bytes: 25748
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let n: usize = sc.get();
    let a: Vec<usize> = sc.vec(n);
    let mut b = VecDeque::new();
    for i in 0..n {
        if i % 2 != 0 {
            b.push_front(a[i]);
        } else {
            b.push_back(a[i]);
        }
    }
    let ans: Vec<_> = if n % 2 != 0 {
        b.into_iter().rev().collect()
    } else {
        b.into_iter().collect()
    };
    for &bi in &ans {
        println!("{}", bi);
    }
}


Measured memory_bytes: 11248
#include <bits/stdc++.h>
using namespace std;
#define maxn 8005
#define ll long long

int n, m;

int main()
{
    cin >> n >> m;
    int tot = 0;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        if (x >= m)
            tot++;
    }
    cout << tot << endl;
    return 0;
}

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

class Program
{
    static void Main()
    {
        //input
        string[] In = Console.ReadLine().Split(' ');
        int n = int.Parse(In[0]);
        long k = long.Parse(In[1]);
        string[] In2 = Console.ReadLine().Split(' ');
        int[] L = new int[n + 1];
        for (int i = 1; i <= n; i++)
        {
            L[i] = int.Parse(In2[i - 1]);
        }
        //processing
        List<int> Route = new List<int>();
        int[] HaveVisited = new int[n + 1];
        for(int i=0; i <= n; i++)
        {
            HaveVisited[i] = -1;
        }
        int now_city = 1;
        while (HaveVisited[now_city] == -1)
        {
            HaveVisited[now_city] = Route.Count;
            Route.Add(now_city);
            now_city = L[now_city];
        }
        //「周期」=「今何手目か」-「前回そこに訪れたのは何手目か」
        int period = Route.Count - HaveVisited[now_city];
        int branch= HaveVisited[now_city];
        if (k < branch) Console.WriteLine(Route[(int)k]);
        else
        {
            k -= branch;
            k %= period;
            Console.WriteLine(Route[branch + (int)k]);
        }
    }
}

Measured memory_bytes: 44988
#include<stdio.h>
#pragma GCC optimize("O2")
static inline char CH()
{
  static char buf[100000],*ptr1=buf,*ptr2=buf;
  return ptr1==ptr2&&(ptr2=(ptr1=buf)+fread(buf,1,100000,stdin),ptr1==ptr2)?EOF:*ptr1++;
}
static inline int IN(void)
{
  int x=0,f=0,c=CH();while(c<48||c>57){f^=c==45,c=CH();}
  while(c>47&&c<58){x=x*10+c-48,c=CH();}return f?-x:x;
}


int main(){
    int n=IN(),i=0,u,v;
    long x = n;
    long a = x*(x+1)*(x+2)/6;
    while(i++ < n-1){
        u=IN();
        v=IN();
        if(u<v){
            a -= 1l * u * (n-v+1);
        }else{
            a -= 1l * v * (n-u+1);
        }
    }
    return printf("%ld", a), 0;
}


Measured memory_bytes: 1600
#include <iostream>
using namespace std;
int main(void){
  int a, b, ab, ba;
  cin >> a >> b;
    ab = a;
    ba = b;
  for (int i=0;i<b;i++) ab *= 10;
  for (int i=0;i<a;i++) ba *= 10;
  if(ab>=ba) {
  	while(b){
    	cout << a;
      	b--;
    }
  } else {
  	while(a){
      cout << b;
  	  a--;
    }
  }
}

Measured memory_bytes: 256
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.06.16 21:01:17
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */

int main() {
    int n, x, l[111];
    scanf("%d%d", &n, &x);
    rep(i, n) {
        scanf("%d", &l[i]);
    }

    int ret = 1;
    int d = 0;
    rep(i, n) {
        d += l[i];
        if (d <= x) {
            ret++;
        } else {
            break;
        }
    }

    printf("%d\n", ret);

    /* --------------------------------- */
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B; cin >> A >> B; //int入力
  int ans;
  if(A >= 13){
    ans = B;
  }else if(6 <= A){
    ans = B/2;
  }else{
    ans = 0;
  }
  cout << ans << endl; //回答出力
}

Measured memory_bytes: 256