akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define 	pb 				push_back
#define 	MOD 			1000000007
#define 	pp 				pop_back
#define 	MAXN   			1000001
#define 	mp 				make_pair
#define 	endl 			'\n'
#define 	ff 				first
#define 	ss 				second
#define 	mapcl 			map<char,ll>
#define 	mapll 			map<ll,ll>
#define 	pll 			pair<ll,ll>
#define 	cmp 			complex<double>
#define 	pi 				3.141592653589793238462643383279502884197169399375105820974944592307816406286 
#define 	inf 			1000
#define 	vll 			vector<ll>
#define 	all(v) 			v.begin(),v.end()
#define 	fr(i,z,n) 		for(ll i=z;i<n;i++)
#define 	sqrt 			sqrtl
#define 	cbrt 			cbrtl
#define		ll 				long long
#define 	ld 				long double
bool 		coll(pll p1,pll p2,pll p3)		{if((p3.ss-p2.ss)*(p2.ff-p1.ff)==(p2.ss-p1.ss)*(p3.ff-p2.ff))return true;else return false;}
void		print(auto x)					{cout<<x<<endl;}
void 		pv(vector<auto> v)				{for(ll i=0;i<(ll)v.size();i++)cout<<v[i]<<" ";cout<<endl;}
void 		pvsl(vector<auto> v)			{for(ll i=0;i<(ll)v.size();i++)cout<<v[i]<<" ";}
void 		in(vector<auto> &v, ll n)		{v.resize(n);for(ll i=0;i<n;i++)cin>>v[i];}
void 		sortv(vector<auto> &v)			{sort(v.begin(),v.end());}
void 		fast()							{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
ll maxi(ll a, ll b){ 
	if (a > b)
		return a;
	return b;
}
ll mini(ll a, ll b){
	if (a > b)
		return b;
	return a;
}
string increment(string s){
	ll size = (ll)s.size();
	bool flag = true;
	//aaa
	for (ll i=size-1;i>=0;i--){
		s[i] += 1;
		if (s[i] > 'z'){
			s[i] = 'a';
		}
		else{
			flag = false;
			break;
		}
	}
	if (flag){
		s = 'a' + s;
	}
	return s;
}
int main(){
	ll n, m;
	cin >> n >> m;
	if (n == m){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <iomanip>
 
using namespace std;
 
struct Point
{
    double x,y;
};
 
Point a[1005],d;
double r;
 
double dist(Point A,Point B)
{
    return sqrt((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y));
}
 
double cross(Point A,Point B,Point C)
{
    return (B.x-A.x)*(C.y-A.y)-(C.x-A.x)*(B.y-A.y);
}
 
void MiniDiscWith2Point(Point p,Point q,int n)
{
    d.x=(p.x+q.x)/2.0;
    d.y=(p.y+q.y)/2.0;
    r=dist(p,q)/2;
    int k;
    double c1,c2,t1,t2,t3;
    for(k=1;k<=n;k++)
    {
        if(dist(d,a[k])<=r) continue;
        if(cross(p,q,a[k])!=0.0)
        {
            c1=(p.x*p.x+p.y*p.y-q.x*q.x-q.y*q.y)/2.0;
            c2=(p.x*p.x+p.y*p.y-a[k].x*a[k].x-a[k].y*a[k].y)/2.0;
            d.x=(c1*(p.y-a[k].y)-c2*(p.y-q.y))/((p.x-q.x)*(p.y-a[k].y)-(p.x-a[k].x)*(p.y-q.y));
            d.y=(c1*(p.x-a[k].x)-c2*(p.x-q.x))/((p.y-q.y)*(p.x-a[k].x)-(p.y-a[k].y)*(p.x-q.x));
            r=dist(d,a[k]);
        }
        else
        {
            t1=dist(p,q);
            t2=dist(q,a[k]);
            t3=dist(p,a[k]);
            if(t1>=t2&&t1>=t3)
            {
                d.x=(p.x+q.x)/2.0;
                d.y=(p.y+q.y)/2.0;
                r=dist(p,q)/2.0;
            }
            else if(t2>=t1&&t2>=t3)
            {
                d.x=(a[k].x+q.x)/2.0;
                d.y=(a[k].y+q.y)/2.0;
                r=dist(a[k],q)/2.0;
            }
            else
            {
                d.x=(a[k].x+p.x)/2.0;
                d.y=(a[k].y+p.y)/2.0;
                r=dist(a[k],p)/2.0;
            }
        }
    }
}
 
void MiniDiscWithPoint(Point pi,int n)
{
    d.x=(pi.x+a[1].x)/2.0;
    d.y=(pi.y+a[1].y)/2.0;
    r=dist(pi,a[1])/2.0;
    int j;
    for(j=2;j<=n;j++)
    {
        if(dist(d,a[j])<=r) continue;
        else
        {
            MiniDiscWith2Point(pi,a[j],j-1);
        }
    }
}
 
int main()
{
    int i,n;
    cin >> n;
    for(i=1;i<=n;i++)
        scanf("%lf %lf",&a[i].x,&a[i].y);
    if(n==1)
    {
        printf("%.2lf %.2lf 0.00\n",a[1].x,a[1].y);
        return 0;
    }
    r=dist(a[1],a[2])/2.0;
    d.x=(a[1].x+a[2].x)/2.0;
    d.y=(a[1].y+a[2].y)/2.0;
    for(i=3;i<=n;i++)
    {
        if(dist(d,a[i])<=r)continue;
        else MiniDiscWithPoint(a[i],i-1);
    }
    cout << setprecision(10) << r << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from operator import itemgetter
def input():
    return sys.stdin.readline()
N, M = map(int, input().split())
chk = {i+1: 1 for i in range(N)}
PY = sorted([list(map(int, input().split())) + [i+1] for i in range(M)], key=itemgetter(0,1))
ans = []
for i in range(M):
    idx = PY[i][0]
    ans.append(('{:0>6}{:0>6}'.format(idx, chk[idx]), PY[i][2]))
    chk[idx] += 1
ans.sort(key=itemgetter(1))
for k, v in ans:
    print(k)

Measured memory_bytes: 49988
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

const int INF = 19191919;

const int N = 100000;
vector<int> G[N];
int d[N][2];

int main(){
    int n,m;
    cin >>n >>m;
    rep(i,m){
        int u,v;
        cin >>u >>v;
        --u;
        --v;
        G[u].pb(v);
        G[v].pb(u);
    }

    rep(i,n)rep(j,2) d[i][j] = INF;
    d[0][0] = 0;
    queue<pi> que({{0,0}});
    while(!que.empty()){
        pi now = que.front();
        que.pop();
        int v = now.fi, p = now.se;
        for(int e:G[v]){
            if(d[e][!p] > d[v][p]+1){
                d[e][!p] = d[v][p]+1;
                que.push({e,!p});
            }
        }
    }

    int ans = INF;
    rep(p,2){
        int tmp = 0;
        rep(i,n) tmp = max(tmp, d[i][p]);
        ans = min(ans, tmp);
    }

    if(ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 10224
Train = Struct.new(:c, :s, :f)

N = gets.to_i
trains = Array.new(N-1) do
  c, s, f = gets.split.map(&:to_i) 
  Train.new(c, s, f)
end

(N-1).times do |i|
  sum = trains[i].c + trains[i].s
  (i+1..N-2).each do |j|
    if sum < trains[j].s
      sum = trains[j].s
    elsif sum % trains[j].f != 0
      sum += trains[j].f - sum % trains[j].f
    end
    sum += trains[j].c
  end
  puts sum
end
puts 0

Measured memory_bytes: 1788
parseInput input = map read $ words input :: [Int]

sumDigits n | n == 0 = 0
			| otherwise = mod n 10 + sumDigits(div n 10)

solve n | n `mod` sumDigits(n) == 0 = "Yes"
		| otherwise = "No"
main = do
	input <- getLine
	let [k] = parseInput input
	putStrLn (solve k)


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)	
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define LOOP while(true)
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(){
	int N, D, X;
	cin >> N >> D >> X;
	vector<int> A(N);
	vector<int> C(N, D - 1);
	rep(i, N){
		cin >> A[i];
		C[i] /= A[i];
		C[i]++;
	}
	int ans = X;
	rep(i, N)ans += C[i];
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,n,a[10000],max,p,m=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    max=a[0];
    for(i=0;i<n;i++)
    {
        if(max<=a[i])
        {
            max=a[i];
            p=i;
        }

    }
    for(i=0;i<n;i++)
    {
        if(i==p)
            continue;
        else
            m=m+a[i];
    }
    printf("%d\n",(max/2)+m);
    return 0;

}

Measured memory_bytes: 128
#include <iostream>
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;
int m[30] = {};
bool p[1000000] = {}, b[1000000] = {};

void calc(int n, int x) {
	rep(i,n) {
		int a = m[i];
		rep2(j,a,x+1) {
			if(b[j-a]) b[j] = 1;
		}
	}
}
int main(){
	int n, x;
	p[0] = p[1] = 1;
	rep2(i,2,1001) {
		if(!p[i]) {
			for(int j = 2*i; j < 1000000; j+=i) {
				p[j] = 1;
			}
		}
	}

	while(cin >> n >> x, (n||x)) {
		fill(m,m+30,0);
		rep(i,n) {
			cin >> m[i];
		}
		rep(i,1000000) {
			b[i] = 0;
		}
		b[0] = 1;
		calc(n,x);
		int i = x;
		for(; i > 0; --i) {
			if(!p[i] && b[i]) {
				cout << i << endl;
				break;
			}
		}
		if(i==0) cout << "NA" << endl;
	}
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N, D;
  cin >> N >> D;
  D = D * 2 + 1;

  if (N % D == 0) {
    COUT(N / D);
  } else {
    COUT(N / D + 1);
  }
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

"""
allsum = 0
for i in range(n-1):
    allsum += a[i] * sum(a[i+1:])
print(allsum % (10**9+7))
"""
s, s2 = 0, 0
for i in range(n):
    s += a[i]
    s2 += a[i] * a[i]
print(((s*s - s2)//2) % (10**9+7))


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

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

const ll mod =  1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

bool f[100005];
bool s[100005];

int main()
{
    int n;   cin >> n;
    int f_dis[n];
    int s_dis[n];
    vector<int> G[100005];
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i,n){
        f_dis[i] = 0;
        s_dis[i] = 0;
    }
    queue<int> qf;
    qf.push(0);
    f_dis[0] = 0;
    
    while(!qf.empty()){
        int now = qf.front(); qf.pop();
        f[now] = true;
        for(auto next : G[now]){
            if(!f[next]){
                qf.push(next);
                f_dis[next] = f_dis[now] + 1;
            }

        }
    }
    queue<int> qs;
    qs.push(n-1);
    s_dis[n-1] = 0;
    while(!qs.empty()){
        int now = qs.front(); qs.pop();
        s[now] = true;
        for(auto next : G[now]){
            if(!s[next]){
                qs.push(next);
                s_dis[next] = s_dis[now] + 1;
            }
        }
    }
    int f_cnt = 0,s_cnt = 0;
    rep(i,n){
        if(f_dis[i] <= s_dis[i]) f_cnt++;
        else if(f_dis[i] > s_dis[i]) s_cnt++;
    }
    if(f_cnt > s_cnt) cout << "Fennec";
    else cout << "Snuke";
}

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

using namespace std;

int main()
{
	string str[128];
	string ans[128];
	int page[128];
	int i,j,k;
	char aa[64];
	
	cin >> str[0] ;
	for(i=0;cin >> page[i] ;i++)
	{
		cin >> str[i+1] ;
	}
	for(j=0;j<i;j++)
	{
		for(k=j+1;k<i;k++)
		{
			if(str[j]>str[k])
			{
				string a;
				int p;
				a=str[j];	str[j]=str[k];	str[k]=a;
				p=page[j];	page[j]=page[k];	page[k]=p;
			}
		}
	}
	for(j=0;j<i;j++)
	{
		for(k=j+1;k<i;k++)
		{
			if(str[j]==str[k])
			{
				if(page[j]>page[k])
				{
					int a;
					a=page[j];
					page[j]=page[k];
					page[k]=a;
//					cout << "page replaced" << endl;
//					cout << "word:" << str[j] << " page1:" << page[j] << " page2:" << page[k] << " j:" << j << " k:" << k << endl;
				}
			}
		}
	}
	
	for(j=0;j<i;j++)
	{
		if(str[j]!="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz")
		{
			sprintf(aa,"%d",page[j]);
			ans[j]+=aa;
			for(k=j+1;k<i;k++)
			{
				if(str[j]==str[k])
				{
					str[k]="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
					sprintf(aa,"%d",page[k]);
					ans[j]+=" ";
					ans[j]+=aa;
				}
			}
		}
	}
	
	for(j=0;j<i;j++)
	{
		if(str[j]!="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz")
		{
			cout << str[j] << endl;
			cout << ans[j] << endl;
		}
	}
}

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

int main(){
  int cnt1=0, cnt2=0;
  string s;
  cin >> s;
  rep(i, s.size()){
    if(i%2==0){
      if(s[i]=='R'||s[i]=='U'||s[i]=='D')cnt1++;
    }
    else{
      if(s[i]=='L'||s[i]=='U'||s[i]=='D')cnt2++;
    }
  }

  if(cnt1+cnt2==s.size())cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3616
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
    int N, M;
    if (scanf("%d%d", &N, &M) < 2) return 0;

    //double p = 1 / pow(2, M);
    //double ans = 1900 * M + 100 * (N - M);
    //ans = ans / p;
    double ans = (1900 * M + 100 * (N - M)) * pow(2, M);

    printf("%d\n", (int)ans);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int a[100], i, j, n;

	scanf("%d", &n);

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

	for (j = n - 1; j >= 0; j--)
	{
		printf("%d", a[j]);

		if (j != 0)
		{
			printf(" ");
		}
	}
	printf("\n");

	return 0;

}


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

int main(){
	int n, k;
	cin >> n >> k;
	int cur = 1;
	for(int i = 0; i < n; i++){
		if(2*cur < cur + k)cur *= 2;
		else cur += k;
	}
	cout << cur << endl;
}

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) {
        // 自分の得意な言語で
        // Let's チャレンジ！！
        InputStreamReader ist = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(ist);

        String str = null;

        try{
            str = br.readLine();
            br.close();
        }catch(IOException e){
            e.printStackTrace();
        }

        String number[] = str.split(" ",0);

        int num[] = new int[2];
        int sum = 0;

        for(int i = 0;i < 2;i++){
            num[i] = Integer.parseInt(number[i]);
        }


        int a,b;
        a = num[0]*num[1];
        b = 2*(num[0]+num[1]);
        System.out.println(a + " " + b);
    }
}



Measured memory_bytes: 24176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ABC
{
    class ABC_IHCA
    {
        const string FILE = "/tmp/data.txt";

        static void Main(string[] args)
        {
#if DEBUG
            Console.SetIn(new StreamReader(FILE));
#endif
            long D = RL();
            long[] Ca = RLa(26);
            long[,] La = RLa(D, 26);

            for (int i = 0; i < D; ++i)
            {
                Console.WriteLine(max(La, i) + 1);
            }

#if DEBUG
            Console.WriteLine("*** end ***");
            Console.SetIn(Console.In);
            Console.ReadKey();
            Console.WriteLine();
#endif
        }

        static int max(long[,] La, int i)
        {
            long m = 0;
            int midx = -1;
            for (int j = 0; j < 26; ++j)
            {
                if (La[i, j] > m)
                {
                    m = La[i, j];
                    midx = j;
                }
            }
            return midx;
        }

        static long RL()
        {
            return long.Parse(Console.ReadLine());
        }

        static long[] RLa(long n)
        {
            string[] sa = Console.ReadLine().Split(' ');
            long[] la = new long[n];
            for (int i = 0; i < n; ++i)
            {
                la[i] = long.Parse(sa[i]);
            }
            return la;
        }

        static long[,] RLa(long r, long c)
        {
            long[,] la = new long[r, c];
            for (int i = 0; i < r; ++i)
            {
                string[] sa = Console.ReadLine().Split(' ');
                for (int j = 0; j < c; ++j)
                {
                    la[i, j] = long.Parse(sa[j]);
                }
            }
            return la;
        }
    }
}


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

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1]; // 横、縦、左下、右下

bool X[N][N];

void initialize(){ //最初は駒がないので全てFREEに初期化する。
  for(int i = 0;i<N;i++){
    row[i]=FREE;
    col[i]=FREE;
  }    
    for(int i = 0;i<2*N-1;i++){
      dpos[i] = FREE;
      dneg[i] = FREE;
    }
}

void printBoard(){ // 出力関数
  for(int i = 0;i<N;i++){
    for(int j = 0;j<N;j++){
      if(X[i][j] == true){
	if(row[i] != j)return;
      }
    }
  }
  for(int i;i<N;i++){
    for(int j = 0;j<N;j++){
      cout << ((row[i] == j) ? "Q" : "." );
    }
    cout << endl;
  }
}

void recursive(int i){
  if(i==N){ // クイーンの配置が成功した場合
    printBoard();return;
  }

  for(int j=0;j<N;j++){
    //(i,j)が他のクイーンに襲撃されている場合は無視
    if(col[j] == NOT_FREE ||
       dpos[i+j] == NOT_FREE ||
       dneg[i-j+N-1] == NOT_FREE) continue;
    // (i,j)にクイーンを配置する
    row[i] = j; col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
    // 次の行を試す
    recursive(i+1);
    // (i,j)に配置されているQを取り除く
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE; 
  }
  // クイーンの配置に失敗
}

int main(){
  int k,r,c;

  initialize();
  
  for(int i = 0;i < N;i++){
    for(int j = 0;j<N;j++) X[i][j] = false;
  }

  cin >> k;
  for(int i = 0;i<k;i++){
    cin >> r >> c;
    X[r][c] = true;
  }
  recursive(0);
  
  return 0;
}



Measured memory_bytes: 3116
public class Hello{
    public static void Main(){

        int N = int.Parse(System.Console.ReadLine());
        int[] d = new int[N];
        for(int i = 0; i < N; i++) d[i] = int.Parse(System.Console.ReadLine());

        //餅を昇順に並び替える
        System.Array.Sort(d);

        //隣を比較して、異なればカウント(最低1個ある)
        int count = 1;
        for(int i = 0; i < N - 1; i++){
            if(d[i] != d[i+1]) count++;
        }
        System.Console.WriteLine(count);
    }
}


Measured memory_bytes: 13140
n=int(input())
# s=[input().split(" ") for i in range(n)]
JPY=0
BTC=0

for i in range(n):
    s=input().split()
    x=float(s[0])
    u=s[1]
    if(u=="JPY"):
        JPY+=x
    else:
        BTC+=x

print(JPY+BTC*380000)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1<<28)
#define int long long
#define double long double
#define floot10 cout<<fixed<<setprecision(10)


signed main(){
  int h,w;
  cin>>h>>w;
  vector<int> a,b;
  lp(i,h){
    int x;
    cin>>x;
    a.push_back(x);
  }
  lp(i,w){
    int x;
    cin>>x;
    b.push_back(x);
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  int bit=0,bsum=0,ans=0;
  lp(i,a.size()){
    int now=a[i];
    while(1){
      if(bit==b.size()) break;
      if(b[bit]<now){
	bsum+=b[bit];
	bit++;
      }
      else{
	break;
      }
    }
    ans+=now*(w-bit)+bsum;
  }
  cout<<ans<<endl;
  return 0;
}





Measured memory_bytes: 5244
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Linq.Enumerable;
using static System.Math;

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());

        var ans = ModInt.Pow(new ModInt(10), N) - ModInt.Pow(new ModInt(9), N) * new ModInt(2) + ModInt.Pow(new ModInt(8), N);

        WriteLine(ans);
    }
}

struct ModInt
{
    public const int Mod = 1000000007;

    public long X { get; }

    public ModInt(long x = 0) => X = (x % Mod + Mod) % Mod;

    public static ModInt operator +(ModInt mint) => mint;
    public static ModInt operator -(ModInt mint) => new ModInt(-mint.X);
    public static ModInt operator +(ModInt mint1, ModInt mint2) => new ModInt(mint1.X + mint2.X);
    public static ModInt operator -(ModInt mint1, ModInt mint2) => new ModInt(mint1.X - mint2.X);
    public static ModInt operator *(ModInt mint1, ModInt mint2) => new ModInt(mint1.X * mint2.X);
    public static ModInt operator /(ModInt mint1, ModInt mint2) => mint1 * Inv(mint2);

    public static ModInt Pow(ModInt mint, long t)
    {
        if (t == 0)
            return new ModInt(1);

        var a = Pow(mint, t >> 1);
        a *= a;

        if (t % 2 == 1)
            a *= mint;

        return a;
    }

    public static ModInt Inv(ModInt mint) => Pow(mint, Mod - 2);

    public override string ToString() => X.ToString();
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 27528
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
const int N=2005;
int n;
char ans[N][N];
const char S4[4][4]={{'a','a','b','c'},
					 {'d','d','b','c'},
					 {'e','f','g','g'},
					 {'e','f','h','h'}};
const char S5[5][5]={{'a','a','b','b','c'},
					 {'h','i','i','.','c'},
					 {'h','.','.','j','d'},
					 {'g','.','.','j','d'},
					 {'g','f','f','e','e'}};
const char S7[7][7]={{'.','a','a','b','b','c','c'},
					 {'a','d','f','f','.','.','.'},
					 {'a','d','.','g','.','.','.'},
					 {'b','e','e','g','.','.','.'},
					 {'b','.','.','.','d','g','g'},
					 {'c','.','.','.','d','.','f'},
					 {'c','.','.','.','e','e','f'}};
bool fr[1005];
int main(){
	scanf("%d",&n);
	if (n==2) return puts("-1"),0;
	For(i,1,n) For(j,1,n) ans[i][j]='.';
	if (n%3==0){
		for (int i=1;i<=n;i+=3){
			ans[i][i]=ans[i][i+1]='a';
			ans[i+1][i+2]=ans[i+2][i+2]='a';
		}
	}
	else{
		fr[0]=1;
		For(i,0,n) if (fr[i])
			fr[i+4]=fr[i+5]=fr[i+7]=1;
		assert(fr[n]);
		int m=n;
		for (;n;){
			if (n>=4&&fr[n-4]){
				For(i,0,3) For(j,0,3)
					ans[n-i][n-j]=S4[i][j];
				n-=4;
			}
			if (n>=5&&fr[n-5]){
				For(i,0,4) For(j,0,4)
					ans[n-i][n-j]=S5[i][j];
				n-=5;
			}
			if (n>=7&&fr[n-7]){
				For(i,0,6) For(j,0,6)
					ans[n-i][n-j]=S7[i][j];
				n-=7;
			}
		}
		n=m;
	}
	For(i,1,n)
		printf("%s\n",ans[i]+1);
}


Measured memory_bytes: 3200
package main

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

type io struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func newIO() *io {
	return &io{
		scanner: bufio.NewScanner(os.Stdin),
		writer:  bufio.NewWriter(os.Stdout),
	}
}

func (io *io) nextLine() string {
	io.scanner.Scan()
	return io.scanner.Text()
}

func (io *io) nextInt() int {
	i, e := strconv.Atoi(io.nextLine())
	if e != nil {
		panic(e)
	}
	return i
}

func (io *io) scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		num = io.nextInt()
		nums = append(nums, num)
	}
	return
}

func (io *io) printLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func sumSlice(nums []int) int {
	sum := 0
	for _, n := range nums {
		sum += n
	}
	return sum
}

func binarySearch(target int, list []int) int {
	left := 0
	right := len(list) - 1
	mid := (left + right) / 2

	for {
		if list[mid] < target {
			left = mid + 1
		} else {
			right = mid
		}
		mid = (left + right) / 2
		if left >= right {
			break
		}
	}
	return mid
}

// IO |
var IO = newIO()

func main() {
	IO.scanner.Split(bufio.ScanWords) // switch to separating by space
	// scanner.Buffer([]byte{}, 1000000009) // switch to read large size input

	N := IO.nextInt()
	coordinates := IO.scanNums(N)
	coordinates = append(coordinates, 0)
	costs := make([]int, N+1)

	prev := 0
	cost := 0
	for i, c := range coordinates {
		cost = abs(c - prev)
		costs[i] = cost
		prev = c
	}

	totalCost := sumSlice(costs)

	difference := 0
	reference := 0

	for i := 0; i < N; i++ {
		if i == 0 {
			reference = 0
		} else {
			reference = coordinates[i-1]
		}

		difference -= costs[i]
		difference -= costs[i+1]
		difference += abs(coordinates[i+1] - reference)

		IO.printLn(totalCost + difference)
		difference = 0
	}
	IO.writer.Flush()
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N, K;
  cin >> N >> K;

  string S;
  cin >> S;

  vector<P> run_length;
  vll sums;

  char before;
  ll count;
  ll all_count = 0;
  rep(i, N) {
    all_count++;
    if (i == 0) {
      before = S[i];
      count = 1;
      // sums.pb(0);
      continue;
    }

    if (S[i] == before) {
      count++;
    } else {
      debug(before);
      debug(count);
      debug(all_count);
      run_length.pb({before, count});
      sums.pb(all_count - 1);
      count = 1;
      before = S[i];
    }
  }
  run_length.pb({before, count});
  sums.pb(all_count);

  debugV(sums);

  ll ans = 0;
  rep(i, run_length.size()) {
    char num = run_length[i].first;
    if (num == '1') {
      if (i + 2 * K <= (ll)sums.size() - 1) {
        if (i == 0) {
          ans = max(ans, sums[i + 2 * K] - 0);
          continue;
        } else {
          ans = max(ans, sums[i + 2 * K] - sums[i - 1]);
          continue;
        }
      } else {
        if (i == 0) {
          ans = max(ans, sums[sums.size() - 1] - 0);
        } else {
          ans = max(ans, sums[sums.size() - 1] - sums[i - 1]);
        }
        continue;
      }
    }
    if (num == '0' && i == 0 && i + 2 * K - 1 <= (ll)sums.size() - 1) {
      ans = max(ans, sums[i + 2 * K - 1] - 0);
      continue;
    }
    if (num == '0' && i == 0 && i + 2 * K - 1 > (ll)sums.size() - 1) {
      ans = max(ans, sums[sums.size() - 1] - 0);
      continue;
    }
  }
  if (ans == 0) {
    COUT(N);
  } else {
    COUT(ans);
  }

  return 0;
}

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

#define MaxN 2005
#define INF 2140000000

using namespace std;

int N,Q,K,Min=INF,v[MaxN],s[MaxN];
multiset<int>Act,All;

int Solve(int tresh)
{
    Act.clear();
    All.clear();

    for(int i=1;i<=N;i++)
    {
        if(v[i]<tresh)
        {
            int Limit=Act.size()-K;
            for(auto x:Act)
            {
                if(Limit<0)
                    break;
                Limit--;
                All.insert(x);
            }
            Act.clear();
        }
        else
            Act.insert(v[i]);
    }
    int Limit=Act.size()-K;
    for(auto x:Act)
    {
        if(Limit<0)
            break;
        All.insert(x);
        Limit--;
    }
    if(All.size()<Q)
        return INF;
    else
    {
        int p=1;
        for(auto x:All)
        {
            if(p==Q)
                return x;
            else p++;
        }
    }
}

int main()
{
    cin>>N>>K>>Q;
    for(int i=1;i<=N;i++)
        cin>>v[i],s[i]=v[i];
    sort(s+1,s+1+N);

    s[0]=-1;

    for(int i=1;i<=N;i++)
        if(s[i]!=s[i-1])
            Min=min(Min,Solve(s[i])-s[i]);
    cout<<Min;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <map>
#include <vector>
//#include <unordered_map>
//#include <unordered_set>
#include <stack>
#include <set>
#include <queue>
#include <list>
typedef long long LL;
using namespace std;
int main()
{
    int n,z;
    scanf("%d",&n);
    int k,a=0,b=0;
    for(int i=0;i<n;++i)
    {
        scanf("%d",&k);
        if(k%4==0)
        {
            ++a;
        }else if(k%2==0)
        {
            ++b;
        }
    }
    z=0;
    if(n&1) z=1;
    if(a*2+z+b>=n)
    {
        puts("Yes");
    }else puts("No");
	return 0;
}


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

using namespace std;

int truck[100000+10],A[100000+10];
int n,k,sum=0;

int check(int load,int k,int tot)
{
    int j=0;
    for(int i=0;i<k;i++)
    {
        truck[i]=0;
        while(j<n)
        {
          int temp=truck[i]+A[j];
          if(temp<=load)
          {
           truck[i]=temp;
           tot-=A[j];
           j++;
          }
          else break;
        }
    }
    if(tot>0) return 0; //说明k辆卡车无法装载所有货物
    else  return 1;//说明k辆卡能够装载所有货物
}

int Binary_sech(int left,int right)
{
    while(left+1<right)
    {
        int mid=(left+right)/2;
        if(check(mid,k,sum)) right=mid;//由于卡车无法装载所有货物，因此需要在更大范围内搜索P值
        else left=mid;//由于卡车能够装载所有货物，因此可以考虑在更小范围内进行搜索
    }
    return right;
}

int main()
{
    scanf("%d %d",&n,&k);

    for(int i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
        sum+=A[i];
    }
    int P=0;
    int res=Binary_sech(0,sum);
    printf("%d\n",res);
    return 0;
}



Measured memory_bytes: 3980
//grid-1
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <vector <int>> vvi;
typedef vector <vector <long long>> vvll;
typedef vector <long long> vll;
typedef pair <int, int> pii;
typedef pair<ll , ll> pll;
typedef vector <pair <int, int>> vpii;

const int MOD = 1e9 + 7;

int main()
{
    int h, w; cin >> h >> w;
    char in;
    ll state[h][w];
    memset(state, 0, sizeof(state));
    state[0][0] = 1;
    for(int i = 0; i < h; i++)
        for(int j = 0; j < w; j++)
        {
            cin >> in;
            if(in == '#') state[i][j] = -1;
        }

    for(int i = 0; i < h; i++)
        for(int j = 0; j < w; j++)
        {
            if(!(state[i][j]+1)) continue;
            if(i + 1 < h && state[i+1][j]+1) state[i+1][j] = (state[i+1][j] + state[i][j]) % MOD;
            if(j + 1 < w && state[i][j+1] + 1) state[i][j+1] = (state[i][j+1] + state[i][j]) % MOD;
        }
    
    cout << state[h-1][w-1] << endl;
}

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

int main() {
	string w;
	cin >> w;
	if (w.size() % 2 != 0){
		cout << "No" << endl;
		return 0;
	}
	int c[26] = {};
	for (int i = 0;i < w.size();i++) {
		c[w[i] - 'a']++;
	}
	for (int i = 0;i < w.size();i++) {
		if (c[w[i] - 'a'] % 2 != 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<bitset>
#include <numeric>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define LONG_INF 9223372036854775807
#define INF 1000000000LL
#define EPS 1e-10
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define dump(a) rep(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define all(v) v.begin(),v.end()
#define pb push_back

#define INT 1.01

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

    int64_t X; // llと比較して実行時間が大幅に速い (2205ms->2ms)
    cin >> X;

    int64_t v = 100;
    //while(true){ //while, for文では実行時間は変わらない
    rep(ret, INF){
        if(X<=v){
            cout << ret << endl;
            break;
        }
        v *= INT; // 実行時間が2ms->6msへと伸びる
        //v += 0.01*v;
    }

    //cout << ret << endl;

    return 0;
}


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

int main(){
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  cout << y1-y2+x2 << " " << x2-x1+y2 << " " << x1+y1-y2 << " " << y1-x1+x2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<string>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
int main() {
	ll N;
	cin >> N;
	ll d[N + 100];
	for (ll i = 0; i < N; i++){cin >> d[i];}
	map<ll, ll>mp;
		for (ll i = 0; i < N; i++) {
			mp[d[i]]++;
		}
	ll res = 0;
    for (ll i=1; i<=100; i++){
		if (mp[i]>0)res++;
}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c) {cout << 1 << endl;}
  else if (a != b && b != c && c != a) { cout << 3 << endl; }
  else { cout << 2 << endl; }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define sign(a) ((a>0)-(a<0))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LL long long
#define INF (LL)(1LL<<60)
#define all(a) a.begin(), a.end()
#define gr greater<LL>()

using namespace std;

const long long MOD = 2019;

void solve(long long L, long long R){
    vector<int> tab;
    if(R-L > 2019){
        cout << 0 << endl;
    }else {
        LL ans = INF;
        for (LL i = L; i <= R - 1; i++) {
            for (LL j = i + 1; j <= R; j++) {
                ans = min(ans, (i * j) % MOD);
            }
        }
        cout << ans << endl;
    }
}

int main(){
    long long L;
    scanf("%lld",&L);
    long long R;
    scanf("%lld",&R);
    solve(L, R);
    return 0;
}


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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define R(i,n) for(int i = 0; i < (n); i++)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}

template<class T> ostream &operator<<(ostream& os, set<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}

template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAX = 101;
vector<int> d[MAX];
int n;
PII spr1(int a){
  vector<int> degs;
  vector<int> vis(MAX);
  vector<int> s1,s2;
  s1.PB(a);
  vis[a] = 1;
  int gl = 0;
  while(SZ(s1)){
    degs.PB(0);
    for(int v:s1){
      maxi(degs[gl],SZ(d[v]));
      for(int el:d[v]){
        if(!vis[el]){
          vis[el] = 1;
          s2.PB(el);
        }
      }
    }
    gl++;
    swap(s1,s2);
    s2.clear();
  }
  int il = 1;
  R(i,gl-1){
    il *= degs[i] - (i != 0);
  }
  return {gl,il};
}
PII spr2(int a,int b){
  vector<int> degs;
  vector<int> vis(MAX);
  vector<int> s1,s2;
  s1.PB(a);
  s1.PB(b);
  vis[a] = vis[b] = 1;
  int gl = 0;
  while(SZ(s1)){
    degs.PB(0);
    for(int v:s1){
      maxi(degs[gl],SZ(d[v]));
      for(int el:d[v]){
        if(!vis[el]){
          vis[el] = 1;
          s2.PB(el);
        }
      }
    }
    gl++;
    swap(s1,s2);
    s2.clear();
  }
  int il = 2;
  R(i,gl-1){
    il *= degs[i] - 1;
  }
  return {gl,il};
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n;
  R(i,n-1){
    int a,b;
    cin >> a >> b;
    a--;b--;
    d[a].PB(b);
    d[b].PB(a);
  }
  PII res = {100,-1};
  R(i,n)mini(res,spr1(i));
  R(i,n)for(int el:d[i]){
    mini(res,spr2(i,el));
  }
  cout << res.FI << " " << res.SE << "\n";
}




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

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

struct edge{
    int to,cost;
};
int v,e,r;

vector<edge> G[100010]; //グラフを入れる隣接リスト
vector<int> d(100010,INF); //頂点rから各頂点への最短距離。パスが無い場合はINF

void dijkstra(){
    priority_queue<P> q; //最後に見た頂点から次に見る可能性のある頂点の(コスト、頂点番号)をpairで保存
    q.push(MP(0,r)); 
    while(!q.empty()){
        P p=q.top(); //キューから取り出す
        q.pop(); //キューからは削除
        int now=p.se; //今見る頂点番号がnowに入る
        int cost=-p.fi;
        if(cost>d[now]) continue;  //見た距離が求めた現状の最短距離より大きければその時点で切る
        rep(i,0,G[now].size()){ //今いる頂点から直接辺が張られている頂点を全て走査
            edge e=G[now][i];
            int to=e.to; //nowに繋がる頂点番号
            int new_cost=cost+e.cost; //頂点nowまでの最短距離と、nowとtoを繋ぐ辺のコストの和、つまり頂点toへ辿り着ける最短経路の候補となる距離
            if(new_cost<d[to]){ //nowの距離が今まで求めた最短経路より小さければd[]を更新
                d[to]=new_cost;
                q.push(MP(-d[to],to)); //更新できれば頂点toのデータをキューに入れる（次に見る頂点の候補）。priority_queueの性質上、一番小さい値を取ってくるので、マイナスにして入れる
            }
        }
    }
}
int main(){
    cin>>v>>e>>r;
    d[r]=0;
    rep(i,0,e){
        int a,b,c;
        cin>>a>>b>>c;
        G[a].pb(edge{b,c});
    }
    dijkstra();
    rep(i,0,v){
        if(d[i]==INF)cout<<"INF"<<endl;
        else cout<<d[i]<<endl;
    }
    
    
    return 0;
}



Measured memory_bytes: 13096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		for (int i=1; i*k<=b; i++){
			if (i*k >= a && i*k <=b){
				System.out.println("OK");
				return;
			}
		}
		System.out.println("NG");
	}
}

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

void chmax(ll &a, const ll b) { if (a < b) a = b; return; }
const ll INF = 1ll<<60;

int main() {
    int n; cin >> n;
    vector<ll> a(n); for (int i = 0; i < n; i++) cin >> a[i];
    if (n % 2 == 0) {
        ll count = 0;
        for (int i = 0; i < n; i += 2) count += a[i];
        ll ans = count;
        for (int i = n-2; i >= 0; i -= 2) {
            count += a[i+1];
            count -= a[i];
            chmax(ans,count);
        }
        cout << ans << endl;
        return 0;
    }
    else {
        vector<vector<ll>> dp(n+2,vector<ll>(3,-INF));
        dp[0][0] = 0ll;
        for (int i = 1; i <= n+1; i++) {
            for (int j = 0; j < 3; j++) {
                if (i-2 >= 0) chmax(dp[i][j], dp[i-2][j] + a[i-2]);
            }
            for (int j = 1; j < 3; j++) {
                if (i-1 >= 0) chmax(dp[i][j], dp[i-1][j-1]);
            }
        }
        cout << dp[n+1][2] << endl;
        return 0;
    }
}

Measured memory_bytes: 15612
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    char c;
    cin>>c;
    if(c=='A')
        {
        cout<<'T'<<endl;

    }
    else if(c=='C')
    {
        cout<<'G'<<endl;
    }

      else if(c=='T')
    {
        cout<<'A'<<endl;
    }
    else if(c=='G')
    {
        cout<<'C'<<endl;
    }

    return 0;


}







Measured memory_bytes: 3584
#include<iostream> 
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main(){	
	int n;
	cin>>n;
	int h[n];
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	int mn=h[n-1];
	for(int i=n-1;i>=0;i--){
		if(h[i]>mn){
			h[i]--;
		}
		else{
			mn=h[i];
		}
	}
	for(int i=1;i<n;i++){
		if(h[i-1]<=h[i]){
			continue;
		}
		else{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
    return 0;
} 

Measured memory_bytes: 640
def merge(a, l, m, r):
    global cnt
    ll = a[l:m] + [1e9 + 1]
    rl = a[m:r] + [1e9 + 1]
    i, j = 0, 0
    for k in range(l, r):
        if ll[i] < rl[j]:
            a[k] = ll[i]
            i += 1
        else:
            a[k] = rl[j]
            j += 1
        cnt += 1


def merge_sort(a, l, r):
    if l + 1 < r:
        m = (l + r) // 2
        merge_sort(a, l, m)
        merge_sort(a, m, r)
        merge(a, l, m, r)


n, a, cnt = int(input()), list(map(int, input().split())), 0
merge_sort(a, 0, n)
print(*a)
print(cnt)

Measured memory_bytes: 63848
#include <iostream>
#include <set>
#include <stack>
using namespace std;

int main () {
	set<int> A;
	stack<int> B;
	int n, q, m, a, s;
	cin >> n;
	cin >> a;
	A.insert(a);
	set<int>::iterator itA;
	for (int i = 1; i < n; i++) {
		cin >> a;
		s = A.size();
		itA = A.begin();
		for (int j = 0; j < s; j++) {
			B.push(a + *itA);
			itA++;
		}
		s = B.size();
		for (int j = 0; j < s; j++) {
			A.insert(B.top());
			B.pop();
		}
		A.insert(a);
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> m;
		if (A.count(m))
			cout << "yes" << endl;
		else
			cout << "no" << endl;
	}
	return 0;
}

Measured memory_bytes: 3124
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n, m = readmi()
a = readl()
d = defaultdict(int)
k = []
for i in a:
    heapq.heappush(k,(-i, 1))
for i in range(m):
    x, y = readmi()
    heapq.heappush(k,(-y, x))
count = 0
while(n > 0):
    x, y = heapq.heappop(k)
    count += min(y * (-x), n * (-x))
    n = max(n - y, 0)
print(count)

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

void solve(long long T, long long X){
    printf("%.3f\n", (double)T / (double)X);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long T;
    scanf("%lld",&T);
    long long X;
    scanf("%lld",&X);
    solve(T, X);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	string t=s;
	reverse(t.begin(), t.end());
	for(int i=0;i<t.size();i++){
		if(t[i]=='b')t[i]='d';
		else if(t[i]=='d')t[i]='b';
		else if(t[i]=='p')t[i]='q';
		else if(t[i]=='q')t[i]='p';
	}
	if(s==t)printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 3840
//テスト
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1000000007;
// const ll INF = 1000000000000000000LL;


int main(){
    int d;
    cin >> d;
    vector<int> c(26);
    rep(i,26) cin >> c[i];
    vector<vector<int>> s(d,vector<int>(26));
    rep(i,d){
        rep(j,26){
            cin >> s[i][j];
        }
    }
    ll sum=0;
    vector<int> last(26);
    //答え入れる配列
    vector<int> ans(d);

    for(int i=0;i<d;i++){
        ll nax=-INF;
        ll nax_i;
        rep(j,26){
            ll now_sum=0;
            now_sum+=s[i][j];
            ll minus=0;
            rep(k,26){
                if(k!=j)
                    minus+=c[k]*(i+1-last[k]);
            }
            now_sum-=minus;
            if(nax<now_sum){
                nax_i = j;
                nax = now_sum;
            }
        }
        ans[i] = nax_i+1;
        last[nax_i] = i+1;
    }  
    rep(i,d){
        cout << ans[i] << endl;
    }
	return 0;   
}


Measured memory_bytes: 3680