akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var s = GetIntArray().OrderByDescending(p => p).ToArray();
            var ans = 0;
            ans += s[0];
            s[0]--;
            ans += s.Max();

            Console.Write(ans);
        }



        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(void){
    int N, K;
    cin >> N >> K;
    int ans = K * pow(K-1, N-1);
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;

int main() {
    ll A, B, C;
    cin >> A >> B >> C;
    if (A + B >= C) cout << B + C << endl;
    else {
        cout << B + A + B + 1 << endl;
    }
    return 0;
}

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

const int INF=1e6;
class SegmentTree{
    int N;
    vector<int> dat;
    vector<int> lazy;
    int impl(int a,int b,int k,int l,int r,int x){
        if(a<=l && r<=b){
            lazy[k]+=x;
            return dat[k]+lazy[k];
        }
        if(b<=l || r<=a){
            return -INF;
        }
        int mid=(l+r)/2;
        int c1=impl(a,b,k*2+1,l,mid,x);
        int c2=impl(a,b,k*2+2,mid,r,x);
        return lazy[k]+(dat[k]=max(c1,c2));
    }
    public:
    SegmentTree(int N){
        this->N=1;
        while(this->N<N){
            this->N*=2;
        }
        dat.assign(2*this->N-1,0);
        lazy.assign(2*this->N-1,0);
    }
    void add(int a,int b,int x){
        impl(a,b,0,0,N,x);
    }
    int query(int a,int b){
        return impl(a,b,0,0,N,0);
    }
};
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> l(n),r(n);
    for(int i=0;i<n;i++) cin>>l[i]>>r[i];
    SegmentTree seg(m+2);
    for(int i=0;i<=m+1;i++){
        seg.add(i,i+1,i);
    }
    vector<int> idx(n);
    iota(idx.begin(),idx.end(),0);
    sort(idx.begin(),idx.end(),[&l](int lhs,int rhs){return l[lhs]<l[rhs];});

    int res=0;
    for(int i=0;i<n;i++){
        seg.add(0,r[idx[i]]+1,1);
        res=max(res,seg.query(0,m+2)-(l[idx[i]]+m+1));
        // cerr<<"#deb"<<endl;
        // for(int i=0;i<m+2;i++){
        //     cerr<<seg.query(i,i+1)<<" ";
        // }
        // cerr<<endl;
        // cerr<<"#"<<res<<endl;
    }
    cout<<max(res,n-m)<<endl;
    
    return 0;
}

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

#define pb(a) push_back(a)

typedef long long ll;
const ll inf = 1e9+7;
const int MAX_N = 1e5+5;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
vector<ll> prime;

ll inv[MAX_N],fac[MAX_N];

template <class T = ll> T in(){T x;cin >> x;return x;}

inline ll GCD(ll a,ll b){ll c;while(b!=0){c=a%b;a=b;b=c;}return a;}
inline ll LCM(ll a,ll b){return a*b/GCD(a,b);}
inline ll POW(ll a,ll b){ll c=1;while(b>0){if(b&1){c=a*c%inf;}a=a*a%inf;b>>=1;}return c;}
inline void _nCr(){fac[0]=1;for(int i=1;i<MAX_N;i++){fac[i]=fac[i-1]*i%inf;}for(int i=0;i<MAX_N;i++){inv[i]=POW(fac[i],inf-2);}}
inline ll nCr(ll n,ll r){return (fac[n]*inv[r]%inf)*inv[n-r]%inf;}
inline void PRI(ll n){bool a[n+1];for(int i=0;i<n+1;i++){a[i]=1;}for(int i=2;i<n+1;i++){if(a[i]){prime.pb(i);ll b=i;while(b<=n){a[b]=0;b+=i;}}}}

class UnionFind {
private:
	int par[MAX_N];
	int rank[MAX_N];
public:
	void init(int n);
	int find(int x);
	void unite(int x,int y);
	bool same(int x,int y);
};

void UnionFind::init(int n) {
	for (int i = 0;i < n;i++) {
		par[i] = i;
		rank[i] = 0;
	}
}

int UnionFind::find(int x) {
	if (par[x] == x) return x;
	else return par[x] = find(par[x]);
}

void UnionFind::unite(int x,int y) {
	x = find(x);
	y = find(y);
	if (rank[x] < rank[y]) par[x] = y;
	else {
		par[y] = x;
		if (rank[x] == rank[y]) rank[x]++;
	}
}

bool UnionFind::same(int x,int y) {
	x = find(x);
	y = find(y);
	return x == y;
}

UnionFind uf;

int main() {
	string s;cin >> s;
	cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			solveA();
			//			 solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int numR = nextInt();
		int numG = nextInt();

		out.println(numG * 2 - numR);
	}

	private void solveB() {
		int numN = nextInt();

		out.println("");
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

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

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 22868
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


typedef pair<LL, LL> P;
void solve(long long N, std::vector<long long> x, std::vector<long long> y){
    LL res=N;
    REP(a,N){
        FOR(b,a+1,N){
            LL p = x[b]-x[a];
            LL q = y[b]-y[a];
            LL cnt = N;
            REP(i, N){
                REP(j, N){
                    if(x[j]-x[i]==p && y[j]-y[i]==q){
                        cnt--;
                    }
                }
            }
            res = min(res, cnt);
        }
    }
    cout<<res<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
    }
    solve(N, std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std ;
#define ll long long int
#define modm  1000000007
#include<map>
#include<algorithm>
#include<vector>

ll pow( ll a , ll b )
{

    if( b==0)
        return 1 ;


    ll   c= pow(a , b/2) ;
    c= (c*c)%modm ;


    if(b%2==1)
    {

        c= (c*a)%modm ;
    }

    return c  ;
}

ll gdc (ll a , ll b)
{

    if(a==0)
        return b ;
    return gdc( b%a , a ) ;
}
pair<ll ,ll> fract( ll a , ll b )
{


    ll d = 1 ;
    if(  (a<0 && b>0 )  ||  (a>0 && b<0) )
    {
        d= -1 ;
    }
        a = abs(a) ;
        b = abs(b) ;

    ll c = gdc( a , b) ;


    return make_pair(d*(a/c) , b/c ) ;
}
int main()
{

    ll n ;
    cin>> n ;
    map<pair<ll, ll> , ll >count ;
    ll zer = 0 ;


    for(ll i =0;i< n ;i++)
    {

        ll a  , b ;
        cin>>a >> b ;

        if(a==0 && b==0)
        {

            zer = (zer+1)%modm ;
            continue ;
        }


        pair<ll ,ll> inp = fract ( a ,b );



        count[inp]++ ;

    }


    ll ans = 1 ;
    for(auto brr : count )
    {





        pair<ll ,ll> arr  , i  ;
        i = brr.first ;




        if( i.first==0  && i.second!=0 )
        {

            arr = make_pair( 1 ,0 )  ;
        }else if( i.second == 0 && i.first!=0  )
        arr = make_pair( 0 ,1 ) ;
        else
        {

            ll sig = 1 ;
            if( i.first  <0 )
                sig = -1 ;

                arr=  make_pair( -1*sig*abs(i.second) , abs(i.first ) )  ;

        }

        ll cnt =( (  (pow( 2 ,brr.second  ) )%modm  +  (pow( 2 , count[ arr] )  )%modm  )%modm -1 +modm    )%modm   ;




         ans = (ans*cnt)%modm ;

if( count.find(arr)!=count.end())
        count.erase ( arr ) ;
count.erase(i) ;





    }
    ans=  (ans+  (zer)%modm )%modm   ;
ans = (ans+ modm -1)%modm ;
    cout<< ans<<endl;



}


Measured memory_bytes: 16100
// https://atcoder.jp/contests/dp/tasks/dp_c
#include <bits/stdc++.h>
#define ll long long int
#define pr pair<ll, ll>
#define tp tuple<ll, ll, ll>
#define infinity (ll)4e18
using namespace std;
long long int mod = 1e9 + 7;

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

    ll n;
    cin >> n;
    ll cost[n][3];
    for (ll i = 0; i < n; i++)
        for (ll j = 0; j < 3; j++)
            cin >> cost[i][j];
    ll dp[n][3];
    memset(dp, 0, sizeof(dp));
    for (ll i = 0; i < 3; i++)
        dp[0][i] = cost[0][i];
    for (ll i = 1; i < n; i++)
        for (ll j = 0; j < 3; j++)
            for (ll k = 0; k < 3; k++)
                if (k != j)
                    dp[i][j] = max(dp[i][j], cost[i][j] + dp[i - 1][k]);
    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
    return 0;
}

Measured memory_bytes: 4992
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

m = min([a,b,c,d,e])
t = 4
if n%m==0:
    t += n//m
else:
    t += n//m + 1
print(t)

Measured memory_bytes: 3060
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)
	writer := bufio.NewWriter(os.Stdout)

	var n, k int
	fmt.Sscan(getNextLine(scanner), &n, &k)

	vv := getIntList(scanner)
	lsums := make([]int, n+1)
	rsums := make([]int, n+1)
	for i := 0; i < n; i++ {
		lsums[i+1] = lsums[i] + vv[i]
		rsums[i+1] = rsums[i] + vv[n-1-i]
	}
	max := 0
	for l := 0; l <= k && l <= n; l++ {
		for r := 0; l+r <= k && l+r <= n; r++ {
			chosen := make([]int, l+r)
			for i := 0; i < l; i++ {
				chosen[i] = vv[i]
			}
			for i := 0; i < r; i++ {
				chosen[l+i] = vv[n-1-i]
			}
			sort.Sort(sort.IntSlice(chosen))
			v := lsums[l] + rsums[r]
			for i := 0; i < l+r && chosen[i] < 0 && i+l+r < k; i++ {
				v -= chosen[i]
			}
			if max < v {
				max = v
			}
		}
	}
	fmt.Fprintln(writer, max)

	writer.Flush()
}


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

#define gap " "
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ok cout<<"ok"<<endl
#define dbg(x) cout<<(#x)<<" is "<<x<<endl
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int N=100009;

int main()
{
  ll h,n,sum=0,i,r;
  scanf("%lld %lld",&h,&n);
  for(i=1; i<=n; i++)
  {
    scanf("%lld",&r);
    sum+=r;
  }
  if(sum>=h) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 256
sx, sy, tx, ty = gets.split.map(&:to_i)

dx, dy = tx - sx, ty - sy
dx1, dy1 = dx + 1, dy + 1
puts 'U'*dy + 'R'*dx + 'D'*dy + 'L'*dx1 + 'U'*dy1 + 'R'*dx1 + 'DR' + 'D'*dy1 + 'L'*dx1 + 'U'


Measured memory_bytes: 1916
#include <stdio.h>

int main(void)
{
	int w,t,a;
	scanf("%d %d",&w,&t);
	if(w<t){
		a=t-w;
	}
	else{
		a=w-t;
	}
	printf("%d\n",a);
		
	return 0;
}


Measured memory_bytes: 2120
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    n, m = map(int, input().split())
    x_list = list(sorted(list(map(int, input().split()))))
    y_list = list(sorted(list(map(int, input().split()))))
    MOD = 10 ** 9 + 7

    x = 0
    for i, d in enumerate(range(-(n - 1), n, 2)):
        x += d * x_list[i]
        x %= MOD

    y = 0
    for i, d in enumerate(range(-(m - 1), m, 2)):
        y += d * y_list[i]
        y %= MOD
        
    print((x * y) % MOD)




if __name__ == '__main__':
    main()


Measured memory_bytes: 19508
#include<iostream>
#include<vector>
int main()
{
	for (int i = 1;; i++)
	{
		int W;
		std::cin >> W;
		if (W == 0)
		{
			break;
		}
		int N;
		std::cin >> N;
		std::vector<std::vector<int>>table(N + 1, std::vector<int>(W + 1, -1));
		table[0][0] = 0;
		for (int n = 0; n < N; n++)
		{
			int vi, wi;
			char foo;
			std::cin >> vi >> foo >> wi;
			for (int w = 0; w <= W; w++)
			{
				if (table[n][w] != -1)
				{
					if (table[n + 1][w] < table[n][w])
					{
						table[n + 1][w] = table[n][w];
					}
					if (w + wi <= W)
					{
						table[n + 1][w + wi] = table[n][w] + vi;
					}
				}
			}
		}
		int max_value = 0;
		int weight;
		for (int w = 0; w <= W; w++)
		{
			if (table[N][w] > max_value)
			{
				max_value = table[N][w];
				weight = w;
			}
		}
		std::cout << "Case " << i << ":" << std::endl;
		std::cout << max_value << std::endl;
		std::cout << weight << std::endl;
	}
}


Measured memory_bytes: 6740
# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    S = input()

    kuro_num = 0
    siro_num = 0
    for moji in S:
        if moji == "#":
            kuro_num += 1
        else:
            siro_num += 1

    # ..........############ のパターン
    right_kuro_num = kuro_num
    right_siro_num = siro_num
    ans = siro_num
    for moji in S:
        if moji == "#":
            right_kuro_num -= 1
        else:
            right_siro_num -= 1
        num = right_siro_num + (kuro_num - right_kuro_num)
        ans = min(ans, num)

    print(ans)

"""
26
...##..##...##.....#..#..#
"""
if __name__ == "__main__":
    solve()

Measured memory_bytes: 3500
N,W = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(1,N+1):
    for j in range(W+1):
        dp[i][j] = dp[i-1][j]
        if A[i-1][0]<=j:
            dp[i][j] = max(dp[i][j],dp[i-1][j-A[i-1][0]]+A[i-1][1])
print(dp[N][W])

Measured memory_bytes: 171656
n=gets.to_i
h=gets.split.map(&:to_i)
c = 0
100.times do |i|
  f = false
  n.times do |j|
    if !f && h[j] > i
      f = true
      c += 1
    elsif f && h[j] <= i
      f = false
    end
  end
end
p c

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

int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  
  double th = double(H*60+M)/720 * 2*M_PI;
  double tm = double(M)/60 * 2*M_PI;
  double xh = A*cos(th), yh = A*sin(th);
  double xm = B*cos(tm), ym = B*sin(tm);
  double dx = xh-xm, dy = yh-ym;
  double ans = sqrt(dx*dx + dy*dy);
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 4092
#include<iostream>
#include<algorithm>
using namespace std;
int main(){

  int n;
  while(cin >> n&&n!=0){
    int a[n+1];
    a[0] = 0;
    for(int i=1;i<=n;i++){
      cin >> a[i];
      a[i] += a[i-1];
    }
    int sum = a[1];
    for(int i=0;i<=n;i++){
      for(int j=i+1;j<=n;j++) sum = max(sum,a[j]-a[i]);
    }
    cout << sum << endl;
  }
  
  return (0);
}

Measured memory_bytes: 3080
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	string S = res();
	string T = res();
	int ans = 0;
	for(int i=0;i<3;i++){
		if(S[i] == T[i]){
			ans++;
		}
	}
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
 
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)
template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long mod(long long a, long long b) { return (a%b+b)%b; }
long long gcd(long long x, long long y) { return __gcd(x, y); }
long long lcm(long long x, long long y) { return x * 1ll * y / gcd(x, y); }
 
 
const long long MAXN = 1e9 + 9;
const long long SIZE = 3e5 + 5;
const long long MOD  = 1e9 + 7;


int main() { speedhack()

	int a; cin >> a;
	a = a + a * a + a * a * a;
	cout << a;	
	
	return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#define il inline
#define re register
#define fo(i,j,k) for(register int i=j;i<=k;i++)
#define do(i,j,k) for(register int i=j;i>=k;i--) 
#define inf 0x7fffffff
typedef long long ll;
using namespace std;
il ll read()
{
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return f*x;	
}
int n; 
int main()
{
	cin>>n;
	int a=n/100,b=n/10%10,c=n%10;
	if(a==7||b==7||c==7) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3540
#include <iostream>
#include <algorithm>
#include <vector>
const int MAX = 100;
void matProduct(long long x[MAX][MAX],long long y[MAX][MAX],int a[3])
{
	long long xy[MAX][MAX];


	int i, j, k;

	for (i = 0; i < a[0]; i++) {
		for (j = 0; j < a[2]; j++) {
			xy[i][j] = 0;
			for (k = 0; k < a[1]; k++) {
				xy[i][j] += x[i][k] * y[k][j];
			}
		}
	}

	for (i = 0; i < a[0]; i++) {
		for (j = 0; j < a[2]; j++) {
			if (j)
			{
				std::cout << " ";
			}
			std::cout << xy[i][j];
		}
		std::cout << std::endl;
	}
}
int main() {
	int a[3];
	std::cin >> a[0] >> a[1] >> a[2];
	long long A[MAX][MAX];
	long long B[MAX][MAX];

	for (size_t i = 0; i < a[0]; ++i)
	{
		for (size_t j = 0; j < a[1]; ++j)
		{
			std::cin >> A[i][j];
		}
	}
	for (size_t i = 0; i < a[1]; ++i)
	{
		for (size_t j = 0; j < a[2]; ++j)
		{
			std::cin>>B[i][j];
		}
	}
	matProduct(A, B,a);

	//std::cout << final << std::endl;

	return 0;
}



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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)
#define all(x, r) (x), (x)+(r)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl
#define exst(x, data) (data).find(x) != (data).end()
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define np next_permutation
#define b32 bitset<32>

using ll = long long;
using Pii = pair<int,int>;
using Tiii = tuple<int, int, int>;
template<class T>using V = vector<T>;

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

    ll X[3]; rep(i,3) cin >> X[i];
    ll D[2]; rep(i,2) D[i] = abs(X[i+1] - X[i]);

    rep(i,3) {
        if(X[i]%2 != 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    if(D[0]==0 && D[1]==0) {
        cout << -1 << endl;
        return 0;
    }

    ll ans[2] = {0};
    rep(i,2) {
        while(D[i]!=0 && D[i]%2==0) {
            D[i] /= 2;
            ans[i]++;
        }
    }

    if(D[0] == 0) {
        cout << ans[1] << endl;
    } else if(D[1] == 0) {
        cout << ans[0] << endl;
    } else
        cout << min(ans[0],ans[1]) << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	static int MOD = 998244353;
	static int MAX = 200_000;
	static long[] fac = new long[MAX+1];
	static long[] finv = new long[MAX+1];
	static long[] inv = new long[MAX+1];
	
	static void COMinit() {
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for(int i = 2; i <= MAX; i++) {
			fac[i] = fac[i-1] * i % MOD;
			inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
			finv[i] = finv[i-1] * inv[i] % MOD;
		}
	}
	
	static long cmb(int n, int k){
		if(n < k || k < 0) return 0;
		return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
	}
	
	public static void main(String[] args) {
		COMinit();
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long M = sc.nextInt();
		int K = sc.nextInt();
		long ans = 0;
		long[] l = new long[N];
		l[0] = M;
		for(int i = 1; i < N; i++)
			l[i] = l[i-1] * (M-1) % MOD;
		for(int i = 0; i <= K; i++) {
			ans += cmb(N-1, i) * l[N-1-i];
			ans %= MOD;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 41804
#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;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<vector<int>>a(10, vector<int>(10));
	for (int i = 1; i <= N; i++) {
		int box = i;
		int tp = 0;
		while (box) {
			tp = box % 10;
			box /= 10;
		}
		a[tp][i % 10]++;
	}
	long long int ans = 0;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			ans += a[i][j] * a[j][i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define len(v) (int)(v).size()
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define svec(v) cout << #v << ":";for(auto& fq : v) cout<<fq<<" ";cout << "\n"

using namespace std;

void rot(int& x, int& y)
{
    int xx = x, yy = y;
    x = -yy, y = xx;
}

int main()
{
    while(1){
    int n;
    cin >> n;
    if(n == 0){
        break;
    }
    map<vector<int>,vector<int> > mp;
    vector<vector<int> > vec(n+1);
    rep(i,n+1){
        int m;
        cin >> m;
        int x = 0, y = 0;
        int id = 0;
        rep(j,m){
            int u,v;
            cin >> u >> v;
            if(j){
                if(j == 1){
                    if(u == x){
                        if(v-y>0){
                            id = 3;
                        }else{
                            id = 1;
                        }
                    }else{
                        if(u-x<0){
                            id = 2;
                        }
                    }
                }
                int nx = u-x, ny = v-y;
                rep(k,id){
                    rot(nx,ny);
                }
                vec[i].pb(nx),vec[i].pb(ny);
            }
            x = u, y = v;
        }
        if(i){
            mp[vec[i]].pb(i);
            vector<int> nw(len(vec[i]));
            rep(j,len(vec[i])){
                if(vec[i][j] == 0){
                    nw[len(vec[i])-j-1] = -vec[i][j+1], nw[len(vec[i])-j-2] = 0;
                }else{
                    nw[len(vec[i])-j-1] = 0, nw[len(vec[i])-j-2] = -vec[i][j];
                }
                j++;
            }
            int hoge = 0;
            if(nw[0] == 0){
                if(nw[1] > 0){
                    hoge = 3;
                }else{
                    hoge = 1;
                }
            }else{
                if(nw[0] < 0){
                    hoge = 2;
                }
            }
            rep(j,hoge){
                rep(k,len(nw)){
                    rot(nw[k],nw[k+1]);
                    k++;
                }
            }
            mp[nw].pb(i);
        }
    }
    sort(all(mp[vec[0]]));
    mp[vec[0]].erase(unique(all(mp[vec[0]])),mp[vec[0]].end());
    for(auto& it : mp[vec[0]]){
        cout << it << "\n";
    }
    cout << "+++++\n";
}
}



Measured memory_bytes: 3144
//https://atcoder.jp/contests/dp/tasks/dp_a

#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x << "  = " << x << endl
typedef long long int ll;
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)

#define dbg2(x, y)                                                       \
    {                                                                    \
        cout << #x << ": " << (x) << " , " << #y << ": " << (y) << endl; \
    }
#define fo(i, n) for (int i = 0; i < n; i++)
#define fok(i, k, n) for (int i = k; i < n; i++)
#define foA(i, A) for (auto i : A)
const int mxN=100005;

int ar[mxN];
int dp[mxN];
int n, k;


int rfunII(){
    cin>>n>>k;
    fo(i, n)cin>>ar[i];
    fo(i, n)dp[i]=INT_MAX;
    dp[0]=0;
    dp[1]=abs(ar[1]-ar[0]);
    fo(i, n){
        for(int j=i-1;j>=0 and j>i-k-1;j--){
            dp[i]=min(dp[i], (dp[j]+abs(ar[i]-ar[j])));
        }
    }
    //fo(i, n)cout<<dp[i]<<" ";cout<<endl;
    int ans=dp[n-1];  
    return ans;  
}

int func2(int ind){
    //correct base case
    if(ind==n-1)return 0;
    //terminating base case
    if(ind>n-1)return INT_MAX;//not a valid path
    //Memoization
    if(dp[ind]!=-1)return dp[ind];
    dp[ind]=INT_MAX;
    for(int j=ind+1;j<=ind+k and j<n;j++){
        dp[ind]=min(dp[ind], func2(j)+abs(ar[j]-ar[ind]));
    }
    return dp[ind];
}
int main(){
    fast;
    cin>>n>>k;
    fo(i, n)cin>>ar[i];
    fo(i, n)dp[i]=-1;
    cout<<func2(0);
}


Measured memory_bytes: 4224
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int cost = 1 << 20;
    int a[3];

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

    for(int i=0;i<3;++i)
    {
        for(int j=0;j<3;++j)
        {
            for(int k=0;k<3;++k)
            {
                if(i==j || j==k || i==k) continue;

                cost = min(cost, abs(a[j] - a[i]) + abs(a[k] - a[j]));
            }
        }
    }
    cout << cost << endl;
}

Measured memory_bytes: 256
import sys
import collections
import itertools


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    d = collections.defaultdict(lambda: collections.defaultdict(list))
    for i in range(n):
        s = str(input().rstrip('\n'))
        if s[0] == "M":
            d["M"][s]
        elif s[0] == "A":
            d["A"][s]
        elif s[0] == "R":
            d["R"][s]
        elif s[0] == "C":
            d["C"][s]
        elif s[0] == "H":
            d["H"][s]
    ls = [0] * len(d)
    cur = 0
    for v in d.values():
        ls[cur] += len(v)
        cur += 1
    t = 0
    for v in itertools.combinations(ls, 3):
        t += (v[0] * v[1] * v[2])
    print(t)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 56536
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int a;
  cin>>s;
  a=s.size();
  for(int i=0;i<a;i++){
    for(int j=0;j<a;j++){
      if(s[i]==s[j] && i!=j){
        cout<<"no"<<endl;
        return 0;
      }
    }
  }
  cout<<"yes"<<endl;
}


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

using namespace std;

int main()
{
    int N, M, i, a = 0;
    string S, O[100];
    vector<string> v;
    cin >> N;

    while (cin >> S)
    {
        O[a] = S;
        v.push_back(O[a]);
        a++;
    }

    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    if (v.size() == 3)
    {
        cout << "Three";
    }

    else
    {
        cout << "Four";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
long long int mod = 1000000007;
long long fast_exp(long long a,long long n,long long mod1)
    {
     
      if (n==0)return 1;
      else if (n==1)return a;
      if (n%2==0)return fast_exp((a*a)%mod1,n/2,mod1);
      else return (a*fast_exp((a*a)%mod1,n/2,mod1))%mod1;
    }
static bool is_power[1000001]={false};
void sieve()
{
    for (long long int c=2;c<=1000000;c++)
        if (is_power[c]==true)
            continue;
        else 
            for (long long int c1=c*c;c1<=1000000;c1=c1*c)
                is_power[c1]=true;
    return ;
}
int main()
{
    
    fast_io;
    int t;
    t=1;//cin >> t;
    for (;t>0;t--)
    {
        int n;
        cin >> n;
        long long a=((1LL*n)*(n+1))/2;
        for (int c=1;c<=n;c++)
            if (c%3==0||c%5==0)
                a-=c;
        cout << a << endl;
    }
    return 0;
}




Measured memory_bytes: 3656
#coding: UTF-8

while True:
    N = list(map(int, input().split()))

    total_score = N[0] + N[1]
    
    if N[0] == -1 and N[1] == -1 and N[2] == -1:
        break
    if N[0] == -1 or N[1] == -1:
        print('F')
    elif total_score >= 80:
        print('A')
    elif 80 > total_score >= 65:
        print('B')
    elif 65 > total_score >= 50:
        print('C')
    elif 50 > total_score >= 30:
        if N[2] >= 50:
            print('C')
        elif 50 > N[2]:
            print('D')
    elif 30 > total_score:
        print('F')


Measured memory_bytes: 5596
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define deb2a(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define mod 1000000007
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
#define db1(x) cout<<#x<<"="<<x<<endl
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
// int mI(int a, int m)  {return power(a, m - 2, m);}
// vector<vector<int>> dir = {{1, 0}, {-1, 0}, {0, 1}, {0, -1},{1,1},{1,-1},{-1,1},{-1,-1}};
vector<vector<int>> v;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k;
    cin >> k;
    string s;
    cin >> s;
    if (s.size() > k)
    {
        cout << s.substr(0, k);
        cout << "...";
   }
   else{
       cout << s;
   }

}
    


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+18;

int main() {
    ios::sync_with_stdio(false);
    Int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    for (Int i = 1; i <= n - 1; i++) {
        if (c * (n - 1 - i) - d * i <= b - a && b - a <= d * (n - 1 - i) - c * i) {
            dump("YES");
            return 0;
        }
    }
    dump("NO");
    return 0;
}

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

const int MAXN = 502;
const int MAXM = 10004;
int dp[MAXN][MAXM];

int main() {
  for(int M, N; cin >> M >> N;) {
    vector<int> P(M), C(N), E(N);
    for(int i = 0; i < M; ++i) cin >> P[i];
    for(int j = 0; j < N; ++j) cin >> C[j] >> E[j];
    sort(P.begin(), P.end());
    P.insert(P.begin(), 0);
    for(int i = 0; i < M; ++i) P[i+1] += P[i];

    fill(dp[0], dp[MAXN], 0);
    for(int j = 0; j < N; ++j) {
      for(int i = 0; i < M; ++i) {
        dp[j+1][i] = max(dp[j+1][i], dp[j][i]);
        int ni = min(i + C[j], M);
        int add = P[ni] - P[i] - E[j];
        dp[j+1][ni] = max(dp[j+1][ni], dp[j][i] + add);
      }
    }
    cout << *max_element(dp[0], dp[MAXN]) << endl;
  }
  return 0;
}

Measured memory_bytes: 20928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)

void solve() 
{
    int a,b;cin>>a>>b;cout<<a-b+1<<endl;
}

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

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> edge(n);
    vector<int> num(n, 0);
    int a, b;
    for (int i = 0; i < n + m - 1; i++){
        cin >> a >> b;
        a--; b--;
        num[b]++;
        edge[a].push_back(b);
    }
    vector<int> ans(n);
    vector<int> d(n, 0);
    int root;
    for (int i = 0; i < n; i++) if (num[i] == 0) root = i;
    ans[root] = 0;
    queue<int> q;
    q.push(root);
    while (q.size()){
        root = q.front(); q.pop();
        for (int i = 0; i < edge[root].size(); i++){
            num[edge[root][i]]--;
            if (num[edge[root][i]] == 0) {
                ans[edge[root][i]] = root + 1;
                q.push(edge[root][i]);
            }
        }
    }
    for (int i = 0; i < n; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 7424
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include <iomanip>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
static const double pi = 3.141592653589793;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
    double A,B,H,M; cin >>A>>B>>H>>M;
    double hx,hy,mx,my;
    //double hour = H + 
    hx = A * cos(pi * (H + (M/60)) / 6);
    hy = A * sin(pi * (H + (M/60)) / 6);
    mx = B * cos(pi * M / 30);
    my = B * sin(pi * M / 30);

    double distance = sqrt(pow(hx - mx ,2.0) + pow(hy - my,2.0));

    cout << distance << endl;
}

Measured memory_bytes: 4140
from collections import deque

n, m = map(int, input().split())
People = {x+1:[] for x in range(10**6+1)}

for _ in range(m):
    l, r, d = map(int, input().split())
    People[l].append([r, d])
    People[r].append([l, -d])

INF = 10**10
Visited = [INF for i in range(10**6+1)]

def bfs(v):
    dq = deque()
    dq.append(v)
    Visited[v] = 0
    check = True
    while dq:
        now = dq.popleft()
        Related = People[now]
        for related in Related:
            if Visited[related[0]] == INF:
                dq.append(related[0])
                Visited[related[0]] = Visited[now] + related[1]
            elif Visited[related[0]] != Visited[now] + related[1]:
                check = False
    return check

ans = 'Yes'
for i in range(1,10**6+1):
    if Visited[i] == INF:
        if bfs(i) == False:
            ans = 'No'

print(ans)



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

int main(){
	string s;
	cin>>s;
	
	int jud=-1;
	REP(i,s.size()){
		if(s[i]=='C') jud=0;
		else if(s[i]=='F'&&jud==0) jud=1;
	}
	
	if(jud==1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

#define lli long long int
#define REP(i, s, l) for (lli i = s; i < l; i++)
#define DEBUG 0
#define INF (1LL << 50)
#define MOD 1000000007

int main()
{
    int n; cin >> n;
    vector<double> a(n);
    vector<string> s(n);

    for(int i=0; i<n; i++){
        cin >> a[i] >> s[i];
    }
    for (int i = 0; i < n; i++){
        if(s[i]=="BTC"){
            a[i] = a[i]*380000.0;
        }
    }
    double sum = 0;
    for (int i = 0; i < n*2; i++){
        sum += a[i];
    }
    cout << sum << endl;
    return 0;
}

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

int main(){
    int w,h;
    cin >> h >> w;
    while(!(w == 0 && h == 0)){
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if((i+j)%2 == 0){
                    cout << "#";
                }else{
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
        cin >> h >> w;
    }
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rrep(i, n) for(int i = int(n-1); i >= 0; i--)

using namespace std;

long dp[3001];

int main(){
    int n, s; cin >> n >> s;
    dp[0] = 1;
    rrep(i,n){
        int a; cin >> a;
        rrep(j,s+1){
            dp[j] *= 2;
            if(j-a >= 0) dp[j] += dp[j-a];
            dp[j] %= 998244353;
        }
    }
    cout << dp[s] << endl;
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main() {
	long long int n, ans=1;
	cin >> n;

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

	return 0;
}

Measured memory_bytes: 256
N, M = map(int,input().split())
A0 = list(map(int,input().split()))
BC = []
for i in range(M):
  BC.append(list(map(int,input().split())))

A = [[1,a] for a in A0]
ABC = A + BC
ABC.sort(key = lambda x : x[1], reverse = True)

summation = 0
p = 0
n = 0

while n < N:
  summation += ABC[p][1] * (min(ABC[p][0], N - n))
  n += ABC[p][0]
  p += 1

print(summation)

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

int main() {
	int sum , n;
	cin >> sum >> n;
	vector<int> a(n);
	
	for(int i = 0; i < n; i++){
		cin >> a[i];
		sum -= a[i];
		if (sum <= 0){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
const int N = 3e5+10, P = 998244353;
int n, m, vis[N], sg[N], h[N], f[3][N];
vector<int> g[N];
void add(int &a, ll b) {a=(a+b)%P;}

int main() {
	h[0] = 1;
	h[1] = 1000000000000000000ll%P;
	REP(i,2,N-1) h[i] = (ll)h[i-1]*h[1]%P;
	scanf("%d", &n);
int mx = 0;
	REP(i,0,2) {
		scanf("%d", &m);
mx = max(mx, int(sqrt(1+4*m)/2));
		REP(j,1,n) g[j].clear();
		REP(j,1,m) {
			int u,v;
			scanf("%d%d", &u, &v);
			if (u>v) swap(u,v);
			g[u].pb(v);
		}
		PER(j,1,n) {
			int sz = g[j].size();
			REP(k,0,sz) vis[k] = 0;
			for (int k:g[j]) vis[sg[k]] = 1;
			REP(k,0,sz) if (!vis[k]) {
				sg[j] = k;
				break;
			}
			add(f[i][sg[j]],h[j]);
		}
	}
mx=500;
	int ans = 0;
	REP(i,0,mx) REP(j,0,mx) {
		add(ans, (ll)f[0][i]*f[1][j]%P*f[2][i^j]);
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 15232
MOD = 10**9+7

s = str(input())

dp = [ [0]*13 for _ in range(len(s)+1) ]
dp[0][0] = 1
# if s[0] == '?':
#     dp[]

for i in range(1,len(s)+1):
    if s[i-1] == '?':
        for num in range(10):
            for j in range(13):
                dp[i][(10*j+num)%13] += dp[i-1][j]
                dp[i][(10*j+num)%13]%=MOD
    else:
        num = int(s[i-1])
        for j in range(13):
            dp[i][(10*j+num)%13] = dp[i-1][j]
            dp[i][(10*j+num)%13]%=MOD

print(dp[-1][5])

Measured memory_bytes: 96064
/**
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 2019-11-30:16:06:07
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

constexpr int64 MOD = 1e9 + 7;

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

  int64 n, m; cin >> n >> m;
  vector<int64> x(n), y(m);
  for (int i = 0; i < n; ++i) cin >> x[i];
  for (int i = 0; i < m; ++i) cin >> y[i];

  int64 tx = 0, ty = 0;
  for (int64 i = 0; i < n; ++i) {
    tx += x[i] * (i) - x[i] * (n - i - 1);
    tx %= MOD;
  }

  for (int64 i = 0; i < m; ++i) {
    ty += y[i] * (i) - y[i] * (m - i - 1);
    ty %= MOD;
  }

  cout << tx * ty % MOD << endl;

  return 0;
}

Measured memory_bytes: 1792