akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    vector<int> a;
    cin>>n;
    for(int i=0;i<n;i++){
        int tmp;
        cin>>tmp;
        a.push_back(tmp);
    }
    int b[n];
    for(int i=0;i<n;i++){
        b[a[i]-1]=i+1;
    }
    for(int i=0;i<n;i++){
        cout << b[i];
        if(i!=n-1) cout << " ";
        else cout << endl;
    }
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 1000001;
const int MOD =1000000007;
const int INV2 = (MOD+1)/2;



     signed main(){
   int n,m;
   cin>>n>>m;
   int h[n];
   for(int i=0;i<n;i++)cin>>h[i];
   vector<int> hen[n];
   int a,b;
   for(int i=0;i<m;i++){
     cin>>a>>b;a--;b--;
     hen[a].push_back(b);
     hen[b].push_back(a);
   }
   int ans=0;bool k;
   for(int i=0;i<n;i++){
     k=true;
     for(auto&& j : hen[i]){
       if(h[i]<=h[j])k=false;
     }
     if(k)ans++;
   }
   cout<<ans<<endl;

        





}


        


Measured memory_bytes: 10232
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) << endl ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }


int main(){
	ll n ; cin >> n ;
	vll a(n+1) ;
	for(auto &i:a) cin >> i ;
	ll p = a.at(n) ;
	for(int i=n-1;i>=0;i--){
		p = (p+1)/2+a.at(i) ;
	}
	if(p>1){
		cout << -1 << endl ;
		return 0 ;
	}
	ll ans = 0 ;
	for(int i=0;i<=n;i++) ans += (i+1)*a.at(i) ;
	p = 0 ;
	vll cnt(n+1) ;
	for(int i=n;i>=0;i--){
		cnt.at(i) = p ;
		p += a.at(i) ;
	}
	if(cnt.at(0)>1) ans -= cnt.at(0)-1 ;
	p = 1 ;
	for(int i=1;i<=n;i++){
        //cout << ans << endl ;
		if(p*2>=cnt.at(i)+a.at(i)) p = cnt.at(i) ;
		else{
			ans -= cnt.at(i)+a.at(i)-p*2 ;
            p = p*2-a.at(i) ;
		}
	}
	cout << ans << endl ;
    //for(auto i:cnt) cout << i << " " ;
}

Measured memory_bytes: 4844
n = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0

for i in range(n):
    inp = input()
    if inp == 'AC':
        AC += 1
    elif inp == 'WA':
        WA += 1
    elif inp == 'TLE':
        TLE += 1
    elif inp == 'RE':
        RE += 1

print('AC x ' + str(AC))
print('WA x ' + str(WA))        
print('TLE x ' + str(TLE))    
print('RE x ' + str(RE))

Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for(ll i = 0; i < (n); i++)
//pow(x,n)
//cout << fixed << setprecision(桁数);

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    int a;
    swap(x, y);
    swap(x,z);
    cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split())) * 2
mod = 10**9 + 7
ans = 0
b = 0
c = 0

for i in range(N):
    for j in range(i + 1, 2 * N):
        if j == N:
            c = b
        if A[i] > A[j] and j < N:
            b += 1
        elif A[i] > A[j] and j >= N:
            c += 1
    
    if b == c - b:
        ans += b * K * (K + 1) // 2
    else:
        ans += b * K + (c - b) * K * (K - 1) // 2
    
    b = 0
    c = 0

print(ans % mod)

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

const int P = 1000000007;
int n, dp[2][605][605];
bool b[605], del[605];

int main() {
	scanf("%d", &n);
	int cnt = 0;
	for (int i = 1, x, y; i <= n; ++i) {
		scanf("%d%d", &x, &y);
		if (x != -1 && y != -1) {
			del[x] = del[y] = true;
			continue;
		}
		if (x == -1 && y == -1)
			++cnt;
		if (x != -1) b[x] = true;
		if (y != -1) b[y] = true;
	}
	dp[1][0][0] = 1;
	for (int i = 2 * n; i >= 1; --i) {
		if (del[i]) {
			memcpy(dp[i & 1], dp[i + 1 & 1], sizeof dp[i + 1 & 1]);
			continue;
		}
		memset(dp[i & 1], 0, sizeof dp[i & 1]);
		for (int j = 0; j <= 2 * n - i; ++j)
			for (int k = 0; j + k <= 2 * n - i; ++k)
				if (dp[i + 1 & 1][j][k]) {
					if (!b[i]) {
						dp[i & 1][j + 1][k] = (dp[i & 1][j + 1][k] + dp[i + 1 & 1][j][k]) % P;
						if (j)
							dp[i & 1][j - 1][k] = (dp[i & 1][j - 1][k] + dp[i + 1 & 1][j][k]) % P;
						if (k)
							dp[i & 1][j][k - 1] = (dp[i & 1][j][k - 1] + 1ll * dp[i + 1 & 1][j][k] * k) % P;
					} else {
						dp[i & 1][j][k + 1] = (dp[i & 1][j][k + 1] + dp[i + 1 & 1][j][k]) % P;
						if (j)
							dp[i & 1][j - 1][k] = (dp[i & 1][j - 1][k] + dp[i + 1 & 1][j][k]) % P;
					}
				}
	}
	int ans = dp[1][0][0];
	for (int i = 1; i <= cnt; ++i)
		ans = 1ll * ans * i % P;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



int main(void) {
  int a,b;
  cin >> a >> b;
  cout << max(0,a-2*b) << endl;
         
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define MOD 1000000007
#define all(c) c.begin(), c.end()
#define rep(i, s, e) for (auto i = s; i < e; i++)
#define peek(v)      \
	for (auto i : v) \
		cout << i << ' ';

void solve()
{
	int n;
	cin >> n;
	string gen = "abcdefghijklmnopqrstuvwxyz", az = "";
	for (char i : gen)
	{
		rep(x, 0, 50)
		{
			az += i;
		}
	}
	multiset<char> ss(all(az));
	rep(i, 0, n)
	{
		string s;
		cin >> s;
		multiset<char> in(all(s));
		string t;
		set_intersection(all(ss), all(in), back_inserter(t));
		ss.clear();
		ss = multiset<char>(all(t));
	}
	cout << string(all(ss));
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
	cerr << "\n\n~" << 500 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int yes = 1000, tod;
  long long ans = 1000;
  int cnt = n;
  while (cnt--) {
    cin >> tod;
    if (yes < tod) ans += (ans / yes) * (tod - yes);
    yes = tod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

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

    int t = n;

    int f = 0;
    while (t) {
        f += t % 10;
        t /= 10;
    }

    cout << (n % f ? "No" : "Yes") << endl;

    return 0;
}

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

int main(){
  int N,L;
  cin >> N >> L;
  vector<string> s(N);
  for(int i=0;i<N;i++){
    cin >>  s.at(i);
  }
  sort(s.begin(),s.end());
  
  for(int i=0;i<N;i++){
    cout<<s.at(i);
  }
   cout << endl;
  
return 0;
}
//祝　初B突破　15-June-2020

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a,b,c;

    scanf("%d %d %d",&a,&b,&c);

    int sum = a + b + c;
    int aa = a,bb = b,cc = c,ans = 0;

    if(aa == bb && bb == cc && aa % 2 == 0)
    {
        printf("-1");
    }
    else
    {
        while (aa % 2 == 0 && bb % 2 == 0 && cc % 2 == 0)
        {
            a = (sum - aa) / 2;
            b = (sum - bb) / 2;
            c = (sum - cc) / 2;
            aa = a;bb = b;cc = c;
            ans++;
        }

        printf("%d",ans);
    }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,i;
    cin>>n;
    double sum=0;
    double p[n];
    string dw[n]; 
    for(i=0;i<n;i++){
        cin>>p[i]>>dw[i];
        if(dw[i]=="JPY"){
            sum+=p[i];
        }
        if(dw[i]=="BTC"){
            sum+=p[i]*380000.0;
        }
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

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

typedef unsigned long long ull;
	
double dp[1<<20],b[1<<20];
int c[1<<20];

inline ull gcd(ull a,ull b){
	return b?gcd(b,a%b):a;
}

ull a[20];
int p[20];
int main(){
	int n;
	ull m;
	scanf("%d%llu",&n,&m);
	REP(i,1<<n) b[i]=0,c[i]=0;
	REP(i,n) scanf("%llu",a+i);
	REP(i,n) scanf("%d",p+i);
	FOR(i,1,1<<n) REP(j,n) c[i]+=(i>>j)&1;
	int g=1;
	FOR(k,1,n+1){
		REP(i,1<<n) dp[i]=0;
		FOR(i,1,1<<n){
			if(c[i]<k)
				continue;
			else{
				if(c[i]==k){
					ull s=1;
					REP(j,n)
						if((1<<j)&i){
							ull g=s>a[j]?gcd(s,a[j]):gcd(a[j],s);
							s/=g;
							if(s>m/a[j]){
								s=0;
								break;
							}else
								s*=a[j];
						}
					if(s)
						dp[i]=m/s;
				}else{
					REP(j,n)
						dp[i]+=dp[i^(1<<j)];
					dp[i]/=c[i]-k;
				}
				b[i]+=dp[i]*g;
			}
		}
		g=-g;
	}
	double s=0;
	FOR(i,1,1<<n){
		double e=1;
		REP(j,n)
			if((1<<j)&i)
				e*=0.01*p[j];
			else
				e*=0.01*(100-p[j]);
		s+=b[i]*e;
	}
	printf("%.8f\n",s);
}

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

int main(){
   int a,b,c;
   cin>>a>>b>>c;
   int d = 0;
   for(int x = a;x <= b;x++){
      if(c%x == 0){
         d++;
      }
   }
   cout << d << endl;
   return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <cstdio>

using namespace std;

long long N;
long long A[304][304], d[304][304];
long long s;

int main()
{
    //入力されたら同じグラフの構造の配列をもう１つ用意する。
    //もう１つの方をいじって最終的な答えを出す。
    cin >> N;
    for(long long i = 0; i < N; i++){
        for(long long j = 0; j < N; j++){
            cin >> A[i][j];
            d[i][j] = A[i][j];
        }
    }

    for(long long k = 0; k < N; k++){
        for(long long i = 0; i < N; i++){
            for(long long j = 0; j < N; j++){
                //与えられた条件(地図)が最短のものではなかった時存在しないので-1を出力する。
                if(A[i][j] > A[i][k] + A[k][j]){
                    cout << -1 << endl;
                    return 0;
                }

                //もし最短経路が存在しており、その経路と直接むすぶ道路の長さが等しいならば、その道路は必要ないので消す。
                if(A[i][j] == A[i][k] + A[k][j]){
                    if(i!=k && j != k) d[i][j] = 0;
                }
            }
        }
    }

    //最終的に最短経路を示すのに必要な道路を足し合わせる。
    //足し合わせる時の注意点で、同じ場所をつないでいる部分の道路を二回数えないように工夫する。
    //ここではjにiを代入することで工夫している。
    for(long long i = 0; i < N; i++){
        for(long long j = i; j < N; j++){
            s += d[i][j];
        }
    }

    cout << s << endl;

    return 0;
}


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

using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds; 

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define inf INT_MAX
#define llinf LONG_LONG_MAX

const int N=1e6+3;
const int M=998244353;


int main(){
 	
 	
 	
 	int n,m;
 	sfi(n) sfi(m)

 	vector<ll> v1(n),v2(m);

 	ll k; sfl(k)

 	int cnt=0;

 	f(i,0,n){
 		ll temp;
 		sfl(temp)
 		if(i==0){
 			v1[i]=temp;
 			continue;
 		}
 		v1[i]=v1[i-1];
 		v1[i]+=temp;
 	}

 	f(i,0,m){
 		ll temp;
 		sfl(temp)
 		if(i==0){
 			v2[i]=temp;
 			continue;
 		}
 		v2[i]=v2[i-1];
 		v2[i]+=temp;
 	}

 	int tot=0;

 	f(i,0,n){
 		ll sm=v1[i];
 		if(sm>k)
 			break;
 		int it=upper_bound(v2.begin(),v2.end(),k-sm)-v2.begin();

 		tot=max(tot,it+i+1);
 	}

 	f(i,0,m){
 		ll sm=v2[i];
 		if(sm>k)
 			break;
 		int it=upper_bound(v1.begin(),v1.end(),k-sm)-v1.begin();

 		tot=max(tot,it+i+1);
 	}

 	pfin(tot)
 

 	return 0;
}

Measured memory_bytes: 6416
// #include <iostream>
// #include <string>
// #include <math.h>
// #include <map>
// #include <vector>
// #include <tuple>
// #include <algorithm>
// #include <queue>
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define pii pair<int, int>
#define plli pair <lli, lli>
#define F(i,n) for(lli (i)=0;(i)<(n);(i)++)
#define FR(i,n) for(lli (i)=(n)-1;(i)>=0;(i)--)
#define FSG(i,a,b) for(lli (i)=(a);(i)<(b);(i)++)
#define FSGR(i,a,b) for(lli (i)=(b)-1;(i)>=(a);(i)--)
#define VAL(n) cout << n << endl;
#define VALD(n) cout << #n << ": " << n << endl;
int main(){
  int N;
  cin >> N;
  cout << N * N * N << endl;
  return 0;
}


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

int main() {
  int N, x, y, z, ans=0;
  cin>>N;
  if(N%2==1) {
    cout<<ans<<endl;
  }
  else {
    x=N/2;
  
  vector<int> n(N);
  for(int i=0; i<N; i++){
    cin>>n.at(i);
  }
  sort(n.begin(), n.end());
  y = n.at(x-1);
  z = n.at(x);
  if(y==z) cout<<ans<<endl;
  else {
    y++;
    while(y<=z){
      ans++;
      y++;
    }
    cout<<ans<<endl;
  }
  }
}

Measured memory_bytes: 3764
/*
 *  author : Atul Anand   
 *  created on : Tue Mar 31 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        int N = in.nextInt();
        println((int) Math.ceil(N/2.0));       
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* struct for mod Calculation*/
struct mint {
    ll x;
    mint(ll x = 0):x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
/* global variables */
/* function */
/* main */
int main(){
    string S;
    cin >> S;
    int L = S.size();
    int mod13 = 13;

    // dp[i桁目][(sum(i桁目まで)%13]
    vector<vector<mint> > dp(L + 1, vector<mint>(mod13));
    dp[0][0] = 1;

    for (int i = 0; i < L; i++) {
        for (int j = 0; j < mod13; j++) {
            for (int k = 0; k <= 9; k++) {
                // S[i] == '?' -> 0 ~ 9
                // S[i] == x -> only x
                if (S[i] != '?' && (S[i] - '0') != k) continue;
                // Dpの遷移
                // j * 10^(n) + k * 10^(n - 1)
                //=== 10^(n - 1) * (j * 10 + k)  (10^(n - 1))でくくる
                // === j * 10 + k mod 13         (gcd(10, 13) = 1なので乗算してもおk)
                dp[i+1][(j * 10 + k) % mod13] += dp[i][j];
            }
        }
    }
    cout << dp[L][5] << '\n';
}

Measured memory_bytes: 13568
#include<bits/stdc++.h>
using namespace std;
int n,a[105],s;
bool c(int a,int b){
return a>b;}
int main(){
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i];
sort(a+1,a+n+1,c);
for(int i=1;i<=n;i++){ 
if(i%2==1) s+=a[i];
else s-=a[i];}
cout<<s;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF (ll)1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

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

constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

int main() {
	ll n, x;
	cin >> n >> x;
	ll g = gcd(n, x);
	if (g == 1)cout << (n - 1) * 3 << endl;
	else {
		cout<<((n / g) - 1) * 3 * g<<endl;
	}
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import os
from sys import stdin, stdout

MOD = int(1e9) + 7


def power(a, b):
    ret = 1
    base = a
    while b > 0:
        if b % 2:
            ret *= base
            ret %= MOD
        b //= 2
        base *= base
        base %= MOD
    return ret


def solve(tc):
    n = int(stdin.readline().strip())

    ans = power(10, n)
    ans -= power(9, n)
    ans += MOD
    ans %= MOD

    ans -= power(9, n)
    ans += MOD
    ans %= MOD

    ans += power(8, n)
    ans %= MOD

    print(ans)


tcs = 1
tc = 1
while tc <= tcs:
    solve(tc)
    tc += 1


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

using namespace std;

int main(){
	long long n;
	cin >> n;
	long long a,b;
	for(long long i=1;i*i<=n;i++){
		if(n%i==0)a=i;
	}	
	b=n/a;
	long long ans=(a-1)+(b-1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define MOD 1000000007


LL bigmod(LL a,LL p)
{
    LL ret=1;
    while(p>0)
    {
        if(p&1)ret=(ret*a)%MOD;
        p>>=1;
        a=(a*a)%MOD;
    }
    return ret;
}

LL modinverse(LL x)
{
    return bigmod(x,MOD-2);
}

LL fact[1000009],inv[1000009];

int main()
{
    LL n;
    cin>>n;
    n--;
    if(n==1)
    {
        cout<<1<<endl;
        return 0;
    }
    LL ans=0,cnt=0,x;
    if((n+1)%2)x=(n+2)/2;
    else x=(n+1)/2;
    fact[0]=inv[0]=1;
    for(LL i=1;i<=n;i++)
    {
        fact[i]=(i*fact[i-1])%MOD;
        inv[i]=modinverse(fact[i]);
    }
    LL tmp;
    for(;x<=n;x++)
    {
        tmp=(((fact[x-1]*fact[x])%MOD)*inv[2*x-n-1])%MOD;
        tmp=(tmp-cnt+MOD)%MOD;
        cnt=(cnt+tmp)%MOD;
        ans=(ans+x*tmp)%MOD;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 15872
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

	vector<ll> A(N);
	rep(i, N)
	{
		cin >> A[i];
		A[i] -= i + 1;
	}

	sort(all(A));

	ll ans = 0;

	repl(i, 1, N)
	{
		ans += abs(A[i] - A[0]);
	}

	repl(i, 1, N)
	{
		chmin(ans, ans + i * abs(A[i] - A[i - 1]) - (N - i) * abs(A[i] - A[i - 1]));
	}

	cout << ans << endl;

	return 0;
}

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

	ll n,k,q;
	cin >> n>>k>>q;

	ll cnt[100005] = {};

	rep(i,q) {
		ll a;
		cin >> a;
		a = a-1;
		cnt[a]++;
	}

	ll base = k-q;
	rep(i,n) {
		ll real = base + cnt[i];
		if (real <= 0) {
			cout << "No"<< endl;
		} else {
			cout << "Yes"<<endl;
		}
	}

}

Measured memory_bytes: 1408
N, W = map(int, input().split())
w = [0] * (N+1)
v = [0] * (N+1)
for i in range(1, N + 1):
    w[i], v[i] = map(int, input().split())

dp = [[1000000001] * 100001 for _ in range(N + 1)] #i番目までで価値がj以上となる最小重さ
dp[0][0] = 100000001
ans = 0
for i in range(1, N + 1):
    for j in range(1, 100001):
        if v[i] < j:
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i])
        else:
            dp[i][j] = min(dp[i - 1][j], w[i])


for i in range(100001):
    if dp[N][i] <= W:
        ans = i
print(ans)

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

typedef long long int ll;
typedef long double ld;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD (ll)(1e9 + 7)
#define vi vector<int>
#define vii vector<vector<int> >
#define vl vector<ll>
#define vll vector<vector<ll> >
#define vc(T, nm) vector<T> nm
#define pb push_back
#define popb pop_back
#define si set<int>
#define sl set<ll>
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define ins insert
#define ers erase
#define endl "\n"
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define adr(a, b) ((a % MOD) + (b % MOD)) % MOD
#define FORA(x, s, e, inc) for(ll x = s; x != e; x += inc)
#define ROFA(x, s, e, inc) for(ll x = s; x != e; x -= inc)
#define FOR(x, s, e) FORA(x, s, e, 1)
#define ROF(x, s, e) ROFA(x, s, e, 1)
#define loop(x, n) FOR(x, 0, n)
#define rd1(t, a) 					t a; cin >> a;
#define rd2(t, a, b) 				rd1(t, a); rd1(t, b); 
#define rd3(t, a, b, c) 			rd2(t, a, b); rd1(t, c);
#define rd4(t, a, b, c, d) 			rd3(t, a, b, c); rd1(t, d);
#define rd5(t, a, b, c, d, e) 		rd4(t, a, b, c, d); rd1(t, e);
#define rd6(t, a, b, c, d, e, f) 	rd5(t, a, b, c, d, e); rd1(t, f);
#define rdA(t, nm, len)				t nm[len]; loop(i, len) {cin >> nm[i];}
#ifdef DEBUG
	#define deb(v) cout << endl << #v << ": " << v << endl
	#define db1(v) cout << endl << #v << ": " << "[ "; for(auto x: v) {cout << x << " ";}; cout << "]" << endl;
	#define db2(v) cout << endl << #v << ": " << endl; for(auto r: v) {cout << "[ "; for(auto x: r) {cout << x << " ";}; cout << "]" << endl;};
	#define dbl cout << "-------------------------------" << endl
#else
	#define deb(v)
	#define db1(v)
	#define db2(v)
	#define dbl
#endif

int mxm = (int)(1e7 + 5);

vi sieve() {
    vector<bool> v(mxm + 1, true);
    v[1] = false;
    vi primes;
    
    for(int i = 2; i * i <= mxm; i++) {
        if(v[i]) {
            for(int j = i * i; j <= mxm; j += i) {
                v[j] = false;
            }
        }
    }
    
    for(int p = 2; p < mxm; p++) {
        if(v[p]) {
            primes.pb(p);
        }
    }
    
    return primes;
}

void solve() {
    rd1(int, n);
    int ans = 0;
    for(int i = 1; i < n; i++) {
        ans += ((n - 1)/i);
    }
    
    cout << ans;
}

int main() {
	
	fastio;
// 	rd1(ll, t);
    ll t = 1;
    
    while(t--) {
        solve();
    }


	return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>

int binary(int r);
int n;

int S[100000];

int main(void)
{

  int i,n2,cou = 0;

   int S2[50000];
  scanf("%d",&n);

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

  scanf("%d",&n2);

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



 for(i = 0; i < n2; i++){
   if(binary(S2[i]) == 1){
	cou++;
      }

  }

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


int binary(int key){
  int mid;

  int  L = 0,R = n;
  while (L < R){
    mid = (L + R)/2;
    if(S[mid] == key)  return 1;
    else if (key < S[mid])R = mid;
    else L = mid + 1;
  }
    return 0;

  }

Measured memory_bytes: 1180
use std::io;
use std::io::BufRead;

struct Graph {
    n: usize,
    adj: Vec<Vec<usize>>,
}

fn read_graph() -> Graph {
    let stdin = io::stdin();
    let lock = stdin.lock();
    let mut lines = lock.lines();

    let nm: Vec<_> = lines
        .next()
        .unwrap()
        .unwrap()
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect();
    let n = nm[0];
    let m = nm[1];
    let mut adj = vec![vec![]; n];

    for _ in 0..m {
        let parsed: Vec<usize> = lines
            .next()
            .unwrap()
            .unwrap()
            .split_whitespace()
            .map(|s| s.parse().unwrap())
            .collect();
        let i = parsed[0];
        let j = parsed[1];

        adj[i].push(j);
        adj[j].push(i);
    }

    Graph { n, adj }
}

fn dfs(g: &Graph, d: &mut Vec<Option<usize>>, i: usize, root: usize) {
    d[i] = Some(root);
    for &next_i in g.adj[i].iter() {
        if d[next_i] == None {
            dfs(g, d, next_i, root);
        }
    }
}

fn main() {
    let graph = read_graph();

    let mut d = vec![None; graph.n];

    for i in 0..(graph.n) {
        if d[i] == None {
            dfs(&graph, &mut d, i, i);
        }
    }

    let stdin = io::stdin();
    let lock = stdin.lock();
    let mut lines = lock.lines();
    let q = lines.next().unwrap().unwrap().parse().unwrap();

    for _ in 0..q {
        let parsed: Vec<usize> = lines
            .next()
            .unwrap()
            .unwrap()
            .split_whitespace()
            .map(|s| s.parse().unwrap())
            .collect();
        let i = parsed[0];
        let j = parsed[1];

        println!("{}", if d[i] == d[j] { "yes" } else { "no" });
    }
}



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

using namespace std;
#define ll long long
#define ld long double

ll gcd(ll a, ll b) {
    return b ? gcd(b,a % b) : a;    
}

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

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    ll a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100

int main(){
  int n,l[N],max=0,sum=0,i,j;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&l[i]);
    sum += l[i];
  }
  
  for(j=0;j<n;j++){
    if(max<=l[j]) max = l[j];
  }
   
  if(max<sum-max) printf("Yes");
  else printf("No");

return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

class Graph{
	private:
	int V,E;
	public:
	vvi Pro;
	void add_V(int v){
		V=v;
		Pro=vvi(V,vi(V,inf));
		for(int i=0;i<V;i++) Pro[i][i]=0;
	}
	void add_edge(int x,int y,int c){
		Pro[x][y]=c;
		Pro[y][x]=c;
	}
	void WARSALL(){
		for(int k=0;k<V;k++) for(int i=0;i<V;i++) for(int j=0;j<V;j++) Pro[i][j]=min(Pro[i][j],Pro[i][k]+Pro[k][j]);
	}
};

int V=-1,E;

int main(){
	while(1){
		cin>>E;
		if(!E) break;
		V=0;
		Graph gra;
		vi S,T,C;
		int s,t,c;
		for(int i=0;i<E;i++){
			cin>>s>>t>>c;
			S.push_back(s);
			T.push_back(t);
			C.push_back(c);
			V=max(V,max(s,t));
		}
		V++;
		gra.add_V(V);
		for(int i=0;i<E;i++) gra.add_edge(S[i],T[i],C[i]);
		gra.WARSALL();
		P ans(-1,inf);
		for(int i=0;i<V;i++){
			int sum=0;
			for(int j=0;j<V;j++) sum+=gra.Pro[i][j];
			if(sum<ans.second) ans=P(i,sum);
		}
		cout<<ans.first<<' '<<ans.second<<endl;
	}
}

Measured memory_bytes: 1216
def main():
    import sys
    from collections import deque
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    N, M = [int(x) for x in input().strip().split()]
    G = [deque([]) for _ in range(N)]
    for m in range(M):
        a, b = [int(x) for x in input().strip().split()]
        G[a-1].append(b)
        G[b-1].append(a)
    
    vec = [-1] * N
    q = deque([(0, 1)])
    while q:
        cur, np = q.popleft()
        if vec[np-1] == -1:
            vec[np-1] = cur
            for g in G[np-1]:
                q.append((np, g))
    
    if -1 in vec:
        print('No')
    else:
        print('Yes')
        for v in vec[1:]:
            print(v)

if __name__ == '__main__':
    main()

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

int main(){
    vector<int> v;
    int q;
    cin >> q;
    
    int query_num;
    int x,p;

    for(int i=0;i<q;i++){
        cin >> query_num;
        if(query_num==0){
            cin >> x;
            v.push_back(x);
        }
        else if(query_num==1){
            cin >> p;
            cout << v.at(p) << endl;
        }
        else
            v.pop_back();
    }
}


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

using namespace std;

int main()
{
    int n,i,count=0;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)cin>>a[i];
    for(i=1;i<n-1;i++){
        int q[]={a[i-1],a[i],a[i+1]};
        sort(q,q+3);
        if(q[1]==a[i])count++;
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

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

    int n, k;
    cin >> n >> k;
    int g = 0;
    int mx = -1;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        g = __gcd(g, x);
        mx = max(mx, x);
    }
    if (k % g) {
        cout << "IMPOSSIBLE\n";
        return 0;
    }
    mx /= g;
    k /= g;
    if (k <= mx) {
        cout << "POSSIBLE\n";
    } else {
        cout << "IMPOSSIBLE\n";
    }
}   


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int ss,h,m,s;
    scanf("%d",&ss);
    m=ss/60;
    m=m%60;
    s=ss%60;
    h=ss/3600;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

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

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

typedef long long ll;
typedef long long int64;

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

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

  sort(l.begin(), l.end(), std::greater<int>());

  int ret = 0;
  bool end = false;

  for(int i=0; i<n; i++){
    end = false;
    for(int j=i+1; j<n; j++){
      for(int k=j+1; k<n; k++){
        int a = l[i];
        int b = l[j];
        int c = l[k];
        if(a < b + c && b < c + a && c < a + b){
          ret++;
        }
        else{ 
          if(a > b + c) {
            break;
          }
        }
      }
    }
  }

  cout << ret << endl;

  return 0;
}


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

using namespace std;


int main()
{
  int n;
  cin>>n;
  long s[n],p[n];
  for(int i=0;i<n;++i)
  {
      cin>>s[i];
  }
  sort(s,s+n);
  for(int i=0;i<n;++i)
  {
      if(i==0)
        p[i] = s[i];
      else
        p[i] = p[i-1]+s[i];
  }

  int c=1;
  for(int i=n-2;i>=0;--i)
  {
      if(p[i]*2>=s[i+1])
      {
        ++c;
      }
      else
      break;
  }

  cout<<c<<endl;

  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <cctype>
#include <utility>
#include <map>
#include <string>
#include <climits>
#include <set>
#include <sstream>
#include <utility>
#include <ctime>
#include <cassert>
#include <fstream>
using namespace std;
typedef long long LL;
#define MS(A) memset(A, 0, sizeof(A))
#define MSV(A,a) memset(A, a, sizeof(A))
#define MP make_pair
#define PB push_back
#define getcx getchar_unlocked
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12
#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define MOD 1000000007
#define MAX 1000000

int main() {

		int n, i;
	char ch;
	cin>>ch;

	if(ch >= 'A' && ch <= 'Z') {
		cout<<'A'<<endl;
	} else {
		cout<<'a'<<endl;
	}


	return 0;

}

Measured memory_bytes: 3628
#include<stdio.h>

int main(){
	int n=0,m=0;
	scanf("%d",&n);
	int t[200005]={0};
	for(int i=0;i<n-1;i++){
		scanf("%d",&m);
		t[m-1]++;
	}
	for(int i=0;i<n;i++){
		printf("%d\n",t[i]);
	}
}

Measured memory_bytes: 2512
#include <iostream>

using namespace std;

int n, k, a[100005], cnt = 0;
int main () {
	cin >> n >> k;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for(int i = 0; i < n; i++) {
		if(a[i] >= k) {
			cnt++;
		}
	}
	cout << cnt;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(){
	int i, j, n, ans=10000000;
	scanf("%d",&n);
	int x[n],t[101];
	for(i=0;i<n;i++) scanf("%d",&x[i]);
	for(i=0;i<101;i++) t[i]=0;
	for(i=0;i<101;i++) 
		for(j=0;j<n;j++) t[i]+=(x[j]-i)*(x[j]-i);
	for(i=0;i<101;i++) if(t[i]<ans) ans=t[i];
	printf("%d",ans);
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int x = in.nextInt();
		int y = in.nextInt();
		int temp = 0;
		if(x == y) System.out.println(x);
		else if(x >= y) {
			while(x % y > 0) {
				temp = x % y;
				x = y;
				y = temp;
			}
			System.out.println(temp);
		}
		else {
			while(y % x > 0) {
				temp = y % x;
				y = x;
				x = temp;
			}
			System.out.println(temp);
		}
	}
}



Measured memory_bytes: 26332
#include<cstdio>
#include<algorithm>
using namespace std;
int prime[1000005],cur;
bool isprime[1000005];
int main()
{
	isprime[1]=1;
	for(int i=2;i<1000000;i++)
		if(!isprime[i])
		{
			prime[cur++]=i;
			for(long long j=1LL*i*i;j<1000000LL;j+=1LL*i)
				isprime[j]=1;
		}
	int n;
	while(~scanf("%d",&n))
		printf("%d\n",lower_bound(prime,prime+cur,n)-prime+(!isprime[n]));
	return 0;
}

Measured memory_bytes: 3944
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
int n;
string s;
int main()
{
	cin>>n>>s;
	if(s.size()>n) re(s.substr(0,n)+"...")
	re(s)
	return 0;}

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

using namespace std;

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

    vector<int> xs(n+1);
    vector<int> vs(n+1);
    xs[0] = INT_MIN;
    vs[0] = INT_MIN;
    for(size_t i = 1; i <= n; ++i)
    {
        cin >>xs.at(i);
        vs.at(i) = xs.at(i);
    }
    sort(vs.begin(), vs.end());

    for(size_t i = 1; i <= n; ++i)
    {
        if(xs[i] > vs[(n+1)/2])
            cout << vs[n/2] << endl;
        else
            cout << vs[n/2+1] << endl;
    }

    return 0;
}


Measured memory_bytes: 3712
import math
A, B, H, M = map(int, input().split())


b = (M * 6) % 360
H += M/60
a = (H * 30) % 360
deg = abs(a - b)

theta = math.radians(deg)


cc = (A**2 + B**2) - (2*A*B * math.cos(theta))

print(cc**0.5)


Measured memory_bytes: 9500
h, w = map(int, input().split())
arr = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    arr[i] = list(input())

def isWay(x, y):
    if x >= 0 and x < h and y >= 0 and y < w and arr[x][y] == '.':
        return True
    else:
        return False

numWay = 0
for i in range(h):
    for j in range(w):
        if arr[i][j] == '.':
            numWay += 1

queue = [[0, 0]]
arr[0][0] = 1
while 1:
    if len(queue) == 0:
        break
    cell = queue[0]
    queue.pop(0)
    x = cell[0]
    y = cell[1]
    n = arr[x][y]
    if(isWay(x-1, y)):
        arr[x-1][y] = n+1
        queue.append([x-1, y])
    if(isWay(x+1, y)):
        arr[x+1][y] = n+1
        queue.append([x+1, y])
    if(isWay(x, y-1)):
        arr[x][y-1] = n+1
        queue.append([x, y-1])
    if(isWay(x, y+1)):
        arr[x][y+1] = n+1
        queue.append([x, y+1])
if arr[h-1][w-1] == '.':
    print(-1)
else:
    print(numWay - arr[h-1][w-1])

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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)

int n, l;
int taste[210];

vector<int> u, b;

int main(void){
	cin>>n>>l;

	int sum = 0;

	for (int i = 0; i < n; i++) {
		taste[i] = l + (i + 1) - 1;
		sum += taste[i];
	}

	int minv = INF, tmp = 0;
	for (int i = 0; i < n; i++) {
		if (abs(taste[i]) < minv) {
			tmp = i;
			minv = min(minv, abs(taste[i]));
		}
	}

	int ans = sum - taste[tmp];

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, x, y, z;
  in3(x, y, z);
  a = 0;
  while(x >= y + 2 * z){
    a++;
    x = x - y - z;
  }
  out(a);
  memi;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
#define int long long

void solve() {
	int n; cin >> n;
    vector<int> a(n);
	int sum = 0;
    rep(i, n) {
        cin >> a[i];
		sum += a[i];
    }
	int b = n * (n + 1) / 2;
	if(sum % b != 0) {
		cout << "NO" << endl;
		return;
	}
	int co = sum / b;
	vector<int> c(n);
	rep(i, n) {
		c[i] = a[(i + 1) % n] - a[i];
	}
	rep(i, n) {
		c[i] -= co;
	}
	rep(i, n) {
		if(c[i] > 0 || -c[i] % n != 0) {
			cout << "NO" << endl;
			return;
		}
	}
	cout << "YES" << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 1792
S = input()
def isKaibun(S):
    if S != S[::-1]:
        return False
    return True

def main(S):
    if isKaibun(S)==False:
        return "No"
    N=len(S)
    S_1 = S[0:int((N-1)/2)]
    if isKaibun(S_1)==False:
        return "No"
    S_2 = S[int((N+3)/2)-1:N]
    if isKaibun(S_2)==False:
        return "No"
    return "Yes"

print(main(S))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    for (int i=1;i<s.size();i++) {
        if (s[i]==s[i-1]){
            cout<<"Bad"<<endl;
            return 0;
        }
    }

    cout<<"Good"<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x)  (long long)(x).size()
#define sqr(x) (x)*(x)
#define sof sizeof
#define resz resize
#define ins insert
#define lowerB lower_bound
#define upperB upper_bound
#define mkp make_pair
#define mkt make_tuple
#define act(a,v) (get<(long long)a>(v))
#define mod 1000000007
#define mod1 998244353
#define N 200003
#define inf 1e18
#define minf -1e18
#define min3(a,b,c) min(a,min(b,c));
#define max3(a,b,c) max(a,max(b,c));
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define sumall(v) accumulate(all(v),(ll)0)
#define suma accumulate
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION(n) std::cout.unsetf ( std::ios::floatfield );std::cout.precision((ll)n)
#define PI M_PI
#define fi first
#define se second
#define here cout<<"RSSB"<<endl
#define showzero cout<<std::showpoint
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define br "\n"
#define spac " "
#define zero (ll)0
using namespace  std ;
typedef double db;
typedef long long ll ;
typedef vector<int>vi ;
//typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
typedef vector<pll>vpll;
typedef vector<string>vstr;
typedef vector<tuple<ll,ll,ll> >vtll;
typedef vector<bool>vbool ;
void READ(vll &v, ll n){ll a ;for(ll i=0 ; i<n ; i=i+1){cin>>a ;v.pb(a);}}
void PRINT(vll &v , ll a = 0){for(ll i=a ; i<v.size() ; i=i+1){/*v[i] = max((ll)0,v[i]);*/cout<<v[i]<<"\n" ;}cout<<"\n" ;}
double logy(ll n , ll b){if(b==0){return(-1);}if(n==1){return(0);}return((db)log10(n)/log10(b));}
long long power(long long k , long long n , long long m=mod){long long res = 1;while(n){if(n%2!=0){res = (res*k)%m ;}k = (k*k)%m ;n = n/2 ;}return(res) ;}
double power(double p , ll t){db q = 1;while(t){if(t%2){q*=p;}p*=p;t/=2;}return(q);}
ll dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
ll dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
vpll dr;
void call(){dr.pb(mkp(1,0));dr.pb(mkp(-1,0));dr.pb(mkp(0,1));dr.pb(mkp(0,-1));}
ll n,m,k;
bool ok = false;
bool check(string str)
{
    m = sz(str);
    for(ll i =0 ; i<m ; i++)
    {
        if(str[i]==str[m-1-i])
        {
            continue;
        }
        return(false);
    }
    return(true);
}
int main()
{
    FastIO ;
    PRECISION(20) ;
    ll a,b,c,d,i,j,t,x,y,z,x1,y1,z1,e,f;
    db p,q,r,u,w ;
    char ch,chr ;
    string str,st,str1,str2,str3,str4;
    //ll a1=0,a2=0,b1=0,b2=0,c1=0 ;
    //cin>>str>>str1;
    //call();
    //Constructive is Weak!!
    cin>>n>>m;
    a = (n*(n-1))/2 + (m*(m-1))/2;
    cout<<a;
}

Measured memory_bytes: 256
import itertools

N, A, B, C = map(int, input().split())
L = [int(input()) for n in range(N)]
P = []

for n in range(1, N + 1):
    P.extend(itertools.combinations([n for n in range(N)], n))

add_len = {s: sum(L[i] for i in s) for s in P}


def cost(v, s):
    return 10 * (len(s) - 1) + abs(v - add_len[s])


res = 2 << 30
for a in P:
    cost_a = cost(A, a)
    if res < cost_a:
        continue

    for b in P:
        cost_b = cost(B, b)
        if res < cost_b:
            continue

        set_a = set(a)
        set_b = set(b)
        if len(set_a & set_b):
            continue

        for c in P:
            cost_c = cost(C, c)
            if res < cost_c:
                continue

            set_c = set(c)
            if len(set_a & set_c) or len(set_b & set_c):
                continue
            res = min(res, cost_a + cost_b + cost_c)

print(res)


Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(){
    long n;
    cin >> n;
    long a[200009] = {0};
    long sum = 0;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        sum += a[i];
    }
    
    long x = a[0];
    long y = sum - a[0];
    long minDiff = abs(x - y);
    for(int i = 1; i < n - 1; ++i){
        x += a[i];
        y -= a[i];
        long diff = abs(x - y);
        if(minDiff > diff){
            minDiff = diff;
        }
    }

    cout << minDiff << endl;
}

Measured memory_bytes: 1792