akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int a,b,c,d;cin >> a >> b>> c >> d;
	if(a+b > c+d)
	{
		cout << "Left" << endl;
	}
	else if(a+b == c+d)
	{
		cout << "Balanced" << endl;
	}
	else
	{
		cout << "Right" << endl;
	}
		
	
	return 0;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	map<int, int> w;
	for (int i = 0; i < n; i++)
	{
		int tmp;
		cin >> tmp;
		w[tmp]++;
	}
	bool ok = true;
	int m;
	cin >> m;
	map<int, int> q;
	for (int i = 0; i < m; i++)
	{
		int tmp;
		cin >> tmp;
		q[tmp]++;
		if (w[tmp] < q[tmp])
			ok = false;
	}
	cout << (ok ? "YES" : "NO") << endl;

	return 0;
}

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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int n,m;
    scanf("%d%d",&n,&m);
    if(n*500>=m){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    
    return 0;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())

for i in range(N + 1):
    for j in range(N + 1):
        if i + j > N:
            continue
        k = N - i - j
        if 10000 * i + 5000 * j + 1000 * k == Y:
            print(i, j, k)
            exit()
print(-1, -1, -1)

Measured memory_bytes: 9192
N=int(input())
C=[list(map(int,input().split())) for i in range(N)]
C.sort(key=lambda x:sum(x), reverse=True)
ans=0
for i in range(N):
  if i%2==0:
    ans+=C[i][0]
  else:
    ans-=C[i][1]
print(ans)

Measured memory_bytes: 32224
#include<bits/stdc++.h>
 
using namespace std;
const int N = 2000000;
long long dp[N];
pair<int,int> s[N];
int main(){
	int n,T;
	cin>>n>>T;
	for(int i=1;i<=n;i++){
		cin>>s[i].first>>s[i].second;
	}
	sort(s+1,s+n+1);
	long long ans=0;
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++){
		ans=max(ans,dp[T-1]+s[i].second);
		for(int j=T-1;j>=s[i].first;j--){
			dp[j]=max(dp[j],dp[j-s[i].first]+s[i].second);
		}
	} 
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 17152
#include<bits/stdc++.h>
using namespace std;
void solve(int a,int b,string str);
int j,y;

int main(){

   cin >> j >> y;
   solve(1,0,"A");
   solve(0,1,"B");

return 0;
}

void solve(int a,int b,string str){
    if(a==j&&b==y){
            cout << str << endl;
            return;
    }else if(b==5&&a<=3){
            if(a==j&&b==y){
            cout << str << endl;
            return;
            }
    }else if(a==5&&b<=3){
            if(a==j&&b==y){
            cout << str << endl;
            return;
            }
    }else if(a+b==10){
             if(str[8]=='A'&&str[9]=='A'&&j==6&&y==4){
                cout << str << endl;
                return;
             }else if(str[8]=='B'&&str[9]=='B'&&j==4&&y==6){
                cout << str << endl;
                return;
             }else if(j==5&&y==5){
                cout << str << endl;
                return;
            }
    }else{
    if(a<j)solve(a+1,b,str+"A");
    if(b<y)solve(a,b+1,str+"B");
    }
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
 int v[60][30];
int main(){
    int n;
    cin>>n;
    vector<string>s(n);
    map<pair<int,string>,int>mp;
    //vector<vector<int>>>v(n,0);
   
    for (int i = 0; i < n; i++)
    {
        cin>>s[i];
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < s[i].size(); j++)
        {
           v[i][s[i][j]-'a']++;
        }
        
    }
    string t;
    for (int j = 0; j <=25; j++)
    {
        
        int min_c=60;
        for (int i = 0; i < n; i++)
        {
            if(min_c>v[i][j]){
                min_c=v[i][j];
            }
        }
        for (int k = 0; k < min_c; k++)
        {
            t.push_back('a'+j);
        }    
    }
    sort(ALL(t));
    cout<<t<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;

int main() {
        string s, t;
        cin >> s >> t;
        sort(s.begin(), s.end());
        sort(t.rbegin(), t.rend());
        puts(s < t ? "Yes" : "No");
        return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod=1e9+7;

int main() {
  int H,W;
  cin>>H>>W;
  vector<string>s(H);
  for(int i=0;i<H;i++){
      cin>>s[i];
  }
  vector<int>dx={0,0,-1,1,-1,-1,1,1};
  vector<int>dy={1,-1,0,0,1,-1,1,-1};
  vector<vector<char>>ans(H,vector<char>(W));
  for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
          if(s[i][j]=='#'){ans[i][j]='#';}
          else{
            int cnt=0;
            for(int k=0;k<8;k++){
              int nx=j+dx[k],ny=i+dy[k];
              if(nx<0||nx>=W||ny<0||ny>=H){continue;}
              if(s[ny][nx]=='#'){cnt++;}
            }
            ans[i][j]=(char)(cnt+'0');
          }
      }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
        cout<<ans[i][j];
    }cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

void test_case(){
	int n; cin >> n;
	cout<<360/__gcd(360,n);
	
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


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

typedef std::pair<int64_t, int64_t> P;

int main() {
    int64_t N, X, Y;
    std::cin >> N >> X >> Y;
    X--;
    Y--;

    std::vector<int64_t> v[N];
    for (int i = 0; i < N - 1; ++i) {
        v[i].push_back(i + 1);
        v[i+1].push_back(i);
        if (i == X) {
            v[i].push_back(Y);
            v[Y].push_back(i);
        }
    }
 
    int64_t distance[N] = {0};
    for (int i = 0; i < N; ++i) {
        bool visited[N] = {false};
        std::queue<P> que;
        que.push({i, 0});
        visited[i] = true;
        while (que.empty() == false) { 
            P p = que.front(); que.pop();

            for (int64_t vv : v[p.first]) {
                if (visited[vv] == false) {
                    que.push({vv, p.second + 1});
                    visited[vv] = true;
                    if (i < vv) {
                        distance[p.second+1] += 1;
                    }
                }
            }
        }
    }

    for (int i = 1; i < N; ++i) {
        std::cout << distance[i] << std::endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
struct stu{
	int rank;
	int ai;
}a[100010];
bool cmp(stu x,stu y){
	return x.ai<y.ai;
}
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i].ai;
		a[i].rank=i;
	}
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=n;i++){
		cout<<a[i].rank;
		if(i<n)
		cout<<" ";
	}
	return 0;
} 

Measured memory_bytes: 1536
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm> 
using namespace std;
 
# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
 

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

    // Sが余る場合
    if(n*2>=m){
        p(m/2)
        return 0;
    }

    // Sが不足する場合
    long long int ans=0;
    ans += n;
    m -= n*2;
    ans += m/4;
    p(ans)

}

Measured memory_bytes: 256
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

fn str_to_ints(s: String) -> std::vec::Vec<i32> {
    let mut ret = std::vec::Vec::new();
    let ws = s.split_whitespace();
    for w in ws {
        ret.push(w.parse().unwrap());
    }
    ret
}

fn read_ints() -> std::vec::Vec<i32> {
    str_to_ints(read_line())
}

fn main() {
    let nm = read_ints();
    let n = nm[0];
    let m = nm[1];
    let xs = read_ints();

    let mut xs_sorted: std::vec::Vec<i32> = xs.to_vec();
    xs_sorted.sort();

    let mut xs_diff: std::vec::Vec<i32> = std::vec::Vec::new();
    for i in 0..xs_sorted.len()-1 {
        xs_diff.push(xs_sorted[i+1] - xs_sorted[i]);
    }

    let mut xs_diff_sorted: std::vec::Vec<i32> = xs_diff.to_vec();
    xs_diff_sorted.sort();

    let mut ret = 0;
    if m - n > 0 {
        for i in 0..(m - n) as usize {
        ret += xs_diff_sorted[i];
        }
    }

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

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("ASSA");
            //Yes
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("STOP");
            //No
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("FFEE");
            //Yes
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("FREE");
            //No
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        string s = InputList[0];

        if (s.ToCharArray().Distinct().Count() != 2) {
            Console.WriteLine("No");
            return;
        }

        int[] CntArr = s.ToCharArray().GroupBy(X => X).Select(X => X.Count()).ToArray();
        if (CntArr[0] != 2) {
            Console.WriteLine("No");
        }
        else if (CntArr[1] != 2) {
            Console.WriteLine("No");
        }
        else {
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 11476
#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(f, 0, (x.size()-1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int a,b,c,d;
//=============================
void input()
{
    cin>>a>>b>>c>>d;
}
//=============================
void func(){}
/*
 - 樹形図をかく
*/
//=============================
void solve()
{
    int state;
    state=c+d-a-b;

    cout<<(state>0 ? "Right" : (state<0 ? "Left" : "Balanced"))<<endl;

}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 764
#include <iostream>

using namespace std;

#define MAX_N 200000

// 入力
int N;
int a[MAX_N];

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

    long long sunuke_sum = 0;
    long long araiguma_sum = 0;
    for (int i = 0; i < N; ++i) {
        araiguma_sum += a[i];
    }
    long long dif_of_abs = 1e15;

    for (int i = 0; i < N - 1; ++i) {
        sunuke_sum += a[i];
        araiguma_sum -= a[i];
        dif_of_abs = min(dif_of_abs, abs(sunuke_sum - araiguma_sum));
    }

    cout << dif_of_abs << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, n,m , M, K,a;

vector<ll> v,w;
int main(){
    cin >> N >> M;
    m = 1;
    n = 1;
    for(int i = 0; i < M-1 ; ++i){
        m = 10*m + 1;
    }
    for(int i = 0; i < N-1 ; ++i){
        n = 10*n + 1;
    }
    if(N > M) cout << M * n;
    else cout << N*m;
    return 0;
}


Measured memory_bytes: 256
n, q = map(int, input().split())
s = input()
ss = [0] * n
for i in range(n - 1):
    if s[i:(i+2)] == "AC":
        ss[i] = 1
sss = [0] * n
for i in range(n - 1):
    sss[i + 1] = sss[i] + ss[i]
for _ in range(q):
    l, r  = map(int, input().split())
    print(sss[r - 1] - sss[l - 1])

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

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

int gcd(vector<int> a){
  int ans=a[0];
  for (int i = 1; i < a.size(); i++){
    if(ans<a[i]) swap(ans, a[i]);
    ans = gcd(ans, a[i]);
  }
  return ans;
}

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  cout << gcd(A) << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
    string s;
    cin >> s;

    long res = 0;
    long a = 0;
    for (int p = 0; p < (int)s.size() - 2; p++) {
        if (s[p] == 'A') {
            if (s[p + 1] == 'B' && s[p + 2] == 'C') {
                res += a + 1;
                s[p + 2] = 'A';
                p++;
            } else {
                a++;
            }
        } else {
            a = 0;
        }
    }

    cout << res << endl;
    return 0;
}


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

using namespace std;

int main() {
  int k, n; cin >> k >> n;
  vector<int> a(n+1);
  for (int i = 0; i < n; i++) { cin >> a[i]; }
  a[n] = a[0] + k;

  int max_diff = 0;
  for (int i = 0; i < n; i++) {
    max_diff = max(max_diff, a[i+1] - a[i]);
  }

  cout << k - max_diff << endl;
  return 0;
}

Measured memory_bytes: 1024
def partition(A, left, right):
    pivot = A[right]
    i = -1
    for j in range(left, right):
        if A[j] <= pivot:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[right] = A[right], A[i+1]
    return i + 1


if __name__ == "__main__":
    n = int(input())
    *A, = map(int, input().split())
    
    k = partition(A, 0, len(A)-1)

    A[k] = '[' + str(A[k]) + ']'
    print(*A)


Measured memory_bytes: 16384
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,H;
	cin >> N >> H;
	vector<ll> a(N),b(N);
	rep(i,N)cin >> a[i] >> b[i];
	sort(ALL(a));
	sort(ALL(b));
	ll big = a[N-1];
	ll ans = 0;
	for(int i=N-1;i>=0;i--){
		if(b[i]>=big){
			ans ++ ;
			H -= b[i];
		}
		if(H<=0)break;
	}
	if(H>0){
		ans += (H+a[N-1]-1)/a[N-1];
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
import sys
import math
import bisect

M = 1000000
B = int(math.sqrt(M)+1)
N = M//6
N1 = N+1 if M % 6 == 5 else N
N2 = N+1 if M % 6 >= 1 else N
l = [1] * N1
m = [1] * N2
o = []
for i in range(5,B,6):
    p = (i-5)//6
    ini = (i*5-1)//6
    if l[p] == 1:
        l[p+i::i] = [0] * len(l[p+i::i])
        m[ini-1::i] = [0] * len(m[ini-1::i])
    if m[p] == 1:
        m[p+i+2::i+2] = [0] * len(m[p+i+2::i+2])
        l[ini+1::i+2] = [0] * len(l[ini+1::i+2])

for i in range(N1):
    if l[i] == 1:
        o.append(6*i+5)
    if m[i] == 1:
        o.append(6*i+7)

if N2>N1 and m[N1] ==1:
    o.append(6*N1+7)

for i in sys.stdin:
    n = int(i)
    r =  n-1 if n < 4 else bisect.bisect_right(o, n)+2
    print(r)

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

int main() {
	int n;
	while (scanf("%d", &n), n) {
		int cnt = 0;
		for (int i = 2; i*i <= n; i++) {
			if (n%i == 0) {
				cnt += i;
				if (n / i != i)cnt += n / i;
			}
		}
		if (n != 1)cnt += 1;
		if (cnt > n)puts("abundant number");
		else if (cnt == n)puts("perfect number");
		else puts("deficient number");
	}
}

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

#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)

namespace std {
	template<class S, class T> pair<S, T> operator + (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first + b.first, a.second + b.second);}
	template<class S, class T> pair<S, T> operator - (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first - b.first, a.second - b.second);}
	template<class S, class T> pair<S, T>& operator += (pair<S, T> &a, const pair<S, T> &other) {return a = a + other;}
	template<class S, class T> pair<S, T>& operator -= (pair<S, T> &a, const pair<S, T> &other) {return a = a - other;}
	template<class S, class T> ostream& operator << (ostream& ost, pair<S, T> p) {ost << "(" << p.first << ", " << p.second << ")";return ost;}
	template<class T> ostream& print_iterable_container(ostream& ost, T& container) {
		for (auto&& iter = begin(container); iter != end(container); ++iter) ost << (iter == begin(container) ? " [ " : ", ") << (*iter);
		return ost << " ]";
	}
#	define APPLY_PRINT_ITERABLE_CONTAINER(container_type)\
	template<class T> ostream& operator << (ostream& ost, container_type<T>& container) {\
		return print_iterable_container(ost, container);\
	}
	APPLY_PRINT_ITERABLE_CONTAINER(vector);
	APPLY_PRINT_ITERABLE_CONTAINER(list);
	APPLY_PRINT_ITERABLE_CONTAINER(deque);
}

template<class T> inline bool CHMAX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool CHMIN(T &l,const T &r){return l>r?l=r,1:0;}

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

using ld = long double;

template<class T> using VV = vector<vector<T> >;
template<class T> using maxPQ = priority_queue<T>;
template<class T> using minPQ = priority_queue<T, vector<T>, greater<T> >;
template<class T, class U> using uomap = unordered_map<T, U>;
template<class T> using uoset = unordered_set<T>;

const ll INF = 1001001001;
const ll INFll = (ll)INF * INF;
const ll MOD = 1000000007;
const ll MOD_FFT = 998244353;
const ld EPS = 1e-15;

//function<void(int,int)> tensi_no_3p=[&](int v,int d){
//};

int main() {
	ios_base::sync_with_stdio(false);
	int N, A, B;
	cin >> N >> A >> B;
	cout << min(A, B) << " " << max(0, A + B - N) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, k;
    cin >> n >> k;
 
    ll a = (n-1)*(n-2)/2;
    ll b = a-k;
 
    if(a < k) {
        out(-1);
        re0;
    }
 
    out( (n-1) + b );
 
    exrep(i, 1, n-1) {
        cout << n << " " << i << "\n";
    }
 
    ll cnt = 0;
    exrep(i, 1, n-2) {
        exrep(j, i+1, n-1) {
            if(cnt == b) {
                re0;
            }
            cout << i << " " << j << "\n";
            cnt++;
        }
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c
  >> d >> e >> k;
  
  if(e-a <= k) 
    cout << "Yay!" << endl;
  else
    cout << ":(" << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<(n);i++)
using namespace std;
int main(){   
   int s,ans=0;
   cin>>s;
   vector<int> a(1000000);
   a[0]=s;
   for(int i = 1; i < 1000000; i++)
   {
      if(a[i-1]%2==0) a[i]=a[i-1]/2;
      else a[i]=3*a[i-1]+1;
      rep(j,0,i){
         if(a[j]==a[i]) ans=i+1;
      }
      if(ans!=0) break;
   }
   cout<<ans<<endl;
   
   
return 0;
}


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

int main(int argc, const char * argv[]) {
    uint64_t N;
    cin >> N;
    
    const uint64_t alpha = 26;
    uint64_t a = alpha;
    int t = 1;
    
    uint64_t n = N;
    while (n > a) {
        n -= a;
        a *= alpha;
        t++;
    }
    
    string ans = "";
    char *c = new char[1];
    *c = 'a';
    a = alpha;
    for (int i = 0; i < t; i++) {
        uint64_t amari = N % alpha;
        N /= a;
        if (amari == 0) {
            amari = 26;
            N -= 1;
        }
        
        if (amari > 0) {
            *c += (amari - 1);
        }
        string s = c;
        ans = s + ans;
        
        *c = 'a';
    }

    std::cout << ans << endl;

    delete[] c;
    return 0;
}

Measured memory_bytes: 3056
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
void cntBomb(int* s,int i,int j)
{

}

int main() {

  int h,w;
  cin >> h >> w;

  vector<string> s(h);

  int m[h][w];

  memset(m,0,sizeof(m));

  rep(i,h) cin >> s[i];

  rep(i,h)
  {
    rep(j,w)
    {
      if(s[i][j] == '#')
      {
        for(int a = i - 1;a <= i + 1;a++)
        {
          for(int b = j - 1;b <= j + 1;b++)
          {
            if((0 <= a && a < h) && ( 0 <= b && b < w))
            {
              if(s[a][b] != '#')
              {
                m[a][b]++;
              }
            }
          }
        }
      }
    }
  }

  rep(i,h)
  {
    rep(j,w)
    {
      if(s[i][j] == '#')
      {
        cout << s[i][j];
      }
      else
      {
        cout << m[i][j];
      }
    }
    cout << endl;
  }

  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
a, b, x = map(int, input().split())
ans = 0

def fanc(n, x):
    if n == -1:
        f = 0
    else:
        f = n // x + 1 # 切り捨て除算//を使うとint同士ならintで返してくれるから楽
    return f
print(fanc(b, x) - fanc(a - 1, x))

Measured memory_bytes: 2940
N = int(input())
A = list(map(int, input().split()))
count = 0
NO = 0
while True:
    for i in range(N):
        if A[i] % 2 == 0:
            A[i] = A[i] / 2
        else:
            NO = 1
            break
    if NO == 1:
        break
    count += 1
    
print(count)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t A, B;
    cin >> A >> B;
    cout << A * B / __gcd(A, B) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, m, a[200010], b[200010], d[100010];
pair<int, int> p[100010];
int ans1[100010];
int ans2[200010];
vector<pair<int,int>> vec[100010];
bool bl1[200010], bl2[100010];

signed main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> d[i + 1];
		p[i].first = d[i + 1];
		p[i].second = i + 1;
	}
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		vec[a[i]].push_back(make_pair(b[i], i));
		vec[b[i]].push_back(make_pair(a[i], i));
	}
	sort(p, p + n);
	for (int i = 0; i < n; i++) {
		int k = p[i].second;
		if (bl2[k])continue;
		bool bo = false;
		for (int j = 0; j < (int)vec[k].size(); j++) {
			if (d[vec[k][j].first] <= d[k]) {
				bo = true;
				ans2[vec[k][j].second] = d[k];
				ans1[k] = 1 - ans1[vec[k][j].first];
				bl2[vec[k][j].first] = true;
				break;
			}
		}
		if (!bo) {
			cout << -1 << endl;
			return 0;
		}
	}
	for (int i = 1; i <= n; i++) {
		if (ans1[i] == 0)cout << 'W';
		else cout << 'B';
	}
	cout << endl;
	for (int i = 0; i < m; i++) {
		if (ans2[i] == 0)cout << 1000000000 << endl;
		else cout << ans2[i] << endl;
	}
}

Measured memory_bytes: 15444
import java.util.*;
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 D = (int)B/A;
      if(D>=C){
        System.out.println(C);
      }else{
        System.out.println(D);
      }
    }
}

Measured memory_bytes: 35588
sx,sy,tx,ty= map(int,input().split())
ans = ''
if sx > tx:
    R = 'L'
    L = 'R'
else:
    R = 'R'
    L = 'L'
if sy > ty:
    U = 'D'
    D = 'U'
else:
    U = 'U'
    D = 'D'
if sx == tx:
    ans += U * (abs(ty-sy))
    ans += L
    ans += D * (abs(ty-sy))
    ans += R * 2
    ans += U * (abs(ty-sy))
    ans += L
    ans += U
    ans += R * 2
    ans += D * (abs(ty-sy)+2)
    ans += L * 2
    ans += U
elif sy == ty:
    ans += R * (abs(tx-sx))
    ans += U
    ans += L * (abs(tx-sx))
    ans += D * 2
    ans += R * (abs(tx-sx))
    ans += U
    ans += R
    ans += D * 2
    ans += L * (abs(tx-sx)+2)
    ans += U * 2
    ans += R
else:
    ans += U * (abs(ty-sy))
    ans += R * (abs(tx-sx))
    ans += U
    ans += L * (abs(tx-sx)+1)
    ans += D * (abs(ty-sy)+1)
    ans += R * (abs(tx-sx)+1)
    ans += U * (abs(ty-sy))
    ans += R
    ans += D * (abs(ty-sy)+1)
    ans += L * (abs(tx-sx)+1)
    ans += U
print(ans)

Measured memory_bytes: 9268
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        var nxt = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nxt[0];
        var x = nxt[1];
        var t = nxt[2];
        Console.WriteLine(((n + x - 1) / x) * t);
    }
}

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

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

    double p[N];
    for (int i = 0; i < N; ++i) {
        cin >> p[i];
        p[i] = (p[i] + 1) / 2.0;
    }

    double sum = 0.0;
    for (int i = 0; i < K; ++i) {
        sum += p[i];
    }

    double ans = sum;
    for (int i = 0; i < N - K; ++i) {
        sum = sum - p[i] + p[i + K];
        ans = max(ans, sum);
    }

    cout << setprecision(20) << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let b: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let ans = if a <= b { a } else { a - 1 };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;

int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int a; int b;
	cin>>a>>b;
	int c=1+2+3;
	cout<<c-(a+b)<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <stdexcept>
#include <algorithm>
#include <set>
#include <map>
#include <stdlib.h>
using namespace std;
int main(){
    int N,n,i,j,k,p,q,r,a;
    cin >> N;
    int L[N];
    for(i = 0;i < N;i++){
        cin >> L[i];
    }
    a = 0;
    sort(L,L + N);
    for(i = 0;i < N - 2;i++){
        for(j = i + 1;j < N - 1;j++){
            for(k = j + 1;k < N;k++){
                if(L[i] != L[j] && L[j] != L[k] && (L[i] + L[j]) > L[k]){
                    a++;
                }
            }
        }
    }
    cout << a << endl;
}

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

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

int main() {
    ll N, H;
    cin >> N >> H;

    multiset<int, greater<int> > a, b;
    for(int i = 0; i < N; i++) {
        int aa, bb;
        cin >> aa >> bb;
        a.insert(aa);
        b.insert(bb);
    }

    int mx = *a.begin();

    int ans = 0;
    for(auto& e: b) {
        if(H <= 0) break;
        if(e <= mx) break;
        ans++;
        H -= e;
    }

    if(H > 0) ans += H / mx + (H % mx != 0 ? 1 : 0);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9600
#include<cstdio>  
#include<cstring>  
#include<algorithm>  
#include<iostream>  
#include<string>  
#include<vector>  
#include<stack>  
#include<bitset>  
#include<cstdlib>  
#include<cmath>  
#include<set>  
#include<list>  
#include<deque>  
#include<map>  
#include<queue>
using namespace std;
typedef long long ll;
const ll inf=1<<29;
const ll Maxn=1e6;

int a[Maxn];

int main(){
	int n;
	int ali=0,bob=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+n);
	for(int i=n;i>=1;i-=2){
		ali+=a[i];
	}
for(int i=n-1;i>=1;i-=2){
		bob+=a[i];
	}
	printf("%d\n",ali-bob);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int n,Count=0;
    long long int a [100010];
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]==0){Count++;}
    }
    if(Count>0){cout<<0<<endl;return 0;}
    long long int sum=1;
    for(int i=0; i<n; i++)
    {
        if(a[i]<=1000000000000000000/sum )
        {
            sum=sum*a[i];
        }
        else
        {
           cout<<-1<<endl;
            return 0;
        }
    }
   cout<<sum<<endl;
}


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

int64 solve() {
    string S, T;
    cin >> S >> T;
    int N = S.size();
    auto next = [&](const string &S) {
        int n = (int)S.size();
        vector<vector<int>> res(n + 1, vector<int>(26, n));
        for(int i = n - 1; i >= 0; --i) {
            for(int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
            res[i][S[i] - 'a'] = i;
        }
        return res;
    };
    vector<vector<int>> nx = next(S + S);
    int64 ans = -1;
    for(auto &c : T) {
        c -= 'a';
        int i = (ans + 1) % N;
        if(nx[i][c] == 2 * N) return -1;
        ans += nx[i][c] - i + 1;
    }
    return ans + 1;
}

int main() {
    cout << solve() << endl;
    return 0;
}


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

typedef long long ll;

bool is_prime(int x) {
  for(int i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}

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

    int x; cin >> x;
    for(int i=x;i<=10000000;i++){
        if(is_prime(i)){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

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

int resultMap[100][100];

class Task{
  private:
  int x, y;
  public:
  Task(int x, int y): x(x), y(y){}
  void process(int h, int w, bool map[100][100], queue<Task*>* queue){
    int upRute = 655326;
    int leftRute = 655326;
    if(0 <= x - 1){
      leftRute = resultMap[x - 1][y] + ((map[x - 1][y] && !map[x][y]) ? 1 : 0);
    }
    if(0 <= y - 1){
      upRute = resultMap[x][y - 1] + ((map[x][y - 1] && !map[x][y]) ? 1 : 0);
    }
    resultMap[x][y] = (upRute > leftRute) ? leftRute : upRute;

    if(y == 0 && x + 1 <= w - 1){
      queue->push(new Task(x + 1, y));
    }
    if(y + 1 <= h - 1){
      queue->push(new Task(x, y + 1));
    }
  }
};

signed main() {
  int h,w;
  cin >> h >> w;
  bool map[100][100];
  for(int y = 0; y < h; y++){
    for(int x = 0; x < w; x++){
      resultMap[x][y] = 0;
      char c;
      cin >> c;
      map[x][y] = (c == '.');
    }
  }
  resultMap[0][0] = (map[0][0]) ? 0 : 1;

  queue<Task*>* taskQueue = new queue<Task*>();
  taskQueue->push(new Task(1, 0));
  taskQueue->push(new Task(0, 1));
  while(!taskQueue->empty()){
    Task* task = taskQueue->front();
    taskQueue->pop();
    task->process(h, w, map, taskQueue);
  }
  cout << resultMap[w - 1][h - 1] << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int N, K;
    string S;
    cin >> N >> S >> K;
    char t = S[K-1];
    string R = S;
    rep(i, N) {
        if (S[i] != t) {
            R[i] = '*';
        }
    }
    cout << R << endl;
}

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

#define INF 99999999
#define FER 0.0000000001

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;

struct Edge
{
	int s, t, w;
	Edge(int s,int t,int w):s(s),t(t),w(w){}
	Edge() :Edge(-1, -1, -1) {}
	bool operator<(const Edge& e)const
	{
		return w != e.w ? w < e.w : (s != e.s ? s < e.s : t < e.t);
	}
};


struct P
{
	double x, y;
	P(double x, double y) :x(x), y(y) {}
	P() :P(0, 0) {}
	P operator+(const P& v)const
	{
		return P(x + v.x, y + v.y);
	}
	P operator-(const P& v)const
	{
		return P(x - v.x, y - v.y);
	}
	P operator*(const double v)const
	{
		return P(x*v, y*v);
	}
	bool operator==(const P& v)const
	{
		return abs(x - v.x) <= 0.0000000000001&&abs(y - v.y) <= 0.00000000000001;
	}
	bool operator!=(const P& v)const
	{
		return abs(x - v.x) > 0.0000000000001 || abs(y - v.y) > 0.00000000000001;
	}

	double dot(const P& v)const
	{
		return x*v.x + y*v.y;
	}
	double cross(const P& v)const
	{
		return x*v.y - y*v.x;
	}
	double length()const
	{
		return sqrt(x*x + y*y);
	}
	double length2()const
	{
		return (x*x + y*y);
	}

	bool operator<(const P& v)const
	{
		return x<v.x || (x == v.x) && y < v.y;
	}
	bool operator>(const P& v)const
	{
		return x>v.x || (x == v.x) && y > v.y;
	}
};

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

	int N;
	cin >> N;

	vector<P> points(N);
	for (int i = 0; i < N; i++)
	{
		cin >> points[i].x >> points[i].y;
	}

	vector<vector<double>> L(N, vector<double>(N, 0.0));
	L[0][1] = (points[0] - points[1]).length();

	for (int j = 2; j < N; j++)
	{
		for (int i = 0; i < j; i++)
		{
			if (i + 1 < j)
			{
				L[i][j] = L[i][j - 1] + (points[j - 1] - points[j]).length();
			}
			else
			{
				L[i][j] = numeric_limits<double>::infinity();
				for (int k = 0; k < i; k++)
				{
					L[i][j] = min(L[i][j], L[k][i] + (points[k] - points[j]).length());
				}
			}
		}
	}

	double ans = numeric_limits<double>::infinity();
	for (int k = 0; k < N - 1; k++)
	{
		ans = min(ans, L[k][N - 1] + (points[k] - points[N - 1]).length());
	}

	printf("%.10lf\n", ans);

	return 0;
}


Measured memory_bytes: 10952
#include <bits/stdc++.h>
#include <random>
using namespace std;
using ll = long long;
using ld = long double;
ll Q=1000000007;
const double PI=3.14159265358979323846;

int main(){
  int N;
  string S;
  cin >> N >> S;
  if(N%2!=0){
    cout << "No" << endl;
    return 0;
  }else{
    for(int i=0;i<N/2;i++){
      if(S[i]!=S[i+N/2]){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
        int a,b,c;
        int oa,ob,oc;
        scanf("%d%d%d", &a, &b, &c);
        if(a <= b && b <= c) {
                printf("%d %d %d\n", a, b, c);
        } else if(a <= c && c <= b) {
                printf("%d %d %d\n", a, c, b);
        } else if(b <= a && a <= c) {
                printf("%d %d %d\n", b, a, c);
        } else if(b <= c && c <= a) {
                printf("%d %d %d\n", b, c, a);
        } else if(c <= a && a <= b) {
                printf("%d %d %d\n", c, a, b);
        } else {
                printf("%d %d %d\n", c, b, a);
        }
        return 0;
}

Measured memory_bytes: 596
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  int x;
  cin >> x;
  for(int i=1;;i++){
  	int rem = (i*x)%360;
  	if(!rem){
  		cout << i << endl;return 0;
  	}
  }

return 0;
}
///....


Measured memory_bytes: 3652
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun gcd(a:Long, b:Long):Long {
    val c = a % b
    if (c == 0L) return b
    return gcd(b, c)
}

fun PrintWriter.solve(sc: FastScanner) {
    val a = sc.nextLong()
    val b = sc.nextLong()
    val d = gcd(a, b)
    var m = d
    var ans = 1
    var i = 2L
    while (i * i <= m) {
        if (m % i == 0L) {
            ans++
            while (m % i == 0L) {
                m /= i
            }
        }
        i++
    }
    if (m > 1) ans++
    println(ans)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 31400
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
char asd[100001];
int main()
{
    cin>>asd;
    int zip,ppt=0;
    for(zip=1;zip<strlen(asd);zip++)
    if(asd[zip]!=asd[zip-1])
    ppt++;
    cout<<ppt<<endl;
    return 0;
}

Measured memory_bytes: 384