akhauriyash/Code-Regression huggingface dataset:
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
using namespace std;
#define FAST   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll          long long
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define mii         map<int,int>
#define vi          vector<int>
#define vll         vector<long long>
#define all(a)      (a).begin(),(a).end()
#define clz(a)      __builtin_clz(a) // count leading zeroes
#define ctz(a)      __builtin_ctz(a) // count trailing zeroes
#define popc(a)     __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define SIZE        1000005
#define F           first
#define S           second
#define debug(x)    cerr << #x << " = " << x << endl;
#define mod         998244353

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define endl        '\n'
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

double binexpo(double n, int p)
{
  if(p==0) return 1.0;
  double res=binexpo(n*n,p/2);
  if(p&1) return res*n;
  else return res;
}
void solve()
{
  double n,k; cin>>n>>k;
  double ans=0;
  rep(i,1,n+1)
  { 
    double argu=log(k/((double)(i)))/log(2.0);
    int power=ceil(argu);
    power=max(power,0);
    ans+=(1.0/n)*binexpo(0.5,power);
  }
  cout<<setprecision(15)<<ans;
} 
int main()
{   
    FAST;
    // #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 640
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

int N,M;

LL ans = 0;

void solve(){
	ans += (N-1)*N/2 + (M-1)*M/2;
}
 
int main(){
    cin >> N >> M;
 
    solve();

    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int N;
int a[112345];

int main() {
	cin >> N;
	REP(i, N) scanf("%d", a + i);
	
	vector<int> cx;
	REP(i, N) cx.push_back(a[i]);
	sort(ALL(cx));
	REP(i, N) a[i] = lower_bound(ALL(cx), a[i]) - cx.begin();
	
	int ans = 0;
	REP(i, N) if (i % 2 == 0 && a[i] % 2 == 1) ans++;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+5;
int n,cnt=0;
struct node
{
	int to,next,v;
}e[MAXN*2];
int mp[MAXN];
bool color[MAXN],vis[MAXN]; 
void add(int u,int v,int w){
	cnt++;
	e[cnt].to=v;
	e[cnt].v=w;
	e[cnt].next=mp[u];
	mp[u]=cnt;
}
void dfs(int x,bool f)
{
	int i;
	color[x]=f;
	vis[x]=1;
	for(i=mp[x];i;i=e[i].next){
	    if(vis[e[i].to]) continue;
		bool t=f;
		if(e[i].v%2) t=f^1;
		dfs(e[i].to,t);
	}
	return ;
}
int main()
{
	int i,j,k;
	scanf("%d",&n);
	for(i=1;i<n;i++){
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		add(u,v,w);
		add(v,u,w);
	}
	dfs(1,0); 
	for(i=1;i<=n;i++) printf("%d\n",color[i]);
	return 0;
}

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


typedef unsigned long long Hash;
template<class T>

class RollingHash{
public:
	T src;
	vector<Hash> harr,p;
	
	vector<int> suffixArray;
	RollingHash(T src,Hash w=8999):src(src){
		p.resize(src.size()+1);
		Hash sum = 0;
		for(int i = 0 ; i < src.size() ; i++){
			sum = sum * w + src[i];
			//sum %= mod;
			harr.push_back(sum);
		}
		p[0] = 1;
		for(int i = 1 ; i < p.size() ; i++){
			p[i] = p[i-1] * w;
			//p[i] %= mod;
		}
	}
	// [l,r)
	Hash sub(int l,int r) const{
		if( l >= r ) return 0;
		return harr[r-1] - (l?harr[l-1] * p[r-l]:0);
	}
};

int main(){
	string S,T;
	cin >> S >> T;
	RollingHash<string> s(S),t(T);
	int ans = 0;
	for(int i = 0 ; i+T.size() <= S.size() ; i++){
		int l = 0, r = T.size();
		if( s.sub(i,i+r) == t.sub(0,r) ) continue;
		
		while( l != r ){
			int m = (l+r+1)/2;
			if( s.sub(i,i+m) == t.sub(0,m) ){
				l = m;
			}else{
				r = m-1;
			}
		}
		// cout << l+1 << " " << i+T.size() << ") [" << i << "," << l << ")" << endl;
		if( s.sub(i,i+l) == t.sub(0,l) && s.sub(i+l+1,i+T.size()) == t.sub(l+1,T.size()) ) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 12556
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

ll choose(ll n, ll r){
    ll res = 1;
    for(int i = 1; i <= r; i++){
        res *= n--;
        res /= i;
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    map<int, ll> mp;
    rep(i,n) mp[a[i]]++;
    ll sum = 0;
    for(auto m: mp){
        sum += choose(m.second, 2);
    }
    rep(i,n){
        ll ans = sum;
        ans -= choose(mp[a[i]], 2);
        ans += choose(mp[a[i]]-1, 2);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 11944
import sys
import copy
from collections import deque
import collections
stdin = sys.stdin

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

a, b, c = na()

if a%c==0:
    p = a//c - 1
else:
    p = a//c

res = b//c - p
print(res)

Measured memory_bytes: 68236
def solve(a, b, c):
	ret = 0

	for i in range(len(a)):
		ret += b[a[i]-1]

		if i != 0:
			if a[i] == a[i-1] + 1:
				ret += c[a[i-1]-1]

	return ret

def main():
	n = int(input())

	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	c = list(map(int, input().strip().split()))

	print (solve(a,b,c))

if __name__ == "__main__":
	main()

Measured memory_bytes: 3064
n=int(input())
ans=float("inf")
for i in range(1,n):
    j=n-i
    tmp=0
    I=str(i)
    J=str(j)
    for ii in range(len(I)):
        tmp+=int(I[ii])
    for jj in range(len(J)):
        tmp+=int(J[jj])
    if tmp<ans:
        ans=tmp
print(ans)
        

Measured memory_bytes: 67884
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
double EPS=1e-10;
double EQ(double a,double b){
	return abs(a-b)<EPS;
}
bool f[200001];
void solve(){
	for(int i=0;i<=200000;i++) f[i]=1;
	f[0]=0,f[1]=0;
	for(int i=2;i*i<=200000;i++){
		if(f[i])
			for(int j=i*2;j<=200000;j+=i){
				f[j]=0;
			}
	}
	vector<int> v1,v2;
	for(int i=2;i<=200000;i++) if(f[i]) v1.push_back(i);
//for(int i=0;i<100;i++) cout<<v1[i]<<endl;
	int n,p;
	while(cin>>n>>p,n!=-1&&p!=-1){
		int idx = upper_bound(v1.begin(),v1.end(),n)-v1.begin();
//cout<<idx<<endl<<endl;;
		v2.clear();
		for(int i=0;i<200;i++){
			for(int j=i;j<200;j++) v2.push_back(v1[i+idx]+v1[j+idx]);
		}
		sort(v2.begin(),v2.end());
		cout<<v2[p-1]<<endl;
	}
}

int main(){
   solve();
}

Measured memory_bytes: 1380
from fractions import gcd
from functools import reduce

def gcd_list(L):
    return reduce(gcd,L)

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

def lcm_list(L):
    return reduce(lcm,L)

N,M=map(int,input().split())
a=list(map(int,input().split()))
a=list(map(lambda x:x//2,a))
ans=0

def dev_cnt(x):
    cnt=0
    while x%2==0:
        x/=2
        cnt+=1
    return cnt

dev_pre=dev_cnt(a[0])

for i in range(1,N):
    if dev_pre!=dev_cnt(a[i]):
        print(0)
        exit()
    dev_pre=dev_cnt(a[i])

dev_num=dev_cnt(a[0])

a=list(map(lambda x:x//2**dev_num,a))
lcm_a=lcm_list(a)

i=1
X=lcm_a*i

ans=M//(2**dev_num)
ans=ans//lcm_a+1
ans=ans//2

print(ans)

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

using namespace std;

const int inf = 1000000000;

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

	int n, m;
	cin >> n >> m;

	vector<string> s;
	s.resize(n);

	for(int i = 0; i < n; ++i) {
		cin >> s[i];
	}

	vector<vector<int> > dp;
	dp.resize(n);

	for(int i = 0; i < n; ++i) {
		dp[i].assign(m, inf);
	}

	dp[0][0] = 0;

	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < m; ++j) {
			if(i + 1 < n) {
				dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (s[i][j] != s[i + 1][j]));
			}

			if(j + 1 < m) {
				dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + (s[i][j] != s[i][j + 1]));
			}
		}
	}

	dp[n - 1][m - 1] += (s[0][0] == '#') + (s[n - 1][m - 1] == '#');

	cout << dp[n - 1][m - 1] / 2 << '\n';

	return 0;
}

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

using namespace std;

int main(){
  int n; cin >> n;
  vector<pair<int,int>> a;
  for(int i=0 ; i< n ; i++){
    int x,y; cin >> x >> y;
    a.emplace_back(y,x);
  }
  
  sort(a.begin(), a.end());
  
  int sum = 0;
  bool f = true;
  for(int i=0 ; i<n ; i++){
    sum += a[i].second;
    if(sum > a[i].first){
      f = false;
      break;
    }
  }
  
  cout << (f ? "Yes" : "No") << endl;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main()
{
    cin>>a;
    for(int s=1;s<a.size();s++)
    {
        if(a[s]==a[s-1])
        {
            cout<<s<<" "<<s+1<<endl;
            return 0;
        }
    }
    for(int s=2;s<a.size();s++)
    {
        if(a[s]==a[s-2])
        {
            cout<<s-1<<" "<<s+1<<endl;
            return 0;
        }
    }
    cout<<-1<<" "<<-1<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(){
  int point1,point2,point3,point4,point5,point6,point7,point8,point9,point10,sum=0;
 
    scanf("%d",&point1);
    scanf("%d",&point2);
    scanf("%d",&point3);
    scanf("%d",&point4);
    scanf("%d",&point5);
    scanf("%d",&point6);
    scanf("%d",&point7);
    scanf("%d",&point8);
    scanf("%d",&point9);
    scanf("%d",&point10);

    sum =point1+point2+point3+point4+point5+point6+point7+point8+point9+point10;
  

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

Measured memory_bytes: 600
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

pub fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
pub fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}

fn count(a: u64, b:u64, c:u64) -> u64 {
    let la = ((a+c-1)/c);
    let lb = b/c;
    // debug!(la, lb, la*c, lb*c);
    return lb-la+1;
}

fn main() {
    input!{
      a: u64,
      b: u64,
      c: u64,
      d: u64,
    }
    let e = lcm(c, d);

    let v1 = count(a, b, c);
    let v2 = count(a, b, d);
    let v3 = count(a, b, e);
    // debug!(v1, v2, v3);
    let mut ans = v1+v2-v3;
    println!("{}", b-a+1-ans);
}


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

int N;
vector<int> D;

int Min(int a, int b, int c, int d) {
    return min(a, min(b, min(c, d)));
}

int cc[52][30][30];
int dp(int idx, int mx, int mn) {
    if(idx == N) return 1e9;
    int &ret = cc[idx][mx][mn];
    if(ret != -1) return ret;

    ret = 0;
    ret = max(ret, Min(D[idx], abs(mn - D[idx]), abs(mx - D[idx]), dp(idx + 1, mx, D[idx])) );
    ret = max(ret, Min(24 - D[idx], abs(mn - 24 + D[idx]), abs(mx - 24 + D[idx]), dp(idx + 1, 24 - D[idx], mn)) );
    return ret;
}

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

    D.resize(N);
    for(int i = 0; i < N; i++) {
        scanf("%d", &D[i]);
    }

    sort(D.begin(), D.end());
    memset(cc, -1, sizeof(cc));
    printf("%d", dp(0, 0, 24));
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <atcoder/all>
#define F first
#define S second
using namespace std;
using namespace atcoder;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N; cin >> N;
  ll D; cin >> D;
  ll Point[N][2];
  two_sat S(N);
  for (int i = 0; i < N; i++) {
    cin >> Point[i][0] >> Point[i][1];
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < N; k++) {
        if (i != k) {
          for (int l = 0; l < 2; l++) {
            if (abs(Point[i][j] - Point[k][l]) < D) {
              S.add_clause(i,1-j,k,1-l);
            }
          }
        }
      }
    }
  }

  if (S.satisfiable()) {
    cout << "Yes" << endl;
    vector<bool> ans = S.answer();
    for (int i = 0; i < N; i++) {
      cout << Point[i][ans[i]] << endl;
    }
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

vector<pair<int,int>> solve(vector<int> &v){
  int n = v.size();
  map<int,int> ma;
  for(auto x : v) ma[x]++;

  vector<pair<int,int>> ret;
  ret.pb({n, -rand()});
  for(auto p : ma) ret.pb({n - p.second, p.first});
  sort(all(ret));

  return ret;
}

int main(){
  vector<vector<int>> vv(2);
  int n;
  cin>>n;
  rep(i,n) {
    int x;
    cin>>x;
    vv[i%2].pb(x);
  }

  auto v1 = solve(vv[0]);
  auto v2 = solve(vv[1]);

  if(v1[0].second != v2[0].second) cout << v1[0].first + v2[0].first << endl;
  else cout << min(v1[1].first + v2[0].first, v1[0].first + v2[1].first)  << endl;

  return 0;
}


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

int main(void)
{
    long long N, K;
    cin >> N >> K;
    vector<long long> x;
    vector<long long> y;
    for (long long i = 0; i < N; i++)
    {
        long long a;
        cin >> a;
        if (a >= 0)
        {
            x.push_back(a);
        }
        else
        {
            y.push_back(a * (-1));
        }
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    long long countx = 0;
    long long county = 0;
    long long preans;

    long long ans;
    if (x.size() > K)
    {
        ans = x[K-1];
        countx = K;
    }
    else
    {
        if (x.size() == 0)
        {
            ans = y[K-1];
            cout << ans << endl;
            exit(0);
        }
        if (y.size() == 0)
        {
            ans = x[K-1];
            cout << ans << endl;
            exit(0);
        }
        ans = min(2*x[x.size()-1] + y[K-x.size()-1], 2*y[K-x.size()-1] + x[x.size()-1]);
        countx = x.size();
        county = K-x.size();
    }
    for (long long i = 0; i < countx-1; i++)
    {
        if (county < y.size())
        {
            preans = min(2*x[x.size()-2-i] + y[K-x.size()+i], 2*y[K-x.size()+i] + x[x.size()-2-i]);
            if (ans > preans)
            {
                ans = preans;
            }
            county++;
        }
        else
        {
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4500
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define pb push_back
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
const int MOD = 1e9+7;

int main() {
	string s;
  	cin >> s;
  	int n = s.size();
  	char first,end;
  	first = s[0];
  	end = s[n-1];
  	int i = n-2;
  	cout << first << i << end << endl;
}

Measured memory_bytes: 256
### main

loop do
  n, k, m, r = gets.strip.split(' ').map{|s| s.to_i}
  break if (n | k | m | r) == 0
  #p [n, k, m, r]

  den = 1
  num = n

  if m > 0
    den0 = 1
    num0 = 1
    for i in (1...n)
      den1 = 1
      num1 = i
      den0 = den0 * num1 + den1 * num0
      num0 = num0 * num1
    end

    den *= den0
    num *= num0
  end

  g = den.gcd(num)
  den /= g
  num /= g

  d = den / num
  den = (den - d * num) * 10

  str = d.to_s + '.'

  r.times do
    d = den / num
    den = (den - d * num) * 10
    str += d.to_s
  end

  puts str
end

Measured memory_bytes: 14228
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int prime[100001];

void sieve() {
    for(int i = 0; i < 100000; i++) prime[i] = 1;
    prime[0] = prime[1] = 0;
    for(int i = 2; i <= 100000; i++) {
        if (prime[i]) {
            for(int j = i + i; j <= 100000; j += i) {
                prime[j] = 0;
            }    
        }
    }
}
/*
bool isPrime(int n) {
    if (n == 1) return false;
    if (n == 2) return true; 
    for(int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}
*/


int isSimilarTo2017(int n) {
    return prime[n] && prime[(n + 1) / 2];
}

int main() {
    sieve();
    vector<int> acc(100001, 0);
    for(int i = 1; i <= 100000; i++) {
        acc[i] = acc[i - 1] + (isSimilarTo2017(i) == true ? 1 : 0);
    }
    int Q;
    scanf("%d", &Q);
    for(int q = 0; q < Q; q++) {
        int l, r;
        scanf("%d%d", &l, &r);
        printf("%d\n", acc[r] - acc[l - 1]);
    }
    return 0;
}

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


int main(){
  string s,t;
  cin>>s>>t;
  int count=0;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]) count++;
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 3916
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

constexpr ll mod = 1e9 + 7;
const double PI = acos(-1.0);

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

  int n; cin >> n;
  vector<P> vecab(n);
  vector<P> vecc(n);
  rep(i, n) {
    ll a, b; cin >> a >> b;
    vecab[i] = P(a,b);
    ll c = a+b;
    vecc[i] = P(c, i);
  }
  sort(vecc.rbegin(), vecc.rend());

  ll ans = 0;
  for(int i=0; i<n; i++) {
    int pos = vecc[i].second;
    if (i%2 == 0) {
      ans += vecab[pos].first;
    } else {
      ans -= vecab[pos].second;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define lli long long
lli dp[101][100002];
lli w[100002],val[100002];

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

Measured memory_bytes: 78720
import sys
readline = sys.stdin.readline
s = readline().strip()
n = int(readline())
rev = False
h = []
t = []
for i in range(n):
    q = readline()
    if q.startswith("1"):
        rev = not rev
    if q.startswith("2 1"):
        if not rev:
            h.append(q[-2])
        else:
            t.append(q[-2])
    if q.startswith("2 2"):
        if not rev:
            t.append(q[-2])
        else:
            h.append(q[-2])
s = "".join(h[::-1]) + s + "".join(t)
if rev:
    print(s[::-1])
else:
    print(s)


Measured memory_bytes: 6216
S = list(input())
N = len(S)
T = input()
M = len(T)

ans = []

for i in range(N-M+1):
    tmp_S = S[:]
    if S[i] == "?" or S[i] == T[0]:
        tmp_S[i] = T[0]
        tmp = 1
        for j in range(i+1, i+M):
            if S[j] == "?" or S[j] == T[tmp]:
                tmp_S[i+tmp] = T[tmp]
                tmp += 1
            else:
                break
        tmp_S = "".join(tmp_S)
        if T in tmp_S:
            tmp_S = tmp_S.replace("?", "a")
            ans.append(tmp_S)

if ans:
    ans.sort()
    print(ans[0])
else:
    print("UNRESTORABLE")


Measured memory_bytes: 3064
using static System.Math;using static System.Console;using System.Collections.Generic;using System.Linq;using System;
using System.Reflection;

class Program
{
    #region Reader
    static string ReadStr => Console.ReadLine();
    static string[] ReadStrs => Console.ReadLine().Split(' ');
    static int ReadInt => Convert.ToInt32(Console.ReadLine());
    static int[] ReadInts => Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
    static long ReadLong => Convert.ToInt64(Console.ReadLine());
    static long[] ReadLongs => Console.ReadLine().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
    #endregion

    static int mod = (int)Pow(10, 9) + 7;

    static void Main()
    {
        int N = ReadInt;
        int[] ans = new int[N];

        for (int i = 0; i < N; i++)
        {
            string S = ReadStr;
            string T = ReadStr;

            int[,] dp = new int[S.Length + 1, T.Length + 1];

            int count = 0;
            for (int t = 1; t <= T.Length; t++)
            {
                for (int s = 1; s <= S.Length; s++)
                {
                    if (T[t - 1] == S[s - 1])
                    {
                        dp[s, t] = dp[s - 1, t - 1]+1;
                    }
                    else
                    {
                        dp[s, t] = Max(dp[s - 1, t], dp[s, t - 1]);
                    }
                    count = Max(count, dp[s, t]);
                }
            }
            ans[i] = count;
        }
        WriteLine(string.Join("\n", ans));
    }


    public class Item
    {
        public Item(int v,int w)
        {
            this.v = v;
            this.w = w;
        }
        public int v;
        public int w;
    }


}



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

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	int n, m;

	while(scanf("%d%d", &n, &m)==2)
	{
		vi a(n);

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

		int t=0;
		sort(a.rbegin(), a.rend());
		for(int ma:a) t+=ma;

		int ans=(a[m-1]*4*m>=t);
		printf("%s\n", ans?"Yes":"No");
	}
	return 0;
}


Measured memory_bytes: 256
N = int(input())
red = [list(map(int, input().split())) for _ in range(N)]
blue = [list(map(int, input().split())) for _ in range(N)]
red.sort()
blue.sort()
ret =0
for c, d in blue:
    diff = 10 ** 5
    tmp = -1
    for i, (a, b) in enumerate(red):
        if c > a and d > b:
            if diff > d-b:
                diff = d - b
                tmp = i
    if tmp > -1:
        red[tmp] = [10**5, 10**5]
        ret += 1
print(ret)

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

int main() {
  double a, b, x;
  cin >> a >> b >> x;
  double h = x / (a * a);
  if (h * 2 <= b) {
    double A = h * a * 2 / b;
    cout << fixed << setprecision(12) << atan2(b, A) / M_PI * 180 << endl;
  } else {
    double A = h * 2 - b;
    cout << fixed << setprecision(12) << atan2(b - A, a) / M_PI * 180 << endl;
  }
}


Measured memory_bytes: 4172
n,m=map(int,input().split())
r=[[*input()] for _ in range(n)]
ans=[[[0] for _ in range(m)] for _ in range(n)]
dir=[[0,0,1,1,1,-1,-1,-1],[-1,1,-1,0,1,-1,0,1]]
for i in range(n):
  for j in range(m):
    count=0
    if r[i][j]=='#':
      ans[i][j]='#'
      continue
    for k in range(8):
      dx,dy=i+dir[0][k],j+dir[1][k]
      if 0<=dx<n and 0<=dy<m and r[dx][dy]=='#':
        count+=1
    ans[i][j]=count
[print(*i,sep='') for i in ans]

Measured memory_bytes: 9324
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <string>
#include <vector>
#include <limits>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

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

    vector<int> h(n);

    for(int i = 0; i < n; ++i)
        cin >> h[i];

    vector<int> dp(n);
    dp[0] = 0;

    for(int i = 1; i < n; ++i) {
        dp[i] = dp[i - 1] + std::abs(h[i - 1] - h[i]);
        if(i - 2 >= 0)
            dp[i] = min(dp[i], dp[i - 2] + std::abs(h[i - 2] - h[i]));
    }

    cout << dp[n - 1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

const int N = 100;

int main(void) {
  int r = 0;
  int c = 0;

  std::cin >> r >> c;

  int t[N + 1][N + 1] = {0};

  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      std::cin >> t[i][j];
      
      t[r][c] += t[i][j];
      t[i][c] += t[i][j]; 
      t[r][j] += t[i][j];
    }
  }

  for (int i = 0; i <= r; i++) {
    for (int j = 0; j <= c; j++) {
      std::cout << t[i][j];

      if (j < c) {
	std::cout << " ";
      }
    }

    std::cout << std::endl;
  }
  
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++) cin >> vec.at(i);
  sort(vec.begin(), vec.end());
  int ans = 0;
  for(int i = 0; i < N; i++){
    if(i != 0 && vec.at(i) == vec.at(i - 1)) continue;
    else ans++;
  }
  cout << ans << endl;
}


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

const int MAXN = 105;

int a[MAXN], n;
int T[MAXN];

int main()
{
	scanf("%d", &n);
	int maxv = 0;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		maxv = max(maxv, a[i]);
		T[a[i]]++;
	}
	int min_len = INT_MAX;
	for (int i = 0; i <= maxv; i++) {
		if (!T[max(i, maxv-i)]) {
			puts("Impossible");
			return 0;
		}
		T[max(i, maxv-i)]--;
		min_len = min(min_len, max(i, maxv-i)+1);
	}
	for (int i = 1; i <= n-1; i++)
		if (T[i] && i < min_len) {
			puts("Impossible");
			return 0;
		}
	puts("Possible");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

template<typename T> struct SegmentTree {
  size_t n;
  vector<vector<T>> data;

  SegmentTree(size_t n_, vector<T> v) {
    n = 1;
    while(n < n_) n *= 2;
    data.resize(2 * n - 1);
    build(v);
  }
  void build(vector<T> v) {
    for (int i = 0; i < v.size(); ++i) data[i + n - 1].push_back(v[i]);
    for (int i = n - 2; i >= 0; --i) {
      int lch = i * 2 + 1;
      int rch = i * 2 + 2;
      data[i].resize(data[lch].size() + data[rch].size());
      merge(begin(data[lch]), end(data[lch]), begin(data[rch]), end(data[rch]),
          begin(data[i]));
    }
  }
  void query(int a, int b, int x0, int x1, vector<int>& res, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    if (b <= l || r <= a) return;
    if (a <= l && r <= b) {
      auto lb = lower_bound(begin(data[k]), end(data[k]), P{x0, -1});
      auto ub = upper_bound(begin(data[k]), end(data[k]), P{x1, n});
      for (auto itr = lb; itr != ub; ++itr) {
        res.push_back(itr->second);
      }
      return;
    }
    query(a, b, x0, x1, res, k * 2 + 1, l, (l + r) / 2);
    query(a, b, x0, x1, res, k * 2 + 2, (l + r) / 2, r);
  }
};

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

  vector<int> xs(n);
  vector<P> ys(n);
  vector<pair<int, P>> ps(n);
  for (int i = 0; i < n; ++i) {
    int x, y; scanf("%d%d", &x, &y);
    ps[i] = {x, {y, i}};
  }
  sort(begin(ps), end(ps));
  for (int i = 0; i < n; ++i) tie(xs[i], ys[i]) = ps[i];

  SegmentTree<P> seg(n, ys);
  int q; cin >> q;
  while (q--) {
    vector<int> ans;
    int sx, tx, sy, ty; scanf("%d%d%d%d", &sx, &tx, &sy, &ty);
    int l = lower_bound(begin(xs), end(xs), sx) - begin(xs);
    int r = upper_bound(begin(xs), end(xs), tx) - begin(xs);
    seg.query(l, r, sy, ty, ans);
    sort(begin(ans), end(ans));
    for (auto&& x : ans) printf("%d\n", x);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 141928
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int n,w;
int maxvalue = 0;

int nowvalue = 0;
int nowweight = 0;

int value[101];
int weight[101];

int standweight = 0;
vector<int> w1, w2, w3, w4;
vector <int> s1, s2, s3, s4;
int main () {
    
    
    scanf("%d%d", &n, &w);
    
    
    for (int i = 0; i < n; i++) {
        scanf("%d%d", weight + i, value + i);
        if (i == 0) {
            standweight = weight[i];
            w1.push_back(value[i]);
        }
        else {
            if (weight[i] == standweight) {
                w1.push_back(value[i]);
            }
            else if (weight[i] == standweight + 1){
                w2.push_back(value[i]);
            }
            else if (weight[i] == standweight + 2){
                w3.push_back(value[i]);
            }
            else if (weight[i] == standweight + 3){
                w4.push_back(value[i]);
            }
        }
        
    }
    sort (w1.begin(), w1.end());
    reverse (w1.begin(), w1.end());
    sort (w2.begin(), w2.end());
    reverse (w2.begin(), w2.end());
    sort (w3.begin(), w3.end());
    reverse (w3.begin(), w3.end());
    sort (w4.begin(), w4.end());
    reverse (w4.begin(), w4.end());
    
    s1.push_back(0);
    s2.push_back(0);
    s3.push_back(0);
    s4.push_back(0);
    
    
    int sum = 0;
    for (int i = 0; i < w1.size(); i++) {
        sum += w1[i];
        s1.push_back(sum);
    }
    sum = 0;
    for (int i = 0; i < w2.size(); i++) {
        sum += w2[i];
        s2.push_back(sum);
    }
    sum = 0;
    for (int i = 0; i < w3.size(); i++) {
        sum += w3[i];
        s3.push_back(sum);
    }
    sum = 0;
    for (int i = 0; i < w4.size(); i++) {
        sum += w4[i];
        s4.push_back(sum);
    }
    nowweight = 0;
    for (int i = 0; i <= w1.size() && i * standweight <= w; i++) {
        nowweight += i * standweight;
        for (int j = 0; j <= w2.size() && j * (standweight + 1) + nowweight <= w; j++) {
            nowweight += j * (standweight + 1);
            for (int k = 0; k <= w3.size() && k * (standweight + 2) + nowweight <= w; k++) {
                nowweight += k * (standweight + 2);
                
                
                int l = (w - nowweight) / (standweight + 3);
                if (l > w4.size()) {
                    l = w4.size();
                }
                nowvalue = s1[i] + s2[j] + s3[k] + s4[l];
                if (nowvalue > maxvalue)
                    maxvalue = nowvalue;
                
                
                nowweight -= k * (standweight + 2);
            }
            nowweight -= j * (standweight + 1);
        }
        nowweight -= i * standweight;
    }
    
    
    printf("%d", maxvalue);
}


Measured memory_bytes: 256
eq = input()
eq = eq.replace('\r\n',' ')
eq = eq.replace('\n',' ')
eq = eq.split()
a = int(eq[0])
b = int(eq[2])
if (eq[1] == '+'):
    c = a + b
elif (eq[1] == '-'):
    c = a -b
print(c)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
vector<int>vec[500005];
int visited[500005];
int cnt;
int dfs(int src) {
    visited[src]=1;
    for(int i=0;i<vec[src].size();i++) {
        int u=vec[src][i];
        if(visited[u]==0) {
            cnt++;
            dfs(u);
        }
    }
    return cnt;
}
int main()
{

int n,m;
     cin>>n>>m;
     for(int i=0;i<m;i++) {
        int u,v;
        cin>>u>>v;
        vec[u].push_back(v);
        vec[v].push_back(u);

    }
    int mx=0;
    for(int i=0;i<n;i++) {
        cnt=0;

        if(visited[i]==0) {


           //cout<<cnt<<endl;
            int x=dfs(i);
            //cout<<x<<endl;
            mx=max(x,mx);
        }
    }
    cout<<mx+1<<endl;

}


Measured memory_bytes: 28428
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto S = readln.chomp;
    char last;
    int cnt;
    foreach (c; S) {
        if (c != last) ++cnt;
        last = c;
    }
    writeln(cnt);
}

Measured memory_bytes: 2428
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int bom[50][50];

int main(){
  int H,W;
  cin>>H>>W;
  vector<string> S(H);
  for(int i=0;i<H;i++)
    cin>>S[i];

  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      for(int di=-1;di<=1;di++)
        for(int dj=-1;dj<=1;dj++)
          {
            int ni=i+di,nj=j+dj;
            if(ni>=0&&ni<H&&nj>=0&&nj<W&&S[i][j]=='#')
              bom[ni][nj]++;
          }

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(S[i][j]=='#')cout<<"#";
      else cout<<bom[i][j];
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn.{readLine,readInt}

object Main {

  def main(args: Array[String]) = {
    val n = readInt
    val (min,max,sum):(Int,Int,Long) = readLine.split(" ")
                                .map(_.toInt)
                                .foldLeft(Int.MaxValue,Int.MinValue,0.toLong){ case ((min,max,sum),x)=>(Math.min(min,x),Math.max(max,x),sum+x) }
    printf("%d %d %d\n",min,max,sum)
  }
}

Measured memory_bytes: 49980
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s == "Sunny")
    cout << "Cloudy" << endl;
  if(s == "Cloudy")
    cout << "Rainy" << endl;
  if(s == "Rainy")
    cout << "Sunny" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    lld a, b, c, x, y;
    scanf("%lld %lld %lld %lld %lld", &a, &b, &c, &x, &y);
    lld a_b = a+b;
    c *= 2;
    lld min = x<y ? x : y;
    lld max = x<y ? y : x;
    lld buf = max - min;
    lld ans = 0;
    if(a_b >= c){
        ans += c * min;
    }else{
        ans += a_b * min;
    }
    if(x > y){
        if(a > c){
            ans += c * buf;
        }else{
            ans += a * buf;
        }
    }else{
        if(b > c){
            ans += c * buf;
        }else{
            ans += b * buf;
        }
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define endl "\n"
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   vi a(n);
   rep(i,0,n)cin>>a[i];
   int pre[n+1];
   pre[n]=0;
   for(int i=(n-1);i>=0;i--)
   {
       pre[i]=pre[i+1]+a[i];
       pre[i]%=M;
   }
   int ans=0;
   for(int i=0;i<n;i++)
   {
       ans+=(a[i]*pre[i+1]);
       ans%=M;
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 6368
#!/usr/bin/env python3
#ABC141 A

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
if s == 'Sunny':
    print('Cloudy')
elif s == 'Cloudy':
    print('Rainy')
else:
    print('Sunny')

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <bitset>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

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

//static const ll MOD = 1000000007;
//static const ll INF = 100000000;
#define PI 3.14159265359

int main() {
    double ans = 0;

    // input
    double R;
    cin >> R;

    // process
    ans = R * PI * 2;

    cout << ans;

    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int a[3][3];
bool c[3][3];

int main(){
  rep(i, 3)rep(j, 3)cin>>a[i][j];

  int n;cin>>n;
  vector<int>b(n);
  rep(i, n)cin>>b[i];

  for(auto p:b)rep(i, 3)rep(j, 3)if(p==a[i][j])c[i][j]=true;

  bool f = false;
  rep(i, 3){
    if(c[i][0] && c[i][1] && c[i][2])f=true;
    if(c[0][i] && c[1][i] && c[2][i])f=true;
  }
  if(c[0][0] && c[1][1] && c[2][2])f=true;
  if(c[2][0] && c[1][1] && c[0][2])f=true;

  if(f)cout<<"Yes";
  else cout<<"No";

  return 0;
}

Measured memory_bytes: 256
x,n = map(int,input().split())
p = list(map(int, input().split()))
temp = 101
p.sort()

for i in range(0,102):
    if i in p:
        continue
    if temp <= min(abs(i - x),temp):
        break
    temp = min(abs(i - x),temp)
    ans = i

print(ans)

Measured memory_bytes: 9136
list = gets.split(" ").map!{|i|i.to_i}
array = []
list[0].times do |i|
  array.push gets.to_i
end
array.sort!
bus_count = 1
under = array.first
bus_lim = 0
array.each_with_index do |i,ind|
  if (i - under <= list[2] && list[1] > bus_lim)
    bus_lim += 1
  else
    bus_count += 1
    bus_lim = 1
    if array.length != ind
      under = i
    else
      break
    end
  end
end
puts bus_count

Measured memory_bytes: 4016
#include <stdio.h>

int main(void) {
	int N;
	
	scanf("%d", &N);
	
	if((N % 10) == 7)					printf("Yes\n");
	else if(((N / 10) % 10) == 7)		printf("Yes\n");
	else if(((N / 100) % 10) == 7)	printf("Yes\n");
	else								printf("No\n");
	
	return 0;
}


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

int n;

void solve(string s, int len, int p);

int main() {
  cin >> n;
  solve("", 0, 0);
  return 0;
}

void solve(string s, int len, int p) {
  if(len == n) {
    cout << s << endl;
    return;
  }
  for(int i = 0; i <= p; ++i) {
    string t = s;
    t += 'a' + i;
    solve(t, len + 1, p + (i == p));
  }
}

Measured memory_bytes: 1536
using System;

namespace aizu
{
    class OnlineJudge
    {
        const int Max = 104730;
        static void Main()
        {
            bool[] check = new bool[Max];
            long[] total = new long[10001];
            int add = 1;
            int count = 1;
            for(long i=2; i < Max; i += add) {
                if(i == 3) {
                    ++add;
                }
                if(!check[i]) {
                    total[count++] += total[count - 2] + i;
                    if(i <= 323) {
                        for(long l = i; i * l < Max; ++l) {
                            check[l * i] = true;
                        }
                    }
                }
            }
            int input;
            while((input = int.Parse(Console.ReadLine())) != 0){
                Console.WriteLine(total[input]);
            }
        }
    }
}

Measured memory_bytes: 5736
#include <stdio.h>

int main () {
	int N, nodd=0, tmp;
	scanf ("%d", &N);
	for (int i=1; i<=N; i++) {
		scanf ("%d", &tmp);
		if (tmp%2)
			nodd++;
	}
	printf ("%s\n",(nodd%2)?"NO":"YES");
	return 0;
}


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

int main()
{
	int N;
	string S;
	cin >> N >> S;
	int ans = 0;
	for (int i = 0; i <= 9; ++i)
	{
		for (int j = 0; j <= 9; ++j)
		{
			for (int k = 0; k <= 9; ++k)
			{
				int nowidx = 0; //0:i 1:j 2:k
				rep(l,N)
				{
					if (nowidx == 0 && S[l] - '0' == i)
					{
						nowidx++;
					}
					else if (nowidx == 1 && S[l] - '0' == j)
					{
						nowidx++;
					}
					else if (nowidx == 2 && S[l] - '0' == k)
					{
						ans++;
						break;
					}
				}
			}
		}
	}

	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
using namespace std;
ll gcd(ll a,ll b){
	ll t;
	if(a<b){
		t=a;
		a=b;
		b=t;
	}
	if(a%b==0)return b;
	return gcd(b,a%b);
}
int main()
{
	ll K,A=1,B=1,C=1,ANS=0;
	cin>>K;
	for(;;){
		ANS=ANS+gcd(gcd(A,B),C);
		//cout<<A<<":"<<B<<":"<<C<<endl;
		//cout<<gcd(gcd(A,B),C)<<endl;
		if(A==K&&B==K&&C==K)break;
		if(C!=K)C++;
		else if(C==K&&B!=K){
			C=1;
			B++;
		}
		else{
			A++;
			B=1;
			C=1;
		}
	}
	cout<<ANS<<endl;
}


Measured memory_bytes: 3532
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(int *)a>*(int *)b)return 1;
    return -1;
}
int main()
{   long long a,b,c;
    scanf("%lld%lld%lld",&a,&b,&c);
    if(a+b-c>=0){
        printf("No");
        return 0;
    }
    if(4*a*b>=(c-a-b)*(c-a-b)){
        printf("No");
    }else{
        printf("Yes");
    }
    return 0;
}


Measured memory_bytes: 128