akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;
using pint = pair<int,int>;

// 入力
int N, a, b;
vector<int> vx, vy;
map<pint,int> ptoi;

// 整理
map<int, set<int>> xy, yx;
map<int, vector<int>> vxy, vyx;
long long D, res;
vector<long long> deg;
vector<bool> seen;

void dfs(int v) {
    res += deg[v];
    seen[v] = true;
    int x = vx[v], y = vy[v];

    vector<int> nvs;
    // 右側
    {
        auto &se = xy[x + D];
        auto it = se.lower_bound(y - D);
        for (; it != se.end() && *it <= y + D; it = se.erase(it))
            nvs.push_back(ptoi[{x+D, *it}]), yx[*it].erase(x+D);
    }
    // 左側
    {
        auto &se = xy[x - D];
        auto it = se.lower_bound(y - D);
        for (; it != se.end() && *it <= y + D; it = se.erase(it))
            nvs.push_back(ptoi[{x-D, *it}]), yx[*it].erase(x-D);
    }
    // 上側
    {
        auto &se = yx[y + D];
        auto it = se.lower_bound(x - D);
        for (; it != se.end() && *it <= x + D; it = se.erase(it))
            nvs.push_back(ptoi[{*it, y+D}]), xy[*it].erase(y+D);
    }
    // 下側
    {
        auto &se = yx[y - D];
        auto it = se.lower_bound(x - D);
        for (; it != se.end() && *it <= x + D; it = se.erase(it))
            nvs.push_back(ptoi[{*it, y-D}]), xy[*it].erase(y-D);
    }

    // 探索
    for (auto nv : nvs) if (!seen[nv]) dfs(nv);
}

long long solve() {
    D = max(abs(vx[a] - vx[b]), abs(vy[a] - vy[b]));

    // 次数を求める
    deg.assign(N, 0);
    for (int i = 0; i < N; ++i) {
        int x = vx[i], y = vy[i];
        deg[i] += upper_bound(vxy[x + D].begin(), vxy[x + D].end(), y + D)
            - lower_bound(vxy[x + D].begin(), vxy[x + D].end(), y - D);
        deg[i] += upper_bound(vxy[x - D].begin(), vxy[x - D].end(), y + D)
            - lower_bound(vxy[x - D].begin(), vxy[x - D].end(), y - D);
        deg[i] += upper_bound(vyx[y + D].begin(), vyx[y + D].end(), x + D)
            - lower_bound(vyx[y + D].begin(), vyx[y + D].end(), x - D);
        deg[i] += upper_bound(vyx[y - D].begin(), vyx[y - D].end(), x + D)
            - lower_bound(vyx[y - D].begin(), vyx[y - D].end(), x - D);

        if (ptoi.count(pint(x+D, y+D))) --deg[i];
        if (ptoi.count(pint(x+D, y-D))) --deg[i];
        if (ptoi.count(pint(x-D, y+D))) --deg[i];
        if (ptoi.count(pint(x-D, y-D))) --deg[i];
    }
    
    // 連結成分のみを探索
    res = 0;
    seen.assign(N, 0);
    dfs(a);
    return res/2;
}

int main() {
    while (cin >> N >> a >> b) {
        --a, --b;
        vx.resize(N); vy.resize(N); ptoi.clear();
        xy.clear(), yx.clear(), vxy.clear(), vyx.clear();
        for (int i = 0; i < N; ++i) {
            int x, y; cin >> x >> y;
            vx[i] = x + y, vy[i] = x - y;
            ptoi[pint(vx[i],vy[i])] = i;
            xy[vx[i]].insert(vy[i]);
            yx[vy[i]].insert(vx[i]);
            vxy[vx[i]].push_back(vy[i]);
            vyx[vy[i]].push_back(vx[i]);
        }
        for (auto &it : vxy) sort(it.second.begin(), it.second.end());
        for (auto &it : vyx) sort(it.second.begin(), it.second.end());
        cout << solve() << endl;
    }
}


Measured memory_bytes: 100480
#include<stdio.h>

int main(){
    char n[4];
    scanf("%s", n);
    int r=0;
    for (int i=0; i<3; ++i){
        if (n[i]=='7'){
            r=10;
        }
    }
    if (r==10){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 1552
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])
#define MOD 1000000007

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=n;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

struct UnionFind{
    vector<int> data;
    UnionFind(int size){
        data=vector<int>(size,-1);
    }
    bool union_set(int x,int y){
        x=root(x);
        y=root(y);
        if(x!=y){
            if(data[y]<data[x])swap(x,y);
            data[x]+=data[y];
            data[y]=x;
        }
        return x!=y;
    }
    bool find(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0?x:data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    ll x;
    cin>>x;
    ll ans=0;
    ans+=(x/11)*2;
    ans+=x%11==0?0:(x%11)<7?1:2;
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) (find(all(v),x)!=v.end())
#define incls(s,c) (s.find(c)!=string::npos)
#define lb(a,x) distance((a).begin(),lower_bound(all(a),(x)))
#define ub(a,x) distance((a).begin(),upper_bound(all(a),(x)))
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(all(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; cin >> x; return x;}
inline ll lin() { ll x; cin >> x; return x;}
inline char chin() { char x; cin >> x; return x;}
inline string stin() { string x; cin >> x; return x;}
inline double din() { double x; cin >> x; return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const vector<T>& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};

int main () {
  int a, b;
  cin >> a >> b;
  cout << a*b SP 2*(a+b) << endl;
  return 0;
}


Measured memory_bytes: 3080
#include<iostream>
#include<math.h>

using namespace std;

int Func(long long A,long long B){
  int n1=1,n2=1;
  while (A/10>0) {
    n1++;
    A=A/10;
  }
  while (B/10>0) {
    n2++;
    B=B/10;
  }
  if (n1>n2) return n1;
  else return n2;
}

long long yakusu(long long N){
  long long max=1;
  for(long long i=2;i<=sqrt(N);i++){
    if (N%i==0 && abs(i-(N/i))<=abs(max-(N/max))) max=i;
  }
  return max;
}

int main(){
  long long N;
  cin >> N;
  //cout << yakusu(N) << " " << N/yakusu(N) << endl;
  cout << Func(yakusu(N),N/yakusu(N)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <utility> // pair make_pair
#include <algorithm>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))

using namespace std;


int main() {
  string S, T;
  cin >> S;
  cin >> T;

  vector<string> Ans;

  for (int i = S.size() - 1; i >= (int)T.size() - 1; i--) {
    int cnt = 0;
    for (int j = i; j >= 0; j--) {
      int k = (int)T.size() - 1;
      while (S[j] == '?' || S[j] ==T[k]) {
        if (k == 0) {
          string Temp = S;
          for (int m = 0; m < (int)T.size(); m++) {
            Temp[j + m] = T[k + m];
          }
          for (int m = 0; m < (int)S.size(); m++) {
            Temp[m] = (Temp[m] == '?') ? 'a' : Temp[m];
          }
          Ans.push_back(Temp);
          cnt++;
          break;
        }
        j--;
        k--;
      }
      if (cnt) {
        break;
      }
    }
  }

  if (!Ans.empty()) {
    sort(Ans.begin(), Ans.end());
    cout << Ans[0] << endl;
  } else {
    cout << "UNRESTORABLE" << endl;
  }
  
}


Measured memory_bytes: 256
import math

Dot_Num, N_Dimention= (int(i) for i in input().split())
Dot = [[int(i) for i in input().split()] for i in range(Dot_Num)]
count=0

for n in range(0, len(Dot)):
    for j in range(n+1, len(Dot)):
        SUM = math.sqrt(sum(pow(Dot[n][i]-Dot[j][i],2) for i in range(N_Dimention)))
        if SUM.is_integer():
            count+=1

print(count)


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

int main() {
	int H;
	cin >> H;
	string data[H];
	for (int i = 0;i < H; i++){
		cin >> data[i];
	}
    map <string, int> cnt;  // map のデータ構造を用意する。
    // string names[] = { "Tom","Bob","Mike" };
	for (int i = 0;i < H; i++){
		cnt[data[i]] += 1;
	}
	int max = 0;
	for (auto itr = cnt.begin(); itr != cnt.end(); ++itr){
		if(itr->second > max){
			max = itr->second;
		}
	}
	for (auto itr = cnt.begin(); itr != cnt.end(); ++itr)
	{
		if(itr -> second == max){
			cout<<itr -> first << endl;
		}
	}
}


Measured memory_bytes: 26752
from collections import deque
from collections import defaultdict
import math
# k = int(input())
# s =input()
# a = list(map(int, input().split()))
a,b,h,m= map(int, input().split())
# b = [int(input()) for _ in range(n)]
speed1 = 360/(12*60)
speed2 = 360/(60)
time = h*60 + m

k1 = speed1 * time
k2 = speed2 * time

kakudo = min(abs(k1-k2), 360-abs(k1-k2))

print(math.sqrt(a*a +b*b - 2*a*b*math.cos(math.radians(kakudo))))

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

typedef long long llint;
typedef long double ld;
typedef pair<int,int> P;

#define inf 1e18
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)


priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

#define Nmax 200005

vector<vector<int>>G;
llint f[Nmax];
int n,q;


void dfs(int v,int p=-1){
    for(int u:G[v]){
        if(u==p)continue;
        f[u]+=f[v];
        dfs(u,v);
    }
}


void solve(){
    cin >> n >> q;
    G.resize(n+1);
    rep(i,0,n-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i,0,q){
        int p,x;
        cin >> p >> x;
        p--;
        f[p]+=x;
    }
    dfs(0);
    rep(i,0,n)cout << f[i] << " ";
    cout << endl;
}

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





Measured memory_bytes: 28332
str=input()
q=eval(input())
command=[]
replace=[]
numdata=[]
for i in range(q):
    x=input()
    if 'replace' in x:
        a,b,c,d=x.split()
        replace.append(d)
        numdata.append((int(b),int(c)))
    else:
        a,b,c=x.split()
        numdata.append((int(b),int(c)))
    command.append(a)
Re=iter(replace)
for i in range(q):
    if command[i]=='print':
        print(str[numdata[i][0]:numdata[i][1]+1])
    elif command[i]=='reverse':
        temp=str[numdata[i][0]:numdata[i][1]+1]
        str=str[:numdata[i][0]]+temp[::-1]+str[numdata[i][1]+1:]
    else:
        str=str[:numdata[i][0]]+next(Re)+str[numdata[i][1]+1:]

Measured memory_bytes: 7708
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int n, ans=0;
int a[N];

int32_t main()
{
	IOS;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=2;i<=n;i++)
	{
		if(a[i]==a[i-1])
		{
			ans++;
			i++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

LL MOD = 1000000007;

LL mod_pow(LL a, LL p) {
	LL r = 1;
	while (p) {
		if ((1 & p)) r = r * a % MOD;
		a = a * a % MOD;
		p >>= 1;
	}
	return r;
}

VVLL matmul(VVLL a, VVLL b) {
	int n = a.size();
	VVLL ret = VVLL(n, VLL(n, 0));
	REP(i, n)REP(j, n)REP(k, n)ret[i][j] = (ret[i][j] + a[i][k] * b[k][j]) % MOD;
	return ret;
}

VVLL matpow(VVLL a, LL p) {
	VVLL tmp = a;
	int n = a.size();
	VVLL ret = VVLL(n, VLL(n, 0LL));
	REP(i, n)ret[i][i] = 1LL;
	while (p) {
		if (p & 1)ret = matmul(ret, a);
		a = matmul(a, a);
		p >>= 1;
	}
	return ret;
}

LL f(LL a, LL d, LL r) {
	return max((r + d- 1 - a) / d, 0LL);
}

int main() {
	LL l, a, b, d;
	cin >> l >> a >> d >> MOD;
	b = a + (l - 1)*d;
	VVLL ans(3, VLL(3)), tmp(3, VLL(3));
	REP(i, 3)ans[i][i] = 1;
	REP(i, 3)tmp[i][i] = 1;
	tmp[0][1] = tmp[1][2] = 1;
	LL mi = 1, ma = 10;
	REP(i, 19) {
		tmp[0][0] = (tmp[0][0] * 10) % MOD;
		LL p;
		if (i == 18) {
			p = f(a, d, b + 1) - f(a, d, max(a, mi));
		}
		else {
			p = f(a, d, min(b + 1, ma)) - f(a, d, max(a, mi));
		}
		ans = matmul(matpow(tmp, max(p, 0LL)), ans);
		mi *= 10, ma *= 10;
	}
	cout << (ans[0][1] * (a %MOD) + (d%MOD)*ans[0][2]) %MOD << endl;
	return 0;
}

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

int main(){
  std::string word;
  std::cin >> word;

  int count = 0;
  std::string str;
  while(std::cin >> str){
    if(str == "END_OF_TEXT") break;
    std::transform(str.begin(), str.end(), str.begin(), ::tolower);
    if(str == word) count++;
  }

  std::cout << count << std::endl;

  
  return 0;
}



Measured memory_bytes: 3180
import java.util.Scanner;

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

		// 入力値の取得
		int X = sc.nextInt();
		int Y = sc.nextInt();
		
		boolean answer = true;
		if (Y % 2 == 1 || X * 4 < Y || X * 2 > Y) {
			answer = false;
		}
		
		// 結果の出力
		System.out.println(answer? "Yes" : "No");

		sc.close();
	}
}


Measured memory_bytes: 27064
#include <bits/stdc++.h>
using namespace std;
#define PRINT(x) std::cout << x << std::endl;
#define FOR(i, n) for(int i = 0; i < (n); ++i);

int main() {

  int n; 
  cin >> n;
  int copy = (int)floor(n / 10) * 10;
  int sa = n - copy;
  if (sa == 3) {
    PRINT("bon");
  } else if (sa == 2 || sa == 4 || sa == 5 || sa == 7 || sa == 9) {
    PRINT("hon");
  } else if (sa == 0 || sa == 1 || sa == 6 || sa == 8) {
    PRINT("pon");
  }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr front()
#define tp top()
typedef long long int ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <pii, int> ppi;
typedef pair <int, pii> pip;
#define iofast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define iofile freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)
const ll LLINF = 1e18;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1);
const int SIZE = 100005;

int N;
int A[SIZE];

int main (){
	
	int a;
	memset(A,0,sizeof(A));
	
	scanf("%d", &N);
	for(int i=0;i<N;i++){
		scanf("%d", &a);
		A[a]=1;
	}
	int ans=0;
	for(int i=1;i<=100;i++){
		if(A[i]>0) ans++;
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin>>n;
	vector<ll> v(n+1,1);
	vector<int> vec;
	vec.push_back(2);
	for(int i=3;i<=n;i++)
	{
		bool cc=true;
		for(int j=2;j<=sqrt((double)i);j++)
		{
			if(i%j==0)
			{
				cc=false;
				break;
			}
		}
		if(cc)
			vec.push_back(i);
	}

	for(int i=1;i<=n;i++)
	{
		int p=i;
		for(int j=0;j<vec.size();j++)
		{
			while(p%vec[j]==0)
			{
				p/=vec[j];
				v[vec[j]]++;
			}
		}
	}
	ll brojac=1;
	for(int i=0;i<=n;i++)
	{
		brojac=(brojac*v[i])%1000000007;
	}
	cout<<brojac%1000000007<<endl;
	return 0;
}

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



int main() {
	int N = 0, K = 0;
	
	cin >> N;
	cin >> K;

	vector<int> H(N);

	for (int i = 0; i < N; i++) {
		cin >> H.at(i);
	}

	int count=0;


	for (int i = 0; i < N; i++) {
		if (H.at(i) >= K) {
			count++;
		}
	}

	cout << count << endl;
	
	

}


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

int main(void) {
    int a,b;
    string sa,sb;
    cin >> a >> b;
    for(int i=0;i<b;i++) {
        sa += (a + '0');
    }
    for(int i=0;i<a;i++) {
        sb += (b + '0');
    }

    if(sa < sb) {
        cout << sa << "\n";
    } else {
        cout << sb << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <string>

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
int main() {
	ll M, N; cin >> M >> N;
	ll cnt = 0;
	if (N - 2 * M >= 0) {
		cnt += M;
		cnt += (N - 2 * M) / 4;
	}
	else {
		cnt += N / 2;
	}
	cout << cnt << endl;

	return 0;
}

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

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

  vector<int> a(n);

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

  sort(a.begin(), a.end());

  cout << a[n-1] - a[0] << endl;

  return 0;

}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	    public static void main(String[] args) {
	        Scanner scan = new Scanner(System.in);
	        String S = scan.next();
	        String T = scan.next();
	        int num1 = scan.nextInt();
	        int num2 = scan.nextInt();
	        String U = scan.next();

	        if(U.equals(S)){
	        	num1--;
	        }else if(U.equals(T)){
	         	num2--;
	        }
	        scan.close();
	      	System.out.print(num1 + " " + num2);
    }
}


Measured memory_bytes: 21716
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Mon Dec 24 23:45:41 2018
//
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	if N >= 1000 {
		fmt.Println("ABD")
		return
	}
	fmt.Println("ABC")
}


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


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = long.Parse(Console.ReadLine());
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();

        Array.Sort(a);
        long[] t = new long[n];
        for (int i = 0; i < n; i++)
        {
            t[i] = a[i] * 2;
        }

        long[] sum = new long[n];
        sum[0] = a[0];
        for (int i = 0; i < n - 1; i++)
        {
            sum[i + 1] = sum[i] + a[i + 1];
        }

        var ans = 0;
        var max = a.Max();
        var index = n - 1;
        while (index >= 0)
        {
            if (t[index] >= max) ans++;
            else break;
            index--;
        }

        long end = 0;
        if (index >= 0) end = a[index];
        while (index >= 0)
        {
            long tmp = sum[index];
            if (tmp * 2 >= a[index + 1]) ans++;
            else break;

            index--;
        }

        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 40444
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+3;
bool vis[N];
int tel[N];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;ll k;cin >> n >> k;
	for(int i=0;i<n;i++){
		cin >> tel[i];
		tel[i]--;
	}
	vector<int> state;
	state.emplace_back(0);
	vis[0] = 1;
	vector<int> loop;
	while(1){
		int nx = tel[state[state.size()-1]];
		if(vis[nx]) break;
		state.emplace_back(nx);
		vis[nx] = 1;
	}
	loop.emplace_back(tel[state[state.size()-1]]);
	memset(vis,0,sizeof(vis));
	vis[tel[state[state.size()-1]]] = 1;
	while(1){
		int nx = tel[loop[loop.size()-1]];
		if(vis[nx]) break;
		loop.emplace_back(nx);
		vis[nx] = 1;
	}
	if(k < state.size()) cout << state[k]+1 << '\n';
	else{
		k -= state.size();
		cout << loop[k%loop.size()]+1 << '\n';
	}
}


Measured memory_bytes: 6380
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	int n;
	cin>>n;
	int a1=0,a2=0,a3=0,a4=0;
	for(int i=1;i<=n;i++){
		string s;
		cin>>s;
		if(s=="AC"){
			a1++;
		}
		else if(s=="WA"){
			a2++;
		}
		else if(s=="RE"){
			a4++;
		}
		else{
			a3++;
		}
	}
	cout<<"AC x "<<a1<<endl;
	cout<<"WA x "<<a2<<endl;
	cout<<"TLE x "<<a3<<endl;
	cout<<"RE x "<<a4<<endl;
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A , B;
  cin >> A;
  cin >> B;
  int c = 0;
  
  for (int i = 0; i <= B-A; i++) {
    int s , t , u , v;
    s = (A + i)/10000;
    t = (A + i)/1000 - 10*((A + i)/10000);
    u = (A + i)/10 - 10*((A + i)/100);
    v = A + i - 10*((A + i)/10);
    
    if (s == v && t == u) { 
      c++;
    }
  }
  
    cout << c << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Node root = null;
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
		    String type = sc.next();
		    if (type.equals("insert")) {
		        if (root == null) {
		            root = new Node(sc.nextInt());
		        } else {
		            insert(sc.nextInt(), root);
		        }
		    } else {
		        ArrayList<Integer> inList = new ArrayList<>();
		        ArrayList<Integer> preList = new  ArrayList<>();
		        get(root, inList, preList);
		        for (int x : inList) {
		            sb.append(" ").append(x);
		        }
		        sb.append("\n");
		        for (int x : preList) {
		            sb.append(" ").append(x);
		        }
		        sb.append("\n");
		    }
		}
		System.out.print(sb);
	}
	
	static class Node {
	    int key;
	    Node left;
	    Node right;
	    
	    public Node(int key) {
	        this.key = key;
	    }
	}
	
	static void get(Node x, ArrayList<Integer> inList, ArrayList<Integer> preList) {
	    preList.add(x.key);
	    if (x.left != null) {
	        get(x.left, inList, preList);
	    }
	    inList.add(x.key);
	    if (x.right != null) {
	        get(x.right, inList, preList);
	    }
	}
	
	static void insert(int key, Node x) {
	    if (x.key > key) {
	        if (x.left == null) {
	            x.left = new Node(key);
	        } else {
	            insert(key, x.left);
	        }
	    } else {
	        if (x.right == null) {
	            x.right = new Node(key);
	        } else {
	            insert(key, x.right);
	        }
	    }
	}
}



Measured memory_bytes: 186296
#include <stdio.h>

int main(void)
{
    int num[5];
    int tmp;
    int i, j;
    
    while (i < 5) {
        scanf("%d", &num[i]);
        i++;
    }
    
    for (i = 0; i <= 4; i++){
        for (j = 4; i < j; j--){
            if (num[j] < num[j - 1]){
                tmp = num[j];
                num[j] = num[j - 1];
                num[j - 1] = tmp;
            }
        }
    }
    
    for (i = 4; 0 <= i; i--){
        printf("%d", num[i]);
        if (!(i == 0)){
            printf(" ");
        }
    }
    printf("\n");
    
    return (0);
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    ans = [0] * N
    ans[0] = sum(A) - 2*sum(A[1:N:2])
    for i in range(1, N):
        ans[i] = 2*A[i-1] - ans[i-1]
    return ' '.join(map(str, ans))


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 101216
n = int(input())
ans = 0
for i in range(1, n+1):
    if i%2 == 0:
        continue
    cnt = 0
    for j in range(1, i+1):
        if i%j == 0:
            cnt += 1
    if cnt == 8:
        ans += 1
print(ans)

Measured memory_bytes: 38640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	long long n, p;
	long long a[100];
	cin >> n >> p;
	long long g = 1, k = 0;
	for (long long i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 2 == 0) {
			g *= 2;
		}
		else {
			k++;
		}
	}
	long long ans1 = 0;
	if (p == 0) {
		for (long long i = 0; i <= k; i += 2) {
			long long ans = 1;
			for (long long j = 0; j <= i; j++) {
				ans *= (k - j);
				ans /= (j + 1);
			}
			ans1 += ans;
		}
		if (ans1 == 0) {
			ans1 = 1;
		}
	}
	else {
		ans1 = 0;
		for (long long i = 1; i <= k; i += 2) {
			long long ans = 1;
			for (long long j = 0; j < i; j++) {
				ans *= (k - j);
				ans /= (j + 1);
			}
			ans1 += ans;
		}
	}
	cout << ans1 * g << endl;
	return 0;
}


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

using namespace std;
#define ll long long 
int main() {
    int n,k;
    cin>>n>>k;
    vector<int> arr(n);
    
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    
//    sort(arr.begin(),arr.end(),greater<int>());
    ll sum1=0;
    ll sum2=0;
    
    for(int i=0;i<k;i++){
        sum1+=arr[i];
    }
    sum2=sum1;
    
    for(int i=k;i<n;i++){
        sum1=sum1-arr[i-k];
        sum1+=arr[i];
        sum2=max(sum2,sum1);
    }
    
    
    double ans=(double)((double)sum2+(double)k)/(double)2;
    cout<<fixed<<setprecision(7)<<ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 #include<string>
using namespace std;
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define init(arr,value) memset(arr,value,sizeof(arr))
#define test unsigned int tet;cin >> tet;while(tet--)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int max(int a,float b){
    if(a>b)
       return a;
    return b;
}
ll gcd(ll a,ll b){
    if(a%b==0)
        return b;
    else
        return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a*b/gcd(max(a,b),min(a,b));
}
int main() {
	// your code goes here
	string s,t;
	cin>>s>>t;
	int x=s.size(),cnt=0;
	for(int i=0;i<x;i++){
	    if(s[i]!=t[i])
	       cnt++;
	}
	cout<<cnt;
	
	
}

Measured memory_bytes: 3920
N = gets.to_i
xyhs = N.times.map { gets.split.map(&:to_i) }
filtered = xyhs.select { |(_, _, h)| h >= 1 }
if filtered.size == 1
  x, y, h = filtered[0]
  puts "#{x} #{y} #{h}"
  exit 0
end
(0..100).each do |i|
  (0..100).each do |j|
    hs = filtered.map do |(x, y, h)|
      (i - x).abs + (j - y).abs + h
    end
    h = hs[0]
    is_ok = hs.all? do |h2|
      h2 == h
    end
    if is_ok
      puts "#{i} #{j} #{h}"
      exit 0
    end
  end
end


Measured memory_bytes: 2684
#include <iostream>
using namespace std;
class Dice {
    private:
        int num[6];
        void go2N() {
            int tmp = num[0];
            num[0] = num[1];
            num[1] = num[5];
            num[5] = num[4];
            num[4] = tmp;
        }
        void go2S() {
            int tmp = num[0];
            num[0] = num[4];
            num[4] = num[5];
            num[5] = num[1];
            num[1] = tmp;
        }
        void go2E() {
            int tmp = num[0];
            num[0] = num[3];
            num[3] = num[5];
            num[5] = num[2];
            num[2] = tmp;
        }
        void go2W() {
            int tmp = num[0];
            num[0] = num[2];
            num[2] = num[5];
            num[5] = num[3];
            num[3] = tmp;
        }

    public:
        Dice(int *_num) {
            for (int i=0;i<6;i++) {
                num[i] = _num[i];
            }
        }

        void go(char op) {
            switch (op) {
                case 'N':
                    go2N();
                    break;
                case 'S':
                    go2S();
                    break;
                case 'E':
                    go2E();
                    break;
                case 'W':
                    go2W();
                    break;
                default:
                    break;
            }
        }

        int getNum(int id) {
            int ret = 0;
            if (0 <= id && id < 6) ret = num[id];
            return ret;
        }
};

int main() {
    int num[6];
    string op;
    cin >> num[0] >> num[1] >> num[2] >> num[3] >> num[4] >> num[5];
    Dice D(num);
    cin >> op;
    for (int i=0;i<op.size();i++) {
        D.go(op[i]);
    }
    cout << D.getNum(0) << endl;
    return 0;
}

Measured memory_bytes: 3188
using System;
using System.Linq;
using System.Collections.Generic;

class MondaiC
{
    static void Main()
    {
        var line = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var N = line[0];
        var M = line[1];
        var index = new int[M];
        var city = new long[M];
        var pri=new int[M];
        for (int i=0;i<M;++i)
        {
            var l = Console.ReadLine().Split(' ').Select(x=>Int32.Parse(x)).ToArray();
            pri[i] = l[0];
            city[i] = l[1];
            index[i] = i;
        }
        Array.Sort(city,index);
        var ans = new string[M];
        var priCount = new int[line[0] + 1];
        for (int i = 0; i < M; ++i)
        {
            priCount[pri[index[i]]]++;
            ans[index[i]]= string.Format("{0:D6}", pri[index[i]])+ string.Format("{0:D6}", priCount[pri[index[i]]]);
        }
        foreach (var a in ans) {
            Console.WriteLine(a);
        }
    }
}

Measured memory_bytes: 27772
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
    ll n, a, b;
    cin >> n >> a >> b;

    cout << max(0LL, b * (n - 1) + a - (a * (n - 1) + b) + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a, b, c, tmp;
	scanf("%d %d %d", &a, &b, &c);
	if (a > b) {
		tmp = a;
		a = b;
		b = tmp;
	}
	if (b > c) {
		tmp = b;
		b = c;
		c = tmp;
	}
	if (a > b) {
		tmp = a;
		a = b;
		b = tmp;
	}
	printf("%d %d %d\n", a, b, c);
	return 0;
}

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

int main()
{
    op;
    int a,b;
    cin>>a>>b;
    if(b%a==0) cout<<a+b;
    else cout<<b-a;

    return 0;
}


Measured memory_bytes: 256
s = input()
q = int(input())
head = ''
tail = ''
rev = 0

for _ in range(q):
    T = list(input().split())
    if T[0] == '1':
        head, tail = tail, head
        rev += 1
    else:
        if T[1] == '1':
            head += T[2]
        else:
            tail += T[2]

if rev%2 == 0:
    print(head[::-1]+s+tail)
else:
    print(head[::-1]+s[::-1]+tail)


Measured memory_bytes: 10048
k, n = map(int, input().split())
List = list(map(int, input().split()))
max = 0

for i in range(n - 1):
    range = List[i + 1] - List[i]
    if range > max:
        max = range

range = k - (List[n - 1] - List[0])
if range > max:
    max = range

print (k - max)


Measured memory_bytes: 26444
#include <iostream>
#include<algorithm>

using namespace std;

int main() {
	int n;
	
	cin >> n;
	int u = n;
	if (n >= 28)cout << "Yes";
	else if (u == 0 || u == 4 || u == 7 || u == 8 || u == 11 || u == 12 || u == 14 || u == 15 || u == 16 || u == 18 || u == 19 || u == 20 || u == 21 || u == 22 || u == 23 || u == 24 || u == 25 || u == 26 || u == 27)cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  	int n;
  	cin>>n;
	map<int,int>res;
  	int a=0,b=0,c=0,d=0,e=0;
  	for(int j=2; j<=n; j++){
      int m=j;
		for(int i=2; i*i<=m; i++){
			while(m%i==0){
				res[i]++;
				m/=i;
			}
		}	
		if(m!=1)res[m]++;
    }
  for(int i=2; i<=n; i++){
    if(res[i]>=74)a++;
    if(res[i]>=24)b++;
    if(res[i]>=14)c++;
    if(res[i]>=4) d++;
    if(res[i]>=2) e++;
  }
  int ans=a+b*(e-1)+c*(d-1)+d*(d-1)*(e-2)/2;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
//code by lynmisakura.wish to be accepted
/****************************/
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;
 
const long long Mod = 998244353;
const long long mod = 1000000007;
const long long INF = 10000000000000;
 
#define itn int
#define endl "\n"
#define pb push_back
#define mp make_pair
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
 
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
ll dp[100010][13];
int main(void){
	
	string s; cin >> s;
	int n = s.size();
	reverse(all(s));
	if(s[0] == '?'){
		for(int i = 0;i < 10;i++){
			dp[0][i] = 1LL;
		}
	}else{
		dp[0][s[0] - '0'] = 1LL;
	}
	for(int i = 1;i < n;i++){
		ll m = qp(10,i,13);
		if(s[i] != '?'){
			for(int j = 0;j < 13;j++){
				dp[i][(j + (m*(s[i] - '0') %13 )) % 13] += dp[i-1][j];
				dp[i][(j + (m*(s[i] - '0') %13 )) % 13] %= mod;
			}
		}else{
			for(int k = 0;k < 13;k++){
				for(int j = 0;j < 10;j++){
					dp[i][(k + (m*j % 13)) % 13] += dp[i-1][k];
					dp[i][(k + (m*j % 13)) % 13] %= mod;
				}
			}
		}
	}
	/*for(int i = 0;i < n;i++){
		for(int j = 0;j < 13;j++){
			printf("%lld ",dp[i][j]);
		}
		printf("\n");
	}*/
	printf("%lld\n",dp[n-1][5]);
	
	return 0;
}


Measured memory_bytes: 10624
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
#include<ios>
#include<iomanip>

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

int main()
{
	int N;
	string S;
	vector<int>sh,dt;
	cin>>N>>S;
	if(S.length()==1)
	{
		cout<<0<<endl;
		return 0;
	}

	for(int i=0;i<S.length();i++)
	{
		if(i==0)
		{
			sh.push_back(S[i]=='#'?1:0);
			dt.push_back(S[i]=='.'?1:0);
		}
		else
		{
			sh.push_back(sh[i-1]+(S[i]=='#'?1:0));
			dt.push_back(dt[i-1]+(S[i]=='.'?1:0));

		}
	}
	//     mid
	//      l
	//      v
	//......######
	int res=min(sh[S.length()-1],dt[S.length()-1]);
	for(int i=0;i<=S.length();i++)
	{
		int shrep=0,dtrep=0;
		if(i==0)
		{
			dtrep=dt[S.length()-1];
		}
		else if(i==S.length())
		{
			shrep=sh[S.length()-1];
		}
		else
		{
			shrep=sh[i-1];
			dtrep=dt[S.length()-1]-dt[i];
		}
		res=min(res,shrep+dtrep);

	}

	cout<<res<<endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;

const ll MOD = 1000000007LL;

void solve() {

}

int n;
ll k;
vector<int> G[MAX_N];
bool visited[MAX_N];
ll children[MAX_N];
ll ans = 0LL;

void dfs(int node, int parent) {
    visited[node] = true;
    for (auto adj: G[node]) {
    	if (!visited[adj]) dfs(adj, node);
    }

    if (node == 1) {
        children[node] = G[node].size();
        return;
    }
    if (G[node].size() == 1 && node != 1) {
        children[node] = 0;
        return;
    }
    children[node] = G[node].size() - 1;
}

ll countWays(ll N, ll R) {
    if (R > N) {
        return 0;
    }

    ll ret = 1;
    for (ll i=N-R+1; i<=N; i++) {
        ret *= i;
        ret %= MOD;
    }
    return ret;
}

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

    cin >> n >> k;
    for (int i=0; i<n-1; i++) {
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    dfs(1, -1);
    ans = countWays(k-1, children[1])%MOD;
    ans *= k;
    ans %= MOD;

    for (int i=2; i<=n; i++) {
        if (G[i].size() == 1) continue;
        ll tmp = countWays(k-2, children[i])%MOD;
        ans *= tmp;
        ans %= MOD;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 10112
fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val n = sc.nextInt()
    val ss = sc.asSequence().take(n).toList()
    val march = "MARCH".asSequence().map { it to ss.filter { s -> s[0] == it }.count() }.toMap()

    var ret = 0L
    for (f in 1 until 2 * 2 * 2 * 2 * 2) {
        var len = 0
        var ptn = 1L
        for (shift in 0 until 5) {
            if (f and (1 shl shift) != 0) {
                len++
                ptn *= march["MARCH"[shift]] ?: 0
            }
        }
        if (len == 3) {
            ret += ptn
        }
    }
    println(ret)
}


Measured memory_bytes: 52300
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    vec an(5,0);
    rep(i,5) cin>>an[i];
    cin>>K;
    rep(i,5){
        rep(j,i){//j<i
            if(an[i]-an[j] > K){
                cout<<":("<<endl;
                return 0;
            }
        }
    }
    cout<<"Yay!"<<endl;
}

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

const int M = 105;
const int Inf = 1e9 * 2;
int N;
int x[M], y[M], h[M];
int H;

bool solve(int cx, int cy) {
  int low = 1, upp = Inf; // [low, upp]
  rep(i, N) {
    int tmp = h[i] + abs(x[i]-cx) + abs(y[i]-cy);
    if (h[i]) {
      if (low <= tmp && tmp <= upp) low = upp = tmp;
      else return false;
    }
    else {
      if (low <= tmp) upp = min(upp, tmp);
      else return false;
    }
  }
  H = low;
  return true;
}

int main() {
  cin >> N;
  rep(i, N) cin >> x[i] >> y[i] >> h[i];
  for (int i = 0; i <= 100; ++i) {
    for (int j = 0; j <= 100; ++j) {
      if (solve(i, j)) printf("%d %d %d\n", i, j, H);
    }
  }
  return 0;
}

Measured memory_bytes: 256
// https://beta.atcoder.jp/contests/abc080/tasks/abc080_a

#include <iostream>
using namespace std;

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	if (N * A < B) {
		cout << N * A << endl;
	}
	else {
		cout << B << endl;
	}
	return 0;
}

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

int main(){
	long long N,K;
	cin>>N>>K;
	vector<long> A(N+1);
	for(int i=1;i<=N;i++) {cin>>A[i];}
	vector<long> score(N+1);

	for(int i=1;i<=N-K;i++){
		if(A[i]<A[K+i]){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}

}


Measured memory_bytes: 6400
from functools import reduce

n, a, b = map(int, input().split())
mod = 10**9 + 7

def combi_mod(n, r, mod):
    numerator = reduce(lambda x, y: x * y % mod, [n-i for i in range(r)])
    denominater = reduce(lambda x, y: x * y % mod, [i+1 for i in range(r)])
    return numerator * pow(denominater, mod - 2, mod) % mod

print((pow(2, n, mod) -1 - combi_mod(n, a, mod) - combi_mod(n, b, mod)) % mod)

Measured memory_bytes: 11528
//
//  main.cpp
//  AizuOnlineJudge
//
//  Created by TomoyaYamaguchi on 2016/08/05.
//  Copyright ?? 2016??´ TomoyaYamaguchi. All rights reserved.
//

#include <iostream>

using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    int height[10];//?±±?????????
    int tmp = 0;
    int end = 0;
    
    for(int i=0;i<10;i++){
        cin >> height[i];
    }
    
    while(end == 0){
        end = 1;
        for(int i=0;i<9;i++){
            if(height[i] < height[i+1]){
                end = 0;
                tmp = height[i];
                height[i] = height[i+1];
                height[i+1] = tmp;
            }
        }
    }
    
    for(int i=0;i<3;i++){
        cout << height[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1164
line = input().split(' ')
A = int(line[0])
B = int(line[1])
K = int(line[2])

def KthCommonDivisor(A,B,K):
    n = min(A,B)
    c = 0
    for i in range(n, -1, -1):
        if A % i == 0 and B % i == 0:
            c += 1
            if c == K:
                return i

res = KthCommonDivisor(A,B,K)
print(res)

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

bool cmp(Long a,Long b){
   return a>b;
} 

int main(){
   Long n,k;
   cin >> n >> k;
   vector<Long> v(n);
   for(Long i=0 ; i<n ; ++i){
      cin >> v[i];
   }
   if(k>=n) cout << 0;
   else{
      sort(v.begin(),v.end(),cmp);
      Long tot = 0;
      for(Long i = k ; i<n ; ++i) tot += v[i];
      cout << tot ;
   }
   return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h> 
using namespace std;  
#define ll   long long int

int main()
{
	ll t = 3;
	ll c5 = 0,c7 = 0;
	while(t--)
	{
		ll x;
		cin>>x;
		if(x==5)c5++;
		if(x==7)c7++;
	}
	if(c5 == 2 and c7 == 1)puts("YES");
	else puts("NO");
	
	return 0;
}

Measured memory_bytes: 3568