akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return


ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }


/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

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

///////////////////////////////////////////////////////////////////////////

int main(){
    double r;
    cin >> r;

    printf("%.10f\n",r*2*pi);
	
    return  0;
}


Measured memory_bytes: 3768
import bisect
#素数リスト
n = 10**5+10
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
  primes.difference_update(range(i*2, n+1, i))
primes=list(primes)

x = int(input())
idx = bisect.bisect_left(primes, x)
print(primes[idx])

Measured memory_bytes: 61672
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
 



int main()
{
    fastio
    ll i,j,x;
    
    ll a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    
    ll dis=abs(b-a);
    
    ll dis2=abs(v-w);
    dis2*=t;
    
    if(w>=v)
    cout<<"NO";
    else if(dis2>=dis)
    cout<<"YES";
    else
    cout<<"NO";
}


Measured memory_bytes: 3688
import java.io.*;
public class Main{
  public static void main(String args[]) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String s = br.readLine();
    if((s.charAt(s.indexOf(" ") - 1) & 1) == 0){
      System.out.println("Even");
    } else if ((s.charAt(s.length() - 1) & 1) == 0) {
      System.out.println("Even");
    } else {
      System.out.println("Odd");
    }
  }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(){    
  ll N;
  cin >> N;
  ll a = 0;
  for(int i = 0; i < N; i++){
    ll  l,r;
    cin >> l >> r;
    a = a + r - l + 1;
  }
  cout << a << endl;
}


Measured memory_bytes: 256
#include <cstdio>

inline int read(void){
	int res = 0;
	char ch = std::getchar();
	while(ch < '0' || ch > '9')
		ch = std::getchar();
	while(ch >= '0' && ch <= '9')
		res = res * 10 + ch - 48, ch = std::getchar();
	return res;
}

int L, R, d;

int main(){
	L = read(), R = read(), d = read();
	std::printf("%d\n", R / d - (L - 1) / d);
	return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

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

using namespace std;

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

int main()
{
	int a,b;
	cin >> a >> b;
	
	if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0)
	{
		cout << "Possible" << endl;
	}
	else
	{
		cout << "Impossible" << endl;
	}
	
	return 0;
}

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

int main() {
	int N, M, x, y,war=1;
	cin >> N >> M >> x >> y;
	int X[N], Y[M];
	int Xmax = -101, Ymin = 101;
	for (int i = 0;i < N;i++) {
		cin >> X[i];
		if (X[i] > Xmax)
			Xmax = X[i];
	}
	for (int i = 0;i < M;i++) {
		cin >> Y[i];
		if (Y[i] < Ymin)
			Ymin = Y[i];
	}
	for (int i = -100;i < 101;i++)
		if (i > Xmax && i <= Ymin && i > x && i <= y) {
			war = 0;
			break;
		}
	if (war == 1)
		cout << "War" << endl;
	else
		cout << "No War" << endl;


}

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

int n,q,ans;
string s;
char c[N];
bool dir[N];

bool to(int x,int to)
{
	for(int i=0;i<q;i++)
	{
		if(c[i]!=s[x]) continue;
		if(dir[i]) x++;
		      else x--;
		if(x==to) return 1;
		if(x==-1 || x==n) return 0;
	}
	return 0;
}

int main()
{
	
	cin>>n>>q;
	cin>>s;
	for(int i=0;i<q;i++)
	{
		cin>>c[i];
		char x;
		cin>>x;
		if(x=='R') dir[i]=1;
	}
	
	ans=n;
	int l=-1,r=n;
	while(l+1<r)
	{
		int mid=(l+r)/2;
		if(to(mid,-1)) l=mid;
		          else r=mid;
	}
	ans-=r;
	l=-1,r=n;
	while(l+1<r)
	{
		int mid=(l+r)/2;
		if(to(mid,n)) r=mid;
		         else l=mid;
	}
	ans-=n-r;
	cout<<ans<<'\n';
	
	return 0;
}

Measured memory_bytes: 1028
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

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

using namespace std;
int n,m;

int main()
{
    int n,k;
    cin >> n >> k;
    ll a = 1;
    for(int i = 0;i < n;i++)
    {
        ll b = a * 2;
        ll c = a + k;
        a = min(b,c);
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
#define ll long long int
#define MOD 1e9 + 7

int main(){

  ll N, ans = 0;
  cin >> N;
  vector<ll> A(N);
  int cnt = 0;
  bool zero = false;
  ll mini = MOD;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    ans += abs(A[i]);
    mini = min(mini, abs(A[i]));
    if(A[i] == 0){
      zero = true;
    }
    if(A[i] < 0){
      cnt++;
    }
  }
  if(zero || cnt % 2 == 0){
    cout << ans << endl;
  } else {
    cout << ans - 2 * mini << endl;
  }

  return 0;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	var n,x int
	fmt.Scan(&n,&x)
	
	l := make([]int,n)
	for i := range l {
		fmt.Scan(&l[i])
	}
	
	d := make([]int, n+1)
	cnt := 1
	for i := 1; i < n+1 ; i++ {
		d[i] = d[i-1] + l[i-1]
		if d[i] <= x {
			cnt++
        } 
	}
	fmt.Println(cnt)
}

Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    long long K; cin >> K;

    vector<long long> A[20][10];

    for (long long i = 0; i < 10; i++) {
        A[0][i].push_back(i);
    }

    if (K <= 9) {
        cout << K << endl;
        return;
    }

    long long cnt = 9;
    for (long long i = 1; i < 20; i++) {
        for (long long j = 0; j < 10; j++) {
            for (long long k = -1; k <=1 ; k++) {
                if (j == 0 && k == -1) continue;
                if (j == 9 && k == 1) continue;
                for (auto e : A[i-1][j+k]) {
                    long long p = 1;
                    for (long long l = 0; l < i; l++) p *= 10;
                    A[i][j].push_back(e + p * j);
                    //cout << e + powf(10, i) * j << endl;
                    if (j != 0) cnt++;
                    if (cnt == K) {
                        cout << setprecision(20) << e + p * j << endl;
                        return;
                    }
                }
            }
        }
    }
}


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

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


int main() {
	int x,y;
	cin>>x>>y;
	if(x==y)
    {
        cout<<"Draw";
        return 0;
    }
	else if(x==1||y==1)
    {
        if(x==1)
            cout<<"Alice";
            else cout<<"Bob";
            return 0;
    }
    else if(x>y)
        cout<<"Alice";
    else cout<<"Bob";
	return 0;
}


Measured memory_bytes: 256
#44
S = input()
cou1,cou2 = 0,0
a,b = "",""
if len(S)%2 ==0:
    for i in range(int(len(S)/2)):
        a+="01"
        b+="10"
else:
    for i in range(int(len(S)/2)+1):
        a+="01"
        b+="10"
        
for i in range(len(S)):
    if S[i] != a[i]:
        cou1 +=1
    if S[i] != b[i]:
        cou2 +=1
if cou1 <= cou2:
    cou = cou1
else:
    cou = cou2
        
print(cou)

Measured memory_bytes: 9368
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	h := make([]int, N)
	for i := range h {
		fmt.Scan(&h[i])
	}
	ans := 0
	for {
		seeded := false // 一度でも草刈りしたか？
		on := false     // 草刈り装置のon/off
		for i := 0; i < N; i++ {
			if h[i] > 0 {
				if !on {
					on = true
					seeded = true
					ans++
				}
				h[i]--
			} else {
				on = false
			}
		}
		if !seeded {
			break
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        
        int n = scan.nextInt();
        int x = scan.nextInt();
        
        int[] city = new int[n+1];
        city[0] = x;
        for(int i=1;i<city.length;i++)
        {
            city[i] = scan.nextInt();
        }
        
        Arrays.sort(city);
        
        int[] bwc = new int[n];
        for(int i=0;i<bwc.length;i++)
        {
            bwc[i] = city[i+1] - city[i];
        }
        
        int ans = 0;
        if(n==1)
        {
            ans = bwc[0];
        }
        else
        {
            ans = ArrayGcd(bwc);
        }
        
        System.out.println(ans);
    }
    
    
    static int gcd(int a,int b){
        if(b==0)
        {
            return a;
        }
        int r = a % b;
        
        return gcd(b,r);
    }
    
    static int ArrayGcd(int[] p){
        int a = gcd(p[0],p[1]);
        int i = 2;
        while(i<p.length)
        {
            a = gcd(a,p[i]);
            i++;
        }
        return a;
    }
}

Measured memory_bytes: 51636
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main(void)
{
        int n;
        cin >> n;
        vector<pair<pair<string,int>,int> > st(n);

        for(int i=0;i<n;i++)
        {
                string s;
                int p;
                cin >> s >> p;
                st[i]=make_pair(make_pair(s,-p),i+1);
        }

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

        for(int i=0;i<n;i++)
        {
                cout << st[i].second << endl;

        }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N,D;
    cin >> N >> D;
    ll cnt=0;
    rep(i,N){
        ll x,y;
        cin >> x >> y;
        if(x*x+y*y<=D*D){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(void)
{
	int i;
	
	int n;
	scanf("%d",&n);
	
	int S[n];
	for(i=0;i<n;i++)
	{
		scanf("%d",&S[i]);
	}
	int q;
	scanf("%d",&q);
	
	int T[q];
	for(i=0;i<n;i++)
	{
		scanf("%d",&T[i]);
	}
	
	int x=0,count=0;
	for(i=0;i<q;i++)
	{
		x=T[i];
		for(int j=0;j<n;j++)
		{
			if(x==S[j])
			{
				count++;
				break;
			}
		}
	}
	
	printf("%d\n",count);
	
	return 0;
}


Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N,M,C;
    cin>>N>>M>>C;
    vector<int> B(M);
    rep(i,M)cin>>B.at(i);
    int ans=0;
    rep(i,N){
        ll score=C;
        rep(i,M){
            int a;
            cin>>a;
            score+=a*B.at(i);
        }
        if(score>0)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3556
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;



int main(){
	ll X,Y;
	cin>>X>>Y;
	ll d=abs(X-Y);
	if(d<=1)cout<<"Brown"<<endl;
	else cout<<"Alice"<<endl;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

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

   ll m = 1e18;

   ll cnt = 0;
   for (ll i = x; ; i+=x) {
      if (i%x==0 && i%y!=0) {
         cout << i << endl;
         return 0;
      }
      if (cnt >= 10000000 || i > 1e18) {
         cout << -1 << endl;
         return 0;
      }
      cnt++;
   }

   return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
E = {i+1: set() for i in range(N)}
first = set()
for m in range(M):
    a, b = lr()
    if b == N:
        first.add(a)
    E[a].add(b)
if not first.isdisjoint(E[1]):
    print("POSSIBLE")
    exit(0)
print("IMPOSSIBLE")


Measured memory_bytes: 98200
#include <iostream>
#include <string>

using namespace std;
 
int main(){
    int SUM;
    string s;
    while(true){
        getline(cin, s);
        if(s=="0") break;
        SUM = 0;
        for(int i=0;i<s.size();i++){
            SUM += s[i] - '0';
        }
        cout << SUM << endl;
    }
}


Measured memory_bytes: 3204
N, K = map(int,input().split())
P = [0]+list(map(int,input().split()))
for i in range(1,N+1):
  p = P[i]
  p = (1+p)/2
  P[i] = p+P[i-1]
ans = 0
for i in range(N-K+1):
  ans = max(ans,P[i+K]-P[i])
print(ans)

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

const int maxn = 1e6+7;
int t,n,m;
int h,w;
map<int,int> mp;
multiset<int> ans;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> h >> w;
	for (int i=0; i<w; i++) mp[i]=i, ans.insert(0);
	int x,y;
	for (int i=0; i<h; i++){
		cin >> x >> y;
		--x, --y;
		auto it = mp.lower_bound(x);
		int mx =-1;
		while (it != mp.end() && it->first <= y){
			mx = max(mx, it-> second);
			int dis = it->first - it->second;
			ans.erase(ans.find(dis));
			mp.erase(it++); //em.. can't separate mp.erase and it++
		}
		
		if (mx > -1 && y < w-1 && mp.find(y+1) == mp.end() ){
			mp[y+1] = mx;
			ans.insert(y+1-mx);
		}
		
		if (ans.size()) cout << *ans.begin() + i + 1 << endl;
		else cout << -1 << endl;
	}
	return 0;
}


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

using namespace std;

#define int long long

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

#define rep(i,a,b) for (int i = a; i <= (int)b; ++i)
#define f first
#define s second

#define single_test
const int maxn = 1e5 + 1;
int dp[101][maxn];
const int inf = 1e12;
int v[101], w[101];

void solve() {
    for (int i = 0; i < 100; ++i) {
        for (int j = 0; j < maxn; ++j) {
            dp[i][j] = inf;
        }
    }
    int n, W;
    cin >> n >> W;
    for (int i = 0; i < n; ++i) {
        cin >> w[i] >> v[i];
    }
    dp[0][v[0]] = w[0];
    for (int i = 1; i < n; ++i) {
        int val = v[i];
        int wt = w[i];
        for (int j = 0; j < val; ++j) {
            dp[i][j] = dp[i - 1][j];
        }
        dp[i][val] = min(wt, dp[i - 1][val]);
        for (int j = val + 1; j < maxn; ++j) {
            dp[i][j] = min(dp[i - 1][j], wt + dp[i - 1][j - val]);
        }
    }
    int ans = 0;
    for (int i = 0; i < 100; ++i) {
        for (int j = 0; j < maxn; ++j) {
            if (dp[i][j] <= W) {
                ans = max(ans, j);
            }
        }
    }
    cout << ans << '\n';
}

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }

    return 0;
}

Measured memory_bytes: 81776
// single-source shortest path (BFS)
 
#include <cstdio>
#include <cstdlib>
#include <cstring>
 
const int N = 100010;
const int M = 500010;
const int inf = 0x3fffffff;
 
struct Edge {
    int to, len, next;
} es[M];
 
int SIZE = 0; // number of edges
int h[N]; // pointer to edge list
int dist[N], queue[N], inq[N]; // for calculating shortest path
 
inline void add(int u, int v, int w) {
    int i = ++SIZE;
    es[i].to = v;
    es[i].len = w;
    es[i].next = h[u];
    h[u] = i; 
}
 
inline int inc(int x) {
    return (x == N - 1 ? 0 : x + 1);
}
 
void sssp(int r) {
    int front = 0, back = 0;
    queue[back++] = r;
    while (front != back) {
        int x = queue[front];
        inq[x] = 0;
        front = inc(front);
        for (int i = h[x]; i; i = es[i].next) {
            int y = es[i].to;
            int new_d = dist[x] + es[i].len;
            if (new_d < dist[y]) {
                dist[y] = new_d;
                if (!inq[y]) {
                    queue[back] = y;
                    inq[y] = 1;
                    back = inc(back);
                }
            }
        }
    }
}
 
void run() {
    int n, m, r, x, y, w;
    scanf("%d%d%d", &n, &m, &r);
    memset(h, 0, sizeof(h));
    for (int i = 0; i < m; i++) {
        scanf("%d%d%d", &x, &y, &w);
        add(x, y, w);
    }
    for (int i = 0; i < n; i++) {
        dist[i] = (i == r ? 0 : inf);
        inq[i] = 0;
    }
    sssp(r);
    for (int i = 0; i < n; i++)
        if (dist[i] == inf)
            printf("INF\n");
        else
            printf("%d\n", dist[i]);
}
 
int main() {
    run();
}

Measured memory_bytes: 9884
#include <bits/stdc++.h>
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
using namespace std;
const int N=200007,P=1000000007;
int A[N],F[N],G[N];
int main () {
	int n;
	scanf("%d",&n);
	For(i,1,n) scanf("%d",&A[i]);
	n=unique(A+1,A+1+n)-A-1;
	F[0]=1;
	For(i,1,n) {
		G[A[i]]=(G[A[i]]+F[i-1])%P;
		F[i]=G[A[i]];
	}
	printf("%d\n",F[n]);
	return 0;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b,c,d; cin>>a>>b>>c>>d; cout << max(a*b,c*d) << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np
import math

a,b,h,m = map(int,input().split())
time = h+m/60.0
#angle = np.abs(((time-24*m)/60*12))%180
#angle = np.abs(time/12-m/60)*360
angle = np.abs(30*time-m*6)%360
angle = min(angle, 360-angle)
print('{:.20f}'.format(np.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(angle)))))


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

using namespace std;

int main()
{
   long n;
   cin>>n;
   vector<long> v(n);
   for(int i=0;i<n;i++){
       cin>>v[i];
   }
   vector<long> m(n);
   m[0]=v[0];
   for(long i=1;i<n;i++){
       if(v[i]<m[i-1]){
           m[i]=m[i-1];
       }
       else{
           m[i]=v[i];
       }
   }
   long s=0;
   for(long i=0;i<n;i++){
       s+=(m[i]-v[i]);
   }
   cout<<s<<endl;
   
   return 0;
}

Measured memory_bytes: 6372
#include<bits/stdc++.h>
using namespace std;
vector<int>v[200005];
int main()
{
    long int n,k;
    cin>>n>>k;
    int h[n+5];
    for(int i=0;i<n;i++) {
        cin>>h[i];
    }
    vector<int>dp(n,1e9+5);
    dp[0] = 0;
    for(int i=0;i<n;i++)
    for(int j=i+1;j<=i+k;j++){
            if(j<n){
                dp[j] = min(dp[j],dp[i]+abs(h[i]-h[j]));
            }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <map>
#include <string>

using namespace std;

void solve()
{
	string word;
	map<string, int> Map;
	string ansLongWord;
	int maxLen = 0;
	while(cin >> word)
	{
		if(maxLen < word.size())
		{
			maxLen = word.size();
			ansLongWord = word;
		}
		++Map[word];
	}
	map<string, int>::iterator it = Map.begin();
	int maxCount = 0;
	string ansFreqWord;
	while(it != Map.end())
	{
		if(maxCount < it->second)
		{
			maxCount = it->second;
			ansFreqWord = it->first;
		}
		++it;
	}
	cout << ansFreqWord << " " << ansLongWord << endl;
}

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

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

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

  if(N <= 999)
    cout << "ABC" << endl;
  else
    cout << "ABD" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> pii;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag,  //less_equal
             tree_order_statistics_node_update> oset; 
const int MAXN = 2e5 + 5;
const int MOD = 1e9 + 7;
const int MAXK = 2e3 + 2;
#define sz(x) (int)(x).size()
#define f first

vector<int> g[MAXN];
ll prop[MAXN],val[MAXN];

void dfs(int u,int p,ll cnt)
{
	val[u] = cnt;

	for(auto &k : g[u])
	{
		if(k!=p)
		{
			dfs(k , u , cnt + prop[k]);
		}
	}
}

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

int n,q;
cin >> n >> q;
for(int i = 0 ; i < n - 1 ; i++)
{
  int u,v;
  cin >> u >> v;
  g[u].push_back(v);
  g[v].push_back(u);
}

for(int i = 0 ; i < q ; i++)
 {
 	int p,x;
 	cin >> p >> x;
 	prop[p]+=x;
 }
  dfs(1,-1,prop[1]);

  for(int i = 1 ; i <= n ; i++)
  	  cout << val[i] << ' ';


}


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

int main(){
    long sum = 0, ans = 0, n = 0;
    cin >> n;

    for(int i = 1; i <= n; i++){
        if(i % 3 == 0 && i % 5 ==0){}
        else if( i % 3  == 0){}
        else if(i % 5 == 0){}
        else sum += i;
    }

    cout << sum << endl;
}


Measured memory_bytes: 3592
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func gets() string {
	sc.Scan()
	return sc.Text()
}

func atoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	var n int
	fmt.Scan(&n)
	A := make([]int, 20)
	B := make([]int, 20)
	C := make([]int, 20)

	for idx, v := range strings.Split(gets(), " ") {
		A[idx] = atoi(v)
	}

	for idx, v := range strings.Split(gets(), " ") {
		B[idx] = atoi(v)
	}

	for idx, v := range strings.Split(gets(), " ") {
		C[idx] = atoi(v)
	}

	// fmt.Println(A)
	// fmt.Println(B)
	// fmt.Println(C)

	var before int
	sum := 0
	for idx, a := range A[:n] {
		// fmt.Println("idx", idx)
		sum += B[a-1]
		if idx != 0 {
			if before == (a - 1) {
				sum += C[before-1]
			}
		}
		before = a
		// fmt.Println("sum", sum)
	}

	fmt.Println(sum)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
int main()
{
	ll n;

	cin>>n;

	map<ll,ll>mp;

    ll ara[n+1];

    ll sum=0;

	for(ll i=0;i<n;i++ )
    {
		cin>>ara[i];

		sum+=ara[i];

		mp[ara[i]]++;
	}




	ll q;

	cin>>q;

	ll sz=mp.size();

	while(q--)
    {
		ll b,c,nsz=0,i;

		cin>>b>>c;

		sum-=mp[b]*b;

		sum+=(c*mp[b]);

       mp[c]+=mp[b];

        mp[b]=0;
        
		cout <<sum<<endl;


	}





	return 0;
}





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

struct Node{
  int key;
  Node *right,*left,*parent;
};

Node *root,*NIL;

Node * find(Node *p, int a){
  while(p!=NIL && a!=p->key){
    if(a < p->key) p=p->left;
    else p=p->right;
  }
  return p;
}

void insert(int a){
  Node *y=NIL, *x=root, *z;
  z = (Node *)malloc(sizeof(Node));
  z->key=a;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key) x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL) root=z;
  else if(z->key<y->key) y->left=z;
  else y->right=z;
}

void inorder(Node *p){
  if(p==NIL) return;
  inorder(p->left);
  cout << " " << p->key;
  inorder(p->right);
}

void preorder(Node *p){
  if(p==NIL) return;
  cout << " " << p->key;
  preorder(p->left);
  preorder(p->right);
}

int main(){
  int n,x;
  string str;

  cin >> n;

  for(int i=0;i<n;i++){
    cin >> str;
    if(str=="find"){
      cin >> x;
      Node *p=find(root,x);
      if(p!=NIL) cout << "yes" << endl;
      else cout << "no" << endl;
    }
    else if(str=="insert"){
      cin >> x;
      insert(x);
    }
    else if(str=="print"){
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 21948
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
/* map_for : mapでfor文を回す */
/* gcd_lcm : 最大公倍数 & 最小公約数 */
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    string s;
    cin >> s;
    if(s == "ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {
  // subroutines

  static boolean complete(Integer[] nodes, boolean[][] edges) {
    boolean[] reached = new boolean[26];
    Arrays.fill(reached, false);
    reached[nodes[0]] = true;

    ArrayList<Integer> q = new ArrayList<Integer>();
    q.add(nodes[0]);

    while (! q.isEmpty()) {
      int i0 = q.remove(0);

      for (int i1: nodes) {
        if (! reached[i1] && edges[i0][i1]) {
          reached[i1] = true;
          q.add(i1);
        }
      }
    }

    for (int i0: nodes)
      if (! reached[i0]) return false;

    return true;
  }

  // main
  public static final void main(String[] args) throws Exception {
    Scanner sc = new Scanner(System.in);

    for (;;) {
      int n = sc.nextInt();
      if (n == 0) break;

      HashSet<Integer> nhash = new HashSet<Integer>();
      boolean[][] edges = new boolean[26][26];

      for (int i0 = 0; i0 < 26; i0++)
        for (int i1 = 0; i1 < 26; i1++)
          edges[i0][i1] = false;

      int[] nout = new int[26];
      int[] nin  = new int[26];
      Arrays.fill(nout, 0);
      Arrays.fill(nin, 0);

      for (int k = 0; k < n; k++) {
        String w = sc.next();

        int i0 = w.charAt(0) - 'a';
        int i1 = w.charAt(w.length() - 1) - 'a';

        edges[i0][i1] = true;
        nout[i0]++;
        nin[i1]++;

        nhash.add(i0);
        nhash.add(i1);
      }

      boolean euler = true;

      for (int i = 0; i < 26; i++) {
        if (nin[i] != nout[i]) {
          euler = false;
          break;
        }
      }

      if (euler) {
        Integer[] nodes = new Integer[nhash.size()];
        nhash.toArray(nodes);
        euler = complete(nodes, edges);
      }

      System.out.println(euler ? "OK" : "NG");
    }
  }
}

Measured memory_bytes: 47952
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    bool a = false;
    for(int i=1;i<10;i++){
        if(n%i==0){
            if((n/i)/10==0){
                a = true;
            }
        }
    }
    if(a) cout << "Yes";
    else cout << "No";

    return 0;
}

Measured memory_bytes: 3624
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<map>

using namespace std;
typedef pair<int, int> T;
map<T, int>s;
int H, W, N;

int dir[9][2] = { -1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1,0,0 };

void Fill(int x, int y)
{
	for (int i = 0; i < 9; ++i)
	{
		int tx = x + dir[i][0], ty = y + dir[i][1];
		if (tx<2 || ty<2 || tx>H - 1 || ty>W - 1) continue;
		++s[T{ tx,ty }];
	}
}

int result[10];

long long sum;

int main(void)
{
	scanf("%d%d%d", &H, &W, &N);
	int a, b;
	for (int i = 0; i < N; ++i)
	{
		scanf("%d%d", &a, &b);
		Fill(a, b);
	}
	sum = ((long long)H - 2) * ((long long)W - 2);
	for (auto i = s.begin(); i != s.end(); ++i)
	{
		++result[i->second];
		--sum;
	}
	printf("%lld\n", sum);
	for (int i = 1; i <= 9; ++i)
		printf("%d\n", result[i]);
}

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MAX_V
const double PI=3.14159265358979323846;

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain; 

int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    REP(i, n) {
        cin >> x[i];
        y[i] = x[i];
    }

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

    int mae = y[n/2-1];
    int ato = y[n/2];

    REP(i, n) {
        if(x[i] <= mae) cout << ato << endl;
        else cout << mae << endl;
    }



    return 0;
}
 

Measured memory_bytes: 3840
/*######################################################
#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########
#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########
#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#
#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########
#########~~######~~##~~##~~##~~##~~##~~###~~~~##########
######################################################*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#define ll long long
#define str string
#define rtn return
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define db long double
#define MOD 1000000007
#define INF 1e18
#define EPS 1e-15
#define pll pair <ll, ll>
#define vi vector<ll>
#define vpll vector<pll>
#define value_at find_by_order
#define index_of order_of_key
#define fill(a,v) memset(a,v,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(ll i=0;i<n;++i)
#define per(i,n) for(ll i=n-1;i>=0;--i)
#define loop1(i, n) for (int i=1;i<=n;++i)
#define loop(i, begin, end) for (__typeof(end) i = (begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define FAST_IO std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);std::cout.tie(NULL)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " = " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1 << " |";
  __f(comma+1, args...);
}
#else
#define trace(...)
#endif

template<class T> void remin(T &a, T b) {a = min(a, b);}
template<class T> void remax(T &a, T b) {a = max(a, b);}
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define N 100005

int n;
vi adj[N];
ll dp[N][2];

ll add(ll &a, ll b) {
  a += b;
  a %= MOD;
}

void mul(ll &a, ll b) {
  a *= b;
  a %= MOD;
}

//white 0 black 1

ll dfs(int s, int p, int color) {
  if (dp[s][color] != -1) rtn dp[s][color];
  dp[s][color] = 1;
  if (!color) {
    for (auto j : adj[s]) {
      if (j != p) {
        ll px = dfs(j, s, color);
        add(px, dfs(j, s, 1 - color));
        mul(dp[s][color], px);
      }
    }
  } else {
    for (auto j : adj[s]) {
      if (j != p) {
        mul(dp[s][color], dfs(j, s, 1 - color));
      }
    }
  }
  rtn dp[s][color];
}

int main() {
  FAST_IO;
  fill(dp, -1);
  cin >> n;
  rep(i, n - 1) {
    int x, y;
    cin >> x >> y;
    adj[x].pb(y);
    adj[y].pb(x);
  }
  ll ans = 0;
  add(ans, dfs(1, -1, 0));
  add(ans, dfs(1, -1, 1));
  cout << ans << endl;
  rtn 0;
}


Measured memory_bytes: 14208
#include <iostream>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <stack>
#include <limits>
#include <climits>
#include <cassert>
#include <fstream>
#include <cstring>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <ciso646>
#include <set>
#include <array>
#include <unordered_map>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define inf 0x3f3f3f3f
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define VS vector<string>
#define VI vector<ll>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define ll long long
#define ull unsigned long long
#define pii pair<ll,ll>
#define pcc pair<char,char>
#define pic pair<ll,char>
#define pci pair<char,ll>
#define eps 1e-14
#define FST first
#define SEC second
#define SETUP cin.tie(0), ios::sync_with_stdio(false), cout << setprecision(15)

namespace {
	struct input_returnner {
		ll N; input_returnner(ll N_ = 0) :N(N_) {}
		template<typename T> operator vector<T>() const { vector<T> res(N); for (auto &a : res) cin >> a; return std::move(res); }
		template<typename T> operator T() const { T res; cin >> res; return res; }
		template<typename T> T operator - (T right) { return T(input_returnner()) - right; }
		template<typename T> T operator + (T right) { return T(input_returnner()) + right; }
		template<typename T> T operator * (T right) { return T(input_returnner()) * right; }
		template<typename T> T operator / (T right) { return T(input_returnner()) / right; }
		template<typename T> T operator << (T right) { return T(input_returnner()) << right; }
		template<typename T> T operator >> (T right) { return T(input_returnner()) >> right; }
	};
	template<typename T> input_returnner in() { return in<T>(); }
	input_returnner in() { return input_returnner(); }
	input_returnner in(ll N) { return std::move(input_returnner(N)); }
}

const ll MOD = 1e9 + 7;

void solve();

signed main() {
	SETUP;
	solve();
#ifdef _DEBUG
	system("pause");
#endif
	return 0;
}

void solve() {
	string N; cin >> N;
	int suma = 0;
	int sumb = 0;
	REP(i, N.size()) {
		suma += N[i] - '0';
	}
	sumb = 9 * (N.size()-1);
	sumb += N[0] - '0' - 1;
	cout << max(suma, sumb) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
    const int MAX =200002;
const int MOD =1000000007;

     signed main(){
int  n;
cin>>n;
int a[n]={};
string s;
int u=1;for(int i=0;i<9;i++)u*=10;
for(int i=0;i<n;i++){
    cin>>s;
    int t=0;bool k=false;
    for(int j=0;j<s.size();j++){
        if(s[j]=='.'){
            k=true;
            continue;
        }
        a[i]=10*a[i]+(s[j]-'0');
        if(k)t++;
    }
    while(t<9){
        a[i]=10*a[i];
        t++;
    }
}

int y[51][51],ans2=0;

for(int i=0;i<=50;i++)for(int j=0;j<=50;j++)y[i][j]=0;
for(int i=0;i<n;i++){
   
      if(a[i]%u==0)  ans2++;
        int t=a[i];
        int i0=0,j0=0;
        while(t%2==0){
            t/=2;
            i0++;
        }
        while(t%5==0){
            t/=5;
            j0++;
        }
        y[i0][j0]++;
    
}
int ans=0;
for(int i=0;i<=50;i++)for(int j=0;j<=50;j++)for(int p=max(0ll,18-i);p<=50;p++)for(int q=max(0ll,18-j);q<=50;q++){
ans+=y[i][j]*y[p][q];

}
cout<<(ans-ans2)/2<<endl;



     }


 


 






    





      

        


Measured memory_bytes: 5180
program abc161b
      implicit none
      integer::n,m
      integer,allocatable,dimension(:)::A
      integer::i,j,judge,sum
      real::m1

      read *,n,m
      allocate(A(n))
      read *,A(1:n)

      sum=0
      do i=1,n
         sum=sum+A(i)
      end do

      m1=sum*(1.0/(4.0*m))

      judge=0
      do j=1,n
         if (m1<=A(j)) judge=judge+1
      end do

      if (judge>=m) then
         print *,'Yes'
      else
         print *,'No'
      end if
      stop

   end program abc161b

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>

typedef long long ll;

using namespace std;

int main(){
    int k;
    cin >> k;
    vector<ll> v;

    for(int i = 1; i <= 9; i++){
        v.push_back(i);
    }
    for(int i = 0; i < k; i++){
        ll a = v[i] % 10 - 1;
        ll b = v[i] % 10 + 0;
        ll c = v[i] % 10 + 1;
        if(a >= 0) v.push_back(v[i] * 10 + a);
        v.push_back(v[i] * 10 + b);
        if(c <= 9) v.push_back(v[i] * 10 + c);
    }
    
    cout << v[k - 1] << endl;
}

Measured memory_bytes: 7472
nk = input().split()
n = int(nk[0])
k = int(nk[1])
hlist = []
for i in range(n):
    hlist.append(int(input()))

hlist.sort()

submin = 999999999999999999999999999999999
for i in range(0, n - k + 1):
    submin = min(submin, hlist[i+k-1] - hlist[i])

print(submin)


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

int main() {
    int N;
    cin >> N;
    vector<int> H_list;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        H_list.emplace_back(tmp);
    }
    int num_buildings_with_good_sceneary = 0;
    int cur_highest = -1;
    for (int i = 0; i < N; i++) {
        int height = H_list.at(i);
        if (height >= cur_highest) {
            num_buildings_with_good_sceneary += 1;
        }
        cur_highest = max(cur_highest, height);
    }
    cout << num_buildings_with_good_sceneary << "\n";
}

Measured memory_bytes: 256
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *

N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]
data=[[] for i in range(N+1)]
for a,b in AB:
    data[a].append(b)
    data[b].append(a)

count=0
stack=[[1,set([1])]]
while stack:
    point,visited=stack.pop()
    for p in data[point]:
        if not p in visited:
            if len(visited)+1==N:
                count+=1

            else:
                a=set(list(visited))
                a.add(p)
                stack.append([p,a])
print(count)


Measured memory_bytes: 40816
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll amari = 1e9+7;

int main(){
	int n;
	cin >> n;
	map<int,int>a,b;
	int A[n];
	for(int i = 0; i < n; i++)cin >> A[i];
	int m;
	cin >> m;
	int B[m];
	for(int i = 0 ;i < m; i++)cin >> B[i];

	for(int i = 0; i < n; i++)a[A[i]]++;
	for(int i = 0; i < m; i++)b[B[i]]++;

	int ok = 1;
	for(int i = 0; i < m; i++){
		if(b[B[i]] > a[B[i]]){
			cout << "NO" << endl;
			ok = 0;
			break;
		}
	}
	if(ok)cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 20608
#include<stdio.h>
int main() {
    int N, s, d, f, g, w, e;
    scanf("%d", &N);
    s = N % 10;
    d = N / 10;
    f = d % 10;
    g = d / 10;
    w = g % 10;
    e = g / 10;

    if (e==w&&w==f) {
        printf("Yes\n");
    }
    else if(w==f&&f==s){
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }
    return 0;
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long

#define for(i,a,b) for (i=a; i<b; i++)
#define forb(i,a,b) for (i=a; i>b; i--)
#define all(S) S.begin(),S.end()
#define sort(S) sort(all(S))

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

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    ll a,b,n;
    cin >> a >> b >> n;
    cout << (min(b-1,n)*a)/b << endl;
    return 0;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}


int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	int n, k;
	cin >> n >> k;

	vector<int> pref(n + 1);

	map<int, int> mp;
	
	/*
	sumR - sumL = R - L
	sumR - R = sumL - L
	*/

	pref[0] = 0;
	mp[0] = 1;


	ll res = 0;
	for(int i = 1; i <= n; ++i){
		int x;
		cin >> x;
		x--;
		x %= k;

		pref[i] = pref[i - 1];
		pref[i] += x;
		pref[i] %= k;

		if(i >= k) mp[pref[i - k]]--;

		res += mp[pref[i]];
		mp[pref[i]]++;
		// debug() << imie(i) << imie(pref);
	}

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

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

int main(){
    int a, b;
    cin >> a >> b;

    if (a < b){
        cout << "a < b" << endl;
    }
    else if (a > b){
        cout << "a > b" << endl;
    }
    else cout << "a == b" << endl;
}


Measured memory_bytes: 3072
import numpy as np
n,m = map(int,input().split())
a=np.zeros(m,dtype=np.int64)
for i in range(n):
    li=[]
    li = list(map(int,input().split()))
    
    for j in range(li[0]):
        a[li[j+1]-1]=a[li[j+1]-1]+1
        
ans=0
for i in range(m):
    if a[i]==n:
        ans=ans+1
print(ans)

Measured memory_bytes: 21132
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
vector<ll> adj[100005];
bool visited[100005];
map<ll,map<ll,ll> > m1;
ll ans[100005];
void dfs(ll i,ll parent,ll colour){
    vector<ll>::iterator it;
    if(visited[i]==false){
        if(m1[i][parent]%2==0)
            ans[i]=colour;
        else{
            if(colour==0)
                colour=1;
            else
                colour=0;
            ans[i]=colour;
        }
        visited[i]=true;
        for(it=adj[i].begin();it!=adj[i].end();it++)
            dfs(*it,i,colour);
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i,u,v,w;
    cin>>n;
    visited[n]=false;
    for(i=1;i<n;i++){
        cin>>u>>v>>w;
        visited[i]=false;
        m1[u][v]=w;
        m1[v][u]=w;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(1,1,0);
    for(i=1;i<=n;i++)
        cout<<ans[i]<<endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll,ll> Pll;

#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define repp(i, n) for(int i=1;i<=n;i++)
#define all(x) x.begin(), x.end()

#define geti1(X) scanf("%d",&X)
#define geti2(X,Y) scanf("%d%d",&X,&Y)
#define geti3(X,Y,Z) scanf("%d%d%d",&X,&Y,&Z)
#define geti4(X,Y,Z,W) scanf("%d%d%d%d",&X,&Y,&Z,&W)

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define geti(...) GET_MACRO(__VA_ARGS__, geti4, geti3, geti2, geti1) (__VA_ARGS__)

#define INF 7654321
#define IINF 87654321987654321LL
#define MAXV 200500

ll mod = 1e9 + 7;
int N,M,T,K,tc;

int main(){
	int n,a; geti(n,a);
	n %= 500;
	if( n <= a ){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
}


Measured memory_bytes: 764