akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int> > vvi;
#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define frpn(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define fornd(i, n) for(int i=(int)(n); i>=0; --i)

const int INF = (int)1e6+5;
const int NAX = (int)50+5;
const int MOD = (int)1e9+7;

template <class T>
inline void rem(T &n){
   n = (-MOD <= n && n <= MOD) ? n : n%MOD ;
  if(n < 0) n += MOD; 
} 
int a[NAX];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    forn(i, n){
      cin >> a[i];
      --a[i];
    }
    int c = 0, f = 0;
    forn(i, n){
      if(a[a[i]] == i && a[i] != i)
        ++c;
      if(a[i] == i)
         ++f;
      
    }
    if(c == 2 && f == n-2 || c == 0 && f == n)
      cout << "YES\n";
    else
      cout << "NO\n";
    return 0;
  }


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <functional>
#include <vector>
#include <math.h>
#include <typeinfo>
#include <numeric>
using namespace std;

int sum(vector<int> list, int begin, int end)
{
	int result = 0;
	for (int i = begin; i <= end; i++)
	{
		result += list[i];
	}

	return result;
}

int main(void) {
	
	int N;
	cin >> N;
	vector<vector<int>> list(2);
	vector<int> a1(N);
	vector<int> a2(N);
	for (int i = 0; i < N; i++)
	{
		cin >> a1[i];
	}

	for (int i = 0; i < N; i++)
	{
		cin >> a2[i];
	}
	
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		int sum1 = sum(a1, 0, i);
		int sum2 = sum(a2, i, N - 1);
		ans = max(ans, sum1 + sum2);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
int main(){
    int n;
    cin >> n;
    cout << n*(n+1)/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

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

  int x,y,z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y;

  return 0;
}


Measured memory_bytes: 3608
N = gets.to_i
A = gets.split(/ /).map(&:to_i)
LIM = 1000000000000000000

if A.include?(0)
  puts 0
  exit
end
if A.find {|a| a > LIM }
  puts -1
  exit
end

ret = 1
A.each do |a|
  ret *= a
  if ret > LIM
    puts -1
    exit
  end
end
puts ret


Measured memory_bytes: 21680
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t x,a,b;
    cin >> x;
    if(x==2){
        cin >> a >> b;
        cout << a + b << endl;
    }else{
        cout << "Hello World" << endl;
    }
    
}


Measured memory_bytes: 256
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
#include<deque>
#include<chrono>
using namespace std;
#define pi 3.141592653589793238

#define gcd __gcd
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f0 get<0>
#define f1 get<1>
#define f2 get<2>
typedef vector<ll> vi;
typedef vector<vi> vvi;


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    
    //cin >> T;
    while (T--) {
        ll n;
        cin >> n;
        vector<ll> v(n);
        for(i = 0; i < n; i++){
            cin >> v[i];
        }   
        vector<ll> suff(n);
        suff[n - 1] = v[n - 1];
        for(i = n - 2; i >=0; i--){
            suff[i] = gcd(suff[i + 1], v[i]);
        }
        ll ans = -INF;
        ans = suff[1];
        ll g = v[0];
        for(i = 1; i < n - 1; i++){
            ans = max(ans, gcd(suff[i + 1], g));
            g = gcd(g, v[i]);
        }
        ans = max(ans, g);
        cout << ans;
    }

    return 0;
}


Measured memory_bytes: 4776
"use strict";

const main = (input) => {
    const spi = input.split('\n');
    const [n, m] = spi[0].split(' ').map(e => Number(e));
    console.log(n*(n-1)/2 + m*(m-1)/2);
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 30732
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 100000007;


int main() {
  IN(ll, N);
  AIN(ll, A, N);
  map<ll,ll> mp;
  ll count = 0;
  REP(i,N){
    count += mp[i-A.at(i)+1];
    mp[A.at(i)+i+1]++;
  }
  
  
  OUT(count);
}





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

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ld long double
#define MOD 1000000007
#define ff first
#define ss second
#define endl "\n"

int main()
{
    IOS;
    string s,t;
    cin >>s>>t;
    string ans=t+""+s;
    cout <<ans<<endl;
    return 0;
}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int s1 = a * b, s2 = c * d;
    if (s1 >= s2)
        cout << s1 << endl;
    else
        cout << s2 << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(void){
    int a, b, x;
    cin >> a >> b;
    if((a + b) % 2 == 0){
        x = (a + b) / 2;
        cout << x << endl;
    }
    else{
        x = (a + b) / 2 + 1;
        cout << x << endl;
    }
}
    

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

int main()
{
	int n,W; cin>>n>>W;
	vector<long long int> wt(n), val(n);
	for(int i=0;i<n;i++) cin>>wt[i]>>val[i];
	long long int dp[n+1][W+1];
	
	for(int i=0;i<=n;i++)
	{
		for(int w=0;w<=W;w++)
		{
			if (i == 0||w == 0) dp[i][w] = 0; 
            else if (wt[i - 1] <= w)  dp[i][w] = max(val[i - 1] + dp[i - 1][w - wt[i - 1]], dp[i - 1][w]); 
            else dp[i][w] = dp[i - 1][w]; 	
		}
	}cout<<dp[n][W];
}

Measured memory_bytes: 79104
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        int x = sc.nextInt();
        int t = sc.nextInt();

        System.out.println(t > x ? 0 : x - t);
    }
}

Measured memory_bytes: 21588
import java.util.Scanner;

public class Main {

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

		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();

		long ans = 0;
		if(a < 0 && b <= 0) {
			if(c < 0) {
				ans = a * c;
				System.out.print(ans);
			}else{
				ans = b * c;
				System.out.print(ans);
			}
		}else if(c < 0 && d <= 0) {
			if(a < 0) {
				ans = a * c;
				System.out.print(ans);
			}else{
				ans = a * d;
				System.out.print(ans);
			}
		}else {
			if(a * c > b * d) {
				System.out.print(a * c);
			}else {
				System.out.print(b * d);
			}
		}

		sc.close();
	}
}

Measured memory_bytes: 35740
use io::*;
use std::collections::BTreeMap;

fn main() {
    let con = read_string();
    let mut sc = Scanner::new(&con);

    let n: usize = sc.next();
    let s: Vec<char> = sc.next::<String>().chars().collect();

    let mut ll: BTreeMap<(Vec<char>, Vec<char>), i64> = BTreeMap::new();
    let mut rr: BTreeMap<(Vec<char>, Vec<char>), i64> = BTreeMap::new();

    for i in 0..(1 << n) {
        let mut r = vec![];
        let mut b = vec![];
        for j in 0..n {
            if i & (1 << j) != 0 {
                r.push(s[j]);
            } else {
                b.push(s[j]);
            }
        }

        *(ll.entry((r, b)).or_insert(0)) += 1;
    }

    // println!("{:?}", ll);

    for i in 0..(1 << n) {
        let mut r = vec![];
        let mut b = vec![];
        for j in 0..n {
            if i & (1 << j) != 0 {
                r.push(s[n + j]);
            } else {
                b.push(s[n + j]);
            }
        }
        r.reverse();
        b.reverse();

        *(rr.entry((r, b)).or_insert(0)) += 1;
    }

    let mut ans = 0;
    for e in ll.iter() {
        let t = e.0.clone();
        if let Some(r) = rr.get(&(t.1, t.0)) {
            ans += e.1 * r;
        }
    }

    println!("{}", ans);
}

//-----

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


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

using namespace std;

#define INF LLONG_MAX
typedef long long ll;

int M, N;
vector<ll> tw, tt;
vector<ll> c, b;

void init()
{
    tw.resize(M+2); tt.resize(M+2);
    tw[0] = tt[0] = 0;
    tw[M+1] = tt[M+1] = INF;
    c.resize(N); b.resize(N);
}

int solve()
{
    int dp[1<<15];
    memset(dp, -1, sizeof(dp));
    dp[0] = 0;
    
    for (int i = 0; i < (1<<N); i++) {
        if (dp[i] == -1) continue;        
        for (int j = 0; j < N; j++) {
            if (i >> j & 1) continue;                        
            int ni = i | (1<<j);
            int p1 = upper_bound(tw.begin() + dp[i], tw.end(), c[j] + tw[dp[i]]) - (tw.begin()) - 1;
            int p2 = upper_bound(tt.begin() + dp[i], tt.end(), b[j] + tt[dp[i]]) - (tt.begin()) - 1;
            dp[ni] = max(dp[ni], min(p1, p2));
        }
    }

    return dp[(1<<N)-1];
}

int main()
{    
    cin >> M >> N;
    init();
    for (int i = 1; i <= M; i++) {
        cin >> tw[i] >> tt[i];
        tw[i] += tw[i-1];
        tt[i] += tt[i-1];
    }    
    for (int i = 0; i < N; i++) {
        cin >> c[i] >> b[i];
    }
    cout << solve() << endl;
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int c=n%10;
    n=n/10;
    if (c==2||c==4||c==5||c==7||c==9)cout << "hon\n";
    else if (c==0||c==1||c==6||c==8)cout << "pon\n";
    else if (c==3)cout << "bon\n";
        return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;
int a[2010];
signed main(){
  int n,k,q;cin>>n>>k>>q;
  int ans=INF;
  rep(i,n)cin>>a[i];
  rep(ima,n){
    vector<int> res;
    vector<int> v;
    rep(i,n){
      if(a[i]>=a[ima])v.pb(a[i]);
      if(a[i]<a[ima] || i==n-1){
        if(v.size()>=k){
          int m=v.size();
          sort(all(v));
          rep(po,m-k+1){
            res.pb(v[po]);
          }
        }
        v.clear();
      }
    }
    
    if(res.size()>=q){
      sort(all(res));
      ans=min(ans,res[q-1]-res[0]);
    }
  }
        
  cout<<ans<<endl;        
  return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define maxn 300005
#define maxa 2000005
#define MOD    100000000  //1000000007 //998244353
#define INF 1000000000000000000
#define ll unsigned long long

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << " "; cout << endl;}


void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

void solve(){
    ll n, a, b;
    cin >> n ;
    a = 100;
    for(ll i = 1; i <= 5000; i++){
        a += (a/100); //cout << a << " ";

        if(a >= n){
            ANS(i)
        }
    }

}

main(){
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


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

N, A, B = MAP()
ans = 0
for i in range(1, N+1):
	a = [0]*5
	a[0] = i%10
	j = i//10
	a[1] = j%10
	j //= 10
	a[2] = j%10
	j //= 10
	a[3] = j%10
	j //= 10
	a[4] = j
	if A <= sum(a) <= B:
		ans += i

print(ans)


Measured memory_bytes: 5400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

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

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;


int main() {
    int n;
    cin >> n;
    vector<ll> a(n),B(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        B[i] = a[i]-(i+1);
    }
    sort(B.begin(),B.end());
    ll b = B[n/2],ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += abs(b-B[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
//
// Created by kuroneko on 2019-09-15.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>

using namespace std;

typedef long long ll;

#define INF 1000000000000009LL
#define MOD 1000000007LL

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight):src(src), dst(dst), weight(weight) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

int main() {
    string s; cin >> s;
    if (s == "Sunny") cout << "Cloudy" << endl;
    else if (s == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;

    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using ll= long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/


/*.....................DEFINE FUNCTIONS ......................*/



/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__


	int N;
	cin>>N;
	VI S(N);
	int ans=0;
	REP(i,N){
		cin>>S[i];
		ans+=S[i];
	}
	sort(ALL(S));
	if(ans%10==0){
		REP(i,N){
			if(S[i]%10==0)continue;
			else{
				ans-=S[i];
				break;
			}
		}
	}
	if(ans%10==0)ans=0;
	cout<<ans<<endl;




	

		return 0;
}


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

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int n,k;
    cin>>n>>k;
    if(n%k==0)
    cout<<0;
    else{
    	if(n>k)
    	{
    		n=n%k;
    		if(abs(n-k)>n)
    		{
    			cout<<n;
			}
			else 
			cout<<abs(n-k);
		}
		else {
		n=n%k;
		if(k-n>n)
		cout<<n;
		else 
		cout<<k-n;
		}
	}

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		scan.useDelimiter("[^-0-9.]+");
		
		double x=0, y=0;
		int a=0;
		while(true){
			int di = scan.nextInt();
			int ai = scan.nextInt();
			
			if(ai == 0 && di == 0){
				break;
			}
			
			x += Math.sin(Math.toRadians(a)) * di;
			y += Math.cos(Math.toRadians(a)) * di;
			
			a += ai;
		}
		System.out.println(String.format("%d\n%d", (int)x, (int)y));
	}

}

Measured memory_bytes: 25836
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e6 + 4;
int a[N];
int last[N];
int bit[N];
int ans[N];
vector<pair<int, int>> q[N];
void update(int idx, int val)
{
    while (idx < N)
        bit[idx] += val, idx += (idx & -idx);
}
int get(int idx)
{
    int sum = 0;
    while (idx > 0)
        sum += bit[idx], idx -= (idx & -idx);
    return sum;
}
int main()
{
    int n, t;
    memset(last, -1, sizeof(last));
    cin >> n >> t;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 0; i < t; i++)
    {
        int l, r;
        cin >> l >> r;
        q[r].push_back({l, i + 1});
    }
    // sort(q.begin(), q.end());
    for (int i = 1; i <= n; i++)
    {
        if (last[a[i]] == -1)
            last[a[i]] = i, update(i, 1);
        else
        {
            update(last[a[i]], -1);
            last[a[i]] = i;
            update(last[a[i]], 1);
        }
        for (int j = 0; j < q[i].size(); j++)
        {
            ans[q[i][j].second] = get(i) - get(q[i][j].first - 1);
        }
    }
    for (int i = 1; i <= t; i++)
        cout << ans[i] << endl;
}

Measured memory_bytes: 46960
function Main(input){
	input=input.trim().split("\n");
	let r = parseFloat(input);
	let pi = Math.PI;
	console.log("%d %d", (pi * r * r).toFixed(6), (2 * pi * r).toFixed(6));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



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

using namespace std;

const double PI = acos(-1);

int main()
{
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double ang1 = PI / 2. - ( H + M / 60. ) * 2 * PI / 12.;
    double ang2 = PI / 2. - (M / 60.) * 2. * PI;
    double x1 = A * cos(ang1), y1 = A * sin(ang1);
    double x2 = B * cos(ang2), y2 = B * sin(ang2);
    cout.setf(ios::showpoint | ios::fixed);
    cout.precision(10);
    cout << sqrt(pow(y1 - y2, 2) + pow(x1 - x2, 2)) << endl;
    return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>


#include <math.h>  /* M_PI */

int main(){

    double r;
    cin >> r;


    printf("%.5f\n", 2* r * M_PI);
}

Measured memory_bytes: 3780
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>
#include <boost/dynamic_bitset.hpp>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
	// INFILE();
	string a, b;
	cin >> a >> b;

	int i = 0;
	for (; i < a.size() && i < b.size(); i++) {
		cout << a[i] << b[i];
	}

	cout << string(begin(a) + i, end(a)) << string(begin(b) + i, end(b)) << endl;
  return 0;
}

template <class T> static void scan(vector<T> &v) {
  map<type_index, const char *const> m = {{typeid(int), "%d"},
                                          {typeid(ll), "%lld"},
                                          {typeid(double), "%lf"},
                                          {typeid(char), "%c"}};

  auto tFormat = m[typeid(T)];

  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
	if (isWord) {
		for (auto &n : v) {
			cin >> n;
		}
		return;
	}

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
	string s;
	getline(cin, s);

	if (s.size() == 0) {
		getline(cin, s);
	}

	for_each(begin(s), end(s), [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
	return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


Measured memory_bytes: 888
package main

import (
	"fmt"
	"math"
	"sort"
)

var N, ans int

func main() {
	fmt.Scan(&N)
	s := make([]int, 0, N)

	for i := 0; i < N; i++ {
		var t int
		fmt.Scan(&t)
		if t%10 != 0 {
			s = append(s, t)
		}
		ans += t
	}

	sort.Ints(s)
	if len(s) == 0 {
		fmt.Println(0)
	} else if ans%10 == 0 {
		ans -= s[0]
		fmt.Println(ans)
	} else {
		fmt.Println(ans)
	}
}

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

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}

func pow(x, y int) uint64 { return uint64(math.Pow(float64(x), float64(y))) }
func abs(x int) int       { return int(math.Abs(float64(x))) }
func floor(x int) int     { return int(math.Floor(float64(x))) }

type si struct {
	s int
	i int
}

type SortBy []si

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i].s < a[j].s }


Measured memory_bytes: 512
N = int(input())
A = list(map(int,input().split()))
m = 0
z = 0
for i in range(N):
    if A[i]<0:
        m += 1
    elif A[i]==0:
        z += 1
m = m%2
B = sorted([abs(A[i]) for i in range(N)])
p = m-z
if p>0:
    for i in range(z,z+p):
        B[i] = -B[i]
    print(sum(B))
else:
    print(sum(B))

Measured memory_bytes: 92476
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
 
		Scanner scan = new Scanner(System.in);
 
		int N = scan.nextInt();

		int K = scan.nextInt();

		int a[] = new int[N];

		for(int i = 0;i<N;i++){
			a[i] = scan.nextInt();
		}

		if((N-1)%(K-1) == 0){
			System.out.println((N-1)/(K-1));
		}else{
			System.out.println((N-1)/(K-1) + 1);
		}

	}
 
}

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

int main() {
  int n;
  std::cin >> n;
  switch (n%10) {
    case 2 :
    case 4 :
    case 5 :
    case 7 :
    case 9 : std::cout << "hon" << '\n'; break;
    case 0 :
    case 1 :
    case 6 :
    case 8 : std::cout << "pon" << '\n'; break;
    case 3 : std::cout << "bon" << '\n'; break;
  }
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int n,d,x[15][15],ans;
int main(){
	cin>>n>>d;
	for(int i=1;i<=n;i++)
	    for(int j=1;j<=d;j++)
	        cin>>x[i][j];
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
		    int num=0,a;
			for(int k=1;k<=d;k++)
			    a=abs(x[i][k]-x[j][k]),num+=a*a;
			a=1;
			while(a*a<num) a++;
			if(a*a==num) ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int w,n,i;
  int a[30];

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

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

  for(i=0;i<w;i++){
    printf("%d\n",a[i]);
  }
  return 0;
}

Measured memory_bytes: 596
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////


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

    int64 N, A, B;

    cin >> N >> A >> B;

    int64 d = N / (A + B);

    N %= (A + B);

    int64 res = d * A;

    res += min(N, A);

    cout << res << "\n";

    return 0;
}


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

namespace ABC143C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            var slimes = new List<char>();
            slimes.Add(S[0]);

            for (var i = 1; i < N; i++)
            {
                var s = S[i];

                if (s != slimes[slimes.Count - 1])
                    slimes.Add(s);
            }

            Console.WriteLine(slimes.Count);
        }
    }
}


Measured memory_bytes: 13244
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

// double DP[301][301][301];
// int visited[301][301][301];

void solve(void)
{
  int N; cin>>N;
  int K; cin>>K;
  vector<int> vec (K+1,0);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }
  vector<int> DP (K+1,0);
  for (int i = 1; i < K+1; i++)
  {
    for (int j = 0; j < N; j++)
    {
      if(vec[j] > i)continue;
      if(DP[i - vec[j]] == 0)DP[i] =1;
    }
    
  }
  // DEBUG(DP);
  if(DP[K] == 1)
  {
    cout<<"First"<<endl;
  }
  else
  {
    cout<<"Second"<<endl;
  }
  
  
  

  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 1792
// AtCoder ABC057 D - Maximum Average Sets
// 2020.1.22 bal4u

#include <stdio.h>

typedef long long ll;

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

ll in() {   // 非負整数の入力
	ll n = 0; int c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void Qsort(ll *a, int l, int r) {
	int i, j; ll m; ll t;
	
	i = l, j = r, m = a[(l+r) >> 1];
	while (1) {
		while (a[i] > m) i++;
		while (m > a[j]) j--;
		if (i >= j)	break;
		t = a[i], a[i] = a[j], a[j] = t;
		i++, j--;
	}
	if (l+1 < i) Qsort(a, l, i-1);
	if (j+1 < r) Qsort(a, j+1, r);
}

ll tbl[55][55];
ll combi(int n, int k) {
	ll ans;

	if (tbl[n][k]) return tbl[n][k];
	if ((k << 1) > n) k = n-k;
	if (k == 0) ans = 1;
	else if (k == 1) ans = n;
	else ans = combi(n-1, k) + combi(n-1, k-1);
	return tbl[n][k] = ans;
}

ll v[55];

int main()
{
	int i, k, n, A, B, N;
	ll S;
	
	N = in(), A = in(), B = in();
	for (i = 0; i < N; ++i) v[i] = in();
	Qsort(v, 0, N-1);

	if (v[0] == v[A-1]) {
		printf("%lld.0000000000\n", v[0]);
		k = A; for (i = A; i < N; ++i) {
			if (v[i] != v[A-1]) break;
			k++;
		}
		if (B > k) B = k;
		S = 0; for (i = A; i <= B; ++i) S += combi(k, i);
		printf("%lld\n", S);
	} else {
		S = 0;
		for (i = 0; i < A; ++i) S += v[i];
		printf("%.10lf\n", (double)S/A);
		n = 1;
		for (i = A-2; i >= 0; --i) {
			if (v[i] != v[A-1]) break;
			n++;
		}
		k = n;
		for (i = A; i < N; ++i) {
			if (v[i] != v[A-1]) break;
			k++;
		}
		printf("%lld\n", combi(k, n));
	}
	return 0;
}


Measured memory_bytes: 128
#include<iostream>

int main()
{
    int A, B, C, X;
    int answer = 0;
    std::cin >> A >> B >> C >> X;
    for(int i = 0; (i <= A) && (500 * i <= X); i++){
        for(int j = 0; (j <= B) && (500 * i + 100 * j <= X); j++){
            if(((X - 500 * i - 100 * j) / 50 ) <= C){
                answer++;
            }
        }
    }
    std::cout << answer << std::endl;
}

Measured memory_bytes: 256
def f(n,k):
    md = 10 ** 9 + 7
    if k % 2:
        print(0)
        exit()
    k //= 2
    dp = [[[0] * (n ** 2) for _ in range(n + 2)] for __ in range(n + 1)]
    dp[0][0][0] = 1
    for i in range(1, n + 1):
        dpi1 = dp[i - 1]
        for j in range(i + 1):
            for s in range(j, k + 1):
                # 片側、水平、両方上
                #            print(i,j,s)
                tmp = dpi1[j][s - j] * j * 2 + dpi1[j][s - j] + dpi1[j + 1][s - j] * (j + 1) ** 2
                if j:
                    # 両方保留
                    tmp += dp[i - 1][j - 1][s - j]
                dp[i][j][s] = tmp % md
    print(dp[n][0][k])

n, k = map(int, input().split())
f(n,k)


Measured memory_bytes: 67884
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(x):
    print(x,file=sys.stderr)
def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)


#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう？
"""
愚直に操作を実装する
"""
#solution:
A,B,C=pin()
if A==B and B==C:
    print("No")
elif A==B or B==C or C==A:
    print("Yes")
else:
    print("No")
    
"""
N,K=pin()#KはAのうち2つを選んだとき積K番目の値 重複する値を含めるよ！
A=list(pin())
Aplus,Aminus=[],[]
zpm=[0]*3#0と負と正の数　これで数を減らして全探索ちゃうか
for num in A:
    if num==0:
        zpm[0]+=1
    elif num>0:
        zpm[1]+=1
        Aplus.append(num)
    else:
        zpm[-1]+=1
        Aminus.append(num)
#print(zpm)
zeros=zpm[0]*(N-zpm[0])+zpm[0]*(zpm[0]-1)//2 #0となにかの積
plus=(zpm[1]*(zpm[1]-1)+zpm[-1]*(zpm[-1]-1))//2#符号が同じものの積
minus=zpm[1]*zpm[-1]#違うものの積

pz=[zeros,plus,minus]
print(pz)
print((N*(N-1)//2)-sum(pz)) #0:網羅性があるよ
"""

#zpm_product=[,,]#今度は積がどうなるかやろう 
#print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])



Measured memory_bytes: 69228
#include <bits/stdc++.h>
#define Speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;

#define st              first
#define nd              second
#define pb              push_back
#define pf              push_front
#define all(a)          (a).begin(), (a).end()
#define lwb             lower_bound
#define upb             upper_bound
#define vvll            vector<vector<ll> >
#define Mset(s, n)      memset(s, n, sizeof(s))
#define Sz(a)           int((a).size())
#define Max(a, b, c)    max(max((ll)(a), (ll)(b)), (ll)(c))
#define Min(a, b, c)    min(min((ll)(a), (ll)(b)), (ll)(c))
#define Unique(a)       sort(all(a)); (a).resize(unique(all(a)) - (a).begin())

typedef long double ld;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

const ll MOD = 1000000007;
const int oo = 2e9;
const ld PI = acos((ld) -1);
int Getbit(ll x, int k){return (x >> (k - 1)) & 1;}
ll Lcm(ll a, ll b) {return a / __gcd(a, b) * b;}
bool isPrime(ll n){for(ll i = 2; i * i <= n; i++){if(n % i == 0) return 0;} return (n > 1) ? 1 : 0;}
ll Powmod(ll n, ll k, ll p = MOD) {ll r = 1; for(; k; k /= 2, n = n * n % p){if(k & 1) r = r * n % p;} return r;}

const int N = 2e5 + 5;

ll n, m, k;
ll a[N], b[N];

void Solve(){
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b;
}

int main(){
    Speed;
    int query = 1; //cin >> query;
    while(query--){
        Solve();
    }
}












Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

    long long int a,b,c,d;
    cin>>a>>b>>c>>d;
     long long int ta=a*c,tb=b*c,tc=a*d,td=b*d;
     long long int maxi=max(ta,tb);
     maxi=max(maxi,tc);
     maxi=max(maxi,td);
     cout<<maxi<<endl;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  vector<string> s(a);
  for(int i = 0;i<a;i++){
    cin >> s.at(i);
  }
  vector<bool> line(a,false);
  vector<bool> column(b,false);
  
  for(int i = 0;i<a;i++){
    for(int j = 0;j<b;j++){
      if(s.at(i).at(j) == '#'){
        line.at(i) = true;
        column.at(j) = true;
      }
    }
  }
  for(int i = 0;i<a;i++){
    if(line.at(i)){
      for(int j = 0;j<b;j++){
        if(column.at(j)){
          cout << s.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define N 1000000
using namespace std;

int main(){
  int n,tmp,dp[N],dp_odd[N];
  int plc[1000],num;

  for(int i=0;i<N;i++)dp[i] = dp_odd[i] = N+1;
  dp[0] = dp_odd[0] = 0;

  tmp = 1;
  for(num=1;;num++){
    plc[num] = tmp;
    tmp *= num+3; tmp /= num;
    if(tmp>=N)break;
  }
  
  for(int i=0;i<N;i++){
    for(int j=1;j<num;j++){
      if(i<plc[j])break;
      dp[i] = min(dp[i],dp[i-plc[j]]+1);
      if(plc[j]&1)dp_odd[i] = min(dp_odd[i],dp_odd[i-plc[j]]+1);
    }
  }

  while(scanf("%d",&n) && n)printf("%d %d\n",dp[n],dp_odd[n]);
}

Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<ll,ll>;
#define For(i,a,b)  for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define bpc __builtin_popcount
#define MOD (ll)(1e9+7)
#define INF (2e9)
#define EPS (1e-6)
#define NATHANLEE_IS_EVIL_AND_ELECTRIC true
#define int ll
#ifdef LOCAL_TEST
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<"\n";}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
#else
#define debug(...)
#endif
void INIT(){
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(!NATHANLEE_IS_EVIL_AND_ELECTRIC);
	cin.tie(0);
}

ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll fpow(ll b,ll p){
	b%=MOD;
	ll ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

double dp[310][310][310];

int32_t main() {
	INIT();
	//code...
	int n; cin>>n;
	int cnt[3]={0};
	For(i,0,n-1){
		int t; cin>>t;
		cnt[t-1]++;
	}
	cnt[1]+=cnt[2]; cnt[0]+=cnt[1];
	For(k,0,cnt[2]) For(j,0,cnt[1]) For(i,0,cnt[0]){
		if(i==0 && j==0 && k==0){
			dp[i][j][k]=0;
			continue;
		}
		dp[i][j][k]=n;
		if(i>0) dp[i][j][k]+=dp[i-1][j  ][k  ]*i;
		if(j>0) dp[i][j][k]+=dp[i+1][j-1][k  ]*j;
		if(k>0) dp[i][j][k]+=dp[i  ][j+1][k-1]*k;
		dp[i][j][k]/=(double)i+j+k;
	}
	cout<<fixed<<setprecision(15)<<dp[cnt[0]-cnt[1]][cnt[1]-cnt[2]][cnt[2]]<<"\n";
	return 0;
}

Measured memory_bytes: 224380
#include <algorithm>
#include <climits>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <stack>
#include <string>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;

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

ll solve(int N, VL T, VL A){

  VL def(N, 0);
  ll max = 0;
  VL ans(N, 1);

  bool wrong = false;

  REP(i, 0, N){
    if(max < T[i]){
      def[i] = T[i];
      max = T[i];
    } else {
      ans[i] = T[i];
    }
  }

  max = 0;

  for(int i = N-1; i >= 0; i--){
    if(max < A[i]){
      if(def[i] != 0 && A[i] > def[i]){
        //cout << "upper " << i << endl;
        wrong = true;
        break;
      } else if(max < A[i]) {
        def[i] = A[i];
        max = A[i];
        ans[i] = 1;
      }
    } else if(def[i] != 0 && A[i] < def[i]) {
      //cout << "downer " << i << endl;
      wrong = true;
      break;
    } else {
      ans[i] = min(A[i], ans[i]);
    }
  }

  ll ret = 0;

  if(!wrong){
    ret = 1;
    REP(i, 0, N){
      ret = (ret * (ans[i] % (1000000000 + 7))) % (1000000000 + 7);
    }
  }

  if(T[N-1] != A[0]){
    ret = 0;
  }

  return ret;
}

int main(){
  int N;
  cin >> N;

  VL T(N), A(N);

  REP(i, 0, N){
    cin >> T[i];
    T[i];
  }

  REP(i, 0, N){
    cin >> A[i];
    A[i];
  }

  cout << solve(N, T, A) << endl;

  return 0;
}


Measured memory_bytes: 4992
from math import ceil, log10
from itertools import product


def solve(string):
    n = int(string)
    ans = 0
    for i in range(2, ceil(log10(n))):
        tmp = (int("".join(x))
               for x in product("753", repeat=i + 1)
               if "7" in x and "5" in x and "3" in x)
        ans += len([x for x in tmp if x <= n])
    return str(ans)


if __name__ == '__main__':
    print(solve(input()))


Measured memory_bytes: 49756
#include <stdio.h>

int main()
{
	int a,b,c=0;
	
	for( a=1; a<10; a++){
		for( b=1; b<10; b++){
			c = a * b;
			printf("%dx%d=%d\n", a,b,c);
		}
	}
	return 0;
}


Measured memory_bytes: 2048
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();
		int[] arr = r.ria();
		int x = arr[1]*(int)Math.pow(100,arr[0]);
		if(arr[1] == 100)
			print(x + (x/100));
		else print(x);
	}
	
	public static int getDigitSum(int n) {
		String str = ""+n;
		int sum = 0;
		for(int i = 0; i<str.length();i++) {
			sum += Integer.parseInt(""+str.charAt(i));
		}
		return sum;
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}
	
	public static void rolling(long[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}
	
	public static void swap(int[] arr, int pos1, int pos2) {
		int temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	public static void swap(long[] arr, int pos1, int pos2) {
		long temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	
	public static String al(String s) {
		return s + "\n";
	}

	public static void print(String s) {
		System.out.println(s);
	}

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		int ri() {
			return Integer.parseInt(str());
		}

		long rl() {
			return Long.parseLong(str());
		}

		double rd() {
			return Double.parseDouble(str());
		}

		String str() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		String[] rsa() {
			return str().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = str();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}
		
		String[] rsaml(int m) {
			String[] arr = new String[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = str();
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(str());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(str());
			return arr;
		}
	}
}

class Node {
	public int val;
	public boolean visited;
	public Node(int v) { val=v; }
}


Measured memory_bytes: 21204