akhauriyash/Code-Regression huggingface dataset:
macro_rules! scan {
    () =>{
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
}

fn main() {
    let s = scan!();
    let c = s.chars().nth(0).unwrap();
    if c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' {
        println!("vowel")
    } else {
        println!("consonant")
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<set>
#include<vector>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int gcd(int a,int b){
  return b?gcd(b,a%b):a;
}

int prime(int a,set<int>& st){
  li p=2;
  while(a>p*p){
    if(a%p==0){
      if(st.count(p)){
        return 1;
      }else st.insert(p);
      while(a%p==0){
        a/=p;
      }
    }
    p++;
  }
  if(a!=1){
    if(st.count(a)){
      return 1;
    }else st.insert(a);
  }
  return 0;
} 

int main(){
  int n; cin >>n;
  set<int> st;
  int flag=0;
  int g=0;
  rep(i,n){
    int a; cin >>a;
    g=gcd(a,g);
    flag|=prime(a,st);
  }
  
  if(flag==0){
    print("pairwise coprime");
  }else if(g==1){
    print("setwise coprime");
  }else{
    print("not coprime");
  }
}


Measured memory_bytes: 7308
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ")
#define pdd(a,n,m)for(int i=0;i<m;i++)pd(a,m)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>

int n;
vector<int>G[1111];
int d[111];
int f[111];
int cnt;

void dfs(int x){

  d[x]=++cnt;

  rep(i,G[x].size()){
    int to=G[x][i];
    if(d[to]==0)
      dfs(to);
  }
  f[x]=++cnt;
}

int main(){
  cin>>n;
  rep(i,n){
    int k,s;
    cin>>k>>s;
    rep(j,s){
      int to;
      cin>>to;
      G[k].pb(to);
    }
    sort(G[k].begin(),G[k].end());
  }

  for(int i=1;i<=n;i++){
    if(d[i]==0)dfs(i);
  }

  for(int i=1;i<=n;i++){
    cout<<i<<" "<<d[i]<<" "<<f[i]<<endl;
  }

  return 0;
}



Measured memory_bytes: 3184
package main

import (
	"fmt"
)

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	As := make([]int, N)
	var A int
	var sum int
	for i := 0; i < N; i++ {
		fmt.Scan(&A)
		As[i] = A
		sum += A
	}
	threshold := float64(sum) / float64(4*M)
	count := 0
	for i := 0; i < N; i++ {
		if float64(As[i]) >= threshold {
			count++
		}
	}
	res := "No"
	if count >= M {
		res = "Yes"
	}
	fmt.Println(res)

}


Measured memory_bytes: 512
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <math.h>
#include <string>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mk make_pair
#define fr first
#define sc second

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

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

const int maxn = 100100;

int n;
ll s, res;
map <ll,int> mp;

void solve(){
	scanf("%d", &n);
	mp[0ll] = 1;
	for(int i = 1, x; i <= n; i ++){
		scanf("%d", &x);
		s += x;
		res += mp[s];
		mp[s] ++;
	}
	printf("%lld", res);
}

int main(){
	int t = 1;
	while(t --){
		solve();
	}
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
#define N 405
using namespace __gnu_pbds;
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
const int mod = 1e9 + 7;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
LL z = 1;
int read(){
	int x, f = 1;
	char ch;
	while(ch = getchar(), ch < '0' || ch > '9') if(ch == '-') f = -1;
	x = ch - '0';
	while(ch = getchar(), ch >= '0' && ch <= '9') x = x * 10 + ch - 48;
	return x * f;
}
int ksm(int a, int b, int p){
	int s = 1;
	while(b){
		if(b & 1) s = z * s * a % p;
		a = z * a * a % p;
		b >>= 1;
	}
	return s;
}
int s[N][N], f[N][N], a[N], b[N];
int main(){
	int i, j, k, t, n, m;
	for(i = 0; i <= 400; i++){
		for(j = 1; j <= 400; j++){
			s[i][j] = (s[i][j - 1] + ksm(j, i, mod)) % mod;
		}
	}
	scanf("%d%d", &n, &m);
	for(i = 1; i <= n; i++) a[i] = read();
	for(i = 1; i <= n; i++) b[i] = read();
	for(i = 0; i <= m; i++){
		f[1][i] = s[i][b[1]] - s[i][a[1] - 1];
		//printf("%d %d\n", i, f[1][i]);
	}
	for(i = 2; i <= n; i++){
		for(j = 0; j <= m; j++){
			for(k = 0; k <= j; k++){
				t = (z * f[i - 1][k] * (s[j - k][b[i]] - s[j - k][a[i] - 1]) % mod) % mod;
				f[i][j] = (f[i][j] + t) % mod;
			}
			//printf("%d %d %d===\n", i, j, f[i][j]);
		}
	}
	f[n][m] = (f[n][m] + mod) % mod;
	printf("%d", f[n][m]);
	return 0;
}


Measured memory_bytes: 1664
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int calc_sum_digits(string num) {
  int sum_digits = 0;

  for(int i = 0; i < num.size(); i++) {
    sum_digits += num[i] - '0';
  }

  return sum_digits;
}

int main(){
  while(true) {
    string num;
    cin >> num;

    if(num == "0") {
      break;
    }

    int sum_digits = calc_sum_digits(num);

    printf("%d\n", sum_digits);
  }
}



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

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

ll lcm(ll a, ll b) { //最小公倍数
  return a * b / gcd(a, b);
}

ll digit_sum(ll a){ //10進桁和
  ll ans=0;
  while(a>0){
    ans+=a%10;
    a/=10;
  }
  return ans;
}



int main()
{
  string s;
  cin>>s;
  s.erase(0,4);
  cout<<"2018"+s<<endl;
  return 0;
}


Measured memory_bytes: 3520
<?php
class Dice{
  public $label=[1,2,3,4,5,6];#index+1????????¢?????????
  public $pos=[0,1,2];#?????¢,?????¢,??\??¢???index ???????????¢???5-index
  function __construct($sLabel){$this->label=explode(' ',$sLabel,6);}
  function move($s){
    $x=$this->pos[0];
    if($s=='E'){
      $this->pos[0]=5-$this->pos[2];
      $this->pos[2]=$x;
    }
    elseif($s=='W'){
      $this->pos[0]=$this->pos[2];
      $this->pos[2]=5-$x;
    }
    elseif($s=='N'){
      $this->pos[0]=$this->pos[1];
      $this->pos[1]=5-$x;
    }
    elseif($s=='S'){
      $this->pos[0]=5-$this->pos[1];
      $this->pos[1]=$x;
    }
  }
  function spin($s){
    $x=$this->pos[1];
    if($s=='L'){
      $this->pos[1]=$this->pos[2];
      $this->pos[2]=5-$x;
    }
    elseif($s=='R'){
      $this->pos[1]=5-$this->pos[2];
      $this->pos[2]=$x;
    }
  }
  function toTop($label){
    for($j=0;$j<4;$j++){
      if($this->top()==$label) return 1;
      $this->move('N');
    }
    for($j=0;$j<2;$j++){
      $this->move('E');
      if($this->top()==$label) return 1;
      $this->move('E');
    }
    return 0;
  }
  function toSpin($label){
    for($j=0;$j<4;$j++){
      if($this->front()==$label) return 1;
      $this->spin('L');
    }
    return 0;
  }
  function top(){return $this->label[$this->pos[0]];}
  function front(){return $this->label[$this->pos[1]];}
  function right(){return $this->label[$this->pos[2]];}
}

$dice=new Dice(trim(fgets(STDIN)));
$q=trim(fgets(STDIN));
for($i=0;$i<$q;$i++){
  list($a,$b)=explode(' ',trim(fgets(STDIN)));
  $dice->toTop($a);
  $dice->toSpin($b);
  echo $dice->right(),PHP_EOL;
}

Measured memory_bytes: 15416
#include <bits/stdc++.h>
using namespace std;
#define __ <<' '<<
#define ___ <<' '
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {IoSetup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout <<fixed<<setprecision(12);
    cerr <<fixed<<setprecision(12);
}}IoSetup;

using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,1,0,-1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    string s, t;
    cin >> s >> t;

    cout << (s[0]==t[0]) + (s[1]==t[1]) + (s[2]==t[2]) << endl;
  
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<functional>

using namespace std;
#define LL long long
#define ALF "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define LLBIG 1999999999999999999LL
#define INTBIG 1111111111
#define MOD 1000000007
#define PI pair<int,int>
#define PL pair<LL,LL>
#define VI vector<int>
#define VVI vector<vector<int>>

LL N, M, ans = 0;
map<LL, LL> drink;

int main() {
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		LL a, b; cin >> a >> b;
		drink[a]+=b;
	}
	auto itr = drink.begin();
	for (int i = M; i > 0;) {
		LL tmp = itr->second;
		if (tmp < i) {
			ans += itr->first * tmp;
			i -= tmp;
			itr=next(itr,1);
		}
		else {
			ans += i * itr->first;
			i = 0;
		}
		
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
using namespace std;
int main() {
    int r, c; cin >> r >> c;
    int a[r + 1][c + 1];
    for (int i = 0; i <= r; i++) {
        for (int j = 0; j <= c; j++) {
            a[i][j] = 0;
        }
    }
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            a[i][c] += a[i][j];
            a[r][j] += a[i][j];
        }
    }
    for (int i = 0; i < c; i++) {
        a[r][c] += a[r][i];
    }
    for (int i = 0; i <= r; i++) {
        for (int j = 0; j <= c; j++) {
            cout << a[i][j];
            if (j != c) cout << ' ';
        }
        cout << endl;
    }
}


Measured memory_bytes: 3112
S = list(str(input()))
T = list(str(input()))

S_ = set(list(S))
T_ = set(list(T))
for c in T:
    if c not in S_:
        print(-1)
        exit()

d = [[] for _ in range(26)]
for i, s in enumerate(S):
    d[ord(s)-ord('a')].append(i)
#print(d)

q = 0
pre = -1
import bisect
for t in T:
    j = ord(t)-ord('a')
    idx = bisect.bisect_right(d[j], pre)
    if idx == len(d[j]):
        q += 1
        pre = d[j][0]
    else:
        pre = d[j][idx]
print(q*len(S)+pre+1)


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

int main() {
  double n;
  cin>>n;
  vector<double> s(n);
  for (int i=0;i<n;i++) {
    cin>>s[i];
  }
  double sum = 0;
  for (int i=0;i<n;i++) {
    sum += 1/s[i];
  }
  cout<<1/sum<<endl;
}


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

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

int main() {
    vector<vector<int> >  a(3,vector<int>(3,0));
    REP(i,3){
        REP(j,3){
            cin >> a[i][j];
        }
    }

    int N;
    cin >> N;

    vector<int> b(N,0);
    REP(i,N) cin >> b[i];

    vector<vector<bool> >  ok(3,vector<bool>(3,false));


    REP(i,N){
        int num = b[i];
        REP(j,3){
            REP(k,3){
                if(a[j][k]==num) ok[j][k] = true;
            }
        }
    }


    bool bingo  = false;

    REP(i,3){
        if(ok[i][0]&&ok[i][1]&&ok[i][2]) bingo = true;
        if(ok[0][i]&&ok[1][i]&&ok[2][i]) bingo = true;
    }

    if(ok[0][0]&&ok[1][1]&&ok[2][2]) bingo = true;
    if(ok[0][2]&&ok[1][1]&&ok[2][0]) bingo = true;

    if(bingo) cout << "Yes" << endl;
    else cout << "No" << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

const ll MAX_N = 100010;
const ll MAX_E = 200020;

// antsbook p.86
ll par[MAX_N];
ll _rank[MAX_N];

void init(ll n){
    rep(i, n){
        par[i] = i;
        _rank[i] = 0;
    }
}

ll find(ll x){
    if(par[x] == x){
        return x;
    }else{
        return par[x] = find(par[x]);
    }
}

void unite(ll x, ll y){
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(_rank[x] < _rank[y]){
        par[x] = y;
    }else{
        par[y] = x;
        if(_rank[x] == _rank[y]) _rank[x]++;
    }
}

bool same(ll x, ll y){
    return find(x) == find(y);
}

// antsbook p.101
struct edge { ll u, v, cost; };

bool comp(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;
}

edge es[MAX_E];
ll V, E;

ll Kruskal(){
    sort(es, es+E, comp);
    init(V);
    ll res = 0;
    rep(i, E){
        edge e = es[i];
        if(!same(e.u, e.v)){
            unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    V = n;
    E = 2*(n-1);
    vll x(n), y(n);
    vp ix(n), iy(n);
    rep(i, n){
        cin >> x[i] >> y[i];
        ix[i].first = x[i];
        ix[i].second = i;
        iy[i].first = y[i];
        iy[i].second = i;
    }
    sort(ALL(ix));
    sort(ALL(iy));
    rep(i, n-1){
        es[2*i]   = {ix[i].second, ix[i+1].second, ix[i+1].first-ix[i].first};
        es[2*i+1] = {iy[i].second, iy[i+1].second, iy[i+1].first-iy[i].first};
    }
    cout << Kruskal() << endl;
    return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define ll long long
const int mod=1e9+7;
using namespace std;
int n,ma=-0x3f3f3f3f;
string s;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    map<string,int>m;
    for(int i=1;i<=n;i++){
        cin>>s;
        m[s]++;
        ma=max(m[s],ma);
    }
    for(auto it=m.begin();it!=m.end();it++)
        if(it->second==ma) cout<<it->first<<endl;
    return 0;
}

Measured memory_bytes: 23808
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <unordered_map>

using namespace std;

void solve() {
    int x, a; cin >> x >> a;
    if(x < a) cout << 0 << endl;
    else cout << 10 << endl;
}

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

Measured memory_bytes: 256
import sys
h, w = [int(i) for i in sys.stdin.readline().split()]
s = [sys.stdin.readline().strip() for _ in range(h)]

WHITE = '.'
BLACK = '#'

def can_draw():
    for i in range(h):
        for j in range(w):
            if s[i][j] == WHITE:
                continue

            top = i - 1
            bottom = i + 1
            left = j - 1
            right = j + 1

            if top >= 0:
                if s[top][j] == BLACK:
                    continue

            if bottom < h:
                if s[bottom][j] == BLACK:
                    continue

            if left >= 0:
                if s[i][left] == BLACK:
                    continue

            if right < w:
                if s[i][right] == BLACK:
                    continue

            return False
    return True

if can_draw():
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#!/usr/bin/env python3

def main():
    N = int(input())
    S1 = input()
    S2 = input()

    m = 10 ** 9 + 7
    v = (S1[0] == S2[0])
    r, i = 0, 0
    if v:
        r = 3
        i = 1
    else:
        r = 6
        i = 2

    while i < N:
        if S1[i] == S2[i]:
            if v:
                r *= 2
                r %= m
            v = True
            i += 1
        else:
            if v:
                r *= 2
                r %= m
            else:
                r *= 3
                r %= m
            v = False
            i += 2


    print(r)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
/*************************************************************
     File Name: B.cpp
     Created Time: Sat 07 Apr 2018 08:11:17 PM CST
 ************************************************************/

#include <iostream>
#include <string>
#include <set>

using namespace std;
string s;
int main() {
    while (cin >> s) {
        set<char> myset;
        for (auto it : s ) {
            // cout << it << endl;
            myset.insert(it);
        }
        if (myset.size() == 3) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define sz(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int n;string s;cin>>n>>s;
    int ans=0;
    rep(i,n-1){
        int mp=0;
        unordered_set<char> se;
        unordered_set<char> se_;
        rep(j,i+1){
            se.insert(s[j]);
        }
        FOR(j,i+1,n-1){
            se_.insert(s[j]);
        }
        for (auto z : se_) {
            if(se.count(z)){
                mp++;
            }
        }
        ans=max(ans,mp);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

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

typedef long long ll;

int main()
{
	ll num;
	int cp, cnt;
	bool j;
	while(cin >> num)
	{
		if(num == 0)
			break;
		
		ll ans = 0;
		while(num)
		{
			ans += num / 5;
			num /= 5;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
 
int main(){
  int n;cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  int m=a[n-1];
  vector<int>b(m+1,1);
  rep(i,n){
    if(b[a[i]]){
      if(i>0)if(a[i]==a[i-1])b[a[i]]=0;
      for(int j=2;a[i]*j<=m;j++){
        b[a[i]*j]=0;
      }//for
    }//if
  }//rep
  int ans=0;
  rep(i,n){
    if(b[a[i]])ans++;
  }
  cout<<ans;
}  

Measured memory_bytes: 8012
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

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

signed main() {
	int N, Q;
	string S;
	cin >> N >> S >> Q;

	rep(i, Q) {
		int k;
		cin >> k;

		int pt0 = 0;
		int pt1 = 0;
		int cntM = 0;
		int cntC = 0;
		
		while (pt0 < N && S[pt0] != 'D') pt0++;
		if (pt0 == N) {
			cout << 0 << endl;
			continue;
		}

		int ret = 0;
		int tmp = 0;
		pt1 = pt0;
		while (pt0 < N) {
			while (pt1 < N && pt1 - pt0 < k) {
				if (S[pt1] == 'M') cntM++;
				else if (S[pt1] == 'C') {
					cntC++;
					tmp += cntM;
				}
				pt1++;
			}

			ret += tmp;

			pt0++;
			while (pt0 < pt1 && S[pt0] != 'D') {
				if (S[pt0] == 'M') {
					cntM--;
					tmp -= cntC;
				} else if (S[pt0] == 'C') {
					cntC--;
				}
				pt0++;
			}
			while (pt0 < N && S[pt0] != 'D') {
				pt0++;
				pt1++;
			}
		}

		cout << ret << endl;
	}

    return 0;
}


Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
Int memo[55][55];
Int comb(int n, int r) {
    if (n < r) return 0;
    if (memo[n][r] > 0) return memo[n][r];
    if (r == 0 || r == n) return memo[n][r] = 1;
    return memo[n][r] = comb(n - 1, r - 1) + comb(n - 1, r);
}
Int solve2(int K, int B, const vector<int> &A) {
    vector<Int> ary(1 << B);
    vector<Int> F(A.size() + 1);
    for (int i = 1; i <= A.size(); i++) {
        for (int j = 1; j <= K; j++) F[i] += comb(i, j);
    }
    for (int i = 0; i < (1 << B); i++) {
        map<int, int> M;
        for (auto a : A) M[a & i]++;
        for (auto &p : M) ary[i] += F[p.second];
    }
    Int ans = 0;
    for (int i = 0; i < (1 << B); i++) {
        ans += (__builtin_popcount(i) % 2 == 0 ? +1 : -1) * ary[i];
    }
    return ans;
}
Int solve(int K, int S, int T, const vector<int> &A) {
    vector<int> B;
    for (auto a : A) {
        if ((a & S) != S) continue;
        if ((a & ~T) != 0) continue;
        B.push_back(a);
    }
    T &= ~S;
    for (auto &b : B) {
        int j = 0, k = 0;
        for (int i = 0; i < 18; i++) if ((1 << i) & T) {
            k |= !!(b & (1 << i)) << j;
            j++;
        }
        b = k;
    }
    return solve2(K, __builtin_popcount(T), B);
}
int main() {
    int N, K, S, T; cin >> N >> K >> S >> T;
    vector<int> A(N); for (auto &a : A) cin >> a;
    cout << solve(K, S, T, A) << '\n';
    return 0;
}

Measured memory_bytes: 5344
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rp(i,n) for (int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define all_acc(x) (x).begin(), (x).end(), 0LL
#define int long long
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool { return abs(i) < abs(j); });
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
using ll = long long;
double pi=3.14159265359;


signed main(){
    int n; cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];

    vector<vector<int>> dp(n,vector<int>(2,0));

    //0を所持金,1を所持株にする。
    dp[0][0]=1000;
    int money=1000;
    int stock=0;

    for(int i=0;i<n;i++){
        if(i==n-1){
            money+=stock*a[n-1];
            stock=0;
        }
        else{
            if(a[i]<a[i+1]){
                int num=money/a[i];
                money-=num*a[i];
                stock+=num;
            }else if(a[i]>a[i+1]){
                money+=stock*a[i];
                stock=0;
            }
        }
    }

    cout<<money<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
    using namespace std;
    #define int long long int
    #define vi vector<int>
    #define pii pair<long long ,long long>
    #define pll pair<int,int>
    #define mod 1000000007
    #define hell 998244353
    #define all(x) x.begin(),x.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb push_back
    #define ff first
    #define ss second
    #define rep(n) for(int i=0;i<n;i++)
    #define lb lower_bound
    #define up upper_bound
    int dp[100006];
    void solve()
    { 
      
      int n,k;
      cin>>n>>k;
      vi v(n);
      rep(n)
       cin>>v[i];
      dp[0]=false;
      for(int i=1;i<=k;i++)
      {
         dp[i]=false;
         for(int j=0;j<n;j++)
         {
            if(v[j]>i) continue;

            if(!dp[i-v[j]])
              dp[i]=true;
         }
      }
      if(dp[k])
         cout<<"First";
       else
        cout<<"Second";
     

      

    }



    signed main()
    {

      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      cout.tie(NULL);


    /*  #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: 1024
from scipy.sparse.csgraph import floyd_warshall as ws
import numpy as np

N,M=list(map(int,input().split()))
dist=np.array([[10**9 for _ in range(N)] for _ in range(N)])
for i in range(N):
    dist[i,i]=0

for i in range(M):
    a,b,c=list(map(int,input().split()))
    dist[a-1,b-1]=c
    dist[b-1,a-1]=c

wsdist=np.array(ws(dist),dtype='int')
ans=-N
for i in range(N):
    for j in range(N):
        if wsdist[i][j]==dist[i][j]:
            ans+=1
print(M-ans//2)

Measured memory_bytes: 17000
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<string>
#include<map>
#include<queue>

using namespace std;

int main(void){

    string str;
    cin >> str;
    int count = 0;

    for(int i = 0;str[i] != '\0';i++){
        if(str[i] == 'o') count++;
    }

    cout << 700 + 100 * count << endl;

    return 0;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  int city[N]={0};
  int a, b;
  for (int i = 0; i<M; i++){
    cin >> a >> b;
    city[a-1]++;
    city[b-1]++;
  }
  for (int i=0;i<N;i++) cout << city[i] << endl;

}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: LRUD Game
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

/* global variables */

char s[MAX_N + 4], t[MAX_N + 4];

/* subroutines */

/* main */

int main() {
  int h, w, n, sy, sx;
  scanf("%d%d%d%d%d%s%s", &h, &w, &n, &sy, &sx, s, t);

  int x0 = 1, y0 = 1, x1 = w, y1 = h;
  for (int i = n - 1; i >= 0; i--) {
    switch (t[i]) {
    case 'L': if (x1 < w) x1++; break;
    case 'R': if (x0 > 1) x0--; break;
    case 'U': if (y1 < h) y1++; break;
    case 'D': if (y0 > 1) y0--; break;
    }

    switch (s[i]) {
    case 'L': x0++; break;
    case 'R': x1--; break;
    case 'U': y0++; break;
    case 'D': y1--; break;
    }

    if (x0 > x1 || y0 > y1) {
      puts("NO");
      return 0;
    }
  }

  if (x0 <= sx && sx <= x1 && y0 <= sy && sy <= y1)
    puts("YES");
  else
    puts("NO");
  return 0;
}


Measured memory_bytes: 640
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int x = sc.nextInt();
    int t = sc.nextInt();
    
    int ans = 0;
    if (n%x==0){
      ans = (n/x)*t;
    }
    else{
      ans = (n/x+1)*t;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35780
from collections import Counter
N, li = int(input()), list(map(int, input().split()))
cnt_dict, cnt_total = Counter(li), 0
for i in cnt_dict.items():
    cnt_total += i[1] * (i[1]-1) // 2
for k in range(N):
    buf = cnt_dict[li[k]]
    print(cnt_total - buf*(buf-1)//2 + (buf-1)*(buf-2)//2)

Measured memory_bytes: 87756
#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 whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<ll, ll>;
#define debug(var) cout << "[" << #var << "] " << var << endl
const ll mod = 1000000007;


int main(){
    int n, k;
    cin >> n >> k;
    vector<P> s(n);
    rep(i, n) {
        cin >> s[i].first >> s[i].second;
        s[i].first--;
    }
    auto comp = [](P a, P b) {
        if (a.second!=b.second) return a.second>b.second;
        else return a.first<b.first;
    };
    sort(s.begin(), s.end(), comp);
    priority_queue<P, vector<P>, decltype(comp)> q{comp};
    vector<ll> num(n);
    ll sum = 0;
    ll nt = 0;
    rep(i, k) {
        q.push(s[i]);
        if (num[s[i].first]==0) nt++;
        num[s[i].first]++;
        sum += s[i].second;
    }
    ll ans = nt*nt + sum;

    

    for (int i=k; i<n; i++) {
        if (num[s[i].first]) continue;
        P now = P(-1, 0);
        while (!q.empty()) {
            now = q.top();
            q.pop();
            if (num[now.first]>1) break;
        }
        if (q.empty() || now.first==-1) break;
        sum -= now.second;
        sum += s[i].second;
        nt++;
        num[s[i].first]++;
        ans = max(ans, sum+nt*nt);
    }
    
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4724
#include<iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	int ans=0;
	int ansi=1;
	for(int i=1;i<=n;i++){
		int count=0;
		int j=i;
		while(j%2==0){
			j/=2;
			count++;
		}
		if(ans<count){
			ans=count;
			ansi=i;
		}
	}
	cout << ansi << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll h, n;
ll d[10005];

int main()
{
    cin>>h>>n;
    for(ll i = 1; i <= h; i++)
    {
        d[i] = 4e18;
    }
    for(ll i = 0; i < n; i++)
    {
        ll a, b;
        cin>>a>>b;
        for(ll i = 0; i < h; i++)
        {
            d[min(i + a, h)] = min(d[min(i + a, h)], d[i] + b);
        }
    }
    cout<<d[h]<<endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Collections;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int cN = sc.nextInt();
		int nL = sc.nextInt();

		ArrayList<String> dics = new ArrayList<String>();

		for(int i=0; i< cN;i++){
			dics.add(sc.next());
		}

		Collections.sort(dics);

		String dicsordered = "";
		for(int i=0; i< cN;i++){
			dicsordered = dicsordered + dics.get(i);
		}
		System.out.println(dicsordered);

	}
}


Measured memory_bytes: 15124
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N = int(input())
A = list(map(int, input().split()))

MOD= 10 ** 9 + 7

acc = [0] * (N + 1)
for i in range(1, N + 1):
    acc[i] = acc[i - 1] + A[i - 1]

ans = 0
for i in range(N):
    now = (acc[N] - acc[i + 1]) % MOD
    ans += now * A[i]
    ans %= MOD
print(ans % MOD)

Measured memory_bytes: 98240
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    h,w,k=map(int,input().split())
    grid=[list(input()) for _ in range(h)]
    now=1
    from itertools import product
    for i,j in product(range(h),range(w)):
        if(grid[i][j]=='#'):
            l=j; r=j
            while(l-1>=0 and grid[i][l-1]=='.'): l-=1
            while(r+1<=w-1 and grid[i][r+1]=='.'): r+=1
            u=i; d=i
            while(u-1>=0 and all(grid[u-1][j]=='.' for j in range(l,r+1))): u-=1
            while(d+1<=h-1 and all(grid[d+1][j]=='.' for j in range(l,r+1))): d+=1
            for s,t in product(range(u,d+1),range(l,r+1)):
                grid[s][t]=now
            now+=1
    for g in grid:
        print(*g)
resolve()

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

int selectionSort(int a[], int n) {
	int counter=0;
	for(int i=0; i<n; i++) {
		int minj = i;
		for(int j=i; j<n; j++) {
			if(a[j] < a[minj])
				minj = j;
		}
		if(i!=minj) {
		swap(a[i],a[minj]);
		counter++;
		}
	}
	return counter;
}

int main() {
	int array[100];
	int n;
	int counter;
	cin >> n;
	for(int i=0; i<n; i++) {
		cin >> array[i];
	}

	counter = selectionSort(array, n);

	for(int i=0; i<n; i++) {
		if(i>0)
			cout << " ";
		cout << array[i];
	}
	cout << endl;

	cout << counter << endl;

}




Measured memory_bytes: 3120
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp> 
using namespace std;using namespace boost::multiprecision;
//型に気を付けよう
//a=0x61=97 '0'=0x30=48
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef string str;
typedef cpp_int cint;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;

//桁数指定　cout << fixed << setprecision(2)
cint fact(int x){//x! 階乗
  cint ans=1;
  for (int i=1;i<=x;i++){
    ans *= i;}
  return ans;
}
cint combination(int n,int k){//nCk　組み合わせ　fact関数必須! O(1)
  cint ans=0;
  if(k==0)return 1;
  if(k==1)return n;
  ans=fact(n)/(fact(k)*fact(n-k));
  ans%=mod;
  return ans;
}

int main() {
  int n,s;cin>>s;
  cint ans=0;
  for(n=1;n<=s/3;n++){
    int sc=s-3*n;
    ans+=combination(n-1+sc,n-1);
    ans%=mod;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int MOD = 1e9+7;
int main()
{
    fastio();
    int h,w;cin>>h>>w;
    char a[h][w];
    ll dp[h+1][w+1]={};
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cin>>a[i][j];
        }
    }
    dp[1][1]=1;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            if(a[i][j]=='#')
            {
                continue;
            }
            dp[i+1][j+1]+= (dp[i][j+1]+dp[i+1][j]);
            dp[i+1][j+1]%=MOD;
        }
    }
    cout<<dp[h][w]<<endl;
    return 0;
 }    

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

using P = pair<ll, ll>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<P> td(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> td[i].first >> td[i].second;
    }
    sort(ALL(td), [](const auto &a, const auto &b) { return a.second > b.second; });
    ll ans = 0, now = 0;
    map<ll, int> sushi;
    priority_queue<ll, vector<ll>, greater<ll>> pq;
    for (ll i = 0; i < k; i++)
    {
        now += td[i].second;
        if (sushi[td[i].first] <= 0)
        {
            sushi[td[i].first]++;
        }
        else
        {
            pq.push(td[i].second);
        }
    }
    ll index = k;
    ans = now + (ll)sushi.size() * (ll)sushi.size();
    while (!pq.empty() && index < n)
    {
        if (sushi[td[index].first] <= 0)
        {
            now -= pq.top();
            pq.pop();
            now += td[index].second;
            sushi[td[index].first]++;
            chmax(ans, now + (ll)sushi.size() * (ll)sushi.size());
        }
        index++;
    }
    cout << ans << endl;
}

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

int main() {
  string s;
  cin >> s;
  for(int i=0; i < s.size()-1; i++) {
    if(s.substr(i,2) == "AC"){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3640
min_li, max_li = [], []
n = int(input())
for _ in range(n):
    a, b = map(int, input().split())
    min_li.append((a, b))
    max_li.append((a, b))
min_li.sort()
max_li.sort(key=lambda x: x[1], reverse=True)
if n % 2 == 1:
    mid = n // 2
    blue_min = min_li[mid][0]
    blue_max = min(min_li[mid:], key=lambda x: x[1])[1]
    red_max = max_li[mid][1]
    red_min = max(max_li[mid:])[0]
else:
    mid_1 = n // 2 - 1
    mid_2 = n // 2
    min_li_half = sorted(min_li[mid_1:], key=lambda x: x[1])
    blue_min = min_li[mid_1][0] + min_li[mid_2][0]
    blue_max = min_li_half[0][1] + min_li_half[1][1]
    max_li_half = sorted(max_li[mid_1:], reverse=True)
    red_max = max_li[mid_1][1] + max_li[mid_2][1]
    red_min = max_li_half[0][0] + max_li_half[1][0]

ans = red_max - blue_min + 1

print(ans)

Measured memory_bytes: 53504
#include <bits/stdc++.h>
#define ll long long
#define PI 3.14159265
using namespace std;
const int N = 3e5 + 5, mod = 1e9 + 7;




int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long double a, b, h, m;
    cin >> a >> b >> h >> m;
    h = h * 5 + (m * 5 / 60);
    long double kam;
    if(h > m) kam = h - m;
    else kam = m - h;
    if(kam > 30) kam = 60 - kam;
    kam = kam * 90 / 15;
    long double ans = a * a + b * b - (2 * a * b * cos(kam * 2*acos(0) / 180.00));
    cout << fixed << setprecision(10) << sqrt(ans);


    return 0;

}


Measured memory_bytes: 4140
N=int(input())
w=[]
for _ in range(N):
  w_i=str(input())
  w.append(w_i)
for i in range(N):
  for j in range(i+1,N):
    if w[i]==w[j]:
      print("No")
      exit()
for i in range(N-1):
  p=w[i]
  q=w[i+1]
  if p[-1]!=q[0]:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RNG(i, a, b) for(int i = a; i < b; i++)
#define RBF(i, v) for(auto& i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main()
{	
	string s;
	cin >> s;
	if (s == "AAA" || s == "BBB") {
		col("No");
	}
	else {
		col("Yes");
	}

	return 0;
}


Measured memory_bytes: 3648
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Init() {
  sc.Split(bufio.ScanWords)
}

func NextLine() (string, bool) {
  nonstop := sc.Scan()
  return sc.Text(), nonstop
}

func NextWord() (string, bool) {
  nonstop := sc.Scan()
  return sc.Text(), nonstop
}

func NextInt() (int, bool) {
  nonstop := sc.Scan()
  res, _ := strconv.ParseInt(sc.Text(), 10, 32)
  return int(res), nonstop
}

func NextLong() (int64, bool) {
  nonstop := sc.Scan()
  res, _ := strconv.ParseInt(sc.Text(), 10, 64)
  return int64(res), nonstop
}

func NextFloat() (float32, bool) {
  nonstop := sc.Scan()
  res, _ := strconv.ParseFloat(sc.Text(), 32)
  return float32(res), nonstop
}

func NextDouble() (float64, bool) {
  nonstop := sc.Scan()
  res, _ := strconv.ParseFloat(sc.Text(), 64)
  return float64(res), nonstop
}

func main(){
  Init()
  n, _ := NextInt()
  p := make([]int, n)
  for i := 0; i < n; i++ {
    p[i], _ = NextInt()
  }
  ans := 0
  for i := 1; i < n-1; i++ {
    if p[i-1] < p[i] && p[i] < p[i+1] {
      ans++
    }else if p[i-1] > p[i] && p[i] > p[i+1] {
      ans++
    }
  }
  fmt.Printf("%d\n", ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int M;
  cin>>M;
  int N=M;
  int sum=0;
  for(int i=0;i<9;i++){
    sum+=N%10;
    N/=10;
  }
  if(M%sum==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007)
#define IINF (1<<28)
#define LINF (1LL<<60)
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"

namespace solver {
  using namespace std;
  typedef long long ll;
  typedef vector<vector<ll> > matrix;

  int N;
  ll K;
  matrix G;

  void init() {
    cin >> N >> K;
    G.resize(N);
    rep(i, N) {
      G[i].resize(N);
      rep(j, N) {
        cin >> G[i][j];
      }
    }
  }

  matrix mul(matrix &A, matrix &B) {
    matrix C(N, vector<ll>(N));
    rep(i, N) rep(j, N) rep(k, N) {
      C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD_1_000_000_007;
    }
    return C;
  }

  void solve() {
    matrix A(N, vector<ll>(N));
    rep(i, N) A[i][i] = 1;
    while(K>0) {
      if(K & 1) {
        A = mul(A, G);
      }
      G = mul(G, G);
      K >>= 1;
    }
    ll ans = 0;
    rep(i, N) rep(j, N) ans = (ans + A[i][j]) % MOD_1_000_000_007;
    cout << ans << "\n";
  }
}

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

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

int main(){
  int x,a,b;
  cin>>x>>a>>b;
  if(a-b>=0)
    cout<<"delicious"<<endl;
  else{
    if((x-(b-a))>=0)
       cout<<"safe"<<endl;
       else cout<<"dangerous"<<endl;
  }
}       

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

namespace TestCS
{
    class Program
    {
        public static void Main(string[] args)
        {
            
            int[]input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = input[0];
            int m = input[1];
            int[,] matrix = new int[n, m];
            List<int> vectorB = new List<int>();
            for(int i = 0;i < n; i++)
            {
                int[] vec = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                for(int j = 0; j < m; j++)
                {
                    matrix[i, j] = vec[j];
                }
            }
            for(int i = 0;i < m; i++)
            {
                vectorB.Add(int.Parse(Console.ReadLine()));
            }
            for(int i = 0;i < n; i++)
            {
                int sum = 0;
                for(int j =0;j < m; j++)
                {
                    sum += matrix[i,j] * vectorB[j];
                }
                Console.WriteLine(sum);
            }

        }
    }
}



Measured memory_bytes: 18440
import bisect
def main():
    n = int(input())
    print(0)
    s = input()
    seat_dict = {"Male": 1, "Female": 2}
    if s == "Male":
        ls = [1, 2] * ((n - 1) // 2) + [1] * ((n -1) % 2)
    elif s == "Female":
        ls = [2, 1] * ((n - 1) // 2) + [2] * ((n - 1) % 2)
    else:
        return
    up = n - 1
    down = 0
    for i in range(20):
        mid = (up + down) // 2
        if mid == down:
            mid = up
        print(mid)
        s = input()
        if s == "Vacant":
            break
        _s = seat_dict[s]
        if _s == ls[mid]:
            down = mid
        else:
            up = mid

if __name__ == "__main__":
    main()

Measured memory_bytes: 40388
#include <cstdio>
int a[100010],sum[2],n;
bool flag;
int gcd(int a,int b)
{
	if (b==0) return a;
	else return gcd(b,a%b);
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if (a[i]>1) sum[a[i]&1]++;
	}
	if (n==1)
	{
		if (a[1]&1) printf("Second\n");
		else printf("First\n");
		return 0;
	}
	flag=false;
	while (1)
	{
		if (!sum[0]&&!sum[1])
		{
			if (!flag) printf("Second\n");
			else printf("First\n");
			return 0;
		}
		if (sum[0]&1)
		{
			if (!flag) printf("First\n");
			else printf("Second\n");
			return 0;
		}
		if (sum[1]>1||!sum[1])
		{
			if (!flag) printf("Second\n");
			else printf("First\n");
			return 0;
		}
		int GCD=-1;
		for (int i=1;i<=n;i++)
			if (a[i]>1)
			{
				if (a[i]&1)
				{
					a[i]--;break;
				}
			}
		for (int i=1;i<=n;i++)	
			if (GCD==-1) GCD=a[i];
			else GCD=gcd(a[i],GCD);
		sum[0]=sum[1]=0;
		for (int i=1;i<=n;i++)
		{
			a[i]/=GCD;
			if (a[i]>1) sum[a[i]&1]++;
		}
		flag^=1;
	}
	return 0;
}
//all is 1: who faces even number of even number, lose./odd number of even number, win.

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int x;
	cin >> x;
	if(x % 11 == 0 || x % 11 >= 7)
		if(x % 11 == 0)
			cout << x / 11 * 2 << endl;
		else
			cout << (x / 11 + 1) * 2 << endl;
	else
		cout << x / 11 * 2 + 1 << endl;
}

Measured memory_bytes: 256