akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;
typedef long long ll;

int main(){

  int m,f,r;

  while(cin>>m>>f>>r && !(m==-1 && f==-1 && r==-1)){
    if(m==-1||f==-1){
      cout<<"F"<<endl;
    }
    else if(m+f>=80){
      cout<<"A"<<endl;
    }else if(m+f>=65){
      cout<<"B"<<endl;
    }else if(m+f>=50){
      cout<<"C"<<endl;
    }else if(m+f>=30){
      if(r>=50){
        cout<<"C"<<endl;
      }else{
        cout<<"D"<<endl;
      }
    }else{
      cout<<"F"<<endl;
    }
  }
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
#define pb push_back
#define boostup ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int ll;
using namespace std;
int main()
{
    boostup;
    ll n;
    cin>>n;
    ll x=100;
    ll t=0;
    while(x<n)
    {
        ll d=x*(1.01);
        x=d;
        t++;
    }
    cout<<t;
}

Measured memory_bytes: 3636
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 六  8/26 21:19:20 2017
 *Ended  Time*  : 六  8/26 21:26:49 2017
 *********************************************/

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
const int MaxN = 2e5;
char s[MaxN + 5];
int sum[30][MaxN + 5];

int main()
{
    scanf("%s", s + 1);
    int len = strlen(s + 1);
    for(int i = 0; i < 26; i++){
        char c = i + 'a';
        for(int j = 1; j <= len; j++){
            if(s[j] == c) sum[i][j] = sum[i][j - 1] + 1;
            else sum[i][j] = sum[i][j - 1];
        }
    }
    LL ans = 0;
    for(int i = 1; i <= len; i++){
        ans = ans + (i - sum[s[i] - 'a'][i]);
    }
    printf("%lld\n", ans + 1);
    return 0;
}



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

int n, x[1<<18], y[1<<18];
char d[1<<18];

void Rotate(){
  for(int i = 1; i <= n; i++){
    int cx = y[i],cy = 200000-x[i],cz;
    if(d[i] == 'U') cz = 'R';
    if(d[i] == 'R') cz = 'D';
    if(d[i] == 'D') cz = 'L';
    if(d[i] == 'L') cz = 'U';
    x[i] = cx; y[i] = cy; d[i] = cz;
  }
}

vector<pair<int,char>> v1[1<<19];
vector<pair<int,char>> v2[1<<19];

int solve_01(){
  int ans = (1 << 24);
  for(int i = 0; i <= 500000; i++) v1[i].clear();
  for(int i = 1; i <= n; i++){
    if(!(d[i] == 'R' || d[i] == 'U')) continue;
    v1[x[i]+y[i]].push_back(make_pair(x[i],d[i]));
  }
  for(int i = 0; i <= 500000; i++){
    sort(v1[i].begin(),v1[i].end());
    for(int j = 0; j < (int)v1[i].size() - 1; j++){
     if(!(v1[i][j].second == 'R' && v1[i][j+1].second == 'U')) continue;
     ans = min(ans,v1[i][j+1].first - v1[i][j].first);
    }
  }
   return ans * 10;
}

int solve_02(){
  int ans = (1 << 24);
  for(int i = 0; i <= 500000; i++) v2[i].clear();
  for(int i = 1; i <= n; i++){
    if(!(d[i] == 'L' || d[i] == 'R')) continue;
    v2[y[i]].push_back(make_pair(x[i],d[i]));
  }
  for(int i = 0; i <= 500000; i++){
    sort(v2[i].begin(),v2[i].end());
    for(int j = 0; j < (int) v2[i].size()-1; j++){
      if(!(v2[i][j].second == 'R' && v2[i][j+1].second == 'L')) continue;
      ans = min(ans,v2[i][j+1].first - v2[i][j].first);
    }
  }
  return ans*5;
 }

 int main(){
  cin >> n;
  for(int i = 1; i <= n; i++) cin >> x[i] >> y[i] >> d[i];
  int fans = (1 << 24);
  for(int i = 1; i <= 4; i++){
    int val1 = solve_01(); fans = min(fans,val1);
    int val2 = solve_02(); fans = min(fans,val2);
    Rotate();
  }
  if(fans == (1 << 24)) cout << "SAFE" << endl;
  else cout << fans << endl;
  return 0;
}

Measured memory_bytes: 42632
N=gets.to_i
E=N.times.map{gets.split.map(&:to_i)}.sort{|(x1,y1),(x2,y2)|Math.atan2(y1,x1)<=>Math.atan2(y2,x2)}
ans=0
N.times do |i|
  x,y=0,0
  N.times do |j|
    e=E[(i+j)%N]
    x+=e[0]
    y+=e[1]
    ans=[ans,x**2+y**2].max
  end
end
puts "%.12f"%Math.sqrt(ans)

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string a;
    cin>>a;
    int k;
    cin>>k;
    int n=a.size();
    for(int i=0;i<n;i+=k)
        cout<<a[i];
    cout<<"\n";
    return 0;
}
/**
**/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  double sum = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    sum += 1.0 / a;
  }
  printf("%.10lf\n", 1.0 / sum);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int k, s;
    cin >> k >> s;
    int cnt = 0;
    for (int x = 0; x <= k; x++) {
        if (s == 3*x) cnt++;
        for (int y = x+1; y <= k; y++) {
            if (s == 2*x+y or s == x+2*y) cnt+=3;
            else if (s-x-y <= k && s-x-y > y) cnt+=6;
        }
    }
    cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
   int n,num,x,rev=0;
   cin>>num;
   n=num;
while(num!=0){
    x=num%10;
rev=rev*10+x;
num=num/10;
}
if(n==rev)
    cout<<"Yes";
else
    cout<<"No";
return 0;
}


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

int x, y;

int main() {
    cin >> x >> y;
    if (y % 2 == 0 && y >= 2 * x && y <= 4 * x){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3620
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int D = sc.nextInt();
    int T = sc.nextInt();
    int S = sc.nextInt();
    double dD = D;
    double dS = S;
    if(dD/dS>T){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }
  }
}

Measured memory_bytes: 35668
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

int n,m;

char a[55][55],b[55][55];

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n >> m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin >> a[i][j];
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i][j]=='#') continue;
            a[i][j]='0';
            if(a[i+1][j]=='#') a[i][j]++;
            if(a[i-1][j]=='#') a[i][j]++;
            if(a[i][j+1]=='#') a[i][j]++;
            if(a[i][j-1]=='#') a[i][j]++;
            if(a[i+1][j+1]=='#') a[i][j]++;
            if(a[i+1][j-1]=='#') a[i][j]++;
            if(a[i-1][j+1]=='#') a[i][j]++;
            if(a[i-1][j-1]=='#') a[i][j]++;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cout << a[i][j];
        }
        cout << '\n';
    }
}


Measured memory_bytes: 256
import math

N, K = map(int, input().split())
P = [int(x)-1 for x in input().split()]
C = list(map(int, input().split()))

# cycles = [None]*N
cycle_scores = [None]*N
cycle_lengths = [None]*N

for x in range(N):
    if cycle_scores[x] is not None: continue

    cycle = []
    i = x
    score = 0
    while True:
        i = P[i]
        score += C[i]
        cycle.append(i)
        if i == x: break

    for i in cycle:
        # cycles[i] = cycle
        cycle_scores[i] = score
        cycle_lengths[i] = len(cycle)

best = -math.inf
for x in range(N):
    fuel = K
    i = x
    partial = 0
    for _ in range(min(K, cycle_lengths[x])):
        i = P[i]
        fuel -= 1
        partial += C[i]
        if cycle_scores[i] > 0 and fuel >= cycle_lengths[i]:
            score = partial + cycle_scores[i] * (fuel // cycle_lengths[i])
        else:
            score = partial
        best = max(best, score)

print(best)


Measured memory_bytes: 74540
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,m=39;
vl x,y,d(m);

int main(){
	cin>>n;
	x=y=vl(n);
	int B=0;
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i];
		int t=(abs(x[i])+abs(y[i]))%2;
		if(!i) B=t;
		else if(B!=t){
			cout<<-1<<endl;
			return 0;
		}
	}
	for(int i=m-1;i>=0;i--) d[m-i-1]=1ll<<i;
	if(!B) d.push_back(1),m++;
	cout<<m<<endl;
	for(int i=0;i<m;i++) cout<<d[i]<<" \n"[i==m-1];
	for(int i=0;i<n;i++){
		string s;
		ll X=x[i],Y=y[i];
		for(int j=0;j<m;j++){
			pll p={INF,INF};
			for(int k=0;k<4;k++) p=min(p,{abs(X+d[j]*dx[k])+abs(Y+d[j]*dy[k]),k});
			int k=p.second;
			X+=d[j]*dx[k];Y+=d[j]*dy[k];
			if(k==0) s+='D';
			if(k==1) s+='L';
			if(k==2) s+='U';
			if(k==3) s+='R';
		}
		assert(!X&&!Y);
		cout<<s<<endl;
	}
}

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

using namespace std;

int main(){
    char s[5],c[5];
    int cnt=0;
    scanf("%s%s",s,c);
    for(int i=0;i<3;i++){
        if(s[i]==c[i]) cnt++;
    }
    printf("%d",cnt);
    return 0;
}


Measured memory_bytes: 256
x, y, a, b, c = map(int, input().split())
red = list(map(int, input().split()))
green = list(map(int, input().split()))
colorless = list(map(int, input().split()))

red.sort(reverse=True)
green.sort(reverse=True)
colorless.sort(reverse=True)

red = red[:x]
green = green[:y]

l = red + green + colorless
l.sort(reverse=True)
ans = sum(l[:x + y])
print(ans)

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

int main(){
	int n,k;
	std::cin >> n;
	std::cin >> k;
	std::vector<int> d(k);
	rep(i,k)std::cin >> d[i];
//	rep(i,k)std::cout << d[i] << std::endl;
	for (int i = n; ; i++) {
		/* code */
		int nn=i;
		bool han=true;
		std::vector<int> a;
		
		for (;nn!=0;) {
			/* code */
			a.push_back(nn%10);nn/=10;
		}
	 //  rep(l,d.size())std::cout << d[l] ;
	   // std::cout << std::endl;
	//	rep(j,a.size())std::cout << a[j] << std::endl;
		rep(j,a.size()){
			rep(l,d.size()){
				if(a[j]==d[l])han=false;
			}
			
		}
		if(han){std::cout << i << std::endl;exit(0);}
	}
	
}
	

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException{
		Character objChar1;

		char c;
		int cordchange=97;//??????????????????????????????????????????????????°???
		int total[]=new int[26] ;
		int i=0, num, sum;
		InputStreamReader isr = new InputStreamReader(System.in);
		
		BufferedReader br = new BufferedReader(isr);
		
		do {
			String str = br.readLine();
			if (str == null) {
		        continue;
		    }
		
		for (i = 0; i < str.length(); i++) {
				c = str.charAt(i);
				c=Character.toLowerCase(c);
				if(Character.isLetter(c))
					total[c-cordchange]++;
				
			}
		
		}while (br.ready());
		for(i=0;i<26;i++)
		{
			System.out.println((char)('a'+i)+" : "+total[i]);
		}
}
}

Measured memory_bytes: 24040
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
struct rest {
  string S;
  int P;
  int number;
};
bool restsort(const rest& a, const rest& b) {
  if (a.S < b.S) {
    return true;
  } else if (a.S > b.S) {
    return false;
  }
  return a.P > b.P;
}

int main()
{
  int N;
  cin >> N;
  vector <rest> R(N);
  for (int i = 0; i < N; i++) {
    cin >> R[i].S >> R[i].P;
    R[i].number = i+1;
  }
  sort(R.begin(), R.end(), restsort);
  for (int i = 0; i < N; i++) {
    cout << R[i].number << endl;
  }
  return 0;
}


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

int main(){
    cin >> X;
    cin.ignore();

    if(X <= 599){
        cout << 8 << endl;
    } else if(X <= 799){
        cout << 7 << endl;
    } else if(X <= 999){
        cout << 6 << endl;
    } else if(X <= 1199){
        cout << 5 << endl;
    } else if(X <= 1399){
        cout << 4 << endl;
    } else if(X <= 1599){
        cout << 3 << endl;
    } else if(X <= 1799){
        cout << 2 << endl;
    } else {
        cout << 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

lint n;
vector<double> a;

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

    double sum = 0;
    for(lint i = 0; i < n; i++)  sum += 1 / a[i];

    cout << fixed << setprecision(10) << 1 / sum << endl;
}

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


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

  map<int, int> mp;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    mp[a]++;
  }

  if (mp.size() == 1) {
    if (mp[0] == n) puts("Yes");
    else puts("No");
  } else if (mp.size() == 2) {
    if (n % 3 != 0) {
      puts("No");
    } else {
      int a = n / 3;
      if (mp[0] == a) puts("Yes");
      else puts("No");
    }
  } else if (mp.size() == 3) {
    if (n % 3 != 0) {
      puts("No");
    } else {
      int a = n / 3;
      bool ok = true;
      int xo = -1;
      for (auto e: mp) {
	if (xo == -1) xo = e.first;
	else xo = xo ^ e.first;
	if (e.second != a) {
	  ok = false;
	  break;
	}
      }
      if (ok && xo == 0) puts("Yes");
      else puts("No");
    }
  } else {
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
#define LL long long 
using namespace std;
int n;
int a[200001];
inline int read()
{
	int x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9')
		ch=getchar();
	while(ch>='0'&&ch<='9')
	{
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read(),a[i]-=i;
	sort(a+1,a+1+n);
	LL mid;
	if(n%2==1)
	{
		mid=a[(n+1)>>1];
		LL ans=0;
		for(int i=1;i<=n;i++)
			ans+=abs(a[i]-mid);
		printf("%lld",ans);
	}
	else
	{
		mid=(a[n>>1]+a[(n>>1)+1])>>1;
			LL ans=0;
		for(int i=1;i<=n;i++)
			ans+=abs(a[i]-mid);
		printf("%lld",ans);
	}
}

Measured memory_bytes: 1024
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <bits/stdc++.h>
#include <string>
using namespace std;
using ll = long long;
const ll MOD = 1000000007; 
using plong = pair<long,long>;



int main(){   
    ll D,G;
    cin>>D>>G;
    ll p[D],c[D];
    for(ll i=0;i<D;i++){
        cin>>p[i]>>c[i];
    }
    ll res = 999999999999999;
    for(ll bit=0;bit<(1<<D);bit++){
        ll tmp=0;
        ll num=0;
        for(ll i=0;i<D;i++){
            if((bit>>i)&1){
                tmp += (i+1)*100*p[i]+c[i];
                num += p[i];
            }
        }
        if(tmp>=G)res=min(res,tmp);
        else{
            for(ll i=D-1;i>=0;i--){
                if((bit>>i)&1)continue;
                for(ll j=0;j<p[i];j++){
                    if(tmp>=G)break;
                    tmp+=100*(i+1);
                    num++;
                }
            }
        }
        res = min(res,num);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define x first
#define y second
#define pb push_back
#define all(x) x.begin(), x.end()

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

	long long a;
	cin >> a;
	cout << a + a*a + a*a*a;
}


Measured memory_bytes: 3604
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<long long,long long>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a);}
                a=(a*a);
                b>>=1;
        }
    return ans;
        
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    srand(time(0));
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0)ans+=i;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>

int main(void) {
	int i;
	char s[1201];
	
	
	fgets(s, sizeof(s), stdin);
	
	for(i = 0; i < strlen(s); i++) {
		if(s[i] >= 65 && s[i] <= 90) {
			s[i] += 32;
		} else if(s[i] >= 97 && s[i] <= 122) {
			s[i] -= 32;
		}
	}
	
	
	
	printf("%s", s);
	
	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

int main() {
	int N=0; int M=0;
	cin >> N >> M;
	int max = M / N;

	for (int i = max; i > 0; i--) {
		if (M%i == 0) {
			cout << i;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define mod 1000000007

int main() {
	int k;
	cin >> k;
	queue<long long int> qu;
	for (long long int i = 1; i < 10; i++) {
		qu.push(i);
	}
	for (int i = 1; i < k; i++) {
		int now = qu.front();
		// cout << now << endl;
		qu.pop();
		int tmp = now % 10;
		if (tmp > 0) qu.push((long long int)now * 10 + tmp - 1);
		qu.push((long long int)now * 10 + tmp);
		if (tmp < 9) qu.push((long long int)now * 10 + tmp + 1);
	}
	cout << qu.front() << endl;
}

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


#define mod 1000000007
#define ull unsigned long long int
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<ll,ll>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

ll ncr(int n, int k)  
{  
    if(k>n)return 0;
    ll res = 1;  
    if ( k > n - k )  
        k = n - k;  
    for (int i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
  
    return res;  
} 
  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 
#define  deb(x)       cout << '>' << #x << ':' << x << endl;

void  solve()
{
    int n;
    cin>>n;
    int arr[n];
    forn(i,n)cin>>arr[i];
    forn(i,n)
    {
        if(arr[i]%2==0)
        {
            if(arr[i]%3==0||arr[i]%5==0)continue;

            cout<<"DENIED"<<endl;
            return;
        }
    }
    cout<<"APPROVED"<<endl;
}


int main()
{
 
    FastIO;
   // init();
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  double N,M;
  cin >> N >> M;
  vector<pair<double,double>> v;
  double a,b;
  for(int i=0;i<M;i++){
    cin >> a >> b;
    v.push_back({b,a});
  }
  sort(v.begin(),v.end());
  int ans=1;
  double stone=v[0].first-0.5;
  for(int i=0;i<M;i++){
    if(v[i].second <=stone && stone <=v[i].first){
      continue;
    }else{
      stone=v[i].first-0.5;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

Measured memory_bytes: 3636
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	N := scanInt()
	A := make([][20]int, N)
	for i := 0; i < N; i++ {
		a := scanInt()
		for j := 0; j < 20; j++ {
			if a&(1<<j) > 0 {
				A[i][j] = 1
			}
		}
	}

	tmp, l, r := [20]int{}, 0, 0
	ans := 0
	for r < N {
		// r++できるかどうかの判定
		flg := true
		for i := 0; i < 20; i++ {
			if tmp[i]+A[r][i] >= 2 {
				flg = false
				break
			}
		}

		if flg {
			for i := 0; i < 20; i++ {
				tmp[i] += A[r][i]
			}
			r++
		} else {
			ans += (r - l)
			for i := 0; i < 20; i++ {
				if tmp[i] == 1 {
					tmp[i] -= A[l][i]
				}
			}
			l++
		}
	}
	ans += ((N - l) * (N - l + 1)) / 2
	fmt.Println(ans)
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N+2); A.at(0)=0; A.at(N+1)=0;
  for(int i=1;i<=N;i++){cin >> A.at(i);}
  
  vector<int> B(N+1);
  for(int i=0;i<=N;i++){B.at(i)=abs(A.at(i+1)-A.at(i));}
  
  int ansb=0;
  for(int i=0;i<=N;i++){ansb += B.at(i);}
  
  for(int i=0;i<N;i++){
    cout << ansb - B.at(i) - B.at(i+1) + abs(A.at(i+2)-A.at(i)) << endl;
  }
  
    
}

Measured memory_bytes: 4052
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] light = new int[m];
		int[] p = new int[m];
		
		for(int i = 0; i < m; i++){
		    int k = sc.nextInt();
		    for(int j = 0; j < k; j++){
		        int s = sc.nextInt();
		        light[i] |= 1<<(s-1); 
		    }
		}
		for(int i = 0; i < m; i++){
		    p[i] = sc.nextInt();
		}
		// 計算
		int result = 0;
		for(int i = 0; i < 1<<n; i++){
		    int temp = 0;
		    for(int j = 0; j < m; j++){
		        if(Integer.bitCount(i & light[j])%2 == p[j]){
		            temp++;
		            continue;
		        }
		        break;
		    }
		    if(temp == m) result++;
		}
		
		// 出力
		System.out.println(result);
	}
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1234567;
const ll INF=1000000010;
const ll LINF=1000000000000000010LL;
const int MAX=500010;
const double EPS=1e-3;
int dx[4]={0,1,0,1};
int dy[4]={0,0,1,1};
int main(){
    int n;cin>>n;
    int s=sqrt(n);
    cout<<s*s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	vll a(n) ;
	map<ll,ll> m ;
	for(int i=0;i<n;i++){
		cin >> a.at(i) ;
		m[i+1-a.at(i)]++ ;
	}
	ll ans = 0 ;
	for(int i=0;i<n;i++){
		m[i+1-a.at(i)]-- ;
		ans += m[a.at(i)+i+1] ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 27380
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef int in;
#define int long long
#define pb push_back
#define f first
#define s second
const int MAX=2e10;
const int MAAX=1e9;
const int MOD=1e9+7;
int n,m;
int cost[1004],x,y[1005],z,a[1005][15],vis[15];
int dp[1002][2][2][2][2][2][2][2][2][2][2][2][2];
int fun(int idx,int a1,int a2,int a3,int a4,int a5,int a6,int a7,int a8,int a9,int a10,int a11,int a12)
{
    if(idx==m)
    {
        int x=0;
        for(int i=1;i<=n;i++)
        {
            if(!vis[i])
            {
                x=MAX;
                break;
            }
        }
            return x;
    }
    int &ret=dp[idx][a1][a2][a3][a4][a5][a6][a7][a8][a9][a10][a11][a12];
if(ret!=-1)
{
    return ret;
}
for(int i=0;i<y[idx];i++)
{
    vis[a[idx][i]]++;
}
ret=cost[idx]+fun(idx+1,min(vis[1],1ll),min(vis[2],1ll),min(vis[3],1ll),min(vis[4],1ll),min(vis[5],1ll),min(vis[6],1ll),min(vis[7],1ll),min(vis[8],1ll),min(vis[9],1ll),
                  min(vis[10],1ll),
    min(vis[11],1ll),min(vis[12],1ll));
for(int i=0;i<y[idx];i++)
{
    vis[a[idx][i]]--;
}
ret=min(ret,fun(idx+1,min(vis[1],1ll),min(vis[2],1ll),min(vis[3],1ll),min(vis[4],1ll),min(vis[5],1ll),min(vis[6],1ll),min(vis[7],1ll),min(vis[8],1ll),min(vis[9],1ll),
                min(vis[10],1ll),
    min(vis[11],1ll),min(vis[12],1ll)));
    return ret;
}
in main()
{
    memset(dp,-1,sizeof dp);
cin>>n>>m;
for(int i=0;i<m;i++)
{

    scanf("%lld%lld",&cost[i],&y[i]);
    for(int j=0;j<y[i];j++)
    {
        scanf("%lld",&a[i][j]);
    }
}

int ans=fun(0,0,0,0,0,0,0,0,0,0,0,0,0);
if(ans==MAX)
{
    cout<<-1<<endl;
    return 0;
}
cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 32640
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define N 100005
using namespace std;
int main(){
    ll n;
    cin>>n;
    ll a[n+3],cnt=0,cnt1=0,cnt2=0;
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        if(a[i]%4==0)
            cnt++;
        else if(a[i]%2==0){
            cnt2++;
        }
        if(a[i]%2==1)
            cnt1++;

    }
    if(cnt2%2==1){
        cnt1++;
    }
    if(cnt+1<cnt1){
        cout<<"No\n";
    }
    else{
        cout<<"Yes\n";
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fast_io()                \
    ios::sync_with_stdio(false); \
    std::cin.tie(0);
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> two;

int main() {
    fast_io();
    int h, t;
    cin >> h >> t;
    while (t--) {
        int tmp;
        cin >> tmp;
        h -= tmp;
    }
    if (h > 0) {
        cout << "No";
    } else {
        cout << "Yes";
    }

    return 0;
}


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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  lint n,k; cin >> n >> k;

  map<lint,lint> mp;
  set<lint> st;
  for(lint i=0;i<n;i++) {
    lint a,b; cin >> a >> b;
    mp[a] += b;
    st.insert(a);
  }

  lint cnt=0, ans;
  for(set<lint>::iterator itr=st.begin();itr!=st.end();itr++) {
    cnt += mp[*itr];
    if(cnt >= k) {
      ans = *itr;
      break;
    }
  }

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

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

int main(){
    int K, A, B;
    cin >> K >> A >> B;
    for(int i=1; i<=1000; i++) if(A <= i*K && i*K <= B){
        cout << "OK" << endl;
        return 0;
    }
    cout << "NG" << endl;
    return 0;
}


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

int main(){
    char ch;
    while(1){
        cin.get(ch);
        if(ch=='\n')break;
        else if(islower(ch)){
            cout << (char)toupper(ch);
        }else if(isupper(ch)){
            cout << (char)tolower(ch);}
        else{
        cout.put(ch);
        }
    }
        cout<<endl;
    return 0;
}

Measured memory_bytes: 3064
#!python3

# input
K = int(input())


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


def main():
    ans = 0
    d = {}
    for i in range(1, K + 1):
        for j in range(1, K + 1):
            l = (i, j) if i > j else (j, i)
            if l in d:
                x = d[l]
            else:
                x = gcd(l[0], l[1])
                d[l] = x
            for k in range(1, K + 1):
                l = (x, k) if x > k else (k, x)
                if l in d:
                    y = d[l]
                else:
                    y = gcd(l[0], l[1])
                    d[l] = y
                ans += y
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 10888
#include<iostream>
#include<string>
using namespace std;
const int N_MAX = 1005;
short res[N_MAX][N_MAX];

int lcs(string X, string Y){
	int xLen = X.size();
	int yLen = Y.size();
	int maxRes=0;
	X=' '+X;
	Y=' '+Y;
	for(int i=1;i<=xLen;i++){
		for(int j=1;j<=yLen;j++){
			if(X[i]==Y[j]){
				res[i][j] = res[i-1][j-1]+1;
			}else if(res[i][j-1]>=res[i-1][j]){
				res[i][j] = res[i][j-1];
			}else{
				res[i][j] = res[i-1][j];
			}
			maxRes = (res[i][j]>maxRes)?res[i][j]:maxRes;
		}
	}
	return maxRes;
}

int main(){
	int n;
	string X, Y;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>X>>Y;
		cout<<lcs(X, Y)<<endl;
	}
}


Measured memory_bytes: 5188
#include <stdio.h>

int main(){
    int N,X;
    scanf("%d %d",&N,&X);
    int L[N+1];
    L[0]=0;
    for(int i=1;i<N+1;i++){
        scanf("%d",&L[i]);
    }
    int D=0;
    for(int i=0;i<N+1;i++){
        D=D+L[i];
        if(D>X){
            printf("%d",i);
            break;
        }
        if(i==N){
            printf("%d",i+1);
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int i;
  int len;
  char str[256];
  string d[10][10];
  d[1][1]="a";
  d[1][2]="b";
  d[1][3]="c";
  d[1][4]="d";
  d[1][5]="e";
  d[2][1]="f";
  d[2][2]="g";
  d[2][3]="h";
  d[2][4]="i";
  d[2][5]="j";
  d[3][1]="k";
  d[3][2]="l";
  d[3][3]="m";
  d[3][4]="n";
  d[3][5]="o";
  d[4][1]="p";
  d[4][2]="q";
  d[4][3]="r";
  d[4][4]="s";
  d[4][5]="t";
  d[5][1]="u";
  d[5][2]="v";
  d[5][3]="w";
  d[5][4]="x";
  d[5][5]="y";
  d[6][1]="z";
  d[6][2]=".";
  d[6][3]="?";
  d[6][4]="!";
  d[6][5]=" ";
  while(fgets(str,256,stdin)!=0){
    str[strlen(str)-1]='\0';
    string s(str),t;
    len=s.length();
    if(len%2)
      cout<<"NA"<<endl;
    else{
      for(i=0;i<len;i+=2){
	if(d[s[i]-'0'][s[i+1]-'0'].empty()){
	  cout<<"NA"<<endl;
	  break;
	}else
	  t+=d[s[i]-'0'][s[i+1]-'0'];
      }
      if(i==len)
	cout<<t<<endl;
    }
  }
  return 0;
}

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

using namespace std;
using ll = long long;

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

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

  int c[10][10];
  rep(i, 10) rep(j, 10) c[i][j] = 0;

  for (int i = 1; i <= n; ++i) {
    string s = to_string(i);
    int x = s[0] - '0', y = s[s.size() - 1] - '0';
    ++c[x][y];
  }

  int ans = 0;
  rep(i, 10) rep(j, 10) ans += c[i][j] * c[j][i];

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


Measured memory_bytes: 256
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    n, m = map(int, readline().rstrip().split())
    if n == 1 or m == 1:
        print(abs(abs(n - m) - 1))
        return
    print(abs((m - 2) * (n - 2)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    ll n;   cin >> n;
    vector<ll> v;
    while(n){
        v.push_back((n-1)%26);
        n = (n-(v.back()+1))/26;
    }
    reverse(ALL(v));
    REP(i, v.size()){
        printf("%c", v[i]+'a');
    }
    cout << endl;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>     
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long
#define int ll
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define VAR(v, i) __typeof( i) v=(i)
#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
 
using namespace std;
 
const int maxn = (int)3e3 + 100;
const int N = (int)1e5 + 100;
const int mod = (int)1e9 + 7;
 
#define inf mod
 
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;   
typedef vector<ll> Vll;               
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
 
int n, m;
double p[maxn], dp[maxn][maxn], ans;
main () {
	cin >> n;
	forn(i, 1, n)
		cin >> p[i];	
	dp[0][0] = 1.0;
	forn(i, 1, n){
		forn(s, 0, i){
			if(s)
				dp[i][s] += dp[i - 1][s - 1] * p[i];
			dp[i][s] += dp[i - 1][s] * (1.0 - p[i]);
			if(i == n && s > n - s)
				ans = ans + dp[i][s];
		}
	}
	cout << fixed << setprecision(10) << ans;
}

Measured memory_bytes: 72320
#include "bits/stdc++.h"
#define MAXN 150009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
vector<int>adj[MAXN];
double ans[MAXN],suf[MAXN],pre[MAXN],res[MAXN];
double dfs(int nd,int pr){
	if(~pr and adj[nd].size()==1)
		return 0.0;
	for(int i=0;i<int(adj[nd].size());i++){
		int to=adj[nd][i];
		if(to==pr)
			continue;
		ans[nd]+=dfs(to,nd);	
	}
	if(~pr)
		ans[nd]=ans[nd]/double(adj[nd].size()-1)+1.0;
	else	
		ans[nd]=ans[nd]/double(adj[nd].size())+1.0;
	return ans[nd];	
}
void dfs1(int nd,int pr,double par){
	res[nd]=par;
	for(int i=0;i<int(adj[nd].size());i++){
		int to=adj[nd][i];
		if(to==pr)
			continue;
		res[nd]+=ans[to];	
	}
	res[nd]=res[nd]/double(adj[nd].size())+1;
	if(adj[nd].size()==1){
		if(pr==-1)
			dfs1(adj[nd][0],nd,0);
		return;
	}
	double sum=0;
	for(int i=0;i<int(adj[nd].size());i++){
		int to=adj[nd][i];
		if(to==pr)
			continue;
		pre[to]=sum;
		sum+=ans[to];
	}sum=0;
	for(int i=int(adj[nd].size()-1);i>=0;i--){
		int to=adj[nd][i];
		if(to==pr)
			continue;
		suf[to]=sum;
		sum+=ans[to];
	}
	for(int i=0;i<int(adj[nd].size());i++){
		int to=adj[nd][i];
		if(to==pr)	
			continue;
		dfs1(to,nd,(par+suf[to]+pre[to])/double(adj[nd].size()-1)+1.0);	
	}
}
int main(){
	//~ #ifndef ONLINE_JUDGE
    //~ freopen("file.in", "r", stdin);
	//~ #endif	
	int n;
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		adj[u].pb(v);
		adj[v].pb(u);
	}
	dfs(1,-1);
	dfs1(1,-1,0);
	for(int i=1;i<=n;i++)
		printf("%.12lf\n",res[i]);	
	return 0;
}


Measured memory_bytes: 21120
#include<iostream>
#include <cstddef>
#include<set>
#include<stack>
#include <deque>
#include<queue>
#include<utility>
#include<vector>
#include<map>
#include<cmath>
#include<cstring>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#define  ll  long long
#define ull unsigned long long
#define  sl(a)  scanf("%lld",&a)
#define  si(a)  scanf("%d",&a)
#define mem(n,m) memset(n,m,sizeof(n))
#define PI acos(-1)
#define pb    push_back
#define pf    push_front
#define vll   vector<ll>
#define pll   pair<ll,ll>
#define mp  make_pair
#define vpll vector< pair <ll,ll> >
#define vplpll vector<pair<ll,pair<ll,ll> > >
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S(X) ( (X) * (X) )
#define forab(i, a, b) for(i = a; i <= b; i++)
#define forn(i, n) for(i = 0; i < n; i++)
#define print(a,b) printf("Case %lld: %lld\n",a,b)
using namespace std;
ll powd(ll a,ll b){if(b==1){return a;}if(b%2==1){return powd(a,b-1)*a;}else{ll x=powd(a,b/2); return x*x;}}
ll powm(ll a,ll b,ll m){if(b==0){return 1;}if(b==1){return a%m;}if(b%2==1){return ((powm(a,b-1,m)%m)*(a%m))%m;}else{ll x=powm(a,b/2,m); return ((x%m)*(x%m))%m;}}
ll gcd(ll a,ll b){if(a==0){return b;}return gcd(b,a%b);}
typedef multiset<ll> mlset;
typedef set<ll> mset;
typedef struct node* pnode;
ll d[1000][3];
int main()
{
    ll n;
    sl(n);
    ll ans=0,l=0;
    for(ll i=0;i<n;i++)
    {
        sl(d[i][0]);
        sl(d[i][1]);
        if(d[i][0]!=d[i][1])
        {
            l=0;
        }
        else
        {
            l++;
            if(l==3)
            {
                ans=1;
            }
        }
    }
    if(ans==1)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3684
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
using namespace std;
template<class T>inline void read(T &x) {
    x=0; int ch=getchar(),f=0;
    while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;
const int maxn=200050;
ll n,a[maxn],sta[maxn],top;
ll l[maxn],r[maxn];
int main()
{
	read(n);
	for(int i=1;i<=n;i++) read(a[i]);
	top=0;
	for(int i=1;i<=n;i++)
	{
		while(top&&a[sta[top]]>=a[i]) top--;
		if(top) l[i]=sta[top];
		else l[i]=0;
		sta[++top]=i;
	}
	memset(sta,0,sizeof(sta));top=0;
	for(int i=n;i>=1;i--)
	{
		while(top&&a[sta[top]]>=a[i]) top--;
		if(top) r[i]=sta[top];
		else r[i]=n+1;
		sta[++top]=i;
	}
	ll ans=0;
	for(int i=1;i<=n;i++) ans+=(i-l[i])*(r[i]-i)*a[i];
	//for(int i=1;i<=n;i++) cout<<i<<" "<<l[i]<<" "<<r[i]<<" "<<a[i]<<endl; 
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 6528
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.TreeSet;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		//Long[] anser = new Long[N];
		List<Long> list = new ArrayList<>();
		List<Long> anser = new ArrayList<>();
		for(int i = 0; i < N ; i++) {
			list.add(sc.nextLong());
		}

		//重複しているものを追加しない、自動ソート済み
		TreeSet<Long> TS = new TreeSet<>(list);
		if(list.size() == TS.size()) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	}
}

Measured memory_bytes: 96328
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 gcd(i64 x, i64 y) {
  if (x % y == 0) return y;
  return gcd(y, x % y);
}

int main() {
  i64 n, k;
  vector<i64> a;
  cin >> n >> k;
  read_n(a, n);
  i64 x = a[0];
  for (i64 i = 1; i < n; ++i) x = gcd(x, a[i]);
  for (i64 y : a) {
    i64 z = y - k;
    if (z >= 0 && z % x == 0) {
      cout << "POSSIBLE\n";
      return 0;
    }
  }
  cout << "IMPOSSIBLE\n";
  return 0;
}


Measured memory_bytes: 1024
N = int(input())
lst = []

for i in range(N):
    S,P = input().split()
    P = int(P)
    lst.append([S,P,i+1])

# 点数の降順でソート
lst = sorted(lst, key=lambda x: x[1], reverse=True)

# 市名順ソート
lst = sorted(lst, key=lambda x: x[0])

for _, _, num in lst:
    print(num)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rgi register int
#define ll long long
class fastin{
	private: int _ch,_f;
	public: inline fastin& operator>>(char&c) {c=getchar(); return *this;}
		template<typename _Tp> inline fastin& operator>>(_Tp&_x){
		_x=0; while(!isdigit(_ch)) _f|=(_ch==45),_ch=getchar();
		while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
		_f&&(_x=-_x,_f=0); return *this;}
	fastin() {_ch=_f=0;}
}fin;
class fastout{
#define endl '\n'
	private: int _num[32],_head;
	public: inline fastout& operator<<(char c) {putchar(c); return *this;}
		template<typename _Tp> inline fastout& operator<<(_Tp _x){
		_Tp _k; if(_x==0) {putchar('0'); return *this;} if(_x<0) putchar('-'),_x=-_x;
		while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
		while(_head>0) putchar(_num[_head]),--_head; return *this;}
	fastout() {_head=0;}
}fout;
// ----------------------------
// #define int ll
// using namespace std;
const int maxn=200004;
const int mod=998244353,inf=1000000007;

std::string n;
signed main()
{
	std::cin>>n;
	std::cout<<n[0]<<n[1]<<n[2];
	return 0; 
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MAX=100005;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    Vec past;
    cin>>s;
    string prev = "";
    string tmp = "";
    ll ans=0;

    rep(i,s.length()){
        tmp = tmp+s[i];
        if(tmp!=prev){
            ans ++;
            prev = tmp;
            tmp = "";
        }
    }
    cout<<ans<<endl;
    return  0;
}


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

void ZAlgorithm(const string& s, vector<int>& len)
{
    int n = s.size();
    int i = 1;
    int j = 0;

    len.resize(n);
    len[0] = n;
    while(i < n){
        while(i+j < n && s[j] == s[i+j])
            ++j;
        len[i] = j;
        if(j == 0){
            ++ i;
            continue;
        }

        int k = 1;
        while (i+k < n && k+len[k] < j){
            len[i+k] = len[k];
            ++ k;
        }
        i += k;
        j -= k;
    }
}

void solve(const string& s, vector<bool>& good)
{
    vector<int> len;
    ZAlgorithm(s, len);

    int n = s.size();
    good.assign(n+1, true);
    for(int i=1; i<n; ++i){
        for(int j=1; i*(j+1)<=n; ++j){
            if(len[i*j] < i)
                break;
            good[i*(j+1)] = false;
        }
    }
}

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    if(s == string(n, s[0])){
        cout << n << endl << 1 << endl;
        return 0;
    }

    vector<bool> good;
    solve(s, good);
    if(good[n]){
        cout << 1 << endl << 1 << endl;
        return 0;
    }

    reverse(s.begin(), s.end());
    vector<bool> goodRev;
    solve(s, goodRev);

    int ans = 0;
    for(int i=1; i<n; ++i){
        if(good[i] && goodRev[n-i])
            ++ ans;
    }
    cout << 2 << endl << ans << endl;

    return 0;
}

Measured memory_bytes: 2844