akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(ll i = a; i < (n); ++i)
#define repD(i, a, n) for(ll i = a; i > (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (long long) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
// #define mp make_pair
#define pb push_back
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
const long double PI = 3.141592653589793238462643383;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long int> vll;
typedef vector<double> vd;
typedef vector<pii> vii;
long long Ceil(long long a, long long b){
    if(a%b==0) return a/b;
    else return (a/b)+1;
}
ll p=1000000007;
float E = 0.00000000000001;
ll power(ll x, ll y){
    if(y==0){
        return 1;
    }
    if(y%2==0){
        ll q=power(x,y/2);
        q=q%p;
        return (q*q)%p;
    }
    ll q=power(x,y/2);
    q=q%p;
    return ((x%p)*((q*q)%p))%p; 
}
bool isPowerOfTwo (long long x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}  

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a); 
}
long long int mod(long long int a, long long int b) {
    long long int ret = a%b; return ret>=0? ret: ret+b; 
}
int main(){
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);   
    freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin>>t;
    while(t--){
    	int n;
    	cin>>n;
    	vector <int> vec(n);
    	for(auto& x:vec)
    		cin>>x;
    	sort(vec.begin(), vec.end());
    	long long ans = 0, idx = n-2, count = n-2;
    	ans = vec[n-1];
    	while(count - 2 >= 0){
    		ans += 2*vec[idx--];
    		count -= 2;
    	}
    	if(n%2)
    		ans += vec[idx];
        dbg(vec);
    	cout<<ans<<endl;
    }
    return 0;
}

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

int main(){
    
    for(;;){
        int m, f, r;
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1) break;
        char res;
        if(m == -1 || f == -1 || m+f < 30){
            res = 'F';
        }else if(m+f < 50 && r < 50){
            res = 'D';
        }else if(m+f < 65){
            res = 'C';
        }else if(m+f < 80){
            res = 'B';
        }else{
            res = 'A';
        }
        
        cout << res << endl;
    }
        
    
    return 0;
}


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

int main() {
  int n,k,j=0;
  cin >> n >> k ;
  vector<int> a(n);
  for(int i=0 ; i < n ; i++){
    cin >> a.at(i) ;
  }

  for(int i=k; i < n; i++){
    if(a.at(j) < a.at(i)) cout << "Yes" <<endl ;
    else cout << "No" <<endl ;
    j++;
  }

}


Measured memory_bytes: 4048
N, x = gets.split.map(&:to_i)
ans = N
short, long = [x, N - x].sort
loop do
    if long % short == 0
        ans += short * (2 * long/short - 1)
        puts ans
        exit
    else
        ans += short * 2 * (long/short)
        short, long = long%short, short
    end
end


Measured memory_bytes: 1788
def bubbleSort(A,N):
    flag = True
    count = 0
    i = 0
    while flag:
        flag = False
        for j in range(N-1,i,-1):
            if A[j] < A[j-1]:
                v = A[j]
                A[j] = A[j-1]
                A[j-1] = v
                count += 1
                flag = True
        i+=1
    return count

n = int(input())
x = input().split()
y=[]
for i in range(n):
    y += [int(x[i])]
    
count = bubbleSort(y,n)
for j in range(n-1):
    print(y[j],end=' ')
print(y[n-1])
print(count)



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long n,k,l,tmp,nm,changenm,m,checker;
    int wrongc = 0;
    vector <long> pozo;
    vector <long> rightpozo;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>k;
        pozo.push_back(k);
        rightpozo.push_back(k);
        
    }
    sort(rightpozo.begin(),rightpozo.end());
    
    for(int i=0;i<n;i++)
    {
        
        if(pozo[i]!=rightpozo[i])
        wrongc++;
        
    
        
    }
    if(wrongc==0)
    {
        cout<<"0"<<endl;
        return 0;
    }
    
    cin>>m;

   changenm = 0;
    for(int i=0;i<m;i++)
    {
        changenm++;
        cin>>k>>l;
        tmp = pozo[k-1];
        pozo[k-1] = pozo[l-1];
        pozo[l-1] = tmp;
        if(pozo[k-1]==rightpozo[k-1])
        {
            if(pozo[l-1]!=rightpozo[k-1])
            wrongc--;
        }
        else if(pozo[l-1]==rightpozo[k-1])
        wrongc++;
         if(pozo[l-1]==rightpozo[l-1])
        {
            if(pozo[k-1]!=rightpozo[l-1])
            wrongc--;
        }
        else if(pozo[k-1]==rightpozo[l-1])
        wrongc++;
        if(wrongc==0)
        break;
    }
   if(wrongc)
   cout<<"-1"<<endl;
   else
   cout<<changenm<<endl;
    return 0;
    
}



Measured memory_bytes: 9200
#include<stdio.h>

int main(void){
    int n,p[200000],i,c=0,f,min=300000;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&p[i]);
    }
    for(i=0;i<n;i++){
        f=0;
        if(p[i]<min){
            min = p[i];
            f = 1;
        }
        if(f==1) c++;
    }
    printf("%d\n", c);
    return 0;
}

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

const int N=1e5+10;
LL a[N],ans;
int n;

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    ans = 0;
    for(int i=1;i<=n;i++)
    {
        ans +=a[i]/2LL;
        if(a[i] & 1){
            if(i+1<=n && a[i+1])
            {
                ans+=1LL;
                a[i+1]-=1;
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1024
// luogu-judger-enable-o2
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 1e2+5;
int n, m;
char s[N], t[N];
int main()
{
    scanf("%d%s%s", &n, s+1, t+1);
    for(m = 0; m < n; ++m)
    {   
        int valid = 1;
        for(int i = 1; i <= n-m; ++i)
            if(s[m+i] != t[i]) valid = 0, i = n;
        if(valid) break;
    }
    printf("%d\n", n+m);
    return 0;
}

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

int main(){
    int N,M,ans=0;
    cin>>N>>M;
    vector<int>A(2*M);
    for(int i=0;i<2*M;i++){
        cin>>A.at(i);
    }
    for(int i=1;i<=N;i++){
        for(int j=0;j<2*M;j++){
            if (A.at(j)==i){
                ++ans;
            }
        }
        cout<<ans<<endl;
        ans = 0;
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n,m,l,i,j,k;
	long c;
	int A[100][100];
	int B[100][100];

	cin >> n >> m >> l;

	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++)
			cin >> A[i][j];

	for (i = 0; i < m; i++)
		for (j = 0; j < l; j++)
			cin >> B[i][j];

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < l; j++)
		{
			c = 0;
			for (k = 0; k < m; k++)
			{
				c += A[i][k] * B[k][j];
			}
			cout << c;
			if (j < l-1) cout << ' ';
			else cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3128
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
using ll = long long;

const long double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

    ll a[n];
    ll wa = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        wa += a[i];
        wa = wa % MOD;
    }

    ll ans = wa * wa % MOD;
    for(int i = 0; i < n; i++) ans = (ans + MOD*MOD - a[i]*a[i]) % MOD;

    ans = ans * modinv(2, MOD) % MOD;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5196
n = int(input())
li = list(map(int, input().split()))
li.sort()
inf = (10**6)+1
isprime = [False]*(inf+1)
for i in li:
    isprime[i] = True
temp = 0
for i in li:
    if i == temp:
        isprime[i] = False
    if not isprime[i]:
        continue
    for k in range(i*2, inf+1, i):
        isprime[k] = False
    temp = i
prime_list = []
for i in range(len(li)):
      if i+1<len(li):
            if li[i] == li[i+1]:
                isprime[li[i]] = False
for i in range(1, inf+1):
    if isprime[i]:
        prime_list.append(i)
print(len(prime_list))


Measured memory_bytes: 121988
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
int main(){
    int n; cin >> n;
    vector<int> V(n),C(n);
    rep(i, n) cin >> V[i];
    rep(i, n) cin >> C[i];

    int ans=0;
    rep(i,n){
        if(V[i]>=C[i]) ans+=V[i]-C[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		if(c>=a&&c<=b) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}

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

int main()
{
    int a,b,c;
    cin >> a >> b >>c;
    if(a == b)
        cout << c <<endl;
    else if(a == c)
        cout << b <<endl;
    else
        cout << a << endl;
    return 0;
}


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()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int e = 0;
	int w = 0;
	rep(i,n) {
		if (s[i] == 'E') e++;
	}
	int ans = INF;
	rep(i,n) {
		if (s[i] == 'E') e--;
		ans = min(ans, w + e);
		if (s[i] == 'W') w++;
	}
	cout << ans << endl;
}

int main() {
	solve();
	return 0;
}

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

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

    double ans = 0;
    for (int i = 0; i < N; i++) {
        double x;
        string u;
        cin >> x >> u;

        ans += x * (u == "JPY" ? 1 : 380000);
    }

    printf("%09f\n", ans);

    return 0;
}


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

#define fastIO ios_base::sync_with_stdio(false)
#define forI0N(i, a, b) for(int i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

    vector<int> a(N), b(N), c(N);
    forI0N(i, 0, N) cin >> a[i] >> b[i] >> c[i];

    vector<ull> A(N), B(N), C(N);
    A[0] = a[0];
    B[0] = b[0];
    C[0] = c[0];

    forI0N(i, 1, N) {
        A[i] = max(B[i - 1], C[i - 1]) + a[i];
        B[i] = max(A[i - 1], C[i - 1]) + b[i];
        C[i] = max(A[i - 1], B[i - 1]) + c[i];
    }

    cout << max(A[N - 1], max(B[N - 1], C[N - 1]));
}

Measured memory_bytes: 3840
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<cmath>
#include<set>
#include<map>
using namespace std;
int main() {
	string s;
	cin >> s;
	long long counter = 0, ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'B') {
			counter++;
		}
		else {
			ans += counter;
		}
	}
	cout << ans;
	return 0;
}

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

#define ll long long



using namespace std;

const int N_MAX = 102;

string s;

ll n;

ll cntl, cntr;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s >> n;
    if(s.size() == 1)
    {
        cout << n / 2 << "\n";
        return 0;
    }
    bool eq = true;
    for(int i = 1; i < s.size(); i++)
        if(s[i] != s[0])
            eq = false;
    if(eq == true)
    {
        if(s.size() % 2 == 0)
            cout << 1LL * s.size() / 2 * n << "\n";
        else
            cout << 1LL * s.size() / 2 * ((n + 1) / 2) + 1LL * (s.size() / 2 + 1) * (n / 2) << "\n";
        return 0;
    }
    ll ans = 0;
    ll lg = 1;
    for(int i = 1; i < s.size(); i++)
    {
        if(s[i] == s[i - 1])
            lg++;
        if(s[i] != s[i - 1] || i == s.size() - 1)
        {
            if(cntl == 0)
                cntl = lg;
            cntr = lg;
            ans += lg / 2 * n;
            lg = 1;
        }
    }
    if(s.back() == s.front())
    {
        if(cntl % 2 + cntr % 2 == 0)
            ans += 0;
        else if(cntl % 2 + cntr % 2 == 2)
            ans += n - 1;
    }
    cout << ans << "\n";
    return 0;
}


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

int main(){
	ll n;
	cin>>n;
	
	ll j=1;
	for(ll i=sqrt(n); i>1; i--){
		if(n%i==0){
			j=i;
			break;
		}
	}
	ll i=n/j;
	
	cout << i-1+j-1 << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
using namespace std;
typedef long long ll;

ll mod = 1e9+7;  // 1e9+9

ll add(ll x,ll y){return (x+y)%mod;}
ll mul(ll x,ll y){return (x*y)%mod;}

ll mpow(ll x,ll y){
  ll v=1;
  for(;y;x=mul(x,x),y>>=1)
    if(y&1)v=mul(v,x);
  return v;
}

ll divi(ll x,ll y){return mul(x,mpow(y,mod-2));}
/*
ll ncr[5000][5000];

ll nCr(ll n,ll r){
  if(n==r)return 1;
  if(r==0)return 1;
  if(ncr[n][r])return ncr[n][r];
  ncr[n][r]=(nCr(n-1,r-1)+nCr(n-1,r))%mod;
  return ncr[n][r];
}
*/

/*
ll nCr(ll n,ll r){
  r=min(r,n-r);
  ll A=1,B=1;
  for(ll i=0;i<r;i++){
    A=mul(A, (n-i)%mod );
    B=mul(B, (i+1)%mod );
  }
  return divi(A,B);
}
*/


ll fact[10000000]={1}, factc=0;
ll Fact(ll x){
  while( factc < x ){
    factc++;
    fact[factc]=mul( fact[factc-1] , factc );
  }
  return fact[x];
}

ll nCr(ll n,ll r){
  return divi( Fact(n) , mul( Fact(n-r) , Fact(r) )   );
}


/*
ll nHr(ll n,ll r){
  return nCr( n+r-1 , n );
}
*/

ll dp[1001][1001];
int main(){
  ll n,k;
  cin>>n>>k;
  dp[0][0]=1;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=k;j++){
      dp[i][j]+=dp[i-1][j-1];
      dp[i][j]+=dp[i-1][j]*j;
      dp[i][j]%=mod;
    }
  }
  ll ans=0;
  for(int j=k;j<=k;j++)
    ans=add(ans,dp[n][j]);
  cout<<ans<<endl;
  return 0;
}




Measured memory_bytes: 10988
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
  public class Program
  {
    public static void Main(string[] args)
    {
      new Program().Solve(new ConsoleInput(Console.In, ' '));
    }

    public void Solve(ConsoleInput cin)
    {
      string s = cin.Read;
      if (s.Length == 3) {
        WriteLine(s.Reverse().ToArray());
      } else {
        WriteLine(s);
      }
    }
  }

  public class ConsoleInput
  {
    private readonly System.IO.TextReader _stream;
    private char _separator = ' ';
    private Queue<string> inputStream;
    public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
    {
      this._separator = separator;
      this._stream = stream;
      inputStream = new Queue<string>();
    }
    public string Read
    {
      get
      {
        if (inputStream.Count != 0) return inputStream.Dequeue();
        string[] tmp = _stream.ReadLine().Split(_separator);
        for (int i = 0; i < tmp.Length; ++i)
          inputStream.Enqueue(tmp[i]);
        return inputStream.Dequeue();
      }
    }
    public string ReadLine { get { return _stream.ReadLine(); } }
    public int ReadInt { get { return int.Parse(Read); } }
    public long ReadLong { get { return long.Parse(Read); } }
    public double ReadDouble { get { return double.Parse(Read); } }
    public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
    public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
    public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
  }
}

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

#define pb push_back
#define F first
#define S second

#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define int long long
#define ll long long


	
void solve(){
	int n;
	cin >> n;
	int ans = ceil(1.0 * n / 1000) * 1000;
	ans -= n;
	cout << ans;
}

signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 3624
import math
s=str(input())
b=''
c=0
d=math.ceil(len(s)/2)
if s[0]=='0':
    for i in range(d):
        b+="01"
else:
    for i in range(d):
        b+="10"
if len(s) != len(b):
    b = b[:-1]
for u in range(len(s)):
    if s[u] != b[u]:
        c+=1
print(c)

Measured memory_bytes: 3316
#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() {
  ll n;
  cin >> n;
  map<string, bool> m;
  rep(i, n) {
    string s;
    cin >> s;
    m.insert(make_pair(s, true));
  }

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

  return 0;
}


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

int main(void){
    int N,T,A;
    int index,imin = 1000000;
    cin >> N;

    cin >> T >> A;

    vector<int> H(N);

    rep(i,N)
        cin >> H.at(i);

    rep(i,N){
        int temp = 1000*T-H.at(i)*6;

        if(imin > abs(1000*A-temp)){
            index = i;
            imin = abs(1000*A-temp);
        }
        
    }

    cout << index+1 << endl;
    
    return 0;
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Read();
            var ans = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == '1') ans++;
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
static const ll mod = 1000000007;
# define INF (1 << 29)
/* ちゃんと考えて実装して問題なくACできた時嬉しいよ！！ */

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

Measured memory_bytes: 256
require 'date'

MEIJI = [Date::new(1868, 9, 8), Date::new(1912, 7, 29)]
TAISHO = [Date::new(1912, 7, 30), Date::new(1926, 12, 24)]
SHOWA = [Date::new(1926, 12, 25), Date::new(1989, 1, 7)]
HEISEI = Date::new(1989, 1, 8)

while s = gets
  s = s.chomp
  
  d = Date::strptime(s, "%Y %m %d")

  if HEISEI <= d then
    puts "heisei %d %d %d" % [d.year-HEISEI.year+1, d.month, d.day]
  elsif SHOWA[0] <= d && d <= SHOWA[1] then
    puts "showa %d %d %d" % [d.year-SHOWA[0].year+1, d.month, d.day]
  elsif TAISHO[0] <= d && d <= TAISHO[1] then
    puts "taisho %d %d %d" % [d.year-TAISHO[0].year+1, d.month, d.day]
  elsif MEIJI[0] <= d && d <= MEIJI[1] then
    puts "meiji %d %d %d" % [d.year-MEIJI[0].year+1, d.month, d.day]
  else
    puts "pre-meiji"
  end
end

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

using namespace std;

int main(){

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

	int total = 0;
	
	for(int i =0;i<n;i++){
		for(int j =i+1;j<n;j++){
			total += (a[i]*a[j]);
		}
	}
	cout<<total<<endl;

	return 0;
}

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

int H,W;
char fid[1001][1001] = {0};
int dx[] = {1,1,1,0,-1,-1,-1,0},dy[] = {1,0,-1,-1,-1,0,1,1,1};

int judge(int y,int x)
{
    if(x < 0 || x >= W || y < 0 || y >= H)return 0;
    return (fid[y][x] == '#');
}

int main()
{
    scanf("%d%d",&H,&W);
    for(int i = 0; i < H; i++)for(int j = 0; j < W; j++)scanf(" %c",&fid[i][j]);

    for(int i = 0; i < H; i++)
    {
        for(int j = 0; j < W; j++)
        {
            if(fid[i][j] != '#')
            {
                int res = '0';
                for(int k = 0; k < 8; k++)
                {
                    res += judge(i + dy[k],j + dx[k]);
                }
                fid[i][j] = res;
            }
            printf("%c",fid[i][j]);
        }printf("\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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

int main()
{
    int H,W; cin >> H >> W;
    char s[H+2][W+2];
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cin >> s[i][j];
        }
    }
    vector<vector<ll> > dist(H+2,vector<ll>(W+2,MOD));
    if(s[1][1] == '#')dist[1][1] = 1;
    else dist[1][1] = 0;
    for(int i=1;i<= H;i++){
        for(int j=1;j<=W;j++){
            //下右に動く
            int dy[4] = {1,0};
            int dx[4] = {0,1};
            for (int k = 0; k < 2; k++) {
                int ex = i + dx[k], ey = j + dy[k];
        
                if (s[ex][ey] == '.' || s[ex][ey] == '#'){
                    if(s[ex][ey] == '.')
                        chmin(dist[ex][ey],dist[i][j]);
                    else if(s[ex][ey] == '#'){
                        if(s[i][j] == '#')
                            chmin(dist[ex][ey],dist[i][j]);
                        else
                            chmin(dist[ex][ey],dist[i][j] + 1);
                    }
                }
            }
        }
    }
    cout << dist[H][W] << endl;
}
    

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

const double h = 1.0e11;
const double div_c = 3.0e6;
const double rad = 2.0 * M_PI / div_c;

int N;
vector < double > x,y;

int main() {

    cin >> N;
    x.resize(N);
    y.resize(N);
    REP(i,N) cin >> x[i] >> y[i];

    double cnt[110] = {};
    for (double i = 0.0; i < div_c; i += 1.0) {
        double r = i * rad;
        double xt = h * cos(r);
        double yt = h * sin(r);
        int idx = -1;
        double max_d = 1.0e30;
        REP(j,N) {
            double lx = xt - x[j];
            double ly = yt - y[j];
            double d = sqrt(lx * lx + ly * ly);
            if (max_d > d) {
                max_d = d;
                idx = j;
            }
        }
        cnt[idx] += 1.0;
    }

    REP(i,N) {
        cout << fixed << setprecision(10) << cnt[i] / div_c << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll x;
  cin >> x;

  if (x == 3 || x == 5 || x == 7) cout << "YES" << endl;
  else cout << "NO" << 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>;

vector<int> ans;

void dfs(ll n){
    if(n == 0) return;
    n--;
    ans.push_back(n%26);
    dfs(n/26);
}

int main(){
    ll N;
    cin >> N;
    dfs(N);
    while(ans.size() > 0){
        int a;
        a = ans.back();
        ans.pop_back();
        cout << (char)('a' + a);
    }
    cout << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define repit2(x) for (__typeof((x).begin()) it2 = (x).begin(); it2 != (x).end(); it2++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

// can be applied to string type
#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
template<typename T>
void Debug(const T &val) { cerr << val << End; }
template<typename T, typename... Args>
void Debug(const T &val, Args... args) {
    cerr << val << ' ';
	Debug(std::forward<Args>(args)...);
}

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

// can be applied to string type
#define Sort(v) sort(All(v))
#define SortR(v) sort(All(v), std::greater<__typeof(v[0])>())
// array sorters
#define Sart(a) sort(a, a + sizeof(a) / sizeof(__typeof(a[0])));
#define SartR(a) sort(a, a + sizeof(a) / sizeof(__typeof(a[0])), std::greater<__typeof(a[0])>())

#define pb push_back
#define mp make_pair
#define a first
#define b second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    int n, a, b;

	cin >> n;
	cin >> a >> b;

	int p[n];
	V<int> v[3];

	int i;

	rep(i, n) cin >> p[i];

	Sart(p);

	rep(i, n) {
		if (p[i] <= a) v[0].pb(p[i]);
		else if (p[i] <= b) v[1].pb(p[i]);
		else v[2].pb(p[i]);
	}

	Out(min(v[0].size(), min(v[1].size(), v[2].size())));
	
	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() {
    long A, B;
    cin >> A >> B;

    cout << lcm(A, B) << endl;
}


Measured memory_bytes: 3640
from collections import deque
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n=int(input())
    sum_d=0
    aa=deque()
    for _ in range(n):
        qq=list(map(int, input().split()))
        if qq[0]==0:
            aa.appendleft(qq[1])
        elif qq[0]==1:
            aa.rotate(-qq[1])
            sum_d+=qq[1]
        else:
            aa.popleft()
    aa.rotate(sum_d)
    for a in aa:
        print(a)

main()


Measured memory_bytes: 21704
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

a = inps[0]
b = inps[0]
(a.size + b.size).times do |i|
  unless i.odd?
    print a[i/2]
  else
    print b[i/2]
  end
end
puts 

Measured memory_bytes: 2044
package main

import "fmt"

func main() {
	var (
		n int
		s string
		x int = 0
		m int = 0
	)
	fmt.Scan(&n)
	fmt.Scan(&s)
	for _, v := range s {
		if string(v) == "I" {
			x++
		} else {
			x--
		}
		if x > m {
			m = x
		}
	}
	fmt.Println(m)
}


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

int main(){
	int n, total=0;
	cin >> n;
	int a[n+1], b[n+1], c[n];
	for(int i=1; i<=n; i++)
		cin >> a[i];
	for(int i=1; i<=n; i++)
		cin >> b[i];
	for(int i=1; i<n; i++)
		cin >> c[i];
	
	for(int i=1; i<=n; i++){
		total += b[i];
		if(a[i-1]==a[i]-1) total += c[a[i-1]];
	}
	cout << total;
	return 0;
}

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

map<string, int> Nvotes;
vector<pair<string, int>> votes;

bool cmp(pair<string, int> &v1, pair<string, int> &v2)
{
        if(v1.second!=v2.second)return v1.second>v2.second;
        if(v1.first!=v2.first)return v1.first<v2.first;
}

void preenche()
{
    votes.reserve(Nvotes.size());
    map<string, int>::iterator i;
    for(i = Nvotes.begin(); i!=Nvotes.end(); i++)
    {
        votes.push_back(make_pair(i->first, i->second));
    }
    sort(votes.begin(), votes.end(), cmp);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N;
    cin>>N;
    string s;
    while(N--)
    {
        cin>>s;
        Nvotes.insert( make_pair(s, Nvotes[s]++) );
    }
    preenche();

    int I = 0;

    while(votes[I].second == votes[0].second)
    {
        cout<<votes[I].first<<endl;
        I++;
    }
    return 0;
}


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

int main(){
  int N,M,X,Y;
  cin >> N >> M >> X >> Y;
  
  int x[N], y[M];
  
  for(int i=0;i<N;i++){
    cin >> x[i];
  }
  for(int j=0;j<M;j++){
    cin >> y[j];
  }
  
  sort(x,x+N);
  sort(y,y+M);
  
  if(x[N-1]>=y[0]){cout << "War";}
  else if(x[N-1]>=Y){cout << "War";}
  else if(y[0]<=X){cout << "War";}
  else{cout << "No War";}
  
  return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<map>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e5+5;
const int MOD=1e9+7;
const double EPS=1e-12;
template <class T>
bool sf(T &ret){ //Faster Input
    char c; int sgn; T bit=0.1;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&c!='.'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    if(c==' '||c=='\n'){ ret*=sgn; return 1; }
    while(c=getchar(),c>='0'&&c<='9') ret+=(c-'0')*bit,bit/=10;
    ret*=sgn;
    return 1;
}
int sign(double x){
    return fabs(x) < EPS ? 0 : x>0 ? 1 : -1 ;
}

int main(void){
    ll n,k;
    sf(n);sf(k);
    ll t=n/k;
    if(n%k==0)  cout << 0 << endl;
    else        cout << 1<< endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef   long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define B 998244353ll
#define C 1000000000000000001ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.14159265358979323

int main() 
{
    FAST;
    ll a;
    cin>>a;
    cout<<a*a*a;
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 512
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.IntStream;

public class Main {

    private enum right {
        y,
        u,
        i,
        o,
        p,
        h,
        j,
        k,
        l,
        n,
        m,
        ;
    }

    static int cnt = 0;
    static List<String> hands = new ArrayList<>();

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine().trim()) != null && !"#".equals(line)) {
            output(line);
            clear();
        }
    }

    public static void output(String line) {
        IntStream.range(0, line.length()).mapToObj(i->line.substring(i,i+1)).forEach(key -> {
            if(Arrays.stream(right.values()).map(e->e.name()).anyMatch(e->key.equals(e))) {
                hands.add("r");
            } else {
                hands.add("l");
            };
        });
        IntStream.range(0, hands.size()).filter(i->0<i).forEach(i -> {
            if(!hands.get(i-1).equals(hands.get(i))) cnt++;
        });
        System.out.println(cnt);
    }

    public static void clear() {
        hands.clear();
        cnt = 0;
    }
}


Measured memory_bytes: 33900
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
ll ketawa(ll a){ll r=0;while(a){r+=a%10;a/=10;}return r;}


int main(){
  int N;
  cin >> N;
  ll ans = 0;
  map<string,int> ma;
  FOR(i,0,N){
    string s;
    cin >> s;
    SORT(s);
    ans += ma[s];
    ma[s]++;
  }
  cout << ans << endl;
}




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

int check_value(int n, vector<int> d){
    string s = to_string(n);
    rep(j, s.length()){
        if((d[j+1] > -1) && ((s[j] - '0') != d[j+1])) return 0;
    }
    return 1;
}

int main(void){
    int N, M;
    int d_s = 4;
    cin >> N >> M;
    vector<int> d(d_s);rep(i, d_s){d[i] = -1;}
    rep(i, M){
        int dinx, dnum; cin >> dinx >> dnum;
        if(d[dinx] > -1 && d[dinx] != dnum){
            cout << -1 << endl;
            return 0;
        } else {
            d[dinx] = dnum;
        }
    }
    if(N > 1 && d[1] == 0){
        cout << -1 << endl;
        return 0;
    }
    rep(i, 999){
      	string n = to_string(i);
        if(n.length() == N && check_value(i, d)){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

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

int main()
{
    int n, x, cnt;
    while (1) {
        cnt = 0;
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        for (int i = 1; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) {
                for (int k = j + 1; k <= n; k++) {
                    if (i + j + k == x) cnt++;
                }
            }
        }
        cout << cnt << endl;
    }
}


Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

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

	int c1, c2, c3;
	while(cin >> c1 >> c2 >> c3) {
		bool exist[11] = { false };
		exist[c1] = exist[c2] = exist[c3] = true;

		int cnt = 0;
		for(int i = 1; i <= 10; i++) {
			if(!exist[i] && c1 + c2 + i <= 20) cnt++;
		}
		if(cnt >= 4) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 1184
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        n = int(lines[0])
        for _ in range(n):
            lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]
        n = int(lines[0])
    
    s = lines[1:]


    return (n, s)


def solve(n, s):

    d = dict() 
    max_cnt = 0
    for i in range(n):
        cnt = d.get(s[i], 0)
        cnt = cnt + 1
        d[s[i]] = cnt
        if cnt > max_cnt:
            max_cnt = cnt

    result = []
    for word, cnt in d.items():    
        if cnt == max_cnt:
            result.append(word)

    result.sort()

    return  result


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Measured memory_bytes: 38160
import heapq
def dijkstra_heap(s):
    d = [float("inf")] * n
    used = [True] * n #True: not used
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v],e[1]))
    return d
import sys
input = sys.stdin.readline
n =int(input())
 
edge = [[] for i in range(n)]
#edge[i] : [weght,to]
for i in range(n-1):
    a, b, c = map(int,input().split())
    a, b = a-1, b-1
    edge[a].append((c,b))
    edge[b].append((c,a)) 
q, k = map(int, input().split())
k = k-1
d = dijkstra_heap(k)
for i in range(q):
  x, y = map(int, input().split())
  x, y = x-1, y-1
  print(d[x]+d[y])

Measured memory_bytes: 83616
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl;
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl;
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl;
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl;
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl;
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl;
#define int long long
#define double long double
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  int h,w;
  cin>>h>>w;
  vector<string> mp(h);
  cin>>mp;

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

  int ans = 1;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      if(mp[i][j] == '.') continue;
      
      int flag = 0;
      for(int k=0;k<4;k++){
        int ny = i + dy[k];
        int nx = j + dx[k];
        if(nx < 0 || ny < 0 || ny >= h || nx >= w) continue;
        if(mp[ny][nx] == '.') continue;
        flag = 1;
      }
      ans &= flag;
    }

  cout<<(ans? "Yes":"No")<<endl;

  return 0;
}


Measured memory_bytes: 256
N=int(input())
Ai=list(map(int,input().split()))
n=0
for i in Ai:
    if i%2==0:
        if i%3==0 or i%5==0:
            n+=1
        else:
            pass
    else:
        n+=1

if n==N:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 3060
///----------------------///
///---Code Written by----///
///-----Al-Shahreyaj-----///
///----------------------///

///PRAGMA
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>

///PBDS
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;

//PBDS_SET
//Index of Value - .order_of_key()
//Value at Index - .find_by_order()
//typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds_set; 
//typedef tree<int, null_type, lessorequal<int>, rb_tree_tag,tree_order_statistics_node_update> pbds_multiset; 

#define mem(a, x) memset(a, x, sizeof(a))
#define MP make_air
#define inf 1e8
#define INF 1e18
#define CP(x) printf("Case %d: ", x);
#define unq(v) v.erase(unique(all(v)),v.end())
#define one(x) __builtin_popcount(x)
#define onel(x) __builtin_popcountll(x)
#define ll long long
#define ld long double
#define LMX LLONG_MAX
#define fixpre(x) cout << fixed << setprecision(x)
#define endl "\n"
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define matrix vector<vector<ll> >
#define F first
#define S second
#define pb push_back
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define INT ini()
#define LONG inl()
#define M 1000000007
#define N 100005

int ini(){int x;scanf("%d",&x);return x;}
ll inl(){ll x;scanf("%lld",&x);return x;}


int main()
{
	ll n, ans = 0;
	cin >> n;
	for(ll i = 2; i * i <= n; i++)
	{
		if(n % i == 0)
		{
			int cn = 0;
			while(n % i == 0)
			{
				cn++;
				n /= i;
			}
			int cc = 1;
			while(cn >= cc)
			{
				ans++;
				cn -= cc;
				cc++;
			}
		}
	}
	if(n > 1) ans++;
	cout << ans << endl;
	return 0;
}





Measured memory_bytes: 3640
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n;
    int dif=4280;
    while(cin>>n){
        if(n==-1)break;
        int cost=1150;
        for(int i=1; i<=n;i++)
            if(i<=10)continue;
            else if(i<=20)cost+=125;
            else if(i<=30)cost+=140;
            else cost+=160;
        //cout<<cost<<endl;
        cout<<dif-cost<<endl;
    }
}

Measured memory_bytes: 2980
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define clr(x, y) memset(x,y,sizeof(x));
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define rep(i, m, n) for(int i=m ; i<n ; i++)
#define forr(i, m, n) for(int i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define re return
const int N = 1e5 + 5;
const ll mod = 1e9 + 7;
using namespace std;
int n, m;
vi a[N]; bool vis[N];
bool weslt;

int main() {
    IO;
    double a, b, d, h, m, angle;
    cin >> a >> b >> h >> m;
    angle = cos((h*30.0 - 5.5 * m)/180.0*3.1415926535);
    d = sqrt(a*a + b*b - 2*a*b*angle);
    cout << setprecision(12);
    cout << d << endl;

    /*cin >> n >> m;
    rep(i, 0, m) {
        int u, v;
        cin >> u >> v;
        a[u].pb(v);
        a[v].pb(u);
    }

    forr(i, 2, n) {
        weslt = 0;



        if (!weslt) re cout << "No", 0;
    }*/


}


Measured memory_bytes: 6552