akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        s: chars,
        t: chars,
    }
    let n = s.len();
    let m = t.len();
    let mut mi = m;
    for i in 0..=n - m {
        let c = (0..m).filter(|&j| t[j] != s[i + j]).count();
        mi = min(mi, c);
    }
    puts!("{}\n", mi);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2196
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n, t, ans, val[MAXN];
string s;

int main() {
    fast_io;

    cin >> s;
    s = ">" + s + "<";
    n = s.size();
    for (ll i = 0; i + 1 < n; i++) {
        if (s[i] == '>' && s[i + 1] == '<') val[i] = 0;
    }
    for (ll i = 1; i + 1 < n; i++) {
        if (s[i] == '<') val[i] = val[i - 1] + 1;
    }
    for (ll i = n - 2; i >= 0; i--) {
        if (s[i + 1] == '>') val[i] = max(val[i], val[i + 1] + 1);
    }
    for (ll i = 0; i < n; i++) ans += val[i];
    cout << ans << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 4936
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef vector<LL> vl;
typedef pair<LL, LL> pl;
typedef vector<pair<LL, LL>> VP;
typedef tuple<LL, LL, LL> tl;
const LL N=pow(10, 9)+7;
#define ull unsigned long long int 
#define endl "\n"
#define REP(i, a, b) for(LL i=a; i<b; i++)
#define RREP(i, a, b) for(LL i=a; i>b; i--)
#define WE(i) while(i--)
#define PB push_back
#define PF pop_front
#define MP make_pair
#define MT make_tuple
#define F first
#define S second

LL sod(LL a)
{
    LL sum=0;
    while(a!=0)
    {
        sum=sum+a%10;
        a=a/10;
    }
    return sum;
}

LL num1(LL a)
{
    LL s=0;
    while(a!=0){
        if(a%2==1){
            s++;
        }
        a=a/2;
    }
    return s;
}

LL bmod(string s, LL a)
{
    LL res=0;
    REP(i, 0, s.length()){
        res=(10*res+(LL)s[i]-'0')%a;
    }
    return res;
}

void pd(LL n) 
{ 
    LL ans=0, x=sqrt(n);
    if(x%1==0){
        REP(i, 1, x+1){
            if(n%i==0){
                ans+=2;
            }
            if(n==i*i){
                ans--;
            }
        }
    }
    else{
        REP(i, 0, x){
            if(n%i==0){
                ans+=2;
            }
        }
    }
    cout << ans << endl;
}

void primeFactors(LL n, vl &v)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        v.PB(2); 
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            v.PB(i);
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        v.PB(n);  
}  

LL decToBinary(LL n) 
{
    LL sum=0;
    while (n > 0) { 
        if(n%2==1) sum++; 
        n=n/2; 
    } 
    return sum;
} 

LL solve()
{
    LL r;
    cin >> r;
    cout << r*r << endl;
    return 0;
}

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    LL T=1;
    //cin >> T;
    WE(T){
        solve();
    }
    return 0;
}

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

int main(void)
{
	int n;
	scanf("%d",&n);
	char s[120];
	scanf("%s",s);
	if(n%2 != 0)
	{
		printf("No\n");
		return(0);
	}
	int i = 0;
	while (i < n/2)
	{
		if(s[i] != s[n/2 + i])
		{
			printf("No\n");
			return(0);
		}
		i++;
	}
	printf("Yes\n");
	return(0);
}


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

typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
#define rep(i,n) for (unsigned int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define mp make_pair
const int maxe = 2e5+5;

ll t=1, x=0, k=0, d=0;
ll arr[maxe];

void solve(){
	cin >> x >> k >> d;
	x = abs(x);
	ll y = x/d;
	if(k >= y){
		x -= y*d;
		k -= y;
	}
	else{
		x -= k*d;
		k=0;
	}
	if(k%2 == 0) cout << x;
	else{
		cout << d-x;
	}
	
}

int main(){
	while(t--){
		solve();
	}
	return 0;
}





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

#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define sortv(v) sort(v.begin(),v.end());
#define sorta(a,n) sort(a,a+n);
#define arrayin(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define arrayout(a,n) for(int i=0;i<n;i++) cout<<" ";cout<<"\n";
#define INF INT_MAX //Infinity
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define MOD 1000000007
#define fi first
#define se second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define vi64 vector<lli>
#define viii vector<tuple<int,int,int>>
#define prq priority_queue<int>
#define mii map<int,int>
#define msi multiset<int>
#define nl "\n"
#define sii set<int,int>

typedef long long int lli;
typedef unsigned long long int ulli;
typedef double ld;

using namespace std;

int main()
{
	fio;
	/*int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
	}*/
	int n;
	cin>>n;
	lli a[n];
	REP(i,n)
	{
		if(i==0)
			cin>>a[0];
		else
		{
			lli x;
			cin>>x;
			a[i]=a[i-1]+x;
		}
	}
	lli sum=a[n-1];
	lli min=INF;
	REP(i,n-1)
	{
		//cout<<abs(a[i]-(sum-a[i]))<<endl;
		if(abs(a[i]-(sum-a[i]))<min)
			min=abs(a[i]-(sum-a[i]));
	}
	cout<<min<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
int n,r,i,j,a[100];main(){scanf("%d",&n);for(;i<n;)scanf("%d",a+i++);for(i=0;i<n;i++){for(j=0;j<i;){if(a[i]<a[j++])r++;}}std::sort(a,a+n);for(i=0;i<n;printf("%d",a[i++]))if(i)printf(" ");printf("\n%d\n",r);}

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

bool d[10];

bool check(int n)
{
    while(n)
    {
        if(d[n%10]){
            return false;
        }
        
        n /= 10;
    }
    
    return true;
}

int main(){
    int n; cin >> n;
    int k ; cin >> k;
    
    for(int i = 0 ; i<k;i++)
    {
        int temp; cin >> temp;
        d[temp] = 1;
    }
    
    for(int i = n ;;i++)
    {
        if(check(i)){
            cout << i << endl;
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

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

using namespace std;

int main(){
	int n,m; scanf("%d%d",&n,&m);
	vector<int> G[20];
	int deg[20]={};
	rep(i,m){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		G[u].push_back(v);
		deg[v]++;
	}

	vector<int> ans;
	bool vis[20]={};
	while(count(vis,vis+n,false)>0){
		rep(u,n) if(!vis[u] && deg[u]==0) {
			vis[u]=true;
			rep(i,G[u].size()){
				int v=G[u][i];
				deg[v]--;
			}
			if(u!=1) ans.push_back(u);
		}
	}
	ans.push_back(1);

	rep(u,n) printf("%d%c",ans[u]+1,u<n-1?' ':'\n');

	return 0;
}

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

int main(){
  string s;
  int i;
  cin >> s;
  for(i=0;i<19;i++){
    if(i==5||i==13){
      cout << " ";
    }else{
      cout << s.at(i);
    }
  }
  cout << endl;
}

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

int main() {
    int i,j,k,l,M,N,H,W,a,b,c,d,x,temp ;
  	long long lng;
    string str,ans;
    cin >> N ;
  	lng = 1.0;
  	for(i = 1 ; i<=N ;i++){
      lng = lng*i;
      if(lng > 1000000007){
      	lng = lng % 1000000007;
      }
    }
  	cout << lng << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = 0;
			while ((n = int.Parse(Console.ReadLine())) != 0)
			{
				var s = Console.ReadLine();
				while (n-- != 0)
				{
					var list = new List<string>();
					list.Add(s[0].ToString());
					for (int i = 1; i < s.Length; i++)
					{
						if (list.Last().Contains(s[i]))
						{
							list[list.Count - 1] += s[i];
						}
						else
						{
							list.Add(s[i].ToString());
						}
					}
					s = string.Join("", list.Select(c => c.Count() + c[0].ToString()).ToArray());
				}
				Console.WriteLine(s);
			}
		}
	}
}

Measured memory_bytes: 9012
S = $stdin.gets.chomp.split(//)
max = 0
cnt = 0
is_prev_r = false
S.each do |s|
  if s == 'R'
    if is_prev_r
      cnt += 1
    else
      cnt = 1
    end
    if max < cnt
      max = cnt
    end
    is_prev_r = true
  else
    is_prev_r = false
    cnt = 0
  end
end
puts max


Measured memory_bytes: 14432
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;

 
int main()
{
	ll k,ctr=0;
	lscf(k);
	
	
    rep(i,1,k+1)
	{
	   rep(j,1,k+1)
	   {
	       rep(l,1,k+1)
	       {
	           int a=gcd(i,j);
	           int b=gcd(a,l);
	           
	           ctr+=(b);
	       }
	       
	   } 
	  
	        
	 
	}

        lprin(ctr);
	
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
 long long int i,n,x;
 x=100;
 long long int a[3761];
 for(i=0;i<3761;i++)
 {
  a[i]=x+(x/100);
  x=a[i];
  //cout << a[i] << " ";
 }
 cin >> n;
 for(i=0;i<3761;i++)
 {
  if(a[i]>=n)
  {
   cout << i+1;
   break;
  }
 }
 return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

bool ok;
vector<int> g[5];

void solve(int v, int prev, int cnt) {
    if (cnt == 4) {
        ok = true;
        return;
    }
    for (int u : g[v]) {
        if (u == prev) continue;
        solve(u, v, cnt+1);
    }
}

int main() {
    rep(i, 3) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    solve(0, -1, 1);
    cout << (ok ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define ITR(v, i) for(auto ite = v.begin(); ite != v.end(); ite++)
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    vector<PP> VP;
    rep(i, n) {
        cin >> x;
        VP.push_back({x, i});
    }

    sort(all(VP));
    reverse(all(VP));

    a = 0;
    b = n - 1;
    ll dp[n + 1][n + 1];

    rep(i, n + 1) {
        rep(j, i + 1) {
            h = j + n - i;
            if(i == 0)
                dp[j][h] = 0;
            else {
                a = VP[i - 1].first;
                b = VP[i - 1].second;
                dp[j][h] = 0;
                if(j > 0)
                    dp[j][h] = max(dp[j][h], dp[j - 1][h] + a * (b - (j - 1)));
                if(h < n)
                    dp[j][h] = max(dp[j][h], dp[j][h + 1] + a * (h - b));
            }
        }
    }

    rep(i, n) { ans = max(ans, dp[i][i]); }

    cout << ans << endl;
}

Measured memory_bytes: 26336
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <utility>
#define REP(i,A) for(int i=0;i<A;i++)

using namespace std;
using ll = long long int;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;

const ll MOD = 1e9 + 7;


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

	ll N, X;
	cin >> N >> X;

	int bikk[201];
	bikk[0] = 1;
	for (int i = 1; i<201; i++) {
		bikk[i] = ((ll)bikk[i - 1] * i) % MOD;
	}

	vector<int> s(N);
	REP(i, N) {
		cin >> s[i];
		if (s[i] == 1) {
			cout << 0; return 0;
		}
	}
	sort(s.begin(), s.end());

	int dp[201][100001] = { 0 };
	REP(i,100001){
	dp[1][i]=i%s[0];
	}

	for(int j=2;j<=N;j++){
		for(int i=0;i<100001;i++){
			ll a = dp[j - 1][i%s[j - 1]];
			ll b = dp[j - 1][i];
			dp[j][i] = (a + b*(j - 1)) % MOD;
//			dp[j][i] = (((a*bikk[j-1])%MOD)+((((b*bikk[j-1])%MOD)*(j-1))%MOD))%MOD;
		}
	}

	cout << dp[N][X];

	return 0;
}

Measured memory_bytes: 78848
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define INF (1<<28)

int N, M, C, u[2000], v[2000];
int g[128][128], dp[1024][128];

int main() {
    for(;;) {
        scanf("%d%d%d", &N, &M, &C);
        if(N==0) return 0;
        memset(g, -1, sizeof(g));
        rep(i, N) g[i][i] = 0;
        rep(i, M) {
            int w;
            scanf("%d%d%d", u+i, v+i, &w);
            u[i]--, v[i]--;
            g[u[i]][v[i]] = w;
        }
        rep(k, N) rep(i, N) if(g[i][k]!=-1) rep(j, N) if(g[k][j]!=-1) {
            if(g[i][j]==-1 || g[i][j]>g[i][k]+g[k][j]) g[i][j]=g[i][k]+g[k][j];
        }
        memset(dp, -1, sizeof(dp));
        rep(i, N) dp[0][i] = g[0][i];
        rep(k, M+1) {
            if(dp[k][N-1]<=C) {
                printf("%d\n", k);
                break;
            }
            rep(i, M) if(dp[k][u[i]]!=-1) rep(j, N) if(g[v[i]][j]!=-1) {
                if(dp[k+1][j]==-1 || dp[k+1][j]>dp[k][u[i]]+g[v[i]][j]) {
                    dp[k+1][j] = dp[k][u[i]]+g[v[i]][j];
                }
            }
        }
    }
}

Measured memory_bytes: 1356
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

#include <cstring>
#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 <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define no_answer return cout << "NO", 0;
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const int MXN = 2e5 + 200;
const long long MNN = 3e3 + 200;
const long long MOD = 1e9 + 7;
const long long INF = 1e13;
const int OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong n, k, h[MXN], a[MXN], dp[MXN], ans;
llong t[MXN * 4];

llong get(int v, int tl, int tr, int L, int R){
    if(L <= tl && tr <= R){
        return t[v];
    }
    if(L > tr || tl > R){
        return 0;
    }
    int tm = (tl + tr) / 2;
    return max(get(v * 2, tl, tm, L, R), get(v * 2 + 1, tm + 1, tr, L, R));
}

void upd(llong v, llong tl, llong tr, llong ind, llong x){
    if(tl == tr){
        t[v] = x;
        return ;
    }
    int tm = (tl + tr) / 2;
    if(ind <= tm){
        upd(v * 2, tl, tm, ind, x);
    }else{
        upd(v * 2 + 1, tm + 1, tr, ind, x);
    }
    t[v] = max(t[v * 2], t[v * 2 + 1]);
}

int main () {
    ios;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> h[i];
    }
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for(int i = 1; i <= n; i++){
        dp[i] = get(1, 1, n, 1, h[i] - 1) + a[i];
        ans = max(dp[i], ans);
        upd(1, 1, n, h[i], dp[i]);
    }
    cout << ans;
}


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

using namespace std;

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

const int MAXN = 1e5 + 10;

int nums[MAXN];
vi g[MAXN];
vector<pii> grade;

int dfs(int node, int parent){
    int sum = 0;
    for(int i=0;i<g[node].size();++i){
        int next = g[node][i];
        if(next==parent) continue;
        sum += min(nums[node],nums[next]);
        sum += dfs(next,node);
    }
    return sum;
}

int main(){
    int n; cin >> n;
    int a,b;
    for(int i=0;i<n;++i) grade.push_back(pii(0,i+1));
    for(int i=0;i<n-1;++i){
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
        grade[a-1].first++; grade[b-1].first++;
    }
    int val[n];
    for(int i=0;i<n;++i){
       cin >> val[i]; 
    }
    sort(val,val+n);
    sort(grade.begin(),grade.end());
    
    int pos = n-1;
    int node = 1;

    queue<int> q;
    q.push(node);
    bool visited[MAXN];
    fill(visited, visited+MAXN, false);
    while(!q.empty()){
        node = q.front(); q.pop();
        visited[node] = true;
        nums[node] = val[pos];
        pos--;
        for(int i=0;i<g[node].size();++i){
            int next = g[node][i];
            if(visited[next]) continue;
            q.push(next);
        }
    }

    cout << dfs(1,-1) << endl;
    for(int i=1;i<=n;++i) {
        if(i==1) cout << nums[i];
        else cout << " " << nums[i];
    }
    cout << endl;
}

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

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> l(n+1,0), r(n+1,0);

  rep(i,n) {
    l[i+1] = gcd(a[i],l[i]);
    r[n-i-1] = gcd(a[n-i-1], r[n-i]);
  }
  
  int res = 0;
  rep(i,n) {
    res = max(res, gcd(l[i], r[i+1]));
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 1408
using System;
using System.Linq;

namespace V0015{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var n = sr.Next<int>();
            for(var l = 0; l < n; l++){
                var input =
                    sr.Next<string>(2)
                    .OrderByDescending(s => s.Length)
                    .Select(s => s.Reverse().Select(c => c - '0').Concat(new []{0}).ToList())
                    .ToArray();

                var ans = input[0];
                var add = input[1];

                for(var i = 0; i < add.Count; i++){
                    ans[i] += add[i];
                }
                for(var i = 1; i < ans.Count; i++){
                    if(ans[i - 1] >= 10){
                        ans[i - 1] -= 10;
                        ans[i] += 1;
                    }
                }

                if(ans[ans.Count - 1] == 0) ans.RemoveAt(ans.Count - 1);
                if(ans.Count > 80){
                    Console.WriteLine("overflow");
                    continue;
                }

                ans.Reverse();
                ans.ForEach(Console.Write);
                Console.WriteLine();
            }
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = Console.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var result = new T[x];
            for(var i = 0; i < x; ++i){
                result[i] = Next<T>();
            }
            return result;
        }
    }
}

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

D={"AC":0,"WA":0,"TLE":0,"RE":0}
for _ in range(N):
    S=input()
    D[S]+=1

print("AC x {}".format(D["AC"]))
print("WA x {}".format(D["WA"]))
print("TLE x {}".format(D["TLE"]))
print("RE x {}".format(D["RE"]))


Measured memory_bytes: 69844
n, m, k = map(int, input().split())
a_m, b_m = [], []
c_k, d_k = [], []
def minus(x):
    return int(x)-1

friends_list = [[] for i in range(n)]
block_list = [[] for i in range(n)]
for i in range(m):
    a_m.append(0)
    b_m.append(0)
    a_m[i], b_m[i] = map(minus, input().split())
    friends_list[a_m[i]].append(b_m[i])
    friends_list[b_m[i]].append(a_m[i])
for i in range(k):
    c_k.append(0)
    d_k.append(0)
    c_k[i], d_k[i] = map(minus, input().split())
    block_list[c_k[i]].append(d_k[i])
    block_list[d_k[i]].append(c_k[i])

# どのグループに属しているかを返す
def find(x):
    if parents[x] < 0:
        return x
    else:
        return find(parents[x])

def union(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    if parents[x] > parents[y]:
        x, y = y, x
    parents[x] += parents[y]
    parents[y] = x
    return 0

def union_size(x):
    return -parents[find(x)]

def blocks_in_union(x):
    count = 0
    for block in block_list[x]:
        if find(x) == find(block):
            count += 1
    return count

parents =[ -1 for i in range(n)]
for i in range(m):
    union(a_m[i], b_m[i])
for i in range(n):
    print(union_size(i)-1-len(friends_list[i])-blocks_in_union(i), end=' ')


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

int main(){
  int n;
  cin >> n;
  vector<long>l(n);
  int cnt=0;
  for(int i=0; i<n; i++)cin >> l[i];
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      for(int k=j+1; k<n; k++){
        if(l[i]==l[j])continue;
        if(l[j]==l[k])continue;
        if(l[k]==l[i])continue;
        if(2*max({l[i],l[j],l[k]})<l[i]+l[j]+l[k])cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3208
c = [input().split() for _ in range(3)]

for a1 in range(101):
    b1 = int(c[0][0]) - a1
    if b1 < 0:
        continue

    b2 = int(c[0][1]) - a1
    if b2 < 0:
        continue

    b3 = int(c[0][2]) - a1
    if b3 < 0:
        continue

    a2 = int(c[1][0]) - b1
    if a2 < 0:
        continue

    a3 = int(c[2][0]) - b1
    if a3 < 0:
        continue

    if int(c[1][1]) != (a2 + b2):
        continue

    if int(c[1][2]) != (a2 + b3):
        continue

    if int(c[2][1]) != (a3 + b2):
        continue

    if int(c[2][2]) != (a3 + b3):
        continue

    print("Yes")
    break

else:
    print("No")

Measured memory_bytes: 9160
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int n,m,q;
    cin >> n >> m >> q;
    int ans = 0;
    int a[q],b[q],c[q],d[q];
    rep(i,q)cin >> a[i] >> b[i] >> c[i] >> d[i];
    vector<int>A(10);
    for(int i = 1;i <= m;i++){
        for(int j = i;j <= m;j++){
            for(int k = j;k <= m;k++){
                for(int l = k;l<=m;l++){
                    for(int o = l;o<=m;o++){
                        for(int p=o;p<=m;p++){
                            for(int r=p;r<=m;r++){
                                for(int s=r;s<=m;s++){
                                    for(int t=s;t<=m;t++){
                                        for(int u=t;u<=m;u++){
                                            int sum = 0;
                                            A = {i,j,k,l,o,p,r,s,t,u};
                                            rep(v,q){
                                                if(A[b[v]-1] - A[a[v]-1] == c[v])sum+=d[v];
                                            }
                                            ans = max(ans,sum);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main(void)
{
  int D, N;
  cin >> D >> N;

  int cnt = 0;
  if(D == 0){
    if(N == 100){
      cout << 101 << endl;
    }else{
      cout << N << endl;
    }
  }
  else if(D == 1){
    if(N == 100){
      cout << 10100 << endl;
    }
    else{
      cout << N * 100 << endl;
    }
  }
  else{
    if(N == 100){
      cout << 1010000 << endl;
    }
    else{
      cout << N * 10000 << endl;
    }
  }

  return 0;
}


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

#define PI acos(-1)
#define all(a) a.begin(), a.end()
#define full(a, n) a, a + n
#define ma(type, size) (type *)malloc(sizeof(type) * size)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define f0(i, n) for (i = 0; i < (n); i++)
#define f1(i, n) for (i = 1; i < (n); i++)
#define f1n(i, n) for (i = 1; i <= (n); i++)
#define fab(i, a, b) for (i = (a); i <= (b); i++)
#define fr(i, b, a) for (i = (b); i >= (a); i--)

using namespace std;

/*
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
	tree_order_statistics_node_update> indexed_set;
//*/
typedef long long int ll;
typedef long int lo;

typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tll;

//* utility function
inline bool compare(ll i, ll j)
{
    return i < j;
}
//*/

//* function prototypes
template< typename T>
T gcd(T a, T b);
template< typename T>
T modpow(T number, T power, T mod_value);
//*/

//int row, column;
//int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//int dy[8] = {0, -1, -1, -1, 0, 1, 1, 1};
//int dx[4] = {1,  0, -1, 0};
//int dy[4] = {0, -1,  0, 1};
//ll p2[63] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904};
#ifdef DEBUG
#endif // DEBUG

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll number_of_test_case = 1, test_case;
    //cin >> number_of_test_case;
    for (test_case = 1; test_case <= number_of_test_case; test_case++)
    {
        ll a, b;
        cin >> a >> b;

        cout << max(0ll, a-2*b) << endl;
    	//cout << "Test #" << test_case << ": ";
    	//cout << "Case " << test_case << ": ";
    }
    return 0;
}


template< typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a%b);
}
template< typename T>
T modpow(T number, T power, T mod_value)
{
    if (power == 0)
        return 1%mod_value;
    ll u = modpow(number,power/2,mod_value);
    u = (u*u)%mod_value;
    if (power%2 == 1)
        u = (u*number)%mod_value;
    return u;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        // 主処理
        int count0 = s.replaceAll("[^0]", "").length();
        int count1 = s.replaceAll("[^1]", "").length();
        int result = Math.min(count0, count1) * 2;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 34616
//
//  main.cpp
//  C
//
//  Created by 曾憲揚 on 2020/8/11.
//  Copyright © 2020 曾憲揚. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;

int main(int argc, const char * argv[]) {
    int k; cin >> k;
    
    int reg=0;
    
    if(!(k%2) ){
        cout << -1 << endl; return 0;
    }
    for(int i=1; i<=k+1; i++){
        reg = reg*10 + 7;
        
        if(reg%k == 0){
            cout << i << endl; return 0;
        }
        
        reg %= k;
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3672
#include <stdio.h>
#include <math.h>
int main(void){
    double x1,y1,x2,y2,A;
    scanf("%lf",&x1);
    scanf("%lf",&y1);
    scanf("%lf",&x2);
    scanf("%lf",&y2);
    A=sqrt(pow(x2-x1,2)+pow(y2-y1,2));
    printf("%f\n",A);
    return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;

int main() {
    int N;
    cin >> N;
    cout <<(N + 1) / 2 << endl;
}

Measured memory_bytes: 764
import java.util.*;
public class Main {
    static final long MODVAL = 998244353L;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int p[] = new int[A];
        int q[] = new int[B];
        int r[] = new int[C];
        for(int i=0; i<A; i++) {
            p[i] = sc.nextInt();
        }
        for(int i=0; i<B; i++) {
            q[i] = sc.nextInt();
        }
        for(int i=0; i<C; i++) {
            r[i] = sc.nextInt();
        }
        Arrays.sort(p);
        Arrays.sort(q);
        Arrays.sort(r);

        int total[] = new int[2*(X+Y)];
        int cnt=0;
        for(int i=p.length-1; i>=p.length-X; i--) {
            total[cnt++] = p[i];
        }
        for(int i=q.length-1; i>=q.length-Y; i--) {
            total[cnt++] = q[i];
        }
        for(int i=r.length-1; i>=Math.max(0, r.length-(X+Y)); i--) {
            if(i>=r.length) continue;
            total[cnt++] = r[i];
        }
        Arrays.sort(total);

//        System.out.println(String.format("(X,Y,cnt)=(%d,%d,%d)", X, Y, cnt));
//        for(int i=0; i<total.length; i++) {
//            System.out.print(String.format("%d,", total[i]));
//        }
//        System.out.println();

        long result = 0L;
        cnt = total.length - 1;
        for(int i=0; i<X+Y; i++) {
            result+=total[cnt--];
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 96032
#include<stdio.h>
int main()
{
    int i,j,flag=0;
    char ch[4],ch1[4];
    scanf("%s",ch);
    scanf("%s",ch1);
    for(i=0,j=2;ch1[i]!='\0';i++,j--)
    {
        if(ch[j]!=ch1[i])
        {
             flag=1;
        }
    }
    if(flag==1)
        printf("NO\n");
    else
        printf("YES\n");
    return 0;
}


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

const int kN = 1e5 + 5;

int n, siz[kN], fa[kN]; std::vector <int> E[kN];
void Add(int u, int v) { E[u].push_back(v); }
void Dfs(int u) {
	int cnt = 0; siz[u] = 1;
	for(auto v : E[u]) if(v != fa[u]) {
		fa[v] = u; Dfs(v);
		siz[u] ^= siz[v];
		if(siz[v]) ++cnt;
	}
	if(siz[u]) ++cnt;
//	printf("%d %d\n", u, cnt);
	if(cnt >= 2) {
		printf("First\n");
		exit(0);
	}
}

int main() {
	scanf("%d", &n);
	if(n & 1) {
		printf("First\n");
		return 0;
	}
	for(int i = 1; i < n; ++i) {
		int u, v; scanf("%d%d", &u, &v);
		Add(u, v); Add(v, u);
	}
	Dfs(1);
	printf("Second\n");
	return 0;
}

Measured memory_bytes: 9984
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> nums;
    for(int i = 1; i <= min(a, b); ++i){
        if(a % i == 0 && b % i == 0)
        	nums.pb(i);
    }
    cout << nums[nums.size() - k] << endl;
	return 0;
} 	

Measured memory_bytes: 256
#import <Foundation/Foundation.h>
#import <stdarg.h>

@interface StdIO : NSObject
+(NSString*)stringFromStdIn;
+(NSMutableArray*)stringsFromStdInSeparatedByString:(NSString*)separator;
+(NSMutableArray*)numbersFromStdInSeparatedByString:(NSString*)separator;
+(void)puts:(NSString*)format, ...;
@end

@interface NSString (Split)
-(NSMutableArray*)splitCharacterEvery:(NSUInteger)number;
-(NSMutableArray*)characters;
@end

@implementation NSString (Split)
-(NSMutableArray*)splitCharacterEvery:(NSUInteger)number
{
	if ([self length] <= number) {
		return [NSMutableArray arrayWithObject: self];
	}

	NSMutableArray  *mArray = [NSMutableArray array];
	NSMutableString *mStr   = [NSMutableString stringWithString: self];

	NSRange range = NSMakeRange(0, number);

	while ([mStr length] > 0) {
		if ([mStr length] < number) {
			[mArray addObject: [NSString stringWithString: mStr]];
			[mStr deleteCharactersInRange:NSMakeRange(0, [mStr length])];
		} else {
			[mArray addObject: [mStr substringWithRange: range]];
			[mStr deleteCharactersInRange: range];
		}
	}

	return mArray;
}

-(NSMutableArray*)characters {
	return [self splitCharacterEvery:1];
}

@end

@implementation StdIO
+(NSString*)stringFromStdIn
{
	NSFileHandle *handle = [NSFileHandle fileHandleWithStandardInput];
	NSMutableString *result = [NSMutableString string];
	NSData *data = [handle availableData];
	while ([data length] > 0) {
		[result appendString:[[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding]];
		data = [handle availableData];
	}

	return result;
}

+(NSMutableArray*)stringsFromStdInSeparatedByString:(NSString*)separator
{
	return [NSMutableArray arrayWithArray:[[StdIO stringFromStdIn] componentsSeparatedByString:separator]];
}

+(NSMutableArray*)numbersFromStdInSeparatedByString:(NSString*)separator
{
	NSMutableArray *strings = [StdIO stringsFromStdInSeparatedByString: separator];
	NSMutableArray *numbers = [NSMutableArray array];
	for (NSString *string in strings) {
		[numbers addObject: [NSNumber numberWithInteger: [string integerValue]]];
	}
	return numbers;
}

+(void)puts:(NSString*)format, ...
{
	va_list arguments;
	va_start(arguments, format);
	NSString *stdoutString = [[NSString alloc] initWithFormat: format arguments: arguments];
	
	NSFileHandle *fileHandle = [NSFileHandle fileHandleWithStandardOutput];
	[fileHandle writeData:[stdoutString dataUsingEncoding: NSUTF8StringEncoding]];
	[fileHandle writeData:[@"\n" dataUsingEncoding: NSUTF8StringEncoding]];
	[fileHandle closeFile];	
	
	va_end(arguments);	
}
@end



int main(int argc, const char * argv[]) {
	@autoreleasepool {
		NSString *line = [[StdIO stringsFromStdInSeparatedByString:@"\n"] objectAtIndex: 1];
		NSArray *numbers = [line componentsSeparatedByString:@" "];
		NSInteger result = NSIntegerMax;
		for (NSInteger i = 0; i<[numbers count]; i++) {
			NSInteger num = [[numbers objectAtIndex:i] integerValue];
			NSInteger count = 0;
			while (num % 2 == 0) {
				count++;
				num /= 2;
			}
			result = (result < count) ? result : count;
		}
		[StdIO puts: @"%ld", result];
	}

	return 0;
}

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

const ll mod=998244353;
int n,s;
ll dp[3005],ans;

int main()
{
    scanf("%d%d",&n,&s);
    for(int i=1,x;i<=n;i++)
    {
        scanf("%d",&x);
        dp[0]++;
        for(int j=s;j>=x;j--)
            dp[j]=(dp[j]+dp[j-x])%mod;
        ans=(ans+dp[s])%mod;
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 100000;
ll x[maxn],y[maxn];
ll sx = 0,sy = 0;
ll ans = 0;
ll mod = INF;
int n,m;

int main(){
    cin >> n>>m;
    rep(i,n){
        cin >> x[i];
    }
    rep(i,m){
        cin >> y[i];
    }
    
    rep(i,n){
        sx = (sx + x[i]*(2*i+1-n)%mod)%mod;
    }
    rep(i,m){
        sy = (sy + y[i]*(2*i+1-m)%mod)%mod;
    }
    
    ans = sx * sy % mod;
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

class Main {

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

    void compute() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(a * b + " " + 2 * (a + b));
    }
}


Measured memory_bytes: 26056
import math
A, B, H, M = map(int, input().split())

kakua = H * 30 + M * 0.5
kakub = M * 6

kaku = max(kakub - kakua, kakua - kakub)

if kaku > 180:
    kaku = 360 - kaku

ans = math.sqrt(A * A + B * B - 2 * A * B * math.cos(math.radians(kaku)))
print(ans)


Measured memory_bytes: 9500
N = int(input())
d = []
for i in range(N):
    d.append(int(input()))

x = dict()
ans = 0
for i in range(N):
    if d[i] in x:
        x[d[i]] += 1
    else:
        x[d[i]] = 1

for idx in x:
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
 
using namespace std;
 
void outPut(int Array[],char mark){
    for(int i = 1; i <= 13; i++){
        if(Array[i] == 0) printf("%c %d\n",mark,i);
    }
}
 
int main(){
    char mark[2];
    int n,S[14],H[14],C[14],D[14],tmp;
    for(int i = 0; i < 14; i++) S[i] = H[i] = C[i] = D[i] = 0;
    scanf("%d",&n);
 
    for(int i = 0; i < n; i++){
        scanf("%s %d",mark,&tmp);
        switch(mark[0]){
        case 'S':
            S[tmp] = 1;
            break;
        case 'H':
            H[tmp] = 1;
            break;
        case 'C':
            C[tmp] = 1;
            break;
        case 'D':
            D[tmp] = 1;
            break;
        }
    }
    outPut(S,'S');
    outPut(H,'H');
    outPut(C,'C');
    outPut(D,'D');
}





Measured memory_bytes: 2716
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{

    string s,ss,sss;
    cin>>s;
    for(int i=0; i<s.size(); i++)
    {
        if(i&1)
        {
            ss+="0";
        }
        else
        {
            ss+="1";
        }
    }
    for(int i=0; i<s.size(); i++)
    {
        if(i&1)
        {
            sss+="1";
        }
        else
        {
            sss+="0";
        }
    }
    ll cnta=0;
    ll cntb=0;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]!=ss[i])
        {
            cnta++;
        }
        if(s[i]!=sss[i])
        {
            cntb++;
        }
    }
    cout<<min(cnta,cntb)<<endl;

}


Measured memory_bytes: 3820
from itertools import product
N, = map(int, raw_input().split())
M = len(str(N))
r = 0
for i in range(1, M+1):
  for s in product("357", repeat=i):
    x = int("".join(s))
    if "3" in s and "5" in s and "7" in s and x <= N:
      r += 1
print r

Measured memory_bytes: 2692
#define _USE_MATH_DEFINES
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <typeinfo>

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REP1(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREP1(i, x) for (int i = ((int)(x)); i > 0; i--)
/*
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

#define all(x) (x).begin(),(x).end()
*/

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;
    cin >> k;
    if (k % 2 == 0)
        cout << (k / 2) * (k / 2);
    else
        cout << (k / 2) * (k / 2 + 1);
}

Measured memory_bytes: 256
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace

from queue import PriorityQueue as pq

def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p//common , q//common )
# from itertools import accumulate
# from collections import deque

from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

import random


def main():
    n,m = map(int, input().strip().split())
    l_ab = [[0,0] for _ in range(n)]
    l_cd = [[0,0] for _ in range(m)]
    for i in range(n):
        l_ab[i] = list(map(int, input().strip().split()))
    for i in range(m):
        l_cd[i] = list(map(int, input().strip().split()))

    l_ans = [0 for _ in range(n)]
    for i in range(n):
        dist_min=sys.maxsize
        for j in range(m):
            dist_temp=abs(l_ab[i][0] - l_cd[j][0])  +  abs(l_ab[i][1] - l_cd[j][1])
            if dist_min > dist_temp:
                dist_min = dist_temp
                l_ans[i] = j
            elif dist_min == dist_temp and j < l_ans[i]:
                l_ans[i] = j
            else:
                pass
    for i in range(n):
        print(l_ans[i]+1)
        
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 67052
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

int gcd(int m, int n) {
    return n == 0 ? m : gcd(n, m % n);
}
int lcm(int m, int n) {
    return (m / gcd(m, n)) * n;
}

signed main() {
    cin >> N;
    vi a(N);
    cin >> a;
    int d = 0, q = 0;
    REP(i, N) {
        if (a[i] % 2 == 0)
            d++;
        if (a[i] % 4 == 0)
            q++;
    }
    d -= q;
    if (d == 0)
        d = 1;
    if (d + 2 * q >= N) {
        cout << "Yes" << endl;
    } else
        cout << "No" << endl;
}

Measured memory_bytes: 3772