akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
    int a[5];
    int mini=1000, minii=0;
    for(int i=0; i<5; i++){
        cin>>a[i];
        if(a[i]%10==0){
            continue;
        }
        mini=min(mini,a[i]%10);
        if(mini==a[i]%10){
            minii=i;
        }
    }

    int sum=0;
    for(int i=0; i<5; i++){
        if(i==minii){
            //cout<<mini<<endl;
            sum+=a[minii];
            continue;
        }
        //cout<<(a[i]+9)/10*10<<endl;
        sum+=(a[i]+9)/10*10;
    }
    cout<<sum<<endl;

    return 0;

}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)
#define int long long

using namespace std;
typedef pair<int, int> pii;

string s;
int a[30]={0};

signed main() {
	cin>>s;
    bool f=true;
	rep(i,s.length()){
        if(a[s[i]-97]!=0){
            f=false;
        }
        a[s[i]-97]++;
    }
	
    if(f){
        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++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;


int main(){
	//ios_base::sync_with_stdio(false);
	int N;
	vector<pll> v;
	map<pll, int> mp;

	cin >> N;
	rep(i,N){
		int x, y;
		cin >> x >> y;
		v.emplace_back(x, y);
		mp[pii(x,y)] = i;
	}
	sort(all(v));

	vector<int> cv[2];
	auto check = [&](int i, int k){
		pll a = v[ cv[k][cv[k].size()-2] ];
		pll b = v[ cv[k][cv[k].size()-1] ];
		pll c = v[i];
		if(k == 0) return (b.Y-a.Y) * (c.X-a.X) < (c.Y-a.Y) * (b.X-a.X);
		if(k == 1) return (b.Y-a.Y) * (c.X-a.X) > (c.Y-a.Y) * (b.X-a.X);
	};
	rep(k,2){
		cv[k].push_back(0);
		reps(i,1,N){
			while( cv[k].size() >= 2 && check(i, k) ) cv[k].pop_back();
			cv[k].push_back(i);
		}
	}

	vector<int> convex;
	for(auto t: cv[0]) convex.push_back(t);
	rrep(i, cv[1].size()-1) convex.push_back(cv[1][i]);
	convex.push_back( cv[0][1] );

	//for(auto i: convex) cout << v[i].X << "," << v[i].Y << endl;

	vector<double> ans(N);
	reps(i, 1, convex.size()-1){
		pll a = v[ convex[i-1] ];
		pll b = v[ convex[i] ];
		pll c = v[ convex[i+1] ];
		double vx1 = - (b.Y - a.Y);
		double vy1 = b.X - a.X;
		double vx2 = - (c.Y - b.Y);
		double vy2 = c.X - b.X;
		double cdot = (vx1*vx2 + vy1*vy2);
		double l1 = sqrt(vx1*vx1 + vy1*vy1);
		double l2 = sqrt(vx2*vx2 + vy2*vy2);
		double ang = acos( cdot / l1 / l2 );
		int n = mp[ v[convex[i]] ];
		ans[n] = ang / 2.0 / M_PI;
	}

	for(auto t: ans) printf("%.20f\n", t);

	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		new Main().run();
	}

	void run() {
		String D;
		D = sc.next();
		String aizu = "AIZUNYAN";
		StringBuilder sb = new StringBuilder();
		int len = D.length();
		for (int i = 0; i < len; i++) {
			if (i + aizu.length() <= len
					&& isAna(D.substring(i, i + aizu.length()))) {
				sb.append(aizu);
				i += aizu.length() - 1;
			} else {
				sb.append(D.charAt(i));
			}
		}
		System.out.println(sb.toString());
	}

	boolean isAna(String s) {
		char cs[] = s.toCharArray();
		Arrays.sort(cs);
		char aidu[] = "AIDUNYAN".toCharArray();
		Arrays.sort(aidu);
		if (cs.length != aidu.length)
			return false;
		for (int i = 0; i < cs.length; i++) {
			if (cs[i] != aidu[i])
				return false;
		}
		return true;
	}
}

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

int main() {
  int n;

  cin >> n;

  vector<int> p, q;

  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    p.push_back(tmp);
  }

  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    q.push_back(tmp);
  }

  vector<int> a(n);

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

  int pcnt, qcnt, cnt = 0;

  do {
    cnt++;
    for (int i = 0; i < n; i++) {
      if (a[i] != p[i]) break;
      if (i == n - 1) {
        pcnt = cnt;
        break;
      }
    }
  } while (next_permutation(a.begin(), a.end()));

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

  cnt = 0;

  do {
    cnt++;
    for (int i = 0; i < n; i++) {
      if (a[i] != q[i]) break;
      if (i == n - 1) {
        qcnt = cnt;
        break;
      }
    }
  } while (next_permutation(a.begin(), a.end()));

  cout << abs(pcnt - qcnt);

  return 0;
}

Measured memory_bytes: 256
/*
        |___Arshit Mangukiya___|
        |___DA-IICT____|
        |___201801173____|
*/
        //__WRITE  YOUR  CODE  HERE___//
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;            
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppl;
typedef vector<pll> vpl;
#define ff first
#define ss second
#define pi acos(-1)
#define mr_ad_0501 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define all(a)      a.begin(),a.end()
#define f(i,a,n) for(ll i=a;i<n;i++)
#define MOD 1000000007
#define MAX 200007
#define LM LLONG_MAX
#define sz size()
#define p(x)        cout<< x << " ";
#define pe(x)       cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
const int N=1e5+5;

/*  bool fun(pair<int,int>a , pair<int,int>b)
            {
                if(a.ff == b.ff)    return a.ss < b.ss;
                else            return a.ff < b.ff;
            }*/
           
 /*void bfs(ll x)
 {
    queue<ll> q;
    q.push(x);
    while(!q.empty())
    {
        ll k=q.front();
        q.pop();
        for(auto X:v[k])
        {
            if(!vis[X])
            {
                l[X]=l[k]+1;
                vis[X]=1;
                q.push(X);
            }
        }
    }
 }*/
//ll i,j;
/*void dfs(ll v) {
    visited[v] = true;
    for (auto u : adj[v]) {
        if (!visited[u])
            dfs(u);
    }
}*/

bool prime(ll n)
{
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0) return false;
    return true;
}

ll getSetBitsFromOneToN(ll N)
{
    ll two = 2, ans = 0;
    ll n = N;
 
    while (n) {
        ans += (N / two) * (two >> 1);
 
        if ((N & (two - 1)) > (two >> 1) - 1)
            ans += (N & (two - 1)) - (two >> 1) + 1;
 
        two <<= 1;
        n >>= 1;
    }
    return ans;
}

ll power(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll mod_pow(ll a,ll b,ll m)
{
    ll res = 1;
    while(b)
    {
        if(b&1)
        {
        res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}
 
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll mod_inverse(ll a)
{
	return mod_pow(a , MOD-2 , MOD);
}

void solve()
{
	ll n,x,t;
	cin>>n>>x>>t;
	ll ans=n/x;
	if(n%x)ans++;
	cout<<t*ans;
}

int32_t main(){
    mr_ad_0501;
    ll t=1;
    //cin >> t;
    while(t--)
    {
        solve();
    }	
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<lint>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;
const int INF = 1 << 30;

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

int dp[1000010][2];

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

    reverse(all(S));
    S += '0';
    int n = S.size();

    rep(i, n+1) rep(j, 2) dp[i][j] = INF;
    dp[0][0] = 0;

    rep(i, n) {
        rep(j, 2) {
            int nd = S[i] - '0';
            nd += j;
            rep(a, 10) {
                int ni = i+1, nj = 0;
                int b = a - nd;

                if (b < 0) {
                    nj = 1;
                    b += 10;
                }

                chmin(dp[ni][nj], dp[i][j] + a + b);
            }
        }
    }

    cout << dp[n][0] << endl;
    return 0;
}


Measured memory_bytes: 9220
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define INF 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());
#define usort(a) sort(a.rbegin(),a.rend());

using namespace::std;

int jo(ll int a, ll int b){//累乗
    ll int num=1;
    rep(i,0,b) num=num*a;
    return num;
}
char tobig(char s){//char大文字化
  return (s-0x20);
}
char tolow(char s){//char小文字化
  return (s+0x20);
}
int ctoi(char a){//char->int
  if('0'<=a&&a<='9') return (a-'0');
  return -1;
}

int gcd(ll int a,ll int b) {//最大公約数
  if(a<b) return gcd(b,a);
  int c;
  while ((c=a%b)) {
    a=b;
    b=c;
  }
  return b;
}
int lcm(ll int a,ll int b){//最小公倍数
 return (a*b)/gcd(a,b);
}


int main(){
  string S;
  cin>>S;
  int cnt=0;
  rep(i,0,S.length()/2){
    if(S[i]!=S[S.length()-1-i]) cnt++;
  }
  cout<<cnt;
    
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート
//  sort(変数名.rbegin(),変数名.rend());//降順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示

//  vector<pair<int,int>> data(N);  //2つのデータを格納、.first/.secondで参照
// pairのソートはfirst優先の昇順

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
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() {
    ll N;
    cin >> N;

    ll x[N], y[N];
    REP(i, N) {
        cin >> x[i] >> y[i];
    }

    vector<ll> one_case;
    REP(i, N) {
        one_case.emplace_back(i);
    }

    long double sum = 0;
    ll cnt = 0;
    do {
        ++cnt;
        REP(i, N - 1) {
            sum += sqrt(pow(x[one_case[i + 1]] - x[one_case[i]], 2) + pow(y[one_case[i + 1]] - y[one_case[i]], 2));
        }
    } while(next_permutation(one_case.begin(), one_case.end()));

    cout << fixed << setprecision(15) << sum / cnt << endl;

    return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
const ll INF = 1e18;
const int maxn=2e5+10;
 
int main() 
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll int n,m,a[maxn],i;
	cin >> n;
	for(i=1;i<=n;i++)
	 cin>>a[i];
	ll int mini=a[1],c=1;
	for(i=2;i<=n;i++) 
	{
		if (a[i]<=mini) 
		    c++;
		mini=min(mini,a[i]);
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;

int main() {

    ll N;

    cin >> N;

    vector<ll> L(N);

    rep(i, N) {
        cin >> L[i];
    }

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

    ll ans = 0;

    rep(i, N - 2) {
        repl (j, i + 1,  N - 1)
        {
            ll k = L[i] + L[j];
            auto iter = lower_bound(L.begin(), L.end(), k) - L.begin();
            if (iter > j) ans += (iter - j - 1);
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 3652
import sys
from itertools import product
from bisect import bisect_right as bi_r

cand = [int(''.join(p)) for i in range(3, 10) for p in product('357', repeat=i) if len(set(p)) == 3]

n = int(sys.stdin.readline().rstrip())

def main():
    print(bi_r(cand, n))

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 4212
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();

    String[] list = new String[26];
    char tmp = 'a';
    for (int i = 0; i < 26; i++) {
      list[i] = String.valueOf(tmp++);
    }

    String ans = "";
    while (n > 0) {
      n--;
      int mod = (int) (n % 26);
      ans += list[mod];
      n /= 26;
    }

    StringBuffer str = new StringBuffer(ans);
    String s = str.reverse().toString();
    System.out.println(s);
  }
}

Measured memory_bytes: 39404
#include <bits/stdc++.h>
#define int long long
#define N 100010
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);
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);}
vector<int> G[N];
int num[N];

int can(int pos,int par){
  int sum = 0,mx = 0;
  for(int to:G[pos]) if(to!=par) sum += num[to],Max(mx,num[to]);
  int mxpair = sum-mx < mx? (sum-mx): sum/2;
  if(sum < num[pos]) return 0;

  int target = sum - num[pos];
  if(mxpair < target) return 0;
  num[pos] = num[pos] - target;
  return 1;
}

int check(int pos,int par){
  if(par != -1 && G[pos].size() == 1) return 1;

  int res = 1;  
  for(int to:G[pos]) if(to != par)res &= check(to,pos);
  res &= can(pos,par);
  return res;
}

signed main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++) cin>>num[i];
  
  for(int i=0,a,b;i<n-1;i++){
    cin>>a>>b;  a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int root = 0;
  for(int i=0;i<n;i++) if(G[i].size() == 1) root = i;
  int ans = check(root,-1);
  cout<<(ans? "YES":"NO")<<endl;
  return 0;
}


Measured memory_bytes: 11136
import java.util.*;
import java.io.*;

public class Main{
    static int maxVal=Integer.MAX_VALUE;
    public static void main (String args[]){
        //初期処理
        Scanner sc=new Scanner(System.in);
        int n=Integer.parseInt(sc.nextLine());
        //M[i][j]:i番目からj番目まで(両端含む)の最小積算回数を格納
        int[][] M = new int[n+1][n+1];

        //p[i]:i番目の行列の行数を格納
        int p[] = new int [n+1];
        int q[] = new int [n+1]; //列数

        for (int i=1;i<=n;i++){
            String[] sArr=sc.nextLine().split(" ");
            int a = Integer.parseInt(sArr[0]);
            int b = Integer.parseInt(sArr[1]);

            p[i-1]=a;
            p[i]=b;
            q[i]=b;
        }
        
        for(int i=1;i<=n;i++){M[i][i]=0;}
        
        // k:行列の数 j:始点 l:区切り点
            for(int k=2;k<=n;k++){
                for(int j=1;j<=n-k+1;j++){
                        //M[j][k]=Math.min(M[j+1][k]+p[j]*p[k]*q[k],M[j][k-1]+p[j]*p[k]*q[k]);
                        M[j][j+k-1]=maxVal;
                        for(int l=j;l<j+k-1;l++){
                            M[j][j+k-1]=Math.min(M[j][l]+M[l+1][j+k-1]+p[j-1]*p[l]*p[j+k-1],M[j][j+k-1]);
                        }
                }
            }
            
        System.out.println(M[1][n]);


       

        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //    try{
        //         //int n= Integer.parseInt(br.readLine());
        //         //int[] array = Arrays.stream(sElementArray).mapToInt(Integer::parseInt).toArray();

                
                
        //     }catch(IOException e){e.printStackTrace();}
    }
}
    


Measured memory_bytes: 26548
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

int main(void){
  int a, b, sum = 0;
  char c;
  double r;
  vector<pair<int, int> > v;

  while(cin >> a >> c >> b){
    v.push_back(make_pair(a, b));
  }

  vector<pair<int, int> >::iterator it;
  for(it = v.begin(); it != v.end(); it++){
    sum += (*it).first * (*it).second;
    r += (*it).second;
  }

  cout << sum << endl;
  cout << (r + 1.0) / v.size() << endl;

  return 0;
}

Measured memory_bytes: 1264
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

ll modPow(ll base, ll ex, ll m) {
	ll ret = 1;
	while(ex){
		if(ex & 1){
			ret = ret * base % m;
		}
		ex >>= 1;
		base = base * base % m;
	}
	return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = s.size();
    vector<ll> als(n), crs(n), qls(n), qrs(n);
    for(int i = 0; i < n; i++){
        als[i] = (s[i] == 'A') + (i ? als[i - 1] : 0);
        qls[i] = (s[i] == '?') + (i ? qls[i - 1] : 0);
    }
    for(int i = n - 1; i >= 0; i--){
        crs[i] = (s[i] == 'C') + (i + 1 < n ? crs[i + 1] : 0);
        qrs[i] = (s[i] == '?') + (i + 1 < n ? qrs[i + 1] : 0);
    }
    printde(als, crs, qls, qrs);
    ll ans = 0;
    for(int i = 1; i < n - 1; i++){
        if(s[i] == 'B' || s[i] == '?'){
            ll l = als[i] * modPow(3, qls[i - 1], M) % M + qls[i - 1] * (qls[i - 1] ? modPow(3, qls[i - 1] - 1, M) : 0) % M ,
               r = crs[i] * modPow(3, qrs[i + 1], M) % M + qrs[i + 1] * (qrs[i + 1] ? modPow(3, qrs[i + 1] - 1, M) : 0) % M ;
            ans += l % M * r % M;
            // ans += (als[i] + (i ? qls[i - 1] : 0)) * (crs[i] + (i + 1 < n ? qrs[i + 1] : 0));
        }
        ans %= M;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {
    static int[] c;
    static int[][] dp;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scan.nextInt();
        }
        long ret = 0;
        int tmp = 0;
        int rgt =0;
        for (int lft = 0; lft < n; lft++) {
            while (rgt < n && tmp + a[rgt] == (tmp ^ a[rgt])) {
                tmp += a[rgt];
                rgt++;
            }
            ret += rgt - lft;
            if(lft == rgt) {
                rgt++;
            }
            tmp -= a[lft];
        }
        System.out.println(ret);
    }
}

Measured memory_bytes: 84964
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

const int N = 100100;
int n, x[N], l, q, a, b, jmp[N][33];


void pre() {
	for(int i = 1; i <= n; i++) {
		int nxt = upper_bound(x + 1, x + n + 1, x[i] + l) - x - 1;
		jmp[i][0] = nxt;
	}
	for(int j = 1; j <= 30; j++)
		for(int i = 1; i <= n; i++) {
			jmp[i][j] = jmp[jmp[i][j - 1]][j - 1];
		}

}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i <= n; i++ ) cin >> x[i];
	cin >> l >> q;
	pre();

	for(int i = 1; i <= q; i++) {
		cin >> a >> b;
		if(a > b) swap(a, b);

		int ans = 0;
		for(int i = 30; i >= 0; i--)
			if(jmp[a][i] < b)
				a = jmp[a][i], ans += (1 << i);
		cout << ans + 1 << '\n';
	}
}	

	

Measured memory_bytes: 14080
#![allow(non_snake_case)]
#![allow(dead_code)]

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T) {
    let v: Vec<T> = read_vec();
    (v[0], v[1])
}


struct Vertex {
    name: usize,
    distance: i32,
    visited: bool,
    adjacency_list: Vec<Edge>
}

impl Vertex {
    fn new(name: usize) -> Vertex {
        Vertex {
            name,
            distance: i32::max_value(),
            visited: false,
            adjacency_list: Vec::<Edge>::new()
        }
    }

    fn reset(&mut self) {
        self.distance = i32::max_value();
        self.visited = false;
    }
}


#[derive(Clone)]
struct Edge {
    from: usize,
    to: usize,
    weight: i32,
    cost: i32
}


fn dijkstra(graph: &mut Vec<Vertex>, source: usize) -> Vec<i32> {
    graph[source].distance = 0;
    let mut heap = std::collections::BinaryHeap::new();
    heap.push((0, source));

    while !heap.is_empty() {
        let (dist_v, v) = heap.pop().unwrap();
        let dist_v = -dist_v;
        graph[v].visited = true;
        for e in graph[v].adjacency_list.clone() {
            if !graph[e.to].visited {
                let new_distance = dist_v + e.weight;
                if graph[e.to].distance > new_distance {
                    graph[e.to].distance = new_distance;
                    heap.push((-new_distance, e.to));
                }
            }
        }
    }

    (0..graph.len()).map(|i| graph[i].distance).collect::<Vec<i32>>()
}

fn main() {
    loop {
        let (N, M) = read_tuple::<usize>();
        if N == 0 && M == 0 {
            break;
        }
        let mut graph = Vec::new();
        for i in 0..N {
            graph.push(Vertex::new(i));
        }
        for i in 0..M {
            let vec: Vec<i32> = read_vec();
            let u = (vec[0] - 1) as usize;
            let v = (vec[1] - 1) as usize;
            let d = vec[2];
            let c = vec[3];
            graph[u].adjacency_list.push(Edge {
                from: u,
                to: v,
                weight: d,
                cost: c
            });
            graph[v].adjacency_list.push(Edge {
                from: v,
                to: u,
                weight: d,
                cost: c
            });
        }
        let dist = dijkstra(&mut graph, 0);
        let mut ans = 0;
        for v in 1..N {
            let mut cost = 1000;
            for e in graph[v].adjacency_list.clone() {
                if dist[v] == dist[e.to] + e.weight {
                    cost = std::cmp::min(cost, e.cost);
                }
            }
            ans += cost;
        }
        println!("{}", ans);
    }

}



Measured memory_bytes: 7072
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int cnt[1000005];
signed main() {
    char a;
    cin >> a;
    if(a >= 'a' && a <= 'z') {
        cout << 'a' << endl;
    }
    else {
        cout << "A" << endl;
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>

#define INF 1000000000000000000

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,w;
    cin>>n>>w;
    ll val[n],wt[n];
    for(ll i=0;i<n;i++){
        cin>>wt[i]>>val[i];
    }
    vector<ll> dp(100005,INF),tmp;
    dp[0]=0;
    for(ll i=1;i<=n;i++){
        tmp = dp;
        for(ll j=1;j<100005;j++){
            if(val[i-1]<=j){
                dp[j] = min(tmp[j],tmp[j-val[i-1]]+wt[i-1]);
            }
        }
    }
    for(ll i=100004;i>=0;i--){
        if(dp[i]<=w){
            cout<<i<<endl;
            return 0;
        }
    }
}


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

typedef long long ll;
// typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;

string S;

int main() {
  cin >> S;

  if(S.at(0) != 'A') {
    cout << "WA" << endl;
    return 0;
  }

  int cnt = 0;
  for(int i = 1; i < S.size(); i++) { // 2文字目から末尾までを探索
    if(S.at(i) == 'C') {
      if(2 <= i && i < S.size()-1) cnt++;
      continue;
    }

    if(isupper(S.at(i))) {  // 上記以外に大文字があったら、アウト
      cout << "WA" << endl;
      return 0;
    }
  }
  if(cnt != 1) {
    cout << "WA" << endl;
    return 0;
  }

  cout << "AC" << endl;
}


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

using namespace std;

//void Swap(int *A, int big, int small);
//void Disp(int *A, int n);

int main(void){
	int A, B;
	cin >> A >> B;
	
	//cout << A << endl;
	//cout << B << endl;

	if(A <= B*2){
		printf("%d\n", 0);
	}else{
		printf("%d\n", A-B*2);
	}

	return 0;
}
/*
void Swap(int *A, int big, int small){
	int tmp = A[big];
	A[big] = A[small];
	A[small] = tmp;
}

void Disp(int *A, int n){
	//表示
	for(int i = 0; i < n; i++){
		printf("%d ",A[i]);
	}
	printf("\n");
}
*/

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

int main() {
    int n;
    cin >> n;
    vector<int> f(n), s(n);
    for (int i=0; i<n; ++i) {
        cin >> f[i] >> s[i];
    }
    sort(f.begin(), f.end());
    sort(s.begin(), s.end(), greater<>());
    if (n%2) {
        cout << s[(n-1)/2] - f[(n-1)/2] + 1;
    } else {
        cout << s[n/2] - f[n/2] + s[(n-1)/2] - f[(n-1)/2] + 1;
    }
    return 0;
}

Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
const ll mod = 1e9 + 7;
ll powmod(ll a, ll b) { ll res=1; a%=mod; assert(b>=0); for(;b;b>>=1) { if(b&1) res=res*a%mod; a=a*a%mod; } return res; }
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; }
// ll nCr(ll n, ll r) {
//     return ( ( ( (fac[n] * powmod(fac[n-r], mod-2)) % mod ) * powmod(fac[r], mod-2) ) % mod );
// }
// const ll sz = 1e6 + 5;
// vector<ll> fac(sz, 1);

// * ALways PASS arrays, strings etc to functions BY REFERENCE

vector<vector<int>> adj;

int main() {
    // for (int i = 1; i < sz; i++)
    //     fac[i] = (fac[i-1] * i) % mod;
    
    int t = 1;
    // cin >> t;
    
    while(t--) {
        int n, x, t;
        cin >> n >> x >> t;
        ll res = (ceil(n / (1.0*x)) * t);
        cout << res << endl;
    }
    
	return 0;
}


Measured memory_bytes: 3588
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    char X;
    cin >> X;
    if(X =='a'){
        cout << "vowel" << endl;
    }else if(X =='i'){
        cout << "vowel" << endl;
    }else if(X =='u'){
        cout << "vowel" << endl;
    }else if(X =='e'){
        cout << "vowel" << endl;
    }else if(X =='o'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
} 


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

using namespace std;

int main()
{
  size_t n;
  cin >> n;
  
  vector<pair<pair<string, size_t>, size_t>> Rests;
  for(size_t i = 0; i < n; ++ i)
  {
    string s;
    size_t p;
    cin >> s >> p;
    
    Rests.emplace_back(pair<string, size_t>(s, p), i + 1);
  }
  
  std::sort(Rests.begin(), Rests.end(),
            [](const pair<pair<string, size_t>, size_t>& left, const pair<pair<string, size_t>, size_t>& right)
            {
              if(left.first.first == right.first.first)
                return left.first.second > right.first.second;
              else
              	return left.first.first < right.first.first;
            }
           );
  
  for(size_t i = 0; i < n; ++ i)
    cout << Rests[i].second << endl;
  
  return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,M;
char S[202020];
vector<ll> ans;
ll i, j, minc;
int main(){
    scanf("%lld%lld%s", &N,&M,S);
    i = 0;
    while(i<N){
        minc++;
        j = M;
        if(S[i+M]=='1'){
            for (j = M - 1; j > 0;j--){
                if(S[i+j]!='1')
                    break;
            }
            if(j==0){
                printf("-1");
                return 0;
            }   
        }
        i += j;
    }
    i = N;
    while(i>0){
        j = i < M ? i : M;
        if(S[i-j]=='1'){
            for (j = M - 1; j > 0;j--){
                if(S[i-j]!='1')
                    break;
            }
        }
        ans.push_back(j);
        i -= j;
    }
    for (i = ans.size() - 1; i >= 0;i--)
    {
        printf("%lld ", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
using bll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(v) (v).begin(), (v).end()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
template<typename T> inline void pv(vector<T> v) { for(ll i=0, N=v.size()-1; i<=N; i++) if(i!=N) cout << v[i] << ' '; else cout << v[i] << endl; }
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

signed main() {
	ll N;
	cin>>N;
	vector<ll> a(N,0);
	rep(i,N)cin>>a[i];

	vector<ll> v(N+1,0);
	rep(i,N){
		v[a[i]]=v[a[i]-1]+1;
	}

	ll maxval=0;
	rep(i,N+1){
		chmax(maxval,v[i]);
	}
	cout<<N-maxval<<endl;
	return 0;
}



Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
typedef long long ll;
using namespace std;

void solve(){
  ll n, k; cin >> n >> k;
  vector<ll> a(n + 1), v, v2;
  for(int i = 1; i <= n; i++){
    cin >> a[i];
  }
  vector<bool> visited(n + 1, false);
  visited[1] = true;
  v.push_back(1);
  ll nx = a[1];
  while(visited[nx] == false){
    visited[nx] = true;
    v.push_back(nx);
    nx = a[nx];
  }
  //cout << nx << endl;
  if(k <= v.size() - 1){
    ll ans = v[k];
    cout << ans << endl;
    return;
  }
  bool ok = false;
  for(int i = 0; i < v.size(); i++){
    if(v[i] == nx) ok = true;
    if(ok == true){
      v2.push_back(v[i]);
      //cout << v[i] << endl;
    }
    else k--;
  }
  /*for(int i = 0; i < v.size(); i++){
    cout << v[i] << " ";
  }
  cout << endl;*/
  ll ans = v2[k % v2.size()];
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 9120
N = int(input())
A = list(map(int,input().split()))

def sumXOR(arr, n, MOD):
    s = 0
    for i in range(0, 62):
        zc = 0
        oc = 0
        idsum = 0
        for j in range(0, n):
            if (arr[j] % 2 == 0):
                zc = zc + 1
            else:
                oc = oc + 1
            arr[j] //= 2
        idsum = oc * zc * (1 << i)
        idsum %= MOD
        s = s + idsum
        s %= MOD
    return s

print (sumXOR(A, N, 10**9 + 7))


Measured memory_bytes: 122936
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  string S;
  ll K;
  cin >> S >> K;
  int N = S.size();
  ll cnt = 0;
  char tmp = S[0];
  vector<int> memo;
  int same = 1;
  REP(i, 1, N) {
    if(S[i] == tmp) same++;
    else {
      cnt += same / 2;
      memo.push_back(same);
      tmp = S[i];
      same = 1;
    }
  }
  cnt += same / 2;
  memo.push_back(same);
  if(same == N) {
    cout << N * K / 2 << endl;
  } else {
    if(S[0] == S[N-1] && memo[0] % 2 == 1 && memo.back() % 2 == 1)
      cout << cnt * K + K-1 << endl;
    else
      cout << cnt * K << endl;
  }
  return 0;
}



Measured memory_bytes: 256
n,m=map(int,input().split())
p=10**9+7
a=[int(input()) for i in range(m)]
a.append(n+1)
b=[a[0]-1]
for i in range(m):
  b.append(a[i+1]-a[i]-2)
x=[1]*(max(b)+1)
for i in range(2,max(b)+1):
  x[i]=(x[i-1]+x[i-2])%p

ans=1
if min(b)==-1:
  ans=0
else:
  for i in range(m+1):
    ans=(ans*x[b[i]])%p
print(ans)

Measured memory_bytes: 7876
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,n) for(int i=1; i<=(n); i++)

int main() {
	long long n,ansmax=0;
	cin>>n;
	vector<long long>b(n),cnt(n);
	rep(k,n)cin>>b[k];
	rep(i,n){//for all balls
	    ansmax+=cnt[b[i]];
	    cnt[b[i]]++;
	}
	rep(j,n){
	    cout<<ansmax-cnt[b[j]]+1<<endl;
	}
	return 0;
}



Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>v(n + 3);
    for(int i = 1; i <= n; i++){
        cin >> v[i];
    }
    int dp[n + 3];
    dp[1] = 0, dp[2] = abs(v[2] - v[1]);
    for(int i = 3; i <= n; i++){
        dp[i] = min(dp[i - 1] + abs(v[i] - v[i - 1]), dp[i - 2] + abs(v[i] - v[i - 2]));
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int N=10000000;
int lp[N+7],pr[670000],p=0;

void sieve(){
    for(int i=2;i<=N;i++){
        if(lp[i]==0){
            lp[i]=i;
            pr[p++]=i;
        }
        for(int j=0;(j<p && pr[j]<=lp[i]);j++){
            int x=i*pr[j];
            if(x>N) break;
            lp[x]=pr[j];
        }
    }
}

ll f(int n)
{
    ll m=1;
    if(n==1) return 1;
    int x=0,y=0;
    while(n>1){
        if(y==lp[n]) x++;
        else{
            if(x) m*=(ll)(x+1);
            x=1,y=lp[n];
        }
        n/=lp[n];
    }
    return m*(ll)(x+1);
}

int main()
{
    int n;
    scanf("%d",&n);
    ll s=0;
    sieve();
    for(int i=1;i<=n;i++) s+=(ll)i*f(i);
    printf("%lld\n",s);
    return 0;
}

Measured memory_bytes: 45480
import java.util.*;


class Main {
    static ArrayList<Integer>[]g;
    static ArrayList<Integer>[]num;
    static int[][]p;
    static int dfs(int v,int pp){
        int t=1;
        for(int i=0;i<g[v].size();++i){
            int w=g[v].get(i);
            if(w==pp)continue;
            int s=dfs(w,v);
            p[v][i]=s;
            t+=s;
        }
        return t;
    }
    static void dfs2(int v,int pp,int c){
        for(int i=0;i<g[v].size();++i){
            int w=g[v].get(i);
            if(w==pp){
                p[v][i]=g.length-c;
                continue;
            }
            dfs2(w,v,p[v][i]);
        }
    }
    static long dfs3(int v,int pp,long[]s,int forb){
        long t=0;
        for(int i=0;i<g[v].size();++i){
            int w=g[v].get(i);
            if(w==pp)continue;
            t+=dfs3(w,v,s,forb);
            //System.err.println("v="+v+" i="+i+" p="+p[v][i]+" s="+s[num[v].get(i)]);
            if(forb!=num[v].get(i))
                t+=p[v][i]*s[num[v].get(i)];
        }
        //System.err.println("dfs3 " + v + " " + pp + " " + forb + " ->" + t);
        return t;
    }
    @SuppressWarnings("unchecked")
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n=Integer.parseInt(scan.next());
        g=new ArrayList[n];
        num=new ArrayList[n];
        Arrays.setAll(g,x->new ArrayList<Integer>());
        Arrays.setAll(num,x->new ArrayList<Integer>());
        int[]c=new int[n-1],d=new int[n-1];
        int[]ci=new int[n-1],di=new int[n-1];        
        for(int i=0;i<n-1;++i){
            int a=Integer.parseInt(scan.next())-1;
            int b=Integer.parseInt(scan.next())-1;
            ci[i]=g[a].size();
            di[i]=g[b].size();
            num[a].add(i);
            num[b].add(i);
            g[a].add(b);
            g[b].add(a);
            c[i]=a;
            d[i]=b;
        }
        long[]s=new long[n];
        for(int i=0;i<n;++i)s[i]=Long.parseLong(scan.next());
        p=new int[n][];
        for(int i=0;i<n;++i)
            p[i]=new int[g[i].size()];
        dfs(0,-1);
        dfs2(0,-1,-1);
        int cent=-1;
        long[]ans=new long[n-1];
        for(int i=0;i<n-1;++i){
            int u=p[c[i]][ci[i]];
            int v=p[d[i]][di[i]];
            if(u!=v)
                ans[i]=(s[c[i]]-s[d[i]])/(u-v);
            else
                cent=i;
        }
        long[]w=new long[n];
        if(cent>=0)
            ans[cent]=(s[c[cent]]-dfs3(c[cent],-1,ans,cent))/(n/2);
        for(long a:ans)System.out.println(a);
    }
}


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

int main(){
    //入力
    int N,M;
    cin >> N;

    vector<int> T(N);
    for(int i=0;i<N;i++){
        cin >> T.at(i);
    }

    cin >> M;
    vector<int> P(M),X(M);
    for(int i=0;i<M;i++){
        cin >> P.at(i) >> X.at(i);
    }

    //全部の問題をドリンクなしで解くのにかかる時間
    int time_all=0;
    for(int i=0;i<N;i++){
        time_all+=T.at(i);
    }
    
    //出力
    for(int i=0;i<M;i++){
        cout << time_all - (T.at(P.at(i)-1)-X.at(i)) << endl;
    }
}

Measured memory_bytes: 256
import math
input_list = input().split()
a = int(input_list[0])
b = int(input_list[1])
v = int(input_list[2])
h_1 = 2 * v / (a * b) # triangle s
h_2 = 2 * v / a ** 2 - b
if h_1 > a:
    deg = math.degrees(math.atan((b - h_2) / a))
else:
    deg = math.degrees(math.atan(b / h_1))
print(deg)

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

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


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
    public static int i, j, k;
    public static final int WHITE = 0;
    public static final int GRAY = 1;
    public static final int BLACK = 2;
    public static final int INF = 2147483647;
    public Main(){

    }
    public static void main(String[] args)throws IOException{
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[][] input = new int[n][n];
        int ans;
        //BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        for(i=0 ; i<n ; i++){
          //StringTokenizer S = new StringTokenizer(bf.readLine());
            for(j=0 ; j<n ; j++){
                int a = scan.nextInt();
                input[i][j] = (a == -1) ? INF : a;
                //input[i][j] = Integer.parseInt(S.nextToken());
            }
        }
        ans = prim(n, input);
        System.out.println(ans);
    }

    private static int prim(int n, int[][] G){
        int u;
        int minv;
        int[] color = new int[n];
        int[] a = new int[n];
        int[] b = new int[n];
        int sum = 0;
        for (i=0 ; i<n ; i++){
            a[i] = INF;
            b[i] = -1;
            color[i] = WHITE;
        }
        a[0] = 0;
        while(true){
            u = -1;
            minv = INF;
            for(i=0 ; i<n ; i++){
                if (a[i] < minv && color[i] != BLACK){
                    u = i;
                    minv = a[i];
                }
            }
            if(u == -1){break;}
            color[u] = BLACK;

            for(k=0 ; k<n ; k++){
                if(color[k] != BLACK && G[u][k] != INF){
                    if(a[k] > G[u][k]){
                        a[k] = G[u][k];
                        b[k] = u;
                        color[k] = GRAY;
                    }
                }
            }
        }
        for(i=0 ; i<n ; i++){
            if(b[i] != -1){sum += G[i][b[i]];}
        }

        return sum;
    }
}



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

int main(){
	bool first=false;
	while(1){
		int a, b;
		bool flag=true;
		
		scanf(" %d %d", &a, &b);
		if(a==0 && b==0) break;
		
		if(first) printf("\n");
		
		for(int i=a; i<=b; ++i){
			if( (i%4==0 && i%100!=0) || (i%4==0 && i%100==0 && i%400==0) ){
				printf("%d\n", i);
				flag = false;
			}
		}

		if(flag) printf("NA\n");

		first=true;
	}
	return 0;
}

Measured memory_bytes: 1200
<?php 
    fscanf(STDIN, '%d', $n);

    $ans = 0;

    for($i = 1; $i <= $n; $i++) {
        if($i % 3 != 0 && $i % 5 != 0){
            $ans = $ans + $i;
        }
    }
    echo $ans;

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

int main(void){
  int A,B;
  char S[11],T[11],U[11];
  
  scanf("%s %s",S,T);
  scanf("%d %d",&A,&B);
  scanf("%s",U);
  
  if(strcmp(S,U)==0){
    printf("%d %d\n",A-1,B);
  }
  if(strcmp(T,U)==0){
    printf("%d %d\n",A,B-1);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

vec<vec<pair<int,int>>> G;
vec<bool> visited;
vec<int> x;
bool ans = true;

void dfs(int now,int nowx, int par){
    if(!ans || visited[now]) return;
    visited[now] = true;
    x[now] = nowx;

    for(auto E:G[now]){
        int e = E.first;
        int d = E.second;
        if(e==par) continue;
        int ex = nowx+d;
        if(!visited[e]) {
            dfs(e,ex,now);
        } else {
            if(ex==x[e]) continue;
            else {
                ans=false;
            }
        }
    }
}

int main() {
    int N,M;
    cin >> N >> M;
    G.resize(N,vec<pair<int,int>>());
    
    rep(i,M){
        int L,R,D;
        cin >> L >> R >> D;
        --L,--R;
        G[R].push_back({L,-D});
        G[L].push_back({R,D});
    }
    visited.resize(N,false);
    x.resize(N,0);
    rep(i,N){
        if(!visited[i]) dfs(i,0,-1);
    }
    cout << (ans?"Yes":"No") << endl;
}

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

int main(){

  int N, ans=0;
  cin >> N;
  int V[N],C[N];
  for(int i=0; i<N; i++) cin >> V[i];
  for(int i=0; i<N; i++) cin >> C[i];
  for(int i=0; i<N; i++){
    if((V[i] - C[i]) > 0) ans += V[i] - C[i];
  }

  cout << ans << endl;

  return 0;
}


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

typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const int BIG = 1e9 + 555;
const int maxN = 2e5 + 55;

int n;
int f[maxN];
string s;

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

	cin >> n;

	cin >> s;

	for(int i = 0; i < n + n; i++){
		if(s[i] == 'B'){
			f[i] = 1;
		}	else {
			f[i] = 0;
		}
	}

	ll bal = 0;
	
	if(f[0] != 1){
		cout << "0\n";
		return 0;
	}
	
	ll ans = 1;
	for(int i = 0; i < n + n; i++){
		if((bal % 2) != f[i]){
			bal++;
		} else {
			ans = (ans * bal) % MOD;
			bal--;
		}

		if(bal < 0 || bal > n){
			cout << "0\n";
			return 0;
		}
	}

	if(bal != 0){
		cout << "0\n";
		return 0;
	}

	for(int i = 1; i <= n; i++){
		ans = (ans * i) % MOD;
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 1360
n = gets.to_i
l = gets.chomp.split(" ").map(&:to_i).sort {|a, b| b <=> a }

results = 0
0.upto(n - 1) do |a|
	b = a + 1
	c = n - 1
	while b < c
		if l[c] > l[a] - l[b] then
			results = results + c - b
			b = b + 1
		else
			c = c - 1
		end
	end
end
p results

Measured memory_bytes: 1916
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#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 CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
int main(){
    int n;
    while(cin>>n){
    vi v(10000,INF);
    rep(i,n)cin>>v[i];
    sort(v.begin(),v.begin()+n);
    ll ans=v[0];
    rep(i,n-1){v[i+1]+=v[i];ans+=v[i+1];}cout<<ans<<endl;
    }
}

Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define scl(n) scanf("%lld", &n)
#define pcl(n) printf("%lld\n", n)
#define pcl1(n) printf("%lld ", n)
#define dev(x) cout << #x << " " << x << " ";
#define PTT pair<ll, ll>

map<ll, ll> mp, mp1;
map<ll, ll>::iterator itr;

int main()
{
    ll x, y;
    scl(x);
    scl(y);
    ll a = x, b = 0;
    bool z = false;
    while (b <= x)
    {
        ll c = a * 2;
        ll t = b * 4;
        if (c + t == y)
        {
            z = true;
            cout << "Yes" << endl;
            break;
        }
        b++;
        a--;
    }
    if (!z)
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3628