akhauriyash/Code-Regression huggingface dataset:
//52行目から編集
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

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

int n,m,q;
vi g[100010];
struct Q{int v,d,c;};
Q task[100010];
int col[100010];
int used[100010][12];
void func(int v,int d,int c){
    if(used[v][d])return;
    else{
        used[v][d] = 1;
        if(!col[v])col[v] = c;
    }
    if(d == 0)return;
    func(v,d-1,c);
    for(auto i : g[v]){
        func(i,d-1,c);
    }
    return;
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(20);
    cin >> n >> m;
    rep(i,m){
        int a,b;cin >> a >> b;
        a--,b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    cin >> q;
    rep(i,q){
        int v,d,c;cin >> v >> d >> c;
        task[i] = {--v,d,c};
    }
    reverse(task,task + q);
    rep(i,q){
        func(task[i].v,task[i].d,task[i].c);
    }
    rep(i,n)cout << col[i] << '\n';
    return 0;
}


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

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

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

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	int x;
	for(int i=0;i<n-1;i++){cin >> x;a[x-1]+=1;}
	for(int i=0;i<n;i++){cout << a[i] << endl;}
}


Measured memory_bytes: 4000
#include <iostream>
#include <fstream>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <iterator>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(),x.end()

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const ll INF=1e18+123;
const ld EPS=1e-9;
const int inf=1e9+123;
const int MOD=1e9+7;
const int N=2e5+123;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};

vector<int> t[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,m,q,l,r;
    cin>>n>>m>>q;
    for(int i=1;i<=m;i++){
        cin>>l>>r;
        t[l].push_back(r);
    }
    for(int i=1;i<=n;i++)sort(all(t[i]));
    while(q--){
        cin>>l>>r;
        int cnt=0;
        for(int i=l;i<=r;i++){
            cnt+=(up_b(all(t[i]),r)-t[i].begin());
        }
        cout<<cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 6912
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let n: u32;

    input!(n);

    let mut i = 0;
    let mut j = 0;
    let mut flag = true;

    loop {
        j = 0;
        loop {
            if 4 * i + 7 * j >= n {
                break;
            }
            j += 1;
        }
        if 4 * i > n || 4 * i + 7 * j == n {
            break;
        }

        i += 1;
    }
    if (4 * i + 7 * j == n) {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include<string>
#include<list>
#include<algorithm>
#include<cstdio>
using namespace std;


int main(){
    
    int n,t;
    cin>>n;
    list<int> V;
    string com;
    for(int i=0;i<n;i++){
        
        cin>>com;
        
        if(com[0]=='i'){
            scanf("%d",&t);
            V.push_front(t);
            
        }else if(com[6]=='F'){
                V.pop_front();
                //deleteLast
        }else if(com[6]=='L'){
                V.pop_back();
        }else if(com[0]=='d'){
                scanf("%d",&t);
                for(list<int>::iterator it = V.begin();it!=V.end();it++){
                    if(*it==t){
                        V.erase(it);
                        break;
                    }
                }
            }
    }
    int i=0;

    for(list<int>::iterator it = V.begin();it != V.end();it++){
       if(i++) printf(" ");
        printf("%d",*it);
        }
        
    
    printf("\n");




return 0;
}



Measured memory_bytes: 34480
#include<bits/stdc++.h>
#define ll long long
#define llu unsigned long long

int take() {
    int n;
    scanf("%d",&n);
    return n;

}
double ttake() {
    double n;
    scanf("%lf",&n);
    return n;
}
ll takes() {
    ll n;
    scanf("%lld",&n);
    return n;

}

#define Int take()
#define Dnt ttake()
#define LL takes()
#define done {return 0}
#define fr(n) for(int i=1;i<=n;i++)
#define FR(a,b,x) for(int i=(a);i<=(b);i+=(x))
#define rfr(n) for(int i=n;i>=1;i--)
int cas;
#define print printf("Case %d:",++cas)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pii pair<int,int>
#define vii vector<pii>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mk  make_pair
#define fill(x,v) memset(x,v,sizeof x)

using namespace std;

bool approximatelyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool essentiallyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) > fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool definitelyGreaterThan(float a, float b, float epsilon) {
    return (a - b) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool definitelyLessThan(float a, float b, float epsilon) {
    return (b - a) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
#define STR {struct info}
#define dbg(x) {cout<<"ekhane"<<x<<endl;}
#define  SS second
#define  FF first
#define PQ priority_queue
#define great greatest
#define less lesser
#define mii map<int,int>
#define mil map<int,ll>
#define mll map<ll,ll>
#define msb map<string,bool>
#define M 100005
//////////////////////////////////////////



int main() {

    int a=Int,b=Int;
    a=ceil((a+b)/2.00);
    printf("%d\n",a);
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,s;
int fa[200200];
int d[200200];
int rt1,rt2;

int te;
struct data{
	int to,nxt,id;
}mp[1000100];
int head[200200],cnt;
void link(int x,int y,int id)
{
	mp[++cnt].to=y;
	mp[cnt].id=id;
	mp[cnt].nxt=head[x];
	head[x]=cnt;
}

int ans[200200];
bool del[500500];
int sta[500500][2],top;
int ro[500500],cr;
void dfs(int s)
{
	sta[++top][0]=s;
	sta[top][1]=1;
	int x,v;
	while(top)
	{
		x=sta[top][0];
		int fl=1;
		if(sta[top][1]==1)
		{
			for(int i=head[x];i;i=mp[i].nxt)
			{
				if(del[mp[i].id])continue;
				del[mp[i].id]=1;
				head[x]=mp[i].nxt;
				fl=0;
				v=mp[i].to;
				sta[++top][0]=v;
				sta[top][1]=1;
				break;
			}
			if(fl)
			{
				sta[top][1]=2;
				continue;
			}
		}
		else if(sta[top][1]==2)
		{
			ro[++cr]=sta[top][0];
			top--;
		}
	}
}
int main()
{
	scanf("%d",&n);
	s=n*2+1;
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&fa[i]);
		if(fa[i]==-1)fa[i]=s;
		d[fa[i]]++;
		++te;
		link(fa[i],i,te);
		link(i,fa[i],te);
	}
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&fa[i]);
		if(fa[i]==-1)fa[i]=s;
		else fa[i]=s-fa[i];
		d[fa[i]]++;
		++te;
		link(fa[i],s-i,te);
		link(s-i,fa[i],te);
	}
	for(int i=1;i<s;++i)d[i]=(!(d[i]&1));
	for(int i=1;i<=n;++i)
	{
		if(d[i]!=d[s-i])
		{
			puts("IMPOSSIBLE");
			return 0;
		}
		if(d[i])
		{
			++te;
			link(i,s-i,te);
			link(s-i,i,te);
		}
	}
	dfs(1);
	puts("POSSIBLE");
	for(int i=cr;i>1;--i)
		if(ro[i]+ro[i-1]==s)
		{
			if(ro[i]<=n)ans[ro[i]]=ans[ro[i-1]]=1;
			else ans[ro[i]]=ans[ro[i-1]]=-1;
		}
	for(int i=1;i<=n;++i)printf("%d ",ans[i]);puts("");
	return 0;
}


Measured memory_bytes: 18432
n,d = input().split()
n = int(n)
d = int(d)
ls2 = []
c = 0
for i in range(n):
    ls1 = [int(i) for i in input().split()]
    if ((ls1[0]**2 + ls1[1]**2)**0.5) <= d:
        c += 1
print(c)

Measured memory_bytes: 9604
#include <iostream>

using namespace std;

int n, x, nr;

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> x;
		while (x % 2 == 0)
		{
			nr++;
			x /= 2;
		}
	}
	cout << nr;
	return 0;
}

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

long long int N, M, A, B, i;
unordered_set<long long> a, b;

int main(){
    scanf("%lld%lld", &N, &M);
    for(; i < M; ++i){
        scanf("%lld%lld", &A, &B);
        if(A == 1)a.insert(B);
        if(B == N)b.insert(A);
    }
    for(i : a){
        if(b.count(i))return 0 & puts("POSSIBLE");
    }
    puts("IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 8520
#include <stdio.h>

int main() {
	int n, maxi = 0, h, ans = 0;
	scanf("%d", &n);
	while (n--) {
		scanf("%d", &h);
		if (h >= maxi) {
			ans++;
			maxi = h;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int MOD=1000000007;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(a*n,b) << endl;
}


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

typedef struct{
	double x;
	double y;
}point;

void kock(int d,point p1,point p2)
{
	if(d==0) return;

	point s,t,u;

	s.x = (2 * p1.x + 1 * p2.x) / 3;
	s.y = (2 * p1.y + 1 * p2.y) / 3;
	t.x = (1 * p1.x + 2 * p2.x) / 3;
	t.y = (1 * p1.y + 2 * p2.y) / 3;
	u.x = (t.x - s.x) * cos(M_PI / 3) - (t.y - s.y) * sin(M_PI / 3) + s.x;
	u.y = (t.x - s.x) * sin(M_PI / 3) + (t.y - s.y) * cos(M_PI / 3) + s.y;

	kock(d - 1, p1, s);
	printf("%lf %lf\n", s.x, s.y);
	kock(d - 1, s, u);
	printf("%lf %lf\n", u.x, u.y);
	kock(d - 1, u, t);
	printf("%lf %lf\n", t.x, t.y);
	kock(d - 1, t, p2);
}

int main(void){
	int n;

	scanf("%d",&n);

  point p1 = {0,0} ,p2 = {100,0};

	printf("%lf %lf\n", p1.x, p1.y);
	kock(n, p1, p2);
	printf("%lf %lf\n", p2.x, p2.y);
	return 0;
}



Measured memory_bytes: 2092
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifdef LOCAL
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#else
#define debug(x) ;
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

double dp[301][301][301];

int main(){
  int n, c[4] = {};

  scanf("%d", &n);

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

  dp[c[3]][c[2]][c[1]] = 1;

  double ans = 0;

  for(int i=n;i>=0;i--){
    for(int j=n;j>=0;j--){
      for(int k=n;k>=0;k--){
        int sum = i + j + k;

        if(sum)
          ans += dp[i][j][k] * n / sum;

        if(i>0) dp[i-1][j+1][k] += dp[i][j][k] * (double)i/sum;
        if(j>0) dp[i][j-1][k+1] += dp[i][j][k] * (double)j/sum;
        if(k>0) dp[i][j][k-1]   += dp[i][j][k] * (double)k/sum;
      }
    }
  }

  printf("%.10lf\n", ans);

  return 0;
}


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

int main() {
  long long int a, b, c;
  cin >> a >> b >> c;
  long long int X = c - b - a;
  if (X >= 0 && X * X > 4 * a * b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define mp(a, b) make_pair(a, b)
using namespace std;
typedef pair<ll, ll> pairs;
typedef pair<ll, pairs> tpl;
ll dp[1000001];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    ll a[n + 1];
    for (ll i = 0; i < n; i++)
        cin >> a[i];
    dp[0] = 0;
    for (ll i = 1; i <= k; i++)
    {
        for (ll j = 0; j < n; j++)
        {
            if (i >= a[j] && !dp[i - a[j]])
            {
                dp[i] = 1;
                break;
            }
        }
    }
    if (dp[k])
        cout << "First";
    else

        cout << "Second";
}

Measured memory_bytes: 4436
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Scanner;

public class Main {
	//C問題

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long numCount;
		List<String> lists = new ArrayList<String>();

		numCount = scan.nextLong();

		for (int i = 0; i < numCount; i++) {
			lists.add(scan.next());
		}

		Map<String, Long> map = new HashMap<String, Long>();

		for (String s : lists) {
			if (map.containsKey(s)) {
				Long count = map.get(s);
				count++;
				map.put(s, count);
			} else {
				map.put(s, Long.parseLong("1"));
			}
		}

		Optional<Long> maxCount = map.values().stream().max(Long::compareTo);
		Long maxmax = maxCount.get();
		List<String> ansString = new ArrayList<>();

		for (String key : map.keySet()) {
			if (map.get(key) == maxmax) {
				ansString.add(key);
			}
		}

		Collections.sort(ansString);

		ansString.forEach(System.out::println);

	}

}

Measured memory_bytes: 86924
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const int N = 1e6 + 10;
int n;
int a[N], b[N], s;
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &b[i]);
		s ^= b[i];
	}
	for (int i = 1; i <= n; i++) {
		printf("%d%s", s^b[i], i == n ? "\n" : " ");
	}
	return 0;
}

Measured memory_bytes: 4644
#include <stdio.h>

void change_s(int a[],int x);

int main()
{
  int x,i;
  int a[100];
  
  scanf("%d",&x);
  if(1<=x&&x<=100){
    for(i=0;i<x;i++) {
      scanf("%d",&a[i]);
    }
    for(i=0;i<x;i++) {
      if(i>0) printf(" "); 
      printf("%d",a[i]);
    }
    printf("\n");
  }

  change_s(a,x);

  return 0;
}

void change_s(int a[],int x) {
  int c,d,i,j;
  for(i=0;i<x;i++) {
    c=a[i];
    if(i==0) continue;
    d=i-1;
    while(d>=0 && a[d]>c) {
      a[d+1]=a[d];
      d--;
      a[d+1]=c;
    }
    for(j=0;j<x;j++) {
      if(j>0) printf(" "); 
      printf("%d",a[j]);
    }
    printf("\n");
  }
}



Measured memory_bytes: 2032
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#define PI 3.14159265359
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pai;
typedef pair<ll, ll> pal;
const int MOD = 1e9+7;
const ll LLINF = 1e18;


int main(){
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(max(a*c, a*d), max(b*c, b*d)) << endl;
	return 0;
}



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

int main() {
   //int a, b, c;
   string s, t;
   cin >> s >> t;
   if(s == t.substr(0, s.size())){
      cout << "Yes" << endl;
   }else{
      cout << "No" << endl;
   }
   return 0;
}

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

const long long INF = 1LL<<61;
long long N, K;
vector<long long> A;

long long solve() {
    sort(A.begin(), A.end());
    long long left = -INF, right = INF;
    while (right - left > 1) {
        long long x = (left + right) / 2;
        long long S = 0, T = 0;
        for (int i = 0; i < N; ++i) {
            if (A[i] > 0) {
                int l2 = -1, r2 = N;
                while (r2 - l2 > 1) {
                    int m = (l2 + r2) / 2;
                    if (A[i] * A[m] <= x) l2 = m;
                    else r2 = m;
                }
                S += r2;
            }
            else if (A[i] < 0) {
                int l2 = -1, r2 = N;
                while (r2 - l2 > 1) {
                    int m = (l2 + r2) / 2;
                    if (A[i] * A[m] <= x) r2 = m;
                    else l2 = m;
                }
                S += N - r2;
            }
            else if (x >= 0) S += N;
            if (A[i] * A[i] <= x) ++T;
        }
        long long num = (S - T) / 2;
        if (num >= K) right = x;
        else left = x;
    }
    return right;
}

int main() {
    cin >> N >> K;
    A.resize(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    cout << solve() << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll m;
string s;

int main(){
	cin >> m >> s;
	ll c = 0;
	ll n = 0;
	rep(i,s.size()){
		c += (s[i] == '.');
	}
	ll ans = c;
	// cout << c << " " << n << endl;
	rep(i,s.size()){
		if(s[i] == '.')c--;
		else n++;
		ans = min(ans,n+c);
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;

using namespace std;

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define ALL(a)              a.begin(), a.end()
#define ALLN(a, n)          (a, a+n)
#define MAX                 10000007
#define MIN                 -10000007



              
int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
      
    int t;
    t=1;
     //  cin>>t;
    while(t--){
        	ll n,maxx=0,sum=0;
        	cin>>n;
        	ll a[n];
        	REP(i,0,n-1){cin>>a[i];maxx=max(maxx,a[i]);} 
        	int j=0; 
        	REP(i,0,n-1){
        		if(a[i]==maxx){
        			j=i;break;
        		}
        	}
        	REP(i,j,n-1) sum+=maxx-a[i];
        	REP(i,0,j-1){
        		if(a[i]>a[i+1]){
        			sum+=a[i]-a[i+1];
        			a[i+1]=a[i];
        		}
        	}
        	cout<<sum;

       


             }
             cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}


Measured memory_bytes: 5344
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vpii = vector<pair<int, int>>;

int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 1; i < n; i++)
  {
    int cnt = 0;
    for (char c = 'a'; c <= 'z'; c++)
    {
      bool left = false, right = false;
      for (int j = 0; j < i; j++)
      {
        if (s[j] == c)
          left = true;
      }
      for (int j = i; j < n; j++)
      {
        if (s[j] == c)
          right = true;
      }
      if (left && right)
        cnt++;
    }
    ans = max(ans, cnt);
  }
 

cout << ans << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h> 
#define pb push_back
#define F first
#define S second
#define M (ll)(1e9+7)
#define mp make_pair
  
using namespace std; 
typedef long long ll;
 
void solve()
{
    ll a,b,k;
    cin>>a>>b>>k;
    ll t=k;
    k-=min(a,k);
    a-=min(a,t);
    b-=min(b,k);
    cout<<a<<" "<<b<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
ans=max(a,b)*max(c,d)
ans3=min(a,b)*max(c,d)
ans4=max(a,b)*min(c,d)
ans2=min(a,b)*min(c,d)
print(max(ans,ans2,ans3,ans4))

Measured memory_bytes: 61616
N, M = map(int, input().split())
X = list(map(int, input().split()))

X.sort()
Y = [X[i]-X[i-1] for i in range(1, len(X))]
Y.sort()
if N < M:
    length = len(Y) - N + 1
    print(sum(Y[:length]))
else:
    print(0)


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

const double PI = acos(-1);
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
typedef pair<ll,pair<int,int>> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

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

    int n;
    cin >> n;

    set<pair<int,int>> ans;
    if (n&1) {
        REP(i,n-1) {
            ans.insert({min(n,i+1), max(n,i+1)});
        }
        n--;
    }
    for (int i = 1; i <= n/2; i++) {
        int a = i, b = n + 1 - i;
        REP(j,n) {
            if (j+1 == a || j+1 == b) continue;
            ans.insert({min(a,j+1), max(a,j+1)});
            ans.insert({min(b,j+1), max(b,j+1)});
        }
    }

    cout << ans.size() << endl;
    for (auto p: ans) {
        cout << p.fi << ' ' << p.se << endl;
    }
    return 0;
}


Measured memory_bytes: 512
use std::io;
use std::str::FromStr;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();

    let mut it = buf.split_whitespace().map(|n| i64::from_str(n).unwrap());
    let (x, a, b) = (it.next().unwrap(), it.next().unwrap(), it.next().unwrap());

    if a >= b {
        println!("delicious");
        return;
    }

    if (b - a) <= x {
        println!("safe");
        return;
    }
    println!("dangerous");

}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1000000007;
const long long INF = 1LL << 60;
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s; cin >> s;
    if(s == "Sunny") cout << "Cloudy" << endl;
    else if(s == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
    
    return 0;
}

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

using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; ++i) cin >> vec[i];
    sort(vec.begin(), vec.end());

    int ans = 0;

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < i; ++j) {
            for (int k = 0; k < j; ++k) {
                if (vec[k] != vec[j] and vec[i] != vec[j] and
                    vec[k] + vec[j] > vec[i]) {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
  int64_t n, k, ans = 0, tmp = 0;
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    if (i % k == 0) ++tmp;
  }
  ans += tmp * tmp * tmp;
  if (k % 2 == 0) {
    tmp = 0;
    for (int i = 1; i <= n; ++i) {
      if (i % k == (k / 2)) ++tmp;
    }
    ans += tmp * tmp * tmp;
  }
  
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<utility>

int main(){
    int a[3], tmp;

    std::cin >> a[0] >> a[1] >> a[2];

    if(a[0] > a[1]) std::swap(a[0], a[1]);
    if(a[1] > a[2]) std::swap(a[1], a[2]);
    if(a[0] > a[1]) std::swap(a[0], a[1]);

    std::cout << a[0] << " " << a[1] << " " << a[2] << std::endl;   
    
    return 0 ;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

template<unsigned P> struct ModInt {
  using M = ModInt;
  unsigned v;
  ModInt() : v(0) {}
  template<class Z> ModInt(Z x) : v(x >= 0 ? x % P : (P - -x % P) % P) {}
  constexpr ModInt(unsigned v, int) : v(v) {}
  static constexpr unsigned p() { return P; }
  M operator+() const { return *this; }
  M operator-() const { return {v ? P - v : 0, 0}; }
  explicit operator bool() const noexcept { return v; }
  bool operator!() const noexcept { return !(bool) *this; }
  M operator*(M r) const { return M(*this) *= r; }
  M operator/(M r) const { return M(*this) /= r; }
  M operator+(M r) const { return M(*this) += r; }
  M operator-(M r) const { return M(*this) -= r; }
  bool operator==(M r) const { return v == r.v; }
  bool operator!=(M r) const { return !(*this == r); }
  M& operator*=(M r) { v = (uint64_t) v * r.v % P; return *this; }
  M& operator/=(M r) { return *this *= r.inv(); }
  M& operator+=(M r) { if ((v += r.v) >= P) v -= P; return *this; }
  M& operator-=(M r) { if ((v += P - r.v) >= P) v -= P; return *this; }
  M inv() const {
    int a = v, b = P, x = 1, u = 0;
    while (b) {
      int q = a / b;
      swap(a -= q * b, b);
      swap(x -= q * u, u);
    }
    assert(a == 1);
    return x;
  }
  template<class Z> M pow(Z n) const {
    if (n < 0) return pow(-n).inv();
    M res = 1;
    for (M a = *this; n; a *= a, n >>= 1) if (n & 1) res *= a;
    return res;
  }
  template<class Z> friend M operator*(Z l, M r) { return M(l) *= r; }
  template<class Z> friend M operator/(Z l, M r) { return M(l) /= r; }
  template<class Z> friend M operator+(Z l, M r) { return M(l) += r; }
  template<class Z> friend M operator-(Z l, M r) { return M(l) -= r; }
  friend ostream& operator<<(ostream& os, M r) { return os << r.v; }
  friend istream& operator>>(istream& is, M& r) { lint x; is >> x; r = x; return is; }
  template<class Z> friend bool operator==(Z l, M r) { return M(l) == r; }
  template<class Z> friend bool operator!=(Z l, M r) { return !(l == r); }
};
using Mint = ModInt<(unsigned) 1e9 + 7>;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<Mint> a(n);
  a[0] = Mint(n).pow(-2);
  for (int i = 1; i < n; ++i) {
    a[i] = a[i - 1] + Mint(n).inv() / (n - i);
  }
  Mint res;
  for (int i = 0; i < n - 1; ++i) {
    res += a[i] * 2 / Mint(3).pow(i + 1);
  }
  res += a[n - 1] / Mint(3).pow(n - 1);
  res /= 3;
  cout << res << '\n';
}

Measured memory_bytes: 4224
N = int(input())

A = []

for i in range(1, 10):
    A.append(6 ** i)
    A.append(9 ** i)
    A.append(1)

B = [x for x in A if x < 1000000 ]


dp = [0] * (N + 1)
for i in range(N+1):
    if i == 0:
        dp[0] = 0
    else:
        tmp = 10 ** 10
        for j in B:
            if i >= j :
                tmp = min(tmp, dp[i-j]+1)
        dp[i] = tmp

print(dp[-1])

Measured memory_bytes: 3828
N = int(input())
h = list(map(int, input().split()))

#dp[i]:i番目に到達するまでにはらうコストの最小値

dp = [0 for i in range(N)]
dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2,N):
    cost_1 = dp[i-1] + abs(h[i]-h[i-1])
    cost_2 = dp[i-2] + abs(h[i]-h[i-2])
    dp[i] = min(cost_1, cost_2)

print(dp[N-1])

Measured memory_bytes: 13980
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) tsort(v); reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

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

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

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

    lint a,b,c,d;cin>>a>>b>>c>>d;
    if(min(b,d)-max(a,c)<0)co(0);
    else co(min(b,d)-max(a,c));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
const int MAX_N = 100, MAX_vi = 1000;
const int INF = 1e9+1;
vector<vector<int>> dp(MAX_N+1, vector<int>(MAX_N*MAX_vi+1, INF));
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n, w; cin >> n >> w;
   dp[0][0] = 0;
   rep(i,n){
      int wi, vi; cin >> wi >> vi;
      rep(j,MAX_N*MAX_vi+1){
         dp[i+1][j] = dp[i][j];
         if (j-vi >= 0)
            dp[i+1][j] = min(dp[i+1][j], dp[i][j-vi] + wi);
      }
   }
   int ans;
   rep(i,MAX_N*MAX_vi+1){
      if (dp[n][i] <= w)ans = i;
   }
   cout << ans << endl;
}

Measured memory_bytes: 42828
r,g,b,n = map(int,input().split())
cnt = 0
for i in range(0,n+1,r):
    for j in range(0,n+1-i,g):
        if (n - i - j)%b == 0 and (n - i - j)%b >= 0:
            cnt += 1
print(cnt)

Measured memory_bytes: 9180
#include <iostream>
#include <string>
using namespace std;
int main() {
	char a;
	cin >> a;
	if (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')cout << "vowel" << endl;
	else cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
bool _plus[10];
long long ans;
void dfs(int x)
{
    if(x==s.size()-1)
    {
        long long pre=0,sum=0;
        for(int i=0;i<=x;i++)
        if(_plus[i]){
            long long sumv=0;
            for(int j=pre;j<=i;j++) sumv=sumv*10+(s[j]-48);
            sum+=sumv;
            pre=i+1;
        }
        long long sumv=0;
        for(int j=pre;j<=x;j++) sumv=sumv*10+(s[j]-48);
        sum+=sumv;
		ans+=sum;
        return;
    }
    _plus[x]=0;
    dfs(x+1);
    _plus[x]=1;
    dfs(x+1);
}
int main()
{
    cin>>s;
    dfs(0);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,x=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        while(a[i]%2==0){
            a[i]/=2;
            x++;
        }
    }
    cout<<x<<endl;
    return 0;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;


//long long int ruizyo(long long int aa, long long int bb){
  //  if(aa==0){
    //    return 1;
    //}
    //else if(aa%2==0){
      //  long long int tt=ruizyo(aa/2,bb);
        //return (tt*tt)%MOD;
    //}
    //else{
      //  return (ruizyo(aa-1,bb)*bb)%MOD;
    //}
//}フェルマ－のア


//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

//visited=vector<vector<bool>>(10,vector<bool>(10,false));アを全部falseに


long long int n,cnt=0,ans=0,a[10000000],b[10000000],c,cmp,cmpp=0,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;

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

      cin>>n;
      rep(i,n){cin>>a[i];b[i]=a[i];}
      //奇数を正に
      rep(i,n){
          sum+=b[i];
          if(i%2==0){
              if(sum<=0){
                  cmp+=sum*-1+1;
                  sum=1;
              }
          }
          else{
              if(sum>=0){
                  cmp+=sum+1;
                  sum=-1;
              }
          }
         // Cout(cmp);
      }
     
     //Cout(cmp);
      sum=0;
      rep(i,n){
          sum+=a[i];
          if(i%2!=0){
              if(sum<=0){
                  cmpp+=sum*-1+1;
                  sum=1;
              }
          }
          else{
              if(sum>=0){
                 cmpp+=sum+1;
                  sum=-1;
              }
          }
      }
      ans=min(cmpp,cmp);
      Cout(ans);
return 0;
}


Measured memory_bytes: 3072
import math
N,K=map(int,input().split())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
for i in range(K):
  if N-K>i:
    ans=combinations_count(N-K+1,i+1)*combinations_count(K-1,i)
    ANS=ans%(10**9+7)
    print(ANS)
  elif N-K==i:
    ans=combinations_count(K-1,i)
    ANS=ans%(10**9+7)
    print(ANS)
  else:
    print(0)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n,m;
    cin >> n >> m;
    cout << (n*(n-1)+m*(m-1))/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int n;
vector<int> p;

void input(){
    cin >> n;
    p.resize(n);
    for(int i=0;i<n;i++) cin >> p[i];
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    int ans = 0;
    for(int i=0;i<n-1;i++){
        if(p[i] == i+1){
            swap(p[i], p[i+1]);
            ans++;
        }
    }
    if(p[n-1] == n){
        swap(p[n-2], p[n-1]);
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

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

    int n;
    cin >> n;
    string s;
    cin >> s;

    vector<int> A(n, 0);
    REP(i, n){
        if(s[i] == 'E'){
            A[i]++;
        }
        if(i > 0){
            A[i] += A[i - 1];
        }
    }

    int ans = 1e9;
    REP(i, n){
        if(i > 1){
            ans = min(ans, i - A[i - 1] + A[n - 1] - A[i]);
        }else{
            ans = min(ans, A[n - 1] - A[i]);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1812
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define zoom ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define precise cout.precision(8); cout << fixed;
#define seed srand(chrono::steady_clock::now().time_since_epoch().count());
const double PI = acos(-1);
using namespace std;

void solve() {
    int a; cin >> a;
    cout << a + a * a + a * a * a;
}

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

Measured memory_bytes: 3644
/*input
8
8 2 7 3 4 5 6 1
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

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

void solve(){
  	cin >> n;
  	RE(i,n){
  		int x;cin >> x;
  		ans[x] = i;
  	}
  	RE(i,n)cout << ans[i] << " ";
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 1664
letter="abcdefghijklmnopqrstuvwxyz"
table=[0]*26
while True:
    try:
        input_str=input()
    except:
        break
    for A in input_str:
        index=0
        for B in letter:
            if A == B or A == B.upper():
                table[index] += 1
                break
            index += 1

for i in range(len(letter)):
    print("%s : %d"%(letter[i],table[i]))



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

int main(){
    int q;
    cin>>q;
    vector<int>v;
    while(q--){
    int a,b;
    cin>>a;
    if(a!=2) cin>>b;
    if(!a)v.push_back(b);
    else if(a==1)cout<<v[b]<<endl;
    else v.erase(v.end()-1);
    }
    
}


Measured memory_bytes: 3836
N = int(input())
lst = []
for i in range(N):
  s, p = input().split()
  lst.append([s, p, i])
  lst_2 = sorted(lst, key = lambda x : (x[0], -1 * int(x[1])))
  
for i in lst_2:
  print(i[2] + 1)

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

typedef long long ll;
typedef double keytype;

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int main(){
    int n;
    double v[100];

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

    quicksort(v, 0, n-1);
    int sum = 0;
    for(int i = 0; i < n - 1; ++i){
        v[i+1] = (v[i] + v[i+1]) / 2.0;
    }

    printf("%f\n", v[n-1]);

    return 0;
}


Measured memory_bytes: 1724
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S, T;
    cin >> S >> T;
    int len = 0;
    rep(i, N) {
        bool ok = true;
        rep(j, N - i) {
            if (S[i + j] != T[j]) ok = false;
        }
        if(ok) len = max(len, N - i);
    }
    cout << N * 2 - len << endl;
    return 0;
}
// abcd
//  bcde

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

int main(){
  int X, A, B;
  cin >> X >> A >> B;
  if(B - A > X) cout << "dangerous" << endl;
  else if(B - A <= X && B > A) cout << "safe" << endl;
  else cout << "delicious" << endl;
  return 0;
}


Measured memory_bytes: 256
/*{{{*/
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    double pi=acos(-1);
    int r;
    R(r);
    W(2*r*pi);
    return 0;
}


Measured memory_bytes: 3756
from itertools import accumulate

def my_prime(n):
    if n==1:
        return 0
    for k in range(2, int(n**0.5)+1 ): #検索範囲注意
        if n%k ==0:
            return 0
    return 1


Q = int(input())
L = [0]*Q
R = [0]*Q

for i in range(Q):
    L[i], R[i] = list(map(int, input().split()))

min_L = min(L)
max_R = max(R)

ans=[]
for i in range(min_L, max_R +1):
    if i%2 == 1:
        flg = (my_prime(i) and my_prime((i+1)/2) )
    else:
        flg = 0
    ans.append(flg)

# ここに累積和
ans = [0] + ans
ans = list(accumulate(ans))

for i in range(Q):
    print(ans[R[i] - min_L + 1] - ans[L[i] - min_L])

Measured memory_bytes: 15120
import sys
sys.setrecursionlimit(10000000)
n=int(input())
s=[[]for i in range(n+1)]
g=[0]*(n+1)
h=[True]*(n+1)
for i in range(n-1):
    a,b,c=map(int,input().split())
    s[a].append([b,c])
    s[b].append([a,c])
def dfs(x):
    h[x]=False
    for i in s[x]:
        if h[i[0]]:
            g[i[0]]=g[x]+i[1]
            dfs(i[0])
q,k=map(int,input().split())
dfs(k)
for i in range(q):
    x,y=map(int,input().split())
    print(g[x]+g[y])

Measured memory_bytes: 138704
#include<stdio.h>
int main()
{
    int A,B;
    scanf("%d%d",&A,&B);
    if((A+B)%2==0)
    {
        printf("%d",(A+B)/2);
    }
    else if(A+B==5)
    {
    printf("1");
    }
    else if(A+B==3)
    {
    printf("3");
    }

    return 0;
}

Measured memory_bytes: 128
//QQ
class Main{
    public static void main(String[] a){
        int i = 1;
        int j = 1;
        for(;i<10;i++) {
            for(j=1;j<10;j++) {
                System.out.println(i+"x"+j+"="+(i*j));
            }
        }
    }
}

Measured memory_bytes: 17020
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

// 素集合データ構造
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
	  // 最初は全てのデータiがグループiに存在するものとして初期化
	  for(int i = 0; i < n; i++){
		  par[i] = i;
	  }
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};

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

	UnionFind uf(N);

	rep(i, M) {
		ll x, y, z;
		cin >> x >> y >> z;
		x--;y--;
		uf.unite(x, y);
	}

	set<ll> ans;
	rep(i, N) {
		ans.insert(uf.find(i));
	}
	cout << ans.size() << endl;




}


Measured memory_bytes: 8804