akhauriyash/Code-Regression huggingface dataset:
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 1000000000
#define LLINF 1145141919810LL
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

typedef long long ll;
// #define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, a[200000]; cin >> N;
  int b[200000];
  REP(i, N) {
    cin >> a[i];
    b[a[i]-1] = i;
  }
  int mx = -1, cnt = 1;
  REP(i, N-1){
    if(b[i+1] > b[i]) cnt++;
    else{
      mx = max(mx, cnt);
      cnt = 1;
    }
  }
  cout << N - max(mx, cnt) << endl;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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;
}


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

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  // ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  string s; cin >> s;
  string t = s.substr(0,3);
  cout << t << endl;
  // vector<ll> a(N); rep(i, N) cin >> a[i];
  // ll ans = 0;
  // bool ok = false;

  // cout << ans << endl;
  // cout << (ok?"Yes":"No") << endl;
}


int main(void)
{
  // ll t; cin >> t; REP(i, t)
  solve();
}


Measured memory_bytes: 3612
#include<iostream>
#include <string.h>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(){
    ll n,t,a,h[100000],ans,max = 10000000;
    memset(h,0,sizeof(h));

    cin >> n >> t >> a;

    ll x = (t-a)*1000;

    for(int i = 0; i < n; i++)
    {
        cin >> h[i];
        h[i] = h[i]*6 - x;
        if(h[i] < 0)
        {
            h[i] = -h[i];
        }
        if(h[i] < max)
        {
            ans = i+1;
            max  = h[i];
        }
    } 

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long a,b;
int main()
{
    cin>>a>>b;
    
    if(a>0)cout<<"Positive"<<endl;
    
    else if(a==0||(a<0&&b>0))cout<<"Zero"<<endl;
    
    else if((abs(b)-abs(a))%2!=0)cout<<"Positive"<<endl;
    
    else cout<<"Negative"<<endl;
    return 0;
}

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

string s;
int i;
map<string,int> chem;

int inner_morecule();
int number();
int atom();

int morecule(){
	int ret=0;
	while(s[i]!='$' && s[i]!=')'){
		//cout<<s.substr(i)<<endl;
		int val=inner_morecule();
		if(val==-1){
			return -1;
		}
		ret+=val;
		//cout<<val<<"("<<ret<<","<<i<<")"<<endl;
	}
	return ret;
	
}

int inner_morecule(){
	int ret=0;
	if(s[i]=='('){
		i++;
		ret=morecule();
		i++;
	}else{
		ret=atom();
		if(ret==-1){
			return -1;
		}
	}
	int mul=number();
	if(mul==0) return ret;
	else return ret*mul;	
}

int number(){
	int ret=0;
	while(isdigit(s[i])){
		ret=ret*10+s[i++]-'0';
	}
	return ret;
}

int atom(){
	string ret=s.substr(i,1);
	i++;
	if(islower(s[i])){
		ret+=s[i];
		i++;
	}
	if(chem.find(ret)==chem.end()){
		return -1;
	}
	return chem[ret];
}

string solve(){
	int val=morecule();
	if(val==-1) return "UNKNOWN";
	return to_string(val);
}

int main(){
	{	string tmp;
		while(cin>>tmp,tmp!="END_OF_FIRST_PART"){
			int n; cin>>n;
			chem[tmp]=n;
		}
	}
	while(cin>>s,s!="0"){
		i=0;
		s+="$";
		cout<<solve()<<endl;
	}
	return 0;
}



Measured memory_bytes: 3248
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  int n;
  while(cin >> str){
    if(str=="-") break;
    cin >> n;
    for(int i=0,h;i<n;i++){
      cin >> h;
      string cat = str.substr(0,h);
      str.erase(0,h);
      str+=cat;
    }
    cout << str << endl;
  }
}

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

int main(){

    int N;
    cin >> N;

    vector<int> d(N);
    for (size_t i = 0; i < N; i++)
    {
        cin >> d[i];
    }

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

    int mid1=d[(N-1)/2];
    int mid2=d[(N-1)/2+1];

    cout << mid2-mid1 <<endl;
    

    return 0;
}

Measured memory_bytes: 640
def myAnswer(S:list,K:int) -> int:
   if(K == 1): return S[0]
   ans = ""
   for n,s in enumerate(S):
      if(s != "1"):
         ans = s
         break
      elif(s == "1" and n == K -1 ):
         ans = "1"
         break
   return ans

def modelAnswer():
   tmp=1
def main():
   S = list(input())
   K = int(input())
   print(myAnswer(S[:],K))

if __name__ == '__main__':
   main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }

ll modpow(ll a,ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll n, k;
  cin >> n >> k;

  vector<ll> cnt(k + 1, 0);
  ll ans = 0, cntsum = 0;
  FORR(i, k, 2) {
    ll q = k / i;
    ll comb = modpow(q, n);
    FOR(j, 2, q + 1) {
      comb = (comb - cnt[i * j] + mod) % mod;
    }
    cnt[i] = comb;
    cntsum = (cntsum + comb) % mod;
    ans = (ans + comb * i % mod) % mod;
  }
  ll comb = (modpow(k, n) - cntsum + mod) % mod;
  ans = (ans + comb) % mod;
  cout << ans << '\n';
  

  

  
  return 0;
}

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

namespace ABC080A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, a, b, x;

            var word = Console.ReadLine().Split(' ');

            n = int.Parse(word[0]);
            a = int.Parse(word[1]);
            b = int.Parse(word[2]);

            x = a * n;

            if (x > b)
                x = b;

            Console.WriteLine(x);

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main(){
	int tmp1,tmp2;
	int a=0,b=0;
	for(int i=0; i<4; ++i){
		cin >> tmp1;
		a += tmp1;	
	}
	for(int i=0; i<4; ++i){
		cin >> tmp2;
		b += tmp2;
	}
	if(a >= b){
		cout << a << endl;
	} else if(b > a){
		cout << b << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define INF 1000000000

typedef long double Real;
#define EPS 1e-13
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

int main(){
  Real a,b;
  cin>>a>>b;
  Real s = a*b / 3.305785;
  cout.precision(12);
  cout<<fixed<<s<<endl;
  return 0;
}

Measured memory_bytes: 1288
def modinv(a, mod):
    b = mod
    x, u = 1, 0
    while b:
        q = a//b
        a, b = b, a-q*b
        x, u = u, x-q*u
    x %= mod
    return x


def mod_nCr_init(n, mod):
    fac[0] = fac[1] = 1
    facinv[0] = facinv[1] = 1
    inv[1] = 1
    for i in range(2, n):
        fac[i] = fac[i-1] * i % mod
        inv[i] = -inv[mod % i] * (mod // i) % mod
        facinv[i] = facinv[i-1] * inv[i] % mod


def mod_nCr(n, r, mod):
    if n < r or n < 0 or r < 0:
        return 0
    return fac[n] * (facinv[r] * facinv[n-r] % mod) % mod


N, M, K = map(int, input().split())
fac = [0]*(N*M)
facinv = [0]*(N*M)
inv = [0]*(N*M)

mod = 10**9 + 7
mod_nCr_init(N*M, mod)
C = mod_nCr(N*M-2, K-2, mod)

ans = 0
for _ in [0, 0]:
    for d in range(1, N):
        ans += (N-d)*M*M*d*C

    N, M = M, N

print(ans % mod)



Measured memory_bytes: 26740
#include<bits/stdc++.h>
using namespace std;
 
#define online_judge            freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio                    ios::sync_with_stdio(false);cin.tie(0);
#define ll                      long long
#define pii                     pair<int, int>
#define pli                     pair<ll, int>
#define pil                     pair<int, ll>
#define pll                     pair<ll, ll>
#define vi                      vector<int>
#define vll                     vector<ll>
#define vb                      vector<bool>
#define vd                      vector<double>
#define vs                      vector<string>
#define ff                      first
#define ss                      second
#define pb                      push_back
#define eb                      emplace_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define vpii                    vector<pii>
#define vpll                    vector<pll>
#define umap                    unordered_map
#define all(x)                  x.begin(),x.end()
#define clr(a,b)                memset(a,b,sizeof a)
#define fr(i, n)                for(ll i=0; i<n;++i)
#define fr1(i, n)               for(ll i=1; i<=n; ++i)
#define rfr(i, n)               for(ll i=n-1; i>=0; --i)
#define precise(x)              cout<<fixed<<setprecision(x)
#define wh                      while
#define mp                      make_pair
#define le                      length()
#define endl                    "\n"
#define sf						scanf	
 
const ll m=1e9+7; 
 
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
ll lcm(ll a,ll b)
{ return (a*b)/__gcd(a,b); }
 
 
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;    
 
    x = x % p;
   
    if (x == 0) return 0;
 
    while (y > 0)  
    {  
       
        if (y & 1)  
            res = (res*x) % p;  
 
       
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
bool inside(ll x,ll y,ll n,ll m)
{
    return(x>=0&&x<n&&y>=0&&y<m);
}  

ll powmod(ll n)
{
    ll ret = 1;
    ll a = 2;
    while (n > 0) {
        if (n & 1) ret = ret * a % m;
        a = a * a % m;
        n >>= 1;
    }
    return ret;
}
 
ll modfact(ll n, ll p)
{
    if (n >= p)
        return 0;
 
    ll result = 1;
    for (int i = 1; i <= n; i++)
        result = (result * i) % p;
 
    return result;
}

///////////// TEMPLATE END /////////////////////////////////

 


void solve()
{    
	ll n,x,t;
	cin>>n>>x>>t;
	
	ll d=n/x;
	
	if(n%x)
	{
		d++;
	}
	cout<<d*t<<endl;
	
}



int main()
{
    fastio
   
//    int t;
//    cin>>t;
//    wh(t--)
    {
//        cout<<"Case "<<i<<":"<<endl;
        solve();
    }
   
    return 0;
}

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

bool ans[1000000+5];

int main()
{
	int n,k,sum,i;
	cin>>n>>k;
	
	while(k--)
	{
		int d;
		cin>>d;
		int a[d+5];
		for(i=1;i<=d;i++)
		{
			cin>>a[i];
			ans[a[i]]=true;
		}
	}
	
	for(i=1;i<=n;i++)
	   if(ans[i]==false)
	     sum++;
	     
	cout<<sum;
	
	return 0;
	
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(a,b)<<" "<<max(0,a+b-n)<<endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(200000)

n = int(input())
 
G = {}
for i in range(n):
    G.update({i: []})
 
for i in range(n - 1):
    u, v, w = map(int, input().split())
    G[u - 1].append([v - 1, w % 2])
    G[v - 1].append([u - 1, w % 2])
 
color = [-1 for i in range(n)]
 
def dfs(graph, v, c):
    color[v] = c
    
    for next_v in graph[v]:
        dis = next_v[1]
        if color[next_v[0]] != -1:
            continue
        
        if dis == 0:
            n_c = c
        elif dis == 1:
            n_c = 1 - c
        
        dfs(graph, next_v[0], n_c)
 
dfs(G, 0, 0)
[print(i) for i in color]

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

vector<vector<int>> G;
vector<int> dist, ans;

void bfs(int now)
{
	rep(i, dist.size()) dist.at(i) = INF;
	queue<int> que;
	que.push(now);
	dist[now] = 0;
	while(!que.empty())
	{
		int v = que.front();
		que.pop();
		for(int nv : G[v])
		{
			if (dist[nv] > dist[v] + 1)
				dist[nv] = dist[v] + 1;
			else
				continue;
			que.push(nv);
		}
	}
	rep(i, dist.size())
	{
		if (dist[i] == INF) continue;
		ans[dist[i]]++;
	}
}

signed main(void)
{
	int n, x, y;

	cin >> n >> x >> y;
	--x; --y;
	G.resize(n);
	dist.resize(n);
	ans.resize(n);
	rep(i, n) ans.at(i) = 0;
	rep(i, n - 1)
	{
		G[i].push_back(i + 1);
		G[i + 1].push_back(i);
	}
	G[x].push_back(y);
	G[y].push_back(x);
	rep(i, n)
		bfs(i);
	for(int i = 1; i < n; i++)
		cout << ans.at(i) / 2 << endl;
	return 0;
}


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

int main() {
  string s;
  int ans;
  cin >> s;
  if (s[0] == '1') {
    ans++;
  }
  if (s[1] == '1') {
    ans++;
  }
  if (s[2] == '1') {
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <queue>
#include <math.h>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
#include <bitset>
using namespace std;

int main()
{
    int n, m, p1, p2, ans;
    ans = 0;
    cin >> n >> m;
    vector<set<int>> path;
    vector<int> p;
    path.resize(n+1);
    for(int i=0; i<m; ++i){
        cin >> p1 >> p2;
        path[p1].insert(p2);
        path[p2].insert(p1);
    }
    for(int i=1; i<=n; ++i){
        p.push_back(i);
    }
    do {
        if(p[0] != 1){
            break;
        }
        for(int i=0; i<n; ++i){
            if(i == n-1){
                ans++;
            }
            else if(path[p[i]].find(p[i+1]) == path[p[i]].end()){
                break;
            }
        }
    } while(next_permutation(p.begin(), p.end()));
    cout << ans << endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,N;
  int Y=0;
  cin >> H >> N;
  vector<int>vec(N);
  for (int X=0; X<N; X++){
    cin >> vec.at(X);
    Y+=vec.at(X);
  }
  if (Y>=H){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 640
#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;
const LL MOD = 1e9+7;
const int N = 1e5+1;
LL fac[N+1];
LL fac_inv[N+1];
LL mod_pow(LL base, LL exp)
{
	if(exp==0) return 1;
	if(exp&1) return (base*mod_pow(base,exp-1))%MOD;
	else return mod_pow((base*base)%MOD,exp>>1);
}
LL C(int n, int k)
{
	if(!(0 <= k && k <= n)) return 0;

	LL num = fac[n];
	LL den = (fac_inv[k]*fac_inv[n-k])%MOD;
	return (num*den)%MOD;
}
int loc[N];
int main()
{
	fac[0] = 1;
	for(LL n = 1; n <= N; n++)
		fac[n] = (fac[n-1]*n)%MOD;
	fac_inv[N] = mod_pow(fac[N],MOD-2);
	for(LL n = N-1; n >= 0; n--)
		fac_inv[n] = (fac_inv[n+1]*(n+1))%MOD;

	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n; cin >> n;
	memset(loc,-1,sizeof loc);
	LL before, after;
	for(int i = 1; i <= n+1; i++)
	{
		int x; cin >> x;
		if(loc[x]==-1)
			loc[x] = i;
		else
		{
			before = loc[x]-1;
			after = n+1-i;
			break;
		}
	}
	for(int k = 1; k <= n+1; k++)
		cout<<((C(n+1,k)-C(before+after,k-1))%MOD+MOD)%MOD<<'\n';
	cout<<flush;
	return 0;
}

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

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

using namespace std;

ll cal(ll k){
    ll sum = 0;
    for (ll i = 1; i <= k; ++i)
    {
        sum += i;
    }
    if(k <= 0) return 0;
    else return sum;
}

int main() {

    int n; cin >> n;
    string s; cin >> s;
    set<char> st;
    int Max = -1;
    int tmp  = 0;

    rep(i,n-1){
        tmp = 0;
        st.insert(s[i]);
        for(auto itr = st.begin(); itr != st.end(); ++itr) {
            if(s.substr(i+1,n-i-1).find_first_of(*itr) != string::npos){
                tmp ++;
            }
        }
        Max = max(tmp,Max);
    }
    cout << Max;
    return 0;
}











Measured memory_bytes: 3624
#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int s = n % 10;
    if(s == 3){
        puts("bon");
    }
    else if(s == 0 || s ==  1 || s == 6 || s == 8){
        puts("pon");
    }
    else puts("hon");
    return 0;
}

Measured memory_bytes: 1664
import numpy as np

K =int(input())


ans = 0

dim2 = [[1]*K for i in range(K)]
for i in range(K):
    for j in range(K):
        dim2[i][j] = np.gcd(i+1,j+1)

def row_s(n):
    s = 0
    for i in range(K):
        s = s + dim2[n-1][i]
    return s

for k in range(1,K+1):
    c = 0
    for i in range(K):
        c = c + dim2[i].count(k)
    ans = ans + c * row_s(k)

print(ans)

Measured memory_bytes: 28280
#include <bits/stdc++.h>
#define maxn 100010
#define maxm 200010
#define inf 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long LL;
const LL mod = 1e9 + 7;
int ne[maxn], tot;
bool vis[maxn];
LL dist1[maxn], dist2[maxn], ways1[maxn], ways2[maxn];
struct Edge { int from, to, ne; LL w; }edge[maxm<<1];
void add(int u, int v, LL w) {
    edge[tot] = {u, v, ne[u], w};
    ne[u] = tot++;
}
struct node {
    int v; LL c;
    bool operator < (const node nd) const { return c > nd.c; }
};
int n;
void dfs(int src, LL* dist, LL* ways) {
    memset(vis, 0, sizeof vis);
    for (int i = 1; i <= n; ++i) dist[i] = inf;
    vis[src] = true; dist[src] = 0; ways[src] = 1;
    priority_queue<node> q;
    while (!q.empty()) q.pop();
    while (true) {
        for (int j = ne[src]; ~j; j = edge[j].ne) {
            int v = edge[j].to;
            if (vis[v]) continue;
            LL now = edge[j].w + dist[src];
            if (now == dist[v]) (ways[v] += ways[src]) %= mod;
            else if (now < dist[v]) {
                dist[v] = now; ways[v] = ways[src];
                q.push({v, now});
            }
        }
        while (!q.empty() && vis[q.top().v]) q.pop();
        if (q.empty()) break;
        vis[src = q.top().v] = true;
    }
}
int main() {
    memset(ne, -1, sizeof ne);
    int m, s, t;
    scanf("%d%d%d%d", &n,&m,&s,&t);
    for (int i = 0; i < m; ++i) {
        int u, v; LL w;
        scanf("%d%d%lld", &u,&v,&w);
        add(u, v, w), add(v, u, w);
    }
    dfs(s, dist1, ways1);
    dfs(t, dist2, ways2);
    assert(dist1[t] == dist2[s]);
    assert(ways1[t] == ways2[s]);
    LL ww = ways1[t];
    LL ans = ww * (ww-1) % mod;
    LL dis = dist1[t];
    if (!(dis & 1)) {
        LL half = dis >> 1;
        for (int i = 1; i <= n; ++i) if (dist1[i] == half && dist2[i] == half) {
            LL temp = ways1[i] * ways2[i] % mod;
            ans = (ans - (temp * (temp-1)) % mod + mod) % mod;
        }
    }
    for (int i = 0; i < m; ++i) {
        int id = i<<1,
            u = edge[id].from, v = edge[id].to;
        if (dist1[u] > dist1[v]) swap(u, v);
        if (dist1[u] + edge[id].w + dist2[v] == dis && (dist1[u]<<1) < dis && (dist2[v]<<1) < dis) {
            LL temp = ways1[u] * ways2[v] % mod;
            ans = (ans - (temp * (temp-1)) % mod + mod) % mod;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

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

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

int main()
{
    int N;
    string S;
    cin >> N >> S;
    for (int i = 0; i < S.size(); ++i)
    {
        char s = S[i];
        cout << (char)(((s - 'A' + N) % 26) + 'A');
    }
    return 0;
}


Measured memory_bytes: 256
x = int(input())

if 400 <= x <=599:
  print(8)
if 600 <= x <=799:
  print(7)
if 800 <= x <=999:
  print(6)
if 1000 <= x <=1199:
  print(5)
if 1200 <= x <=1399:
  print(4)
if 1400 <= x <=1599:
  print(3)
if 1600 <= x <=1799:
  print(2)
if 1800 <= x <=1999:
  print(1)


Measured memory_bytes: 9200
package main

import "fmt"

func main() {
	var A, B, K int
	fmt.Scanf("%d %d %d\n", &A, &B, &K)

	if A >= K {
		A -= K
	} else {
		K -= A
		A = 0
		B -= K
	}
	if B < 0 {
		B = 0
	}
	fmt.Println(A, B)
}


Measured memory_bytes: 512
import numpy as np

N = int(raw_input().replace("\n", ""))

inputs = raw_input().replace("\n", "").split(" ")
T, A = map(int, inputs)

inputs = raw_input().replace("\n", "").split(" ")
H_list = map(int, inputs)

T_list = np.asarray(map(lambda x: T - 0.006 * x, H_list))

#print T_list, np.abs(T_list - A)
i = np.argmin(np.abs(T_list - A)) + 1
print(i)


Measured memory_bytes: 19684
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
#include<cmath>
#include<cstdio>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;
typedef pair<int, int> P;


int main() {
	ll i, j, k, l, m, n, sum, flag, cc, M, X, H, W, N, K,h,w;
	cin >> H >> W >> h >> w;
	output(H*W - (h *W+w*H-h*w));
	return 0;
}



Measured memory_bytes: 256
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    N, D, A = NMI()
    M = [NLI() for _ in range(N)]
    M.sort()
    maxj = [0] * N
    j = 0
    for i in range(N):
        while j < N-1:
            if M[j+1][0] <= M[i][0] + D*2:
                j += 1
            else:
                break
        maxj[i] = j
    S = [0]*(N+1)
    ans = 0
    for i in range(N):
        x = M[i][0]
        hp = M[i][1] - S[i]
        need = max((hp-1) // A + 1, 0)
        ans += need
        S[i] += need * A
        S[maxj[i]+1] -= need * A
        S[i+1] += S[i]

    print(ans)





if __name__ == "__main__":
    main()

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

typedef long long ll;
ll arr[2000005] ;

int main()
{
  ll n, cnt = 0, ans = 0;
  cin>>n;
  arr[n];

  for(int i = 0; i < n; i++)  cin>>arr[i];
  sort(arr, arr + n);

  for(int i = 0; i < n; i++){
    ll k = i + 2;
    cnt = 0;
    for(int j = i + 1; j < n; j++){
      while((arr[i] + arr[j] > arr[k] and k < n)) k++;
      cnt += k - j - 1;
    }
    ans += cnt;
  }
  cout<<ans<<endl;
}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, a, b; cin >> n >> a >> b;
    if(n*a < b){
        cout << n*a << endl;
    }else{
        cout << b << endl;
    }
}

Measured memory_bytes: 256
from heapq import heappush, heappop
n,m = map(int,input().split())
a_ls = list(map(int, input().split()))

a_ls = list(map(lambda x: -x, a_ls))
hq = []
for i in range(n):
    heappush(hq,a_ls[i])
for _ in range(m):
    target = heappop(hq)
    target = -(-target//2)
    heappush(hq, target)
print(-sum(hq))


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

#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define mod 998244353
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(ll x=j;x<n;x++)
#define repr(x,j,n)for(ll x=j;x>n;x--)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
const int N=2e6+7;
ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
    if(b&1)
    r=(r*a)%m;
    b=b/2;
    a=(a*a)%m;
    }
    return r%m;
}

int main()
{
 ios::sync_with_stdio(0);
    cin.tie(0);
ll n;
cin>>n;
ll s=0;
rep(i,1,n+1)
{
    if(i%3!=0&&i%5!=0)s+=i;
}

cout<<s;
}



Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#define popcnt(a) __builtin_popcount(a)
#define FastIO() ios::sync_with_stdio(false), cin.tie(0);
#define IO() freopen("palindrome.in","rw",stdin)
#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
} 
typedef long long LL;
const int N = 9e3+9, M = 1e5+9, OO = 0x3f3f3f3f,MOD = 1e9 + 7;
double memo[N][N],arr[N];
int n;
double solve(int idx=0, int p1=0)
{
  if(idx==n) return p1>(n-p1)?1:0;

  double &ret = memo[idx][p1];
  if(ret == ret) return ret;

  ret = 0;
  ret += (arr[idx])*solve(idx+1,p1+1) + (1-arr[idx])*solve(idx+1,p1);
  return ret;
}
int main()
{
  memset(memo,-1,sizeof memo);
  scanf("%d",&n);
  for(int i=0;i<n;++i) scanf("%lf",arr+i);
  printf("%.9lf",solve());

  #ifdef _LOCAL_DEFINE
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0; 
}

Measured memory_bytes: 634496
n = int(input())
arr = list(map(int,input().split()))
res = 1
flag = 0
if 0 in arr:
  print("0")
  flag = 1
if not flag:
  for i in range(n):
    res *= arr[i]
    if res>1000000000000000000:
      print("-1")
      flag = 1
      break
if not flag:
  print(res)

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

ll gcd(ll a, ll b){
    if(a<b) swap(a,b);
    if(a%b == 0) return b;
    else return gcd(b,a%b);
}

int main(){
    int a; cin >> a;
    cout << a+a*a+a*a*a << endl;
}

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

#define mp make_pair
#define pb push_back

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef vector<int> vi;

int n;
i64 a, b;

int main()
{
  cin >> n >> a >> b;
  if (n == 1 && a != b) {
    cout << 0 << endl;
    return 0;
  }
  i64 v = b*(n-1)+a - (a*(n-1)+b);
  if (v < 0)
    cout << 0 << endl;
  else
    cout << v + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
S=[i for i in input()]
ans=[0 for i in range(len(S))]

def run_length(S):
  # 変数初期化
  count = 1
  result = []
  # 配列全体のループ
  for i in range(len(S)):
    try:
      if S[i] == S[i+1]:
        count = count + 1
      else:
        result.append((str(S[i]),count))
        count = 1
    except:
      # 最後の文字セットがOutOfRangeになるので結果に出力
      result.append((str(S[i]),count))
  return result

rl_S = run_length(S)
index = 0
i = rl_S[index][1]-1

while i < len(S):
  ans[i] = (rl_S[index][1]+1)//2 + (rl_S[index+1][1])//2
  ans[i+1] = (rl_S[index][1])//2 + (rl_S[index+1][1]+1)//2
  if index+1 == len(rl_S)-1:break
  i += rl_S[index+1][1] + rl_S[index+2][1]
  index += 2
  
print(*ans)

Measured memory_bytes: 14100
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
#include<deque>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n;
	cin >> n;
	vi a(n);
	int x = 0;
	set<int> st;
	rep(i, 0, n) {
		cin >> a[i];
		if (1 <= a[i] && a[i] < 400) {
			st.insert(1);
		}
		else if (400 <= a[i] && a[i] < 800) {
			st.insert(2);
		}
		else if (800 <= a[i] && a[i] < 1200) {
			st.insert(3);
		}
		else if (1200 <= a[i] && a[i] < 1600) {
			st.insert(4);
		}
		else if (1600 <= a[i] && a[i] < 2000) {
			st.insert(5);
		}
		else if (2000 <= a[i] && a[i] < 2400) {
			st.insert(6);
		}
		else if (2400 <= a[i] && a[i] < 2800) {
			st.insert(7);
		}
		else if (2800 <= a[i] && a[i] < 3200) {
			st.insert(8);
		}
		else {
			x++;
		}
	}
	int min = st.size();
	if (min == 0) {
		min++;
	}
	int max = st.size() + x;
	cout << min << " " << max << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;
signed main(){
    int n,m;cin>>n>>m;
    map<int,int>ma;ma[0]++;
    int sum=0,x;
    rep(i,n){
        cin>>x;
        sum+=x;
        ma[sum%m]++;
    }
    int ans=0;
    map<int,int>::iterator it=ma.begin();
    while(it!=ma.end()){
        ans+=(*it).S*((*it).S-1)/2;
        it++;
    }
    
    cout<<ans;
}

Measured memory_bytes: 4224
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl;
bool G[24][24];
int n,over[24],x[24],y[24],r[24],c[24];
short int dp[1<<24];
int norm(int x,int y) { return x*x+y*y; }
vector<int> col[4];
int dfs(int x){
	if(dp[x]!=-1) return dp[x];
	dp[x]=0;
	bool use[24]={};
	rep(i,n) use[i]=(x>>i)&1;
	rep(i,4){
		rep(a,col[i].size()){
			if(use[col[i][a]] || over[col[i][a]]>0) continue;
			int p=col[i][a];
			rep(b,a){
				if(use[col[i][b]] || over[col[i][b]]>0) continue;
				int q=col[i][b];
				for(int j=p+1;j<n;j++) if(G[j][p]) over[j]--;
				for(int j=q+1;j<n;j++) if(G[j][q]) over[j]--;
				dp[x]=max((int)dp[x],2+dfs(x+(1<<p)+(1<<q)));
				for(int j=p+1;j<n;j++) if(G[j][p]) over[j]++;
				for(int j=q+1;j<n;j++) if(G[j][q]) over[j]++;
			}
		}
	}
	return dp[x];
}
int main(){
	while(true){
		cin>>n;
		if(n==0) break;
		rep(i,n) rep(j,n) G[i][j]=0;
		rep(i,n) over[i]=0;
		rep(i,n) cin>>x[i]>>y[i]>>r[i]>>c[i];
		rep(i,4) col[i].clear();
		rep(i,n){
			c[i]--;
			col[c[i]].pb(i);
		}
		rep(i,n) rep(j,i) if(norm(x[i]-x[j],y[i]-y[j])<norm(r[i]+r[j],0)) G[i][j]=1,over[i]++;
		rep(i,1<<n) dp[i]=-1;
		cout << dfs(0) << endl;
	}
}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> void chmax(T& a, T b){ if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b){ if (a > b) { a = b; } }

int m[1000001];

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        m[a[i]]++;
    }
    sort(all(a));
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (m[a[i]] == 1) {
            ans++;
        }
        if (m[a[i]] > 0) {
            for (int j = a[i]; j <= 1000000; j += a[i]) {
                m[j] = -1;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7952
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
using namespace::std;
int main(){

  int N;
  int L;
  cin>>N>>L;
  int M;
  M=(2*L+N-1)*N/2;
    if(L+N-1<0){
      cout<<M-L-N+1;
    }else if(L>0){
      cout<<M-L;
    }else{
      cout<<M;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 1000 + 5;
int a[N];
int main()
{
   int a,b,c,d;
   while(cin >> a >> b >> c >> d)
   {
       int fl = 0;
       if(abs(a-c) <= d) fl = 1;
       if(abs(b-a) <= d && abs(c-b) <= d) fl = 1;
       if(fl == 1)
        printf("Yes\n");
       else
        printf("No\n");
   }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int N;

long long ans;

char march[5] = {'M', 'A', 'R', 'C', 'H'};
long long cnt[5]; //M,A,R,C,Hで始まる人の人数

int main(){
	cin >> N;
	
	string s;
	for(int i=0; i<N; i++){
		cin >> s;
		
		for(int j=0; j<5; j++){
			if(s[0] == march[j]){
				cnt[j]++;
			}
		}
	}
	
	for(int i=0; i<5; i++){
		for(int j=i+1; j<5; j++){
			for(int k=j+1; k<5; k++){
				ans += cnt[i] * cnt[j] * cnt[k];
			}
		}
	}
	
	cout << ans << endl;
	
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>
#include <random>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
#include<atcoder/all>
int main(void){
    ll n, q;
    cin >> n >> q;
    
    atcoder::fenwick_tree<ll> fw(n);
    rep(i, n){
        ll a;
        cin >> a;
        fw.add(i, a);
    }

    rep(i, q){
        ll t, a, b;
        cin >> t >> a >> b;
        if(t == 0){
            fw.add(a, b);
        } else {
            cout << fw.sum(a, b) << endl;
        }
    }
}



Measured memory_bytes: 8232
/* author:hellojim */
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
ll res=0;
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	string s;
	cin>>s;
	rep(i,s.size())
		res+=(s[i]-'0');
	if(res%9)cout<<"No\n";
	else cout<<"Yes\n";
	return 0;
}



Measured memory_bytes: 3744
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>

struct section{
  int low,high;
};

int comp(const void *p1,const void *p2);
bool check(struct section *sec,int num,int max);

int main(void){
  int N,W,H;
  int i,j,k;
  struct section xsec[100000],ysec[100000];
  int x,y,dist;

  scanf("%d%d%d",&N,&W,&H);
  for(i=0;i<N;i++){
    scanf("%d%d%d",&x,&y,&dist);
    xsec[i]=(struct section){x-dist,x+dist};
    ysec[i]=(struct section){y-dist,y+dist};
  }
  qsort(xsec,N,sizeof(xsec[0]),comp);
  qsort(ysec,N,sizeof(ysec[0]),comp);

  puts((check(xsec,N,W) || check(ysec,N,H))?"Yes":"No");
  return 0;
}

int comp(const void *p1,const void *p2){
  struct section n1=*(struct section *)p1;
  struct section n2=*(struct section *)p2;
  if(n1.low==n2.low) return n2.high-n1.high;
  return n1.low-n2.low;
}

bool check(struct section *sec,int num,int max){
  int now=0;
  int i;
  for(i=0;i<num;i++){
    if(sec[i].low>now) return false;
    if(now<sec[i].high) now=sec[i].high;
  }
  return now>=max;
}

Measured memory_bytes: 2964
#include <iostream>

using namespace std;

int main()
{
  int a, b, c;
  int coins_per_week;
  int residue_coins;
  int weeks, days;
  
  cin >> a >> b >> c;

  coins_per_week = a * 7 + b;
  weeks = c / coins_per_week;
  residue_coins = c % coins_per_week;

  if (residue_coins >= a * 7) {
    days = 7;
  } else if (!(residue_coins % a)) {
    days = residue_coins / a;
  } else {
    days = residue_coins / a + 1;
  }
  cout << days + weeks * 7 << endl;
}



Measured memory_bytes: 3100
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int Q = sc.nextInt();
        TreeSet<Long> sSet = new TreeSet<>();
        TreeSet<Long> tSet = new TreeSet<>();
        long INF=(long)1e13;
        sSet.add(INF);
        sSet.add(-INF);
        tSet.add(INF);
        tSet.add(-INF);
        for(int i = 0; i < A; i++) {
            sSet.add(sc.nextLong());
        }
        for(int i = 0; i < B; i++) {
            tSet.add(sc.nextLong());
        }
        for(int i = 0; i < Q; i++) {
            long num = sc.nextLong();
            long a = sSet.ceiling(num) - num;
            long b = num - sSet.floor(num);
            long c = tSet.ceiling(num) - num;
            long d = num - tSet.floor(num);

            long candidate1 = Math.min(Math.max(a, c), a + d + Math.min(a, d));
            long candidate2 = Math.min(Math.max(b, d), b + c + Math.min(b, c));
            long min = Math.min(candidate1, candidate2);
            System.out.println(min);
        }
    }
}


Measured memory_bytes: 109072
h,w=map(int,input().split())
s=[]
for _ in range(h):
    s.append(input())
ans=[['#'] * w for _ in range(h)]

for i in range(h):
    for j in range(w):
        if s[i][j]=='#':
            continue
        c=0
        for dx in range(-1, 2):
            for dy in range(-1, 2):
                nx=i+dx
                ny=j+dy
                if nx>=0 and nx<h and ny>=0 and ny<w:
                    if s[nx][ny]=='#':
                        c+=1
        ans[i][j]=str(c)
for i in range(h):
    print(''.join(ans[i]))


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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def add(X):
    counter = 0
    while True:
        if counter * (counter + 1) <= X * 2:
            counter += 1
        else:
            counter -= 1
            break
    # print(X, counter)
    return counter

facts = factorization(N)
answer = 0
for f in facts:
    if f[0] != 1:
        answer += add(f[1])
print(answer)

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

#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define eb emplace_back
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
using ull = unsigned long long;
using Vi = vector<int>;

void run() {
    int n;
    cin >> n;
    vector<int> ara(n);
    
    for (auto& i : ara) {
        cin >> i;
    } 
    vector<int> cst(n+2);
    cst[0] = 0;
    cst[1] = abs(ara[0] - ara[1]);

    for (int i = 2; i < n; ++i) {
        cst[i] = min(cst[i-1] + abs(ara[i-1] - ara[i]), cst[i-2]+ abs(ara[i-2]- ara[i]));
    }
    cout << cst[n-1] << endl;
}

int main() 
{
    IO;
    double st = clock();
    run();
    cerr << "\n" << "time = " << (clock() - st) / CLOCKS_PER_SEC << "\n";
    return 0;
}

Measured memory_bytes: 4028
//BISMILLAHIR RAHMANIR RAHIM
//RHYTHM_086_NS_01
//ALAN_IS_ON....

#include <bits/stdc++.h>

#define     boost_              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define     iter_(i,n)          for (int i = 0; i < int(n); i++)
#define     for_n(i, n)         for (int i = 1; i <= int(n); i++)
#define     pb                  push_back
#define     mp                  make_pair
#define     itr                 ::iterator
#define     s_sort(s)           sort(s.begin(),s.end())
#define     n_sort(a)           sort(a,a+n)
#define     thank_you           return 0
#define     precise_impact      cout<<setprecision(10)<<fixed;

using namespace std;

typedef long long int ll;
typedef double db;
#define MOD 1000000007

ll bigmod(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll tm=bigmod(a,b/2);
    tm=(tm*tm)%MOD;
    if(b%2==1)
        tm=(tm*a)%MOD;
    return tm;

}
void solve();


int main()
{
    boost_;
    precise_impact;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Here we go...
    solve();

    thank_you;
}


void solve()
{
    int n;
    cin>>n;
    int a[n];
    iter_(i,n){
        cin>>a[i];
    }
    n_sort(a);
    ll b[2];
    bool b1[2]={true,true};
    int k=0;
    for(int j=n-1;j>=1;j--){
        if(a[j]==a[j-1]){
            if(k<2){
                b[k]=a[j];
                //b1[k]=false;
                k++;
            }
            j--;
        }
    }
    if(k!=2){
        cout<<"0"<<endl;
        //cout<<k<<endl;
    }
    else
        cout<<b[0]*b[1]<<endl;

}



Measured memory_bytes: 3972
#include <bits/stdc++.h>  // ver1.9.4
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl;
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

signed main() {
  cout << fixed << setprecision(15);
  int n,k,q,memo;
  Vi a(n);
  cin >> n >> k >> q;
  rep(i,0,q){
    cin >> memo;
    a[memo-1]++;
  }
  int goal = q-k+1;
  rep(i,0,n){
    if(a[i]>=goal) cYes;
    else cNo;
  }
  return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

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

int main(void){
	int_fast32_t N;
	while(cin >> N && N){
		vector<int_fast32_t> vx, vy;
		vx.push_back(0);
		vy.push_back(0);
		REP(i, N-1){
			int_fast32_t x, d;
			cin >> x >> d;
			vx.push_back(vx[x]+dx[d]);
			vy.push_back(vy[x]+dy[d]);
		}
		cout << *max_element(all(vx))-*min_element(all(vx))+1 << " " << *max_element(all(vy))-*min_element(all(vy))+1 << endl;
	}
}




Measured memory_bytes: 3052