akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#include <string.h>
using namespace std;

int main(void)
{
    int h, w;
    cin >> h;
    cin >> w;

    char *initmap = (char*) malloc(h * w);
    int *changennum = (int*) malloc(h * w * sizeof(int));

    {
        string s;
        getline(cin,s); // 改行読み飛ばし

        for(int r = 0; r < h; r++)
        {
            getline(cin,s);
            for( int c = 0; c < w; c++)
            {
                if (s[c] == '.') 
                {
                    initmap[r * w + c] = 1;
                }
                else
                {
                    initmap[r * w + c] = 0;
                }        
            }
        }
    }

    changennum[0] = (initmap[0] == 1) ? 0 : 1;

    for( int d = 1; d < h + w - 1; d++)
    {
        for( int r = 0; r < d + 1 && r < h; r++)
        {
            int c = d - r;
            if( c >= w ) continue;
            int ans = h + w;
            if( c > 0 )
            {
                int tmp = changennum[ r * w + (c - 1) ];
                if( initmap[r * w + c] != initmap[r * w + (c - 1) ] ) tmp++;
                ans = tmp;
            }

            if( r > 0 )
            {
                int tmp = changennum[ (r - 1) * w + c ];
                if( initmap[r * w + c] != initmap[(r - 1) * w + c ] ) tmp++;
                if( tmp < ans ) ans = tmp;
            }

            changennum[ r * w + c ] = ans;
        }
    }

    cout << (changennum[ h * w - 1 ] + 1) / 2;

    free(initmap);
    free(changennum);
}

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

int A[100010];

int main() {
  int N; cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A, A+N);
  cout << A[N-1] << " ";
  int j = lower_bound(A, A+N-1, A[N-1]/2) - A;
  int nearest_num = A[j];
  if (j == N-1 || (j > 0 && abs(A[N-1] - 2 * A[j-1]) < abs(A[N-1] - 2 * A[j])))
    nearest_num = A[j-1];
  cout << nearest_num << endl;
}

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

int n;

int main() {
  cin >> n;

  int sum;
  sum = 0;
  for (int a = 0; a < n; a++) {
    for (int b = 0; b < n; b++) {
      sum += n;
    }
  }

  cout << sum << endl;

}



Measured memory_bytes: 256
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 2*10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
    
r,c,R,C=map(int,input().split())
ans=0
for i in range(C-c):
  ans=ans+cmb(r+c+1+i,r,mod)*cmb(R-r+C-c-i,R-r,mod)
ans=ans+cmb(r+c,r,mod)
for i in range(R-r):
  ans=ans+cmb(c+r+1+i,c,mod)*cmb(C-c+R-r-i,C-c,mod)
print(ans%mod)

Measured memory_bytes: 133488
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			System.out.printf("%.10f\n", 1 - ((double)(N / 2) / N));
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

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

const int S=1<<20;
char buf[S],*H,*T;
inline char Get()
{
	if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
	if(H==T) return -1;return *H++;
}
inline int read()
{
	int x=0;char c=Get();
	while(!isdigit(c)) c=Get();
	while(isdigit(c)) x=x*10+c-'0',c=Get();
	return x;
}

const int N=100010;
struct Edge{int to,next;} e[N<<1];
int h[N],sum=0,n;
int deg[N],g[N];

void add_edge(int u,int v)
{
	e[++sum].to=v;
	e[sum].next=h[u];
	h[u]=sum;
}

int dfs(int u,int fa)
{
	int falun=0;
	for(int tmp=h[u];tmp;tmp=e[tmp].next)
	{
		int v=e[tmp].to;
		if(v==fa) continue;
		falun+=dfs(v,u);
	}
	if(falun>=2) puts("First"),exit(0);
	return falun^1;
}

int main()
{
	int u,v;
	n=read();
	for(int i=1;i<n;i++)
	{
		u=read();v=read();
		add_edge(u,v);
		add_edge(v,u);
	}
	puts(dfs(1,0)?"First":"Second");
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825;
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int a, b, h, m;
    cin >> a >> b >> h >> m;
    cout << fixed << setprecision(9);
    double th = 0;

    double temp = m * 6.0;
    double t1 = m * 0.5 + h * 30;

    th = abs(temp - t1);
    th = min(th, 360.0 - th);
    th = th * pi / 180.0;
    //  deb(th);
    // if (th == 0)
    //     th = pi / 2.0;
    double ans = sqrt(a * a + b * b - 2 * a * b * cos(th));

    cout << fixed << setprecision(20) << ans;

    return 0;
}

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

using namespace std;

int n, L, a[200005], b[200005];
long long ans, sa[200005], sb[200005];

long long qsuma(int l, int r) {
	return sa[r] - sa[l - 1];
}

long long qsumb(int l, int r) {
	return sb[r] - sb[l - 1];
}

void solve() {
	for (int i = n; i; --i) {
		int bl = (n - i) / 2, al = n - i - bl;
		ans = max(ans, ((n - i & 1) ? b[n - bl] : a[n - al]) + (qsumb(n - bl + 1, n) + qsuma(i, i + al - 1)) * 2);
	}
}

int main() {
	scanf("%d%d", &L, &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		b[i] = L - a[i];
	}

	for (int i = 1; i <= n; ++i) {
		sa[i] = sa[i - 1] + a[i];
		sb[i] = sb[i - 1] + b[i];
	}

	solve();

	for (int i = 1; i <= n; ++i) a[i] = b[n - i + 1];
	for (int i = 1; i <= n; ++i) b[i] = L - a[i];
	for (int i = 1; i <= n; ++i) {
		sa[i] = sa[i - 1] + a[i];
		sb[i] = sb[i - 1] + b[i];
	}
	solve();

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


Measured memory_bytes: 8512
#include<iostream>
#include<vector>

using namespace std;

void show(vector<int> &array,int size){
    int cnt = 0;
    for(int a: array){
        cout << a;
        cnt++;
        if(cnt == size) break;
        else cout << " ";
    }
    cout << endl;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(100);
    for(int i=0;i < n;i++){
        cin >> a.at(i);
    }
    for(int i=0;i < n;i++){
        int v = a.at(i);
        int j=i-1;
        while(j >= 0 && a.at(j) > v){
            a.at(j+1) = a.at(j);
            j--;
        }
        a.at(j+1) = v;
        show(a,n);
    }
    return 0;
}


Measured memory_bytes: 3092
import sys

class Dice:
    def __init__(self, labels):
        self.labels = labels
    def east(self):
        self.labels[0], self.labels[2], self.labels[5], self.labels[3] = self.labels[3], self.labels[0], self.labels[2], self.labels[5]
    def west(self):
        self.labels[0], self.labels[2], self.labels[5], self.labels[3] = self.labels[2], self.labels[5], self.labels[3], self.labels[0]
    def north(self):
        self.labels[0], self.labels[1], self.labels[5], self.labels[4] = self.labels[1], self.labels[5], self.labels[4], self.labels[0]
    def south(self):
        self.labels[0], self.labels[1], self.labels[5], self.labels[4] = self.labels[4], self.labels[0], self.labels[1], self.labels[5]

dice_num = int(input())
dices = []

for _ in range(dice_num):
    dices.append( Dice(list(map(int, input().split()))) )

south_cnt = 0

for d_i1 in range(len(dices)):
    for d_i2 in range(len(dices)):
        if d_i1 == d_i2:
            continue
        dice1 = dices[d_i1]
        dice2 = dices[d_i2]
        for i in range(8):
            for j in range(4):    
                if dice1.labels[0] == dice2.labels[0] and dice1.labels[1] == dice2.labels[1] and dice1.labels[2] == dice2.labels[2] and dice1.labels[3] == dice2.labels[3] and dice1.labels[4] == dice2.labels[4] and dice1.labels[5] == dice2.labels[5]:
                    print("No")
                    sys.exit()

                dice2.south()
                dice2.east()
                dice2.north()

            if south_cnt == 4:
                dice2.east()
            else:
                dice2.south()
                south_cnt += 1
    
print("Yes")



Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> adj[5000];
int mn[5000];
int x[5000], upto, done[5050][5010], memo[5050][5010];
bool impos = false;
void dp(int a = 0)
{
	for (int i = 0; i < adj[a].size(); i++) dp(adj[a][i]);
	upto++;
	done[0][0] = upto;
	memo[0][0] = 0;
	for (int i = 0; i < adj[a].size(); i++)
	{
		int val1 = x[adj[a][i]];
		int val2 = mn[adj[a][i]];
		for (int havetaken = 0; havetaken <= x[a]; havetaken++)
		{
			if (done[i][havetaken] != upto) continue;
			int newhavetaken = havetaken+val1;
			int newans = memo[i][havetaken]+val2;
		//	printf("%d\n", havetaken);
			if (newhavetaken <= x[a])
			{
				if (done[i+1][newhavetaken] != upto)
				{
					done[i+1][newhavetaken] = upto;
					memo[i+1][newhavetaken] = newans;
				}
				else memo[i+1][newhavetaken] = min(memo[i+1][newhavetaken], newans);
			}
			newhavetaken = havetaken+val2;
			newans = memo[i][havetaken]+val1;
			if (newhavetaken <= x[a])
			{
				if (done[i+1][newhavetaken] != upto)
				{
					done[i+1][newhavetaken] = upto;
					memo[i+1][newhavetaken] = newans;
				}
				else memo[i+1][newhavetaken] = min(memo[i+1][newhavetaken], newans);
			}
		}
	}
	int sz = adj[a].size();
	int m = 999999999;
	for (int i = 0; i <= x[a]; i++)
	{
		if (done[sz][i] == upto)
		{
			m = min(m, memo[sz][i]);
		}
	}
//	printf("%d %d\n", a, m);
	if (m == 999999999) impos = true;
	else mn[a] = m;
}
int main()
{
	scanf("%d", &n);
	for (int i = 1; i < n; i++)
	{
		int a;
		scanf("%d", &a);
		a--;
		adj[a].push_back(i);
	}
	for (int i = 0; i < n; i++) scanf("%d", &x[i]);
	dp();
	if (impos) printf("IMPOSSIBLE\n");
	else printf("POSSIBLE\n");
}


Measured memory_bytes: 39680
a, b = gets.split(" ").map(&:to_i)
 
if b == 1
    puts 0
elsif b <= a
    puts 1
else
    if (b - a) % (a - 1) == 0
        puts (b - a) / (a - 1) + 1
    else
        puts (b - a) / (a - 1) + 2
    end
end


Measured memory_bytes: 3836
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n, k;
    string s;
    cin >> n >> k >> s;

    int ans = 0;
    int count = 0;
    int cur = 'a';
    for (int i = 0; i < n; i ++) {
        if (s[i] == cur) {
            ans++;
        } else {
            count++;
            cur = s[i];
        }
    }

    while (k) {
        if (count <= 1) break;
        if (count == 2) {
            ans += 1;
            break;
        }
        ans += 2;
        count -= 2;
        k--;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template

//main
signed main(){
  int N,Q;cin>>N>>Q;
  string s;cin>>s;
  std::vector<char> t(Q),d(Q);
  for(int i=0;i<Q;i++)cin>>t[i]>>d[i];

  int now=0;
  for(int i=Q-1;i>=0;i--){
    if(t[i]==s[now]&&d[i]=='L')now++;
    if(now==0)continue;
    if(t[i]==s[now-1]&&d[i]=='R')now--;
  }

  int now2=N-1;
  for(int i=Q-1;i>=0;i--){
    if(t[i]==s[now2]&&d[i]=='R')now2--;
    if(now2==N-1)continue;
    if(t[i]==s[now2+1]&&d[i]=='L')now2++;
  }



  cout<<max(0LL,now2-now+1)<<endl;
}


Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s;
   cin>>s;
   int val=0;
   for(int i=0;i<s.length();i++)
   {
       val=val+s[i]-'0';
   }
   if(val%9==0)
   {cout<<"Yes";}
   else
   {cout<<"No";}
   
   
}

Measured memory_bytes: 3752
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;


const long long MOD = 1000000007;

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

	int n;
	cin >> n;
	cout << n / 2 + n % 2 << "\n";

	return 0;
}


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


vector<long long> v;
int main(){
	long long n,k,a,sum=0;
	cin >> n >> k;
	for(int i=0;i<n;i++){
		cin >> a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	for(int i=0;i<n-k;i++){
		sum+=v[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <string>
using namespace std;
string s;
string alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
	int i,n;
	cin >> n >> s;
	for(i=0;i<s.size();i++){
		int x = (s[i] - 'A' + n)%26;
		s[i] = alp[x];
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[3001][3001], p[3001], mx = -1e9, n, c = 1, pos = 1, m, x, y, b, a;
int main() {
	string s, t;
	cin >> s >> t;
	pair < int, int > p[3001][3001];
	p[0][0] = {-1, -1};
	n = s.size();
	m = t.size();
	for (int i = 0;i < n;i++)
	{
		for (int j = 0;j < m;j++)
		{
			if (s[i] == t[j])
			{
				dp[i][j] = dp[i - 1][j - 1] + 1;
				p[i][j] = {i - 1, j - 1};
			}
			else
			{
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
				if (dp[i - 1][j] > dp[i][j - 1])
				{
					p[i][j] = {i - 1, j};
				}
				else
				p[i][j] = {i, j - 1};
			}
		}
	}
	x = n - 1;
	y = m - 1;
	vector < char > v;
	while (x >= 0 && y >= 0)
	{
		if (s[x] == t[y])
		{
			v.push_back(s[x]);
		}
		a = x;
		b = y;
		x = p[a][b].first;
		y = p[a][b].second;
	}
	reverse(v.begin(), v.end());
	for (int i = 0;i < v.size();i++)
	{
		cout << v[i];
	}
}

Measured memory_bytes: 109140
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
const int MOD = 2019;

long long mod(long long a) {
	a %= MOD;
	return a >= 0 ? a : a+MOD;
}

int main() {
	string s;
	cin >> s;
	int n = s.size();
	reverse(s.begin(), s.end());
	long long b[2019] = {1};
	int t = 0;
	int x = 1;
	for (int i = 1; i <= n; i++) {
		t = mod(t + mod(x * (s[i-1]-'0')));
		b[t]++;
		x = mod(10 * x);
	}
	long long ans = 0;
	for (int i = 0; i < 2019; i++) {
		if (b[i] > 1) ans += b[i] * (b[i]-1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3692
#include<iostream>
using namespace std;
int main()
{
    int x=0;
    string s;
    int n;
    int max=0;
    cin>>n>>s;
    
    for(int i=0 ; i<n ; i++)
    {
        if(s[i]=='I')   
        {  x++;
        
        }  
         else
         {
             x--;
         }   
    
    if(max<x)
    {
      max=x;
    }
}
 cout<<max;
    
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    
    int a,b,x;
    
    scanf("%d %d %d",&x,&a,&b);
    
    if (b-a<=0) {
        printf("delicious");
    }
    else if(0<b-a && b-a<=x){
        printf("safe");
    }
    else{
        printf("dangerous");
    }
}

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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while (true) {
        C-=B;
        if (C<=0) {
            cout << "Yes";
            return 0;
        }
        A-=D;
        if (A<=0) {
            cout << "No";
            return 0;
        }

    }
}

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

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

int main() {
    int ans = 0;
    rep(i, 3) {
        char c;
        cin >> c;
        ans += (c == '1');
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mod 1000000007
// #define mod 998244353
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, t;
	cin >> n >> t;
	int a[n];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int count = 0, diff = 0, maxi = a[n - 1];
	for (int i = n - 2; i >= 0; i--)
	{
		if (a[i] >= maxi)
		{
			maxi = a[i];
			continue;
		}
		if (diff < maxi - a[i])
		{
			diff = maxi - a[i];
			count = 1;
		}
		else if (diff == maxi - a[i])
		{
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 4012
a = input()		# 文字列の入力  abcdefg...
b = input()		# 文字列の入力  abcdefg...

#print(a, sorted(a))
#print(b, sorted(b, reverse=True))

a = "".join( sorted(a) )
b = "".join( sorted(b, reverse=True) )

#print(a)
#print(b)

ans="Yes"
if a >= b: ans="No"

print(ans)


Measured memory_bytes: 2940
a,b,c,d,e,f = map(int, input().split())

water = set()
sugar = set()

i = 0
while 100*a*i<=f:
    j = 0
    while 100*a*i+100*b*j<=f:
        water.add(100*a*i+100*b*j)
        j+=1
    i+=1

i = 0
while c*i<=f:
    j = 0
    while c*i+d*j<=f:
        sugar.add(c*i+d*j)
        j+=1
    i+=1

sugar.add(0)

water = list(water)
sugar = list(sugar)
water.sort()
sugar.sort()

sugar2 = [0]*(f+1)
for i in range(len(sugar)-1):
    sugar2[sugar[i]:sugar[i+1]] = [sugar[i]]*(sugar[i+1]-sugar[i])

ans = [a*100,0]

for i in range(1,len(water)):
    s = min(f-water[i],water[i]*e//100)
    if ans[1]/ans[0]<sugar2[s]/(water[i]+sugar2[s]):
        ans = [water[i]+sugar2[s], sugar2[s]]

print(ans[0],end=' ')
print(ans[1])



Measured memory_bytes: 39408
N, K = list(map(int, input().split(" ")))
length = {}
list1 = {}
for i in range(K):
    length[i] = int(input())
    list1[i] = list(map(int, input().split(" ")))
count = 0
List = []
for i in range(K):
    List.extend(list1[i])
Set = set(List)
print(N-len(Set))

Measured memory_bytes: 9192
#include<cmath>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>
#include<string>
#include<map>
typedef long long ll;
using namespace std;
const double pi=4*atan(1.0);
const ll mod=1e9+7;
const int inf=0x3f3f3f3f;

int main()
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double xx=fabs(5.5*m-30*h);
    xx=xx/180*pi;
    double c=sqrt(a*a+b*b-2*a*b*cos(xx));
    printf("%.10lf\n",c);
    return 0;
}


Measured memory_bytes: 4228
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;

/* --------------------------------------------------- */

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    rep(i, n) cin >> s[i] >> t[i];
    string x;
    cin >> x;
    
    int ans = 0;
    bool flag = false;
    rep(i, n) {
        if(flag) ans += t[i];
        if(s[i] == x) flag = true;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
#define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const int INF = -1;
ll dp[100005][13];

signed main(void) {
	int N;
	vector<string> S;
	cin >> N;

	ll ans = 0;
	rep(i, N) {
		string tmp;
		cin >> tmp;
		SORT(tmp);
		S.pb(tmp);
	}
	SORT(S);
	ll count = 0;
	rep(i, N) {
		if (i == 0) {
			count = 1;
		} else {
			if (S[i] == S[i-1]) {
				ans += count;
				count++;
			} else {
				count = 1;
			}
		}
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5748
a,b = map(int,input().split())
s=list(input())

c = 0
for i in range(0,a):
    if s[i] == '0' or s[i] == '1' or s[i] == '2' or s[i] == '3' or s[i] == '4' or s[i] == '5'or s[i] == '6' or s[i] == '7' or s[i] == '8' or s[i] == '9':
        c = c+1
if s[a] == '-':
    c = c + 1
for i in range(a+1,a+b+1):
     if s[i] == '0' or s[i] == '1' or s[i] == '2' or s[i] == '3' or s[i] == '4' or s[i] == '5'or s[i] == '6' or s[i] == '7' or s[i] == '8' or s[i] == '9':
        c = c+1
if c == a+b+1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#5888164
N = int(input())
edge = [[] for _ in range(N)]
ans = [-1 for _ in range(N)]
for i in range(N-1):
    u,v,w = map(int,input().split())
    u -= 1
    v -= 1
    w %= 2
    edge[u].append((v,w))
    edge[v].append((u,w))

stack = [(e,0) for e in edge[0]]
ans[0] = 0

while len(stack) > 0:
    e,c = stack.pop()
    n,w = e[0],e[1]
    if ans[n] >= 0:
        continue
    ans[n] = (c + w) % 2
    stack += [(e,ans[n]) for e in edge[n]]

for a in ans:
    print(a)

Measured memory_bytes: 35628
#include <cstdio>
using namespace std;
typedef long long ll;
int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    ll res = 0;
    for (int b = k+1; b <= n; b++) {
        int div = n / b;
        int pad = n % b;
        res += div * (b - k);   // 余りがk以上はb-k個ずつ
        if (k == 0) res += pad;
        else if (pad >= k) res += (pad - k + 1);
    }
    printf("%lld\n", res);
}



Measured memory_bytes: 256
import numpy as np
k, n = map(int, input().split())

A = [int(a) for a in input().split()]
Abar = [0] + A
A.append(A[0]+k)
A = np.array(A)
Abar = np.array(Abar)
dis = A - Abar
print(k - max(dis))


Measured memory_bytes: 35096
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t n, x;
    cin >> n >> x;

    int64_t count = 1;
    int64_t pos = 0;
    for (auto _ : irange(0L, n)) {
        int64_t l;
        cin >> l;

        pos += l;
        if (pos > x) {
            cout << count << endl;
            return 0;
        }

        ++count;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
  int n, m; cin >> n >> m;
  vector<int> pen(n + 1, 0);
  vector<bool> ac(n + 1, false);
  for (int i = 0; i < m; i++) {
    int idx; cin >> idx;
    string res; cin >> res;
    if (res == "AC") {
      ac[idx] = true;  
    } else {
      if (!ac[idx]) pen[idx]++;
    }
  }
  int a = 0, b = 0;
  for (int i = 1; i <= n; i++) {
    a += ac[i];
    if (ac[i]) b += pen[i];
  }
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {

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

		int N = sc.nextInt();
		int A[] = new int[N];
		double bunsuu[] = new double[N];
		double ans = 0;
		double kobai = 0;

		for(int i=0;i<N;i++) {
			A[i] = sc.nextInt();
			kobai += 1/(double)A[i];
		}

		ans = 1 /kobai;




		System.out.println(ans);
	}

}


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

using namespace std;
using ll =long long;
using db = double;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;

//ここから書き始める

int main()
{
	cout << setprecision(10);
	ll n; cin >> n;
	ll k; cin >> k;
	vector<ll> h(n);
	rep(i,n) cin >> h[i];

	ll dp[100100];
	rep(i,100100) dp[i] = INF;
	dp[0] = 0 ;
	rep(i,n){
		For(j,1,k+1){
			chmin(dp[i+j] ,dp[i]+ abs(h[i] - h[i+j]));
		}
	}
	cout << dp[n-1] << endl;

}


Measured memory_bytes: 1792
//Frog 1

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define fi first
#define se second
const int inf = 2147483647;
const ll INF = 9223372036854775807;

int main (){
    int n;cin>>n;
    int ar[200010];
    int dp[200010];
    rep(i,2,n+2)cin>>ar[i];
    ar[0]=ar[1]=ar[2];
    dp[0]=dp[1]=0;
    rep(i,2,n+2)dp[i]=min(dp[i-2]+abs(ar[i]-ar[i-2]),dp[i-1]+abs(ar[i]-ar[i-1]));
    cout << dp[n+1]<< nnn;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int m[1010];

int gcd(int a, int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> xx(n);
  int res, tmp;
  for (int i = 0; i < n; ++i) {
    cin >> tmp;
    xx[i] = abs(x - tmp);
  }

  res = xx[0];
  for (int i = 1; i < n; ++i) {
    res = gcd(res, xx[i]);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 640
def inpl(): return list(map(int, input().split()))

M, D = inpl()
ans = 0
for m in range(1, M+1):
    for d in range(1, D+1):
        d10 = d//10
        d1 = d%10
        ans += m == (d1 * d10) * (d1 > 1) * (d10 > 1)

print(ans)

Measured memory_bytes: 39152
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
Q = INT()
L = [LIST() for i in range(Q)]

graph = defaultdict(list)
c = Counter(A)
ans = sum(A)

for a, b in L:
    if c[a] != 0:
        ans = ans - c[a] * a + c[a] * b
        c[b] += c[a]
        c[a] = 0
    print(ans)




Measured memory_bytes: 37628
#include <bits/stdc++.h>
 
#define ll long long
#define ld long double
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forab(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define foriter(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define endl '\n'
#define INF (ll)(1e9)
#define EPS 1e-9
#define MOD (ll)(1e9+7)
#define PI 3.1415926535897932384626433832795
#define set set
#define mset multiset
#define uset unordered_set
#define umset unordered_multiset
#define map map
#define mmap multimap
#define umap unordered_map
#define ummap unordered_multimap

using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vll;
typedef vector<vll> vvll;
typedef pair<i64, i64> pll;

int inp(){
  int x; 
  cin>>x;
  return x;
}

//=============================================================================//

void solve() {
    int n; cin>>n;
    int a, b; bool ok = false;
    int x=0;
    for0(i, n){
        cin>>a>>b;
        if(a==b) x++;
        else x=0;
        if(x>=3) ok = true;
    }
    if(ok) cout<<"Yes";
    else cout<<"No";
}

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);

    int T=1;
    //cin >> T;
    while (T--) {
        solve();
        cout<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3644
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, x;
  cin >> a >> b >> x;
  if(x >= a && x <= a + b) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

long long  factorial(long long n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}

//int ()



int main()
{
//  int a ,b, c, d, e, X, Y;
  long long  a, b, c, d, e, X, Y;
  //  double  c;
  int  A[200003]={};
//  long long  A[100003]={};
//  long long  B[100003]={};
  int  C[100003][11]={};

  int  flg=0;

//  long long  a, b, c, d, X, Y;
  char s[101][101]={};
  char t[101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p,q;
//  int flag=0;
//  int tmp=0;
  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  int len=0;
  int l=0;
  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  long long ans=1;
  int max=0;
  int sum=0;
  int addr=0;
  int ptn=0;
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
  scanf("%lld%lld", &a,&b);
  if((a+b)%2==0){
    if(a>b) printf("%lld\n", llabs(a-b)/2+b);
    else if(a<=b) printf("%lld\n", llabs(a-b)/2+a);
  }
  else   printf("IMPOSSIBLE\n");
  

    
//    printf("%s %d %d\n", s[i],C[i][0],C[i][1]);
   // printf("%d\n", C[i][1]);
/*  for(i=0;i<addr;i++){
//  scanf("%lld%lld", &B[0][i],&B[1][i]);
//    ans=ans+A[i];
    printf("%lld ", A[i]);
  }
*/
//    printf("%d ", cnt);
   

return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int b[100];
int main(){
  int a[100];
  int i=0,j;
  int x,max=0;
  while(scanf("%d",&x)!=EOF){
    a[i]=x;
    i++;
  }
  for(j=0;j<i;j++){
    b[a[j]]++;
  }
  for(j=0;j<100;j++){
    if(max<b[j])max=b[j];
  }
  for(j=0;j<100;j++){
    if(b[j]==max)printf("%d\n",j);
  }
  return 0;
}

Measured memory_bytes: 596
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = II()
    a = LI()
    x = a[0]
    for i in a[1:]:
        x = x ^ i
    if x:
        print("No")
    else:
        print("Yes")
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 57456
#include<stdio.h>

int main(){
  char text[][10]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
  
  int a,b,c,d,e,f;
  int year,month,day;
  int ans,i;
  
  for(;;){
    year=2004;
    scanf("%d %d",&month,&day);
    if(month==0)
      break;
    if(month==1||month==2){
      year--;
      month=month+13;
    }
    else
      month++;
    a=year*365.25;
    b=month*30.6;
    c=year/400;
    d=year/100;
    e=a+b+c+day-d-429;
    f=e/7;
    f=f*7;
    ans=e-f;
    
    for(i=0;i<ans;i++);
    printf("%s\n",text[i]);
  }
  return 0;
}

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

void solve()
{
	int x;
	cin>>x;
	int rating;
	
	if(x>=400 && x<=599)
	  rating=8;
	else if(x>=600 && x<=799)
	  rating=7;
	else if(x>=800 && x<=999)
	  rating=6;
	else if(x>=1000 && x<=1199)
	  rating=5;
	else if(x>=1200 && x<=1399)
	  rating=4;
	else if(x>=1400 && x<=1599)
	  rating=3;
	else if(x>=1600 && x<=1799)
	  rating=2;
	else
	  rating=1;  
	 
	cout<<rating<<endl;  
}

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

Measured memory_bytes: 3588
using System;
using System.Linq;
using static System.Console;

namespace b {
static class Extensions {
   public static int ToInt(this string str) {
      return int.Parse(str);
   }

   public static int[] readIntArr() {
      return ReadLine().Split(' ').Select(int.Parse).ToArray();
   }
}

class Program {
   public static void Main(string[] args) {
      var arr = new int[5];
      for (var i = 0; i < 5; i++)
         arr[i] = ReadLine().ToInt();

      var arr2 = new int[5];

      for (var i = 0; i < 5; i++) {
         arr2[i] = arr[i] % 10;
      }

      var index = Array.IndexOf(arr2, arr2.Select(x => x == 0 ? 10 : x).ToArray().Min());
      
      if (index == -1) {
         WriteLine(arr.Sum());
      }
      else {
         int time = 0;

         for (int i = 0; i < 5; i++) {
            if (i != index) {
               if (arr[i] % 10 == 0) {
                  time += arr[i];
               }
               else {
                  time += ((arr[i] / 10) + 1) * 10;
               }
            }
            else {
               time += arr[i];
            }
         }

         WriteLine(time);
      }
   }
}

}


Measured memory_bytes: 11348
#include <iostream>
#include <vector>
#include <algorithm>

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

	using Pair = std::pair<int, int>;
	std::vector<Pair> xs(n);
	for (auto&& p : xs)
		std::cin >> p.first >> p.second;

	std::sort(xs.begin(), xs.end());

	int ans = 0;
	int cur = xs[0].first + xs[0].second;
	for (int i = 1; i < n; ++i) {
		int l = xs[i].first - xs[i].second, r = xs[i].first + xs[i].second;

		if (l < cur) {
			++ans;
			if (r < cur)
				cur = r;
		}
		else
			cur = r;
	}

	std::cout << n - ans << std::endl;
}

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

int main(void){
    int x,y,a,b,c;
    cin >> x >> y;
    cin >> a >> b >> c;

    priority_queue<int> red;
    priority_queue<int> green;
    priority_queue<int> white;

    int i,apple;
    for(i=0;i<a;i++){
        cin >> apple;
        red.push(apple);
    }
        for(i=0;i<b;i++){
        cin >> apple;
        green.push(apple);
    }
        for(i=0;i<c;i++){
        cin >> apple;
        white.push(apple);
    }

    priority_queue<int> eat;
    for(i=0;i<x;i++){
        eat.push(red.top());
        red.pop();
    }
    for(i=0;i<y;i++){
        eat.push(green.top());
        green.pop();
    }
    for(i=0;!white.empty();i++){
        eat.push(white.top());
        white.pop();
    }

    long long sum=0;
    for(i=0;i<x+y;i++){
        sum += eat.top();
        eat.pop();
    } 
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3572
N,Q = map(int, input().split())
S = input()
count = [0]*N
ans = []
for i in range(1,N):
    count[i] += count[i-1]
    if S[i-1:i+1]=='AC' : count[i] += 1
for i in range(Q):
    l,r = map(int, input().split())
    ans.append(count[r-1]-count[l-1])
for i in  ans:
    print(i)

Measured memory_bytes: 11888
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
    return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
int h,a;
signed main(){
    cin>>h>>a;
    cout<<(h-1)/a+1<<endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
 
typedef tree<pair<long long,int>, null_type, less<pair<long long,int>>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
 
#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(num) num.begin(), num.end()
#define lp(i, nodess) for (int i = 0; i < nodess; i++)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define X real()
#define Y imag()
#define angle(u) (atan2(u.Y, u.X))
#define vec(u, v) ((v) - (u))
//#define length(u) (hypot(u.Y , u.X))
#define normalize(u) (u) / length(u)
#define dotP(u, v) ((conj(u) * v).X)
#define crossP(u, v) ((conj(u) * v).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(u) dotP(u, u)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(vis, m) conj(vis / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll nodess, ll num, ll m) {
  if (!num)
    return 1;
  if (num % 2)
    return nodess * fastpow(nodess, num - 1, m)%m;
  ll p = fastpow(nodess, num / 2, m);
  p %= m;
  p *= p;
  p %= m;
  return p;
}
 
ll my_mod(ll num, ll mod) {
  ll reto = num % mod;
  while (reto < 0)
    reto += mod;
  return reto;
}
 
ll gcd(ll u, ll v) { return !u ? v : gcd(v % u, u); }
long long dist(pair<ll, ll> u, pair<ll, ll> v) {
  return 
      abs(u.f - v.f)  + abs(u.se - v.se);
}
long long getDist(pair<ll, ll> &u, pair<ll, ll> &v) {
  return 
     (u.f - v.f)*(u.f - v.f)  + (u.se - v.se)*(u.se-v.se);
}
 
 
 
/*vector<int> ap;
int np[MX+5];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <=MX; j+=i) np[j] = 0;
        }
    }
    int idx = 1;
    for(ll i = 2 ; i<= MX ; i++){
		if(np[i]){
			np[i] = idx;
			idx++; 
			ap.pb(i);
		}
	}
	//cout<<idx;
}*/
const int MX = 10009;
ll cnt[10][10];
int main()
{
    IO;
	int n;
	cin>>n;
	for(int i = 1 ;i <= n; i++){
		string s = to_string(i);
		cnt[s[0]-'0'][s.back()-'0']++;
	}
	ll ans = 0;
	for(int i = 0 ;i < 10; i++){
		for(int j = i; j < 10; j++){
				
				ans += cnt[i][j] * cnt[j][i];
				if(i!= j) ans += cnt[i][j] * cnt[j][i];
				//cout<<cnt[i][j]<<" "<<cnt[j][i]<<" "<<i<<" "<<j<<"\n";
		}
	}
	cout<<ans<<"\n";
	return 0;
}



















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

using namespace std;

int main(){
  int n;
  string s;
  cin >> n >> s;
  vector<int> a(n);
  vector<int> b(n);
  int cnt1=0;
  int cnt2=0;
  for(int i=0;i<n;i++){
    if(s[i]=='E'){
      cnt1++;
      a[i]=cnt1;
    }
    if(s[n-i-1]=='W'){
      cnt2++;
      b[n-i-1]=cnt2;
    }
  }
  int m=-1;
  for(int i=0;i<n;i++){
    if(i==0){
      m=max(m,b[n-2]);
    }
    else if(i==n-1){
      m=max(m,a[n-2]);
    }
    m=max(m,a[i-1]+b[i+1]);
  }
  cout << n-m-1 << endl;
}

Measured memory_bytes: 3076
import math

class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y
    
    def __add__(self, q):
        if isinstance(q, Point):
            return Point(self.x + q.x, self.y + q.y)
        else:
            return Point(self.x + q, self.y + q)
    
    def __sub__(self, q):
        if isinstance(q, Point):
            return Point(self.x - q.x, self.y - q.y)
        else:
            return Point(self.x - q, self.y - q)
    
    def __mul__(self, q):
        if isinstance(q, Point):
            return Point(self.x * q.x - self.y * q.y,
                         self.x * q.y + self.y * q.x)
        else:
            return Point(self.x * q, self.y * q)
        
    def __truediv__(self, q):
        if isinstance(q, Point):
            return self * q.conj / q.norm
        else:
            return Point(self.x / q, self.y / q)
    
    @property
    def conj(self):
        return Point(self.x, -self.y)
    
    def rot(self, ang):
        return Point(math.cos(ang) * self.x - math.sin(ang) * self.y,
                     math.sin(ang) * self.x + math.cos(ang) * self.y)
    
    def rot90(self):
        return Point(-self.y, self.x)
    
    def cross(self, q):
        return self.x * q.y - self.y * q.x
    
    def dot(self, q):
        return self.x * q.x + self.y * q.y
    
    @property
    def norm(self):
        return self.dot(self)

    def __abs__(self):
        return self.dot(self) ** 0.5


# ---------------------------------------
# Solution
# ---------------------------------------

N = int(input())
vecs = []
for _ in range(N):
    x, y = map(int, input().split())
    vecs.append(Point(x, y))


def f(x, y):
    res = 0
    for i in range(N):
        res = max(res, abs(vecs[i] - Point(x, y)))
    return res


def g(x, max_iter=100):
    left = -1000
    right = 1000
    for _ in range(max_iter):
        m1 = (left * 2 + right) / 3
        m2 = (left + right * 2) / 3
        if f(x, m1) > f(x, m2):
            left = m1
        else:
            right = m2
            
    return f(x, left)


def solve(max_iter=100):
    left = -1000
    right = 1000
    for _ in range(max_iter):
        m1 = (left * 2 + right) / 3
        m2 = (left + right * 2) / 3
        if g(m1) > g(m2):
            left = m1
        else:
            right = m2
            
    return g(left)


print(solve())


Measured memory_bytes: 46824