akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll sum=0;
    ll maxi=0;
    ll N, K;
    cin >> K >> N;
    VLL A(N);
    rep(i,N){
        cin >> A[i];
    }
    rep(i,N-1){
        sum+=A[i+1]-A[i];
        maxi=max(maxi,A[i+1]-A[i]);
    }
    sum+=K-A[N-1]+A[0];
    maxi=max(maxi,K-A[N-1]+A[0]);
    sum-=maxi;
    cout << sum << endl;
    
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

// 動作環境 : C++14 AOJ
int main(){
    ll n;
    cin >> n;
    VL A(n);
    rep(i, 0, n) cin >> A[i];
    ll mn = INT_MAX, mx = INT_MIN, sum = 0;
    rep(i, 0, n){
        mn = min(mn, A[i]);
        mx = max(mx, A[i]);
        sum += A[i];
    }

    cout << mn << " " << mx << " " << sum << endl;

    return 0;
}



Measured memory_bytes: 3168
#define _CRT_SECURE_NO_WARNINGS

#pragma GCC optimize("O3")

#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <cstring>
#include <numeric>
#include <set>
#include <queue>
#include <deque>
#include <array>
#include <string>
#include <cmath>
#include <random>
#include <ctime>
#include <map>
#include <functional>
#include <bitset>
#include <complex>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>

#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define pb push_back

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using ld = long double;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, k;
	cin >> n >> k;
	vi a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<bool> win(k + 1, false);
	for (int i = 1; i < k + 1; i++) {
		for (int d : a) {
			if (i - d >= 0 && !win[i - d]) {
				win[i] = true;
			}
		}
	}
	cout << (win[k] ? "First" : "Second");
}


Measured memory_bytes: 256
# coding: utf-8

def getLoop(S, K):
    if len(S) > K:
        return K
    if len(S) <= K:
        return len(S)

def solve(S, K):
    SList = [int(x) for x in S]
    for i in range(getLoop(S, K)):
        if SList[i] != 1:
            return SList[i]
    return 1
    
if __name__ == "__main__":
    S = input()
    K = int(input())
    print(solve(S, K))



Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n,m;
  cin>>n>>m;
  if(n>m)
    swap(n,m);
  in fc=1;
  const in mdl=1000000007;
  for(in i=1;i<=n;++i)
    fc=fc*i%mdl;
  for(in i=1;i<=m;++i)
    fc=fc*i%mdl;
  if(n==m)
    fc=fc*2%mdl;
  if(n+1<m)
    fc=0;
  cout<<fc<<endl;
  return 0;
}


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

int main(){
    int k;
    string s;
    cin >> k >> s;
    int len = s.size();
    if (len <= k) {
        cout << s <<endl;
    } 
    else {
        cout << s.substr(0,k) + "..." <<endl;
    }
    return 0;
}

Measured memory_bytes: 3628
N , M = map(int, input().split())
mod = 10 ** 9 + 7

if abs(N - M) >1:
    print(0)
elif N == M:
    n = 1
    m = 1
    for i in range(N):
        n = n * (i + 1) % mod
    for i in range(M):
        m = m * (i + 1) % mod
    print(2 * m * n % mod)
else:
    n = 1
    m = 1
    for i in range(N):
        n = n * (i + 1) % mod
    for i in range(M):
        m = m * (i + 1) % mod
    print(m * n % mod)

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

using namespace std;

int main()
{
  long long N,K,W;
  cin>>N>>K;
  W=N%K;
  if(W<K-W){
    cout<<W;
  }else{
    cout<<K-W;
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
using namespace std;
// using namespace atcoder;

ll A[301];

void Main()
{
    ll n;
    cin >> n;
    rep(i, n) cin >> A[i];

    ll X = 0; // target xor
    for (ll i = 2; i < n; i++) X ^= A[i];

	// vector<int> cand;
	// rep(i,1<<20) if(i<A[0]) {
	// 	ll v=(A[0]-i)^(A[1]+i)^X;
	// 	if((v&((1<<20)-1))==0) cand.push_back(i);
	// }
	
	// ll mi=1LL<<50;
	// for(auto c : cand) {
	// 	for(ll a=c;a<min(mi,A[0]);a+=1<<20) {
	// 		ll v=(A[0]-a)^(A[1]+a)^X;
	// 		if(v==0) mi=min(mi,a);
	// 	}
	// }

	// if(mi==1LL<<50) mi=-1;
	// cout<<mi<<endl;

    vector<ll> cand;
    ll mask = (1LL << 20) - 1;
    rep(a, 1LL << 20) {
        if (a > A[0]) {
            break;
        }
        ll v = (A[0]-a)^(A[1]+a)^X;
        if ((v & mask) == 0) {
            cand.push_back(a);
        }
    }

    ll ma = -1;
    for (ll a1: cand) {
        for (ll a = a1; a < A[0]; a += 1LL << 20) {
            ll v = (A[0]-a)^(A[1]+a)^X;
            if (v == 0) {
                ma = max(ma, A[0]-a);
                break;
            }
        }
    }

    if (ma < 0) {
        put(-1);
        return;        
    }

    ll res = A[0] - ma;
    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 3608
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

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

    int x = accumulate(a.begin(), a.end(), 0) / n;
    int ans = INT_MAX;
    for(int y=x-1; y<=x+1; ++y){
        int cost = 0;
        for(int i=0; i<n; ++i)
            cost += (y - a[i]) * (y - a[i]);
        ans = min(ans, cost);
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  vector<int> V(3);
  cin>>V[0]>>V[1]>>V[2];
  
  sort(V.begin(),V.end());
  reverse(V.begin(),V.end());
  
  cout<<V[0]*10+V[1]+V[2]<<endl;
}

Measured memory_bytes: 256
import math

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a


N,X = map(int,input().split())
x = input().split()
xls = []
 
for n in range(0,N):
    xls.append(int(x[n]))
 
xls.append(X)
xls.sort(reverse = True)
 
tousa = []
 
for n in range(0,N):
    tousa.append(xls[n]-xls[n+1])
 
if len(tousa) == 1:
    print(tousa[0])
    exit()
gcdd = gcd(tousa[0],tousa[1])
 
for n in range(0,N):
    gcdd = gcd(gcdd,tousa[n])
    
print(gcdd)

Measured memory_bytes: 18220
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main() {
	int n, x;
	while (cin >> n >> x && n + x) {
		int ans = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				for (int z = j + 1; z <= n; z++) {
					if (i + j + z == x) {
						ans++;
					}
				}
			}
		}
		cout << ans << endl;
	}
}


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    string s; cin >> s;
    int N = s.size();
    ll ans = 0, now = 0;
    for(int i = N-1; i >= 0; i--) {
        if(s[i] == 'B') {
            ans += (N-1-now)-i;
            now++;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 720
#include "bits/stdc++.h"
using namespace std;
int Function(long long A, long long B) {
	long long tmp1 = A, tmp2 = B;
	long long deg1 = 0, deg2 = 0;
	while (tmp1 != 0) {
		deg1++;
		tmp1 /= 10;
	}
	while (tmp2 != 0) {
		deg2++;
		tmp2 /= 10;
	}
	return max(deg1, deg2);
}
int main() {
	long long N;
	cin >> N;
	int MIN = 100;
	for (long long i = 1; i <= sqrt(N); i++) {
		if (N % i == 0) {
			MIN = min(MIN, Function(i, N / i));
		}
	}
	cout << MIN << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int N,K;
vector<int> A;


void imos(vector<int> &A){
    vector<int> tmp(N,0);
    rep(i,N){
        int left = max(0,i-A[i]);
        int right = min(N-1,i+A[i]);
        tmp[left]++;
        if(right+1<N)tmp[right+1]--;
    }
    rep(i,N-1)tmp[i+1] += tmp[i];
    A = tmp;
    return;
}

int main() {
    cin >> N >> K;
    A.resize(N);

    rep(i,N)cin >> A[i];
    
    K = min(K,50);
    rep(i,K)imos(A);

    rep(i,N)cout << A[i] << endl;

}

Measured memory_bytes: 4848
import java.util.Scanner;

public class Main {
	static String A = "";
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String word = sc.next();
		int n = word.length();
		for(int i = 0; i < n; i++)
			A += 'x';
		System.out.print(A);
		
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N, K;
    string S;
    cin >> N >> S >> K;
    char C = S.at(K - 1);
    rep(i, N) {
        if(S.at(i) != C) S.at(i) = '*';
    }
    cout << S << endl;
}

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

int main()
{
    long n,i,ans=0,l,r;
    cin>>n;

    for(i=0;i<n;i++)
    {
        cin>>l>>r;
        ans+=(r-l+1);
    }
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include <vector>

#define LL long long

using namespace std;



const int INF = 100000000;

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

	int N;
	string W[110];
	string ans = "Yes";

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

	for (int i = 0; i < N; i++) {
		for (int j = i+1; j < N; j++) {
			if (W[i] == W[j]) {
				ans = "No";
			}
		}
		if (i != N - 1) {
			if (!(W[N - i - 1][0] == W[N - i - 2][W[N - i - 2].length() - 1])) {
				ans = "No";
			}
		}
	}

	cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ms(x, n) memset(x,n,sizeof(x));
typedef  long long LL;
const int inf = 1<<30;
const LL maxn = 1e5+10;
const int mod = 2019;

int main()
{
    LL l, r;
    cin >> l >> r;
    if((r/mod) != (l/mod))
        cout << "0" << endl;
    else{
        l %= mod, r %= mod;
        LL ans = inf, t1 = min(l, r), t = max(l, r);
        for(LL i = t1; i <= t; ++i)
            for(LL j = i+1; j <= t; ++j)
                ans = min(ans, i*j%mod);
        cout << ans << endl;
    }
	return 0;
}


Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


### 木の読み込み tree

# サイズが大きいとdefaultdictが早い(for文を書かなくて済む)
from collections import defaultdict
n = int(input())
ns = defaultdict(set)
for _ in range(n-1):
    u,v = map(int, input().split())
    u -= 1
    v -= 1
    ns[u].add(v)
    ns[v].add(u)
    
### BFS 幅優先探索

def bfs(start):
    from collections import deque
    q = deque([start])
    seen = [None] * n
    seen[start] = 0
    while q:
        u = q.pop()
        d = seen[u]
        for v in ns[u]:
            if seen[v] is None:
                seen[v] = d + 1
                q.appendleft(v)
    return seen
d1 = bfs(0)
d2 = bfs(n-1)
v = sum(d1[i]<=d2[i] for i in range(n))
v2 = n-v
if v>v2:
    print("Fennec")
else:
    print("Snuke")

Measured memory_bytes: 114624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N;
    cin>>N;
    map<string,int> Name;
    rep(i,N) {
        string S;
        cin>>S;
        Name[S]++; 
    }
    int counter=0;
    for(auto p : Name) {
        if(p.se>=counter) {
            counter=p.se;
        }
    }
    vector<string> answer;
    for(auto p : Name) {
        if(p.se==counter) answer.pb(p.fi);
    }
    sort(answer.begin(),answer.end());
    answer.erase(unique(answer.begin(),answer.end()),answer.end());
    rep(i,answer.size()) cout<<answer.at(i)<<endl;
}

Measured memory_bytes: 26868
N = int(input())
ls = list(map(int,input().split()))
ans=0
n=0
nls = []
for i in range(N-1):
    if ls[i] >= ls[i+1]:
        n += 1 
    elif ls[i] < ls[i+1]:
        ans = max(ans,n)
        n = 0
    
    if i==N-2:
        ans = max(ans,n)

print(ans)

Measured memory_bytes: 85136
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    long long n;
    cin >> n;

    std::string name = ""; 

  	for(;n>0;){
      n -= 1;
      name += (char)(n%26 + 97);
      n /= 26;
    }
    // 出力
  	std::reverse(name.begin(), name.end());
    cout << name << endl;
    return 0;
}

Measured memory_bytes: 3088
import java.util.*;

public class Main {
    static long INF = 1001001001001001001L;
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        // to: 隣接リスト(有向)
        List<int[]>[] to = new List[n];
        for (int i = 0; i < n; i++) {
            to[i] = new ArrayList<int[]>();
        }
        for (int i = 0; i < n-1; i++) {
            int p = sc.nextInt() - 1;
            int q = sc.nextInt() - 1;
            int dis = sc.nextInt();
            to[p].add(new int[]{q, dis});
            to[q].add(new int[]{p, dis});
        }
        
        int query = sc.nextInt();
        int start = sc.nextInt()-1;
        
        // dist: startからの最短距離
        long[] dist = new long[n];
        Arrays.fill(dist, INF);
        dist[start] = 0;
        
        // ダイクストラ法: BFSで距離を配る。
        // (キューの先頭の点はそう来る他最短経路がないので最短距離が確定する)
        PriorityQueue<Point> que = new PriorityQueue<>();
        que.add(new Point(start, 0));
        while (!que.isEmpty()) {
            Point cur = que.poll();
            int p = cur.name;
            long dis = (long)cur.dist;
            
            // distより大きいdisを持つ点からは配らせない
            if (dis > dist[p]) continue;
            
            // 子に「自分の距離 + p→qの距離」を配る
            for (int[] qData : to[p]) {
                int q = qData[0];
                int PtoQ = qData[1];
                
                // 最短距離が更新される場合だけキューに入れる
                if (dis + PtoQ < dist[q]) {
                    dist[q] = dis + PtoQ;
                    que.add(new Point(q, dist[q]));
                }
            }
        }
        
        while (query-- > 0) {
            int px = sc.nextInt()-1;
            int qx = sc.nextInt()-1;
            System.out.println(dist[px]+dist[qx]);
        }
    }
}
    
class Point implements Comparable<Point> {
    int name;
    long dist;
     
    Point(int name, long dist) {
        this.name = name;
        this.dist = dist;
    }
    
    @Override
    public int compareTo(Point o) {
        //重みの小さい順
        if (this.dist < o.dist) {
            return -1;
        } 
        return 1;
    }
}

Measured memory_bytes: 178936
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    char cans1[4] = {'S', 'W', 'S', 'W'};
    char cans2[4] = {'S', 'W', 'W', 'S'};

    rep(i, 4) {
        vector<char> ans(N);
        ans[0] = cans1[i], ans[1] = cans2[i];
        for (int i = 2; i < N; i++) {
            if (ans[i - 2] == 'S' && ans[i - 1] == 'S') {
                if (s[i - 1] == 'o')
                    ans[i] = 'S';
                if (s[i - 1] == 'x')
                    ans[i] = 'W';
            }
            if (ans[i - 2] == 'W' && ans[i - 1] == 'W') {
                if (s[i - 1] == 'o')
                    ans[i] = 'S';
                if (s[i - 1] == 'x')
                    ans[i] = 'W';
            }
            if (ans[i - 2] == 'S' && ans[i - 1] == 'W') {
                if (s[i - 1] == 'o')
                    ans[i] = 'W';
                if (s[i - 1] == 'x')
                    ans[i] = 'S';
            }
            if (ans[i - 2] == 'W' && ans[i - 1] == 'S') {
                if (s[i - 1] == 'o')
                    ans[i] = 'W';
                if (s[i - 1] == 'x')
                    ans[i] = 'S';
            }
        }

        bool judge = 1;

        rep(i, N) {
            int a = i - 1, b = i + 1;
            if (i == 0)
                a = N - 1;
            if (i == N - 1)
                b = 0;

            if (ans[i] == 'S' && s[i] == 'o') {
                if (ans[a] != ans[b])
                    judge = 0;
            }
            if (ans[i] == 'S' && s[i] == 'x') {
                if (ans[a] == ans[b])
                    judge = 0;
            }
            if (ans[i] == 'W' && s[i] == 'o') {
                if (ans[a] == ans[b])
                    judge = 0;
            }
            if (ans[i] == 'W' && s[i] == 'x') {
                if (ans[a] != ans[b])
                    judge = 0;
            }
        }

        if (judge) {
            rep(i, N) { cout << ans[i]; }
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000
int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
  for(i = 1 ;i<=n ;i++){
    scanf("%hd",&A[i]);
  }
  for(i = 0;i<=VMAX+1;i++){
    C[i] = 0;
  }
  for(j=1;j<=n;j++){
    C[A[j]] = C[A[j]]+1;
  }
  
  for(i = 1 ;i<=VMAX+1;i++){
    C[i] = C[i]+C[i-1];
  }
  for(j=n ;j>=1 ;j--){
    B[C[A[j]]] = A[j];
    C[A[j]] = C[A[j]]-1;
  }
  for(j = 1;j<n+1;j++){
    if(j ==n)
    printf("%d\n",B[j]);
    else printf("%d ",B[j]);
    }
  return 0;
}



Measured memory_bytes: 9596
FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]

####
MOD = 10**9 + 7
YES, NO, IMP = "YES", "NO", "IMPOSSIBLE"
from collections import defaultdict as ddic


def solve(S):
    if S.endswith('s'):
        return S + 'es'
    return S + 's'

print solve(rr())


Measured memory_bytes: 64928
from collections import Counter
def main():
    n = int(input())
    #s = [ list(map(str, input().split(" "))) for i in range(n)]
    s = [str(input()) for i in range(n)]
    #print(s)
    count = Counter(s)
    max_num = max(count.values())
    max_list = [key for key,value in count.items() if value == max_num]
    max_list.sort()

    print('\n'.join(max_list))





    '''
    new_s = sorted(s)
    index = [0]*n
    str_count = [0]*n
    count = 1
    for i in range(n-1):
        if new_s[i] == new_s[i+1]:
            count += 1
        else:
            index[i] = i
            str_count[i] = count
            count = 1
    print(new_s)
    print(str_count)
  '''

if __name__ == '__main__':
    main()

Measured memory_bytes: 35944
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a[] = new int[n];
    for(int i = 0;i<n;i++){
      a[i] = sc.nextInt();
    }
    int ans = 0;
    for(int i = 0;i<n;i++){
      if(a[i]%2==1){
        continue;
      }else if(a[i]%3==0||a[i]%5==0){
        continue;
      }else{
        ans = 1;
        break;
      }
    }
    if(ans == 0){
      System.out.println("APPROVED");
    }else{
      System.out.println("DENIED");
    }
  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define brep(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<n;i++)
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
long long gcd( long long m, long long n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}
long long lcm( long long m, long long n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm


int main(void){
    long long m,n;
    cin >> m >> n;
    string s,t;
    cin >> s >> t;
    int x = gcd(m,n);
    long long ans = lcm(m,n);
    int m2= m/x;
    int n2= n/x;
    rep(i,x){
        if(s[i*m2]!=t[i*n2]){
            ans = -1;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
vector<int>G[100000];
int dist[100000],pre[100000];
signed main(){
    cout<<"Yes"<<endl;
    int n,m,a,b;
    cin>>n>>m;
    while(cin>>a>>b){
        G[--a].push_back(--b);
        G[b].push_back(a);
    }
    for(int i=0;i<n;i++)
        dist[i]=mod,pre[i]=-1;
    queue<int>que;
    dist[0]=0;
    que.push(0);
    while(!que.empty()){
        int v=que.front();
        que.pop();
        for(int i=0;i<G[v].size();i++){
            int nv=G[v][i];
            if(dist[nv]==mod){
                que.push(nv);
                dist[nv]=dist[v]+1;
                pre[nv]=v;
            }
        }
    }
    for(int i=1;i<n;i++)
        cout<<pre[i]+1<<endl;
}

Measured memory_bytes: 13776
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] a = new int[N];
        for(int i = 0; i<N; i++) {
            a[i] = Integer.parseInt(sc.next());
        }
        if(N==2) {
            System.out.println(Math.max(a[0],a[1]));
            return;
        }
	int[] left = new int[N+2];
	int[] right = new int[N+2];
        for(int i = 1; i<N; i++) {
	    left[i] = gcd(a[i-1],left[i-1]);
	    right[N+1-i] = gcd(a[N-i],right[N+2-i]);
        }
	int max = Integer.MIN_VALUE;
	for(int i = 1; i<N+1; i++) {
	    max = Math.max(max, gcd(left[i-1], right[i+1]));
	}
	System.out.println(max);
    }

    public static int gcd(int a, int b) {
	if(a<b) {
	    int tmp = a;
	    a = b;
	    b = tmp;
	}
        if(b==0)return a;
        return gcd(b, a%b);
    }
}

Measured memory_bytes: 48624
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        int n,m; cin >> n >> m;
        vector<pair<ll,ll>>v;
        for(int i = 0; i<n; i++){
            ll a,b; cin >> a >> b;
            v.push_back({a,b});
        }
        sort(all(v));
        ll ans = 0;
        for(int i = 0; i<n; i++){
            if(m==0)break;
            ll mx  = v[i].second;
            ll cost = v[i].first;
            if(m<mx){
                ans+=(m*cost);
                m-=m;
            }
            if(m==0)break;
            if(m>=mx){
                ans+=(mx*cost);
                m-=mx;
            }
        }
        cout<<ans<<endl;

return 0;
}




Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <iomanip>

using namespace std;

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

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

	ll T, X;
	cin >> T >> X;

	double A = (double)T / double(X);

	cout << std::setprecision(10) << A << endl;
}

Measured memory_bytes: 256
function Main(input) {

	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
  
    let k = input[0].split(" ")[1];
    let a_n = input[1].split(" ").map(Number);
    
    a_n.sort((a, b) => a - b);
    
    let sum = 0;
    
    for (let i = 0; i < k; i++) sum += a_n[i];
    
    console.log(sum);
  
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30596
//author : Brijesh1in
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define endl '\n'
#define boost ios::sync_with_stdio(false);
typedef long long li;
double dp[3000];
int main(){

	int n;
	cin>>n;
	double p[n];
	double mul = 1;
	for(int i = 0 ; i < n ; ++i){
		cin>>p[i];
	}
	dp[0] = 1;
	for(int i = 0 ; i < n ; ++i){

		for(int j = i+1 ; j>= 0 ; --j)
			dp[j] = (j==0 ? 0 : dp[j-1]*p[i]) + dp[j]*(1-p[i]);

		/*for(int j = 0 ; j <= i+1 ; ++j)
			cout<<dp[j]<<" \n"[j==i+1];*/
	}
	/*for(int i =0 ; i <= n ; ++i)
		cout<<dp[i]<<" ";
	cout<<endl;*/
	double ans = 0;
	for(int i = 0 ; i <= n ; ++i){

		int t = n-i;

		if(i > t)
			ans += dp[i];
	}

	cout<<fixed<<setprecision(12)<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(std::string S){
  vector<int> ans(S.size(),0);
  ll x[2];
  x[0]=x[1]=0;
  REP(S.size()){
    if(S[i]=='R'){
      ++x[i%2];
    }else if(S[i]=='L'&&S[i-1]=='R'){
      ans[i]=x[i%2];
      ans[i-1]=x[(i%2)^1];
      x[1]=x[0]=0;
    }
  }
  Rev(i,S.size()){
    if(S[i]=='L'){
      ++x[i%2];
    }else if(S[i]=='R'&&S[i+1]=='L'){
      ans[i]+=x[i%2];
      ans[i+1]+=x[(i%2)^1];
      x[1]=x[0]=0;
    }
  }
  REP(S.size()){
    cout<<ans[i];
    if(i==S.size()-1){
      cout<<endl;
    }else{
      cout<<" ";
    }
  }
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long n,m;
int main()
{
	cin>>n>>m;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=n-i;j++)
		{
			int k=n-i-j;
			if(i*10000+j*5000+k*1000==m) 
			{
				cout<<i<<" "<<j<<" "<<k;
				return 0;
			}
		}
	}
	cout<<-1<<" "<<-1<<" "<<-1;
    return 0;
}

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

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int r,c,n;
    cin>>r>>c>>n;
    if(n%(max(r,c))==0)
    {
        cout<<(n/max(r,c))<<endl;
    }
    else
    {
        cout<<((n+max(r,c))/max(r,c))<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    sort(A.begin(), A.end());
    cout << A[N - 1] - A[0];
}


Measured memory_bytes: 256
def f(a, b):
  return pow((a[0]-b[0])**2+(a[1]-b[1])**2, 1/2)

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

a=0
for i in range(N-1):
  for j in range(i+1, N):
    a+=f(xy[i], xy[j])
    
print(2*a/N)

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

char gc() {
	return getchar();
}

template<typename T>
int read(T &ans) {
	ans=0;T f=1;
	char ch=gc();
	while(!isdigit(ch)) {
		if(ch==EOF) return EOF;
		if(ch=='-') f=-1;
		ch=gc();
	}
	while(isdigit(ch))
		ans=ans*10+ch-'0',ch=gc();
	ans*=f;
	return 1;
}

template<typename T1,typename T2>
int read(T1 &a,T2 &b) {
	return read(a)!=EOF&&read(b)!=EOF?2:EOF;
}

template<typename T1,typename T2,typename T3>
int read(T1 &a,T2 &b,T3 &c) {
	return read(a,b)!=EOF&&read(c)!=EOF?3:EOF;
}

typedef long long ll;
const int Maxn=210000;
const ll inf=100000000000000ll;

ll ans,a[Maxn],b[Maxn];
int cnt,t[Maxn],n,k;

int query(int x,int ans=0) {
	for(int i=x;i;i&=i-1) ans+=t[i];
	for(int i=x;i<=cnt;i+=i&-i) t[i]++;
	return ans;
}

int main() {
//	freopen("test.in","r",stdin);
	read(n,k);
	for(int i=1;i<=n;i++) {
		read(a[i]);
		a[i]-=k;
	}
	for(int i=2;i<=n;i++) a[i]+=a[i-1];
	for(int i=0;i<=n;i++) b[i]=a[i];
	sort(b,b+n+1);
	map<ll,int> ma;
	for(int i=0;i<=n;i++)
		if(i==0||b[i]!=b[i-1]) {
			cnt++;
			ma[b[i]]=cnt;
		}
	for(int i=0;i<=n;i++)
		ans+=query(ma[a[i]]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 16768
n = int(input())
ab = [map(int, input().split()) for _ in range(n)]
a, b = [list(i) for i in zip(*ab)]
 
a.reverse()
b.reverse()
ans = 0

for j in range(n):
  a[j] += ans
  if a[j] % b[j] != 0:
    ans += b[j] -(a[j] % b[j])

print(ans)

Measured memory_bytes: 62948
#include <iostream>
#include <map>
using namespace std;
int main(void){
    int n;
    map<int, int> p;
    cin >> n;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        p[a]++;
    }
    if(p.size() == 1){
        if(p[0] == n){
            cout << "Yes" << endl;
            return 0;
        }
    }else if(p.size() == 3 && n%3 == 0){
        int a, b, c;
        auto itr = p.begin();
        a = (itr++)->first;
        b = (itr++)->first;
        c = (itr++)->first;
        if(p[a] == p[b] && p[b] == p[c] && a == (b^c)){
            cout << "Yes" << endl;
            return 0;
        }
    }else if(p.size() == 2 && n%3 == 0){
        int a, b;
        auto itr = p.begin();
        a = (itr++)->first;
        b = (itr++)->first;
        if(a == 0 && p[a] == n/3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3840
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 1e16;

void solve(long long N, long long M, std::vector<long long> L,
           std::vector<long long> R) {
  ll minId = 1;
  ll maxId = N;
  rep(m, 0, M) {
    minId = max(minId, L[m]);
    maxId = min(maxId, R[m]);
  }

  print(max(maxId - minId + 1LL, 0LL));
}

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


Measured memory_bytes: 1792
s = list(input())
K = int(input())

a_num = 97
z_num = 122

for i in range(len(s)):
    if K == 0:
        break
    else:
        if i == len(s) - 1:
          if ord(s[i])+ (K%26) <= z_num:
            s[i] = chr(ord(s[i]) + (K%26))
          else:
            s[i] = chr(ord(s[i]) + (K%26) - 26)

        elif ord(s[i]) == a_num:
            continue
        elif K >= z_num - ord(s[i]) + 1:
            K -= z_num - ord(s[i]) + 1
            s[i]="a"
        
print("".join(s))


Measured memory_bytes: 4156
#include <iostream>
#include <cstring>
using namespace std;
int main(){
  int i, l, a=0;
  char s[101];
  cin >> s;
  l=strlen(s);
  for(i=0; i<l/2; i++)
    if(s[i]!=s[l-1-i]) a++;
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
long Gcd(long a, long b)
{
	if (a%b == 0) { return b; }
	return Gcd(b, a % b);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int>a;
	int gcd = 1;
	for (int i = 0; i < n; i++) {
		int u;
		cin >> u;
		a.pb(u);
		if (i != 0) {
			gcd = Gcd(gcd, u);
		}
		else {
			gcd = u;
		}
	}
	for (int i = 1; i <= gcd; ++i) {
		if (gcd%i == 0)
		{
			cout << i << endl;
		}
	}
	return 0;
}


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

#define _fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pi acos(-1)
#define MAXS 1e(18)
#define MOD 1000000007
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;



int main()
{

    _fastIO;

    ll n, a[200005];

    while(cin>>n){
        ll id=1;
        for(int i=1; i<=n; i++){
            cin>>a[i];
        }
        ll cnt=0;
        for(int i=1; i<=n; i++){
            if(a[i]==id){
                cnt++;
                id++;
            }
        }
        if(!cnt)cout<<"-1"<<endl;
        else cout<<n-cnt<<endl;
    }

    return 0;
}


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

int main(void){
	double x1,y1,x2,y2,d;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);

	d=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));

	printf("%lf\n",d);
	return 0;
}

Measured memory_bytes: 652
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string s; cin>>s;
    int n=s.size();
    if(s.back()=='1' || s[0]=='0'){
        printf("-1\n");
        return 0;
    }
    rep(i,n-1){
        if(s[i]!=s[n-2-i]){
            printf("-1\n");
            return 0;
        }
    }
    int cnt=1;
    for(int i=2;i<=n-1;i++){
        if(s[i-1]=='1'){
            rep(j,cnt) printf("%d %d\n",i-j-1,i);
            cnt=1;
        }
        else{
            cnt++;
        }
    }
    printf("%d %d\n",n-1,n);
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
  int A,B;
  cin >> A >> B;
  cout << (B+A-3)/(A-1) << endl;
}

Measured memory_bytes: 3592
A,B=map(int,input().split())
l=[2,3,4,5,6,7,8,9,10,11,12,13,1]
a,b = l.index(A),l.index(B)
if a>b:
    print("Alice")
elif b>a:
    print("Bob")
else:
    print("Draw")

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

double shortRegTime[] = {
	35.5, 37.5, 40.0, 43.0, 50.0, 55.0, 70.0, DBL_MAX,
};
double longRegTime[] = {
	71.0, 77.0, 83.0, 89.0, 105.0, 116.0, 148.0, DBL_MAX,
};

char* rank[] = {
	"AAA", "AA", "A", "B", "C", "D", "E", "NA",
};

int main()
{
	double time1, time2;
	while( cin >> time1 >> time2 ){
		for( int i = 0; i < 8; ++i ){
			if( time1 < shortRegTime[ i ] && time2 < longRegTime[ i ] ){
				cout << rank[ i ] << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  
  cin >> a >> b;
  
  int sum = a * b;
  if ((sum % 2) == 0) {
  	cout << "Even" << endl;
  } else {
  	cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    constexpr ll mod = 1e9+7;
    ll n, m;
    cin >> n >> m;
    VL x(n+1), y(m+1);
    rep(i, 1, n+1) cin >> x[i];
    rep(i, 1, m+1) cin >> y[i];
    ll X = 0, Y = 0;
    rep(i, 1, n+1){
        X += ((i-1) - (n-i)) * x[i];
        X %= mod;
    }
    rep(i, 1, m+1){
        Y += ((i-1) - (m-i)) * y[i];
        Y %= mod;
    }
    cout << (X * Y) % mod << endl;
    return 0;
}

Measured memory_bytes: 1792
class Elem

  attr_reader :selected
  
  def initialize(a, b, c, s)
    @a = @prev_a = a
    @b = @prev_b = b
    @c = @prev_c = c
    @s = s
    @left_unexpl = true
    @right_unexpl = true
    @selected = nil
  end

  def inc(ch)
    case ch
    when 'A'; @a = @prev_a + 1
    when 'B'; @b = @prev_b + 1
    when 'C'; @c = @prev_c + 1
    end
  end

  def dec(ch)
    case ch
    when 'A'; @a = @prev_a - 1; return @a >= 0
    when 'B'; @b = @prev_b - 1; return @b >= 0
    when 'C'; @c = @prev_c - 1; return @c >= 0
    end
  end

  def to_left
    @left_unexpl = false
    if !dec(@s[1])
      return nil
    end
    inc(@selected = @s[0])
    return [@a, @b, @c]
  end

  def to_right
    @right_unexpl = false
    if !dec(@s[0])
      return nil
    end
    inc(@selected = @s[1])
    return [@a, @b, @c]
  end

  def left_unexpl?
    @left_unexpl
  end

  def right_unexpl?
    @right_unexpl
  end

  def prev_values
    return @prev_a, @prev_b, @prev_c
  end

end

N, a, b, c = $stdin.gets.split.map {|i| i.to_i }
S = []
0.upto(N - 1) do |i|
  S.push($stdin.gets.strip)
end

stack = []
index = 0
while index < N
  elem = stack[index] ||= Elem.new(a, b, c, S[index])
  if elem.left_unexpl?
    if abc = (elem.to_left || elem.to_right)
      a, b, c = *abc
      index += 1
      next
    end
  elsif elem.right_unexpl?
    if abc = elem.to_right
      a, b, c = *abc
      index += 1
      next
    end
  end
  stack[index] = nil
  if (index -= 1) < 0
    puts 'No'
    exit
  end
end
puts 'Yes'
stack.each do |e|
  puts e.selected
end


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll a,b,k; cin>>a>>b>>k;
    if(b-a+1>=2*k){
        rep(i,k) cout<<a+i<<endl;
        for(int i=k-1;i>=0;i--) cout<<b-i<<endl;
    }else{
        for(int i=a;i<=b;i++) cout<<i<<endl;
    }
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e18+7;
const ll MOD=1e9+7;
const ll N = 1000;
ll a[1001];
ll ans = 1;
void clac(ll n){
	ll k=2,nn=n;
	while(n!=1){
		while(n%k==0){
			a[k]++;
			n/=k;
		}
		k++;
	}
	if(nn==1) return;
	clac(nn-1);
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll x;
	cin>>x;
	ll ans = 0;
	ans += x/11;
	ans *= 2;
	x = x%11;
	if(x==0)pri(ans);
	else if(x<=6)pri(ans+1);
	else pri(ans+2);
}

Measured memory_bytes: 256