akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int t; cin >> t; cin.ignore(); while(t--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}
 
vl g[100005];
bool vis[100005];
ll disx[100005];
ll disy[100005];

int main(){
    fast();
 
/* you get what you work for not what you wish for */
    
    inp(n);
    inps(x, y);
    x--, y--;
    for(int i=0; i<n-1; i++){
        inps(u, v);
        u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
    queue <int> q;
    vis[x] = 1;
    q.push(x);
    disx[x] = 0;
    while(!q.empty()){
        ll i = q.front();
        q.pop();
        for(auto j:g[i]){
            if(!vis[j]){
                vis[j] = 1;
                disx[j] = disx[i] + 1;
                q.push(j);
            }
        }
    }
    memset(vis, 0, sizeof(vis));
    q.push(y);
    disy[y] = 0;
    vis[y] = 1;
    while(!q.empty()){
        ll i = q.front();
        q.pop();
        for(auto j:g[i]){
            if(!vis[j]){
                q.push(j);
                vis[j] = 1;
                disy[j] = disy[i] + 1;
            }
        }
    }
    ll ans = 0;
    for(int i=0; i<n; i++){
        if(disy[i]>disx[i]){
            ans = max(ans, disy[i]-1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 8064
package main

import (
	"fmt"
	"math"
)

func main() {
	var s int64
	fmt.Scan(&s)
	m := 100.0
	for i:= 1;;i++ {
		m = math.Floor((m * 1.01))
		if int64(m) >= s {
			fmt.Println(i)
			return 
		}
	}
}


Measured memory_bytes: 1756
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
	ll a, b, t;
	cin >> a >> b >> t;

	ll ans = 0;

	double tt = t + 0.5;
	tt -= a;

	while(tt > 0){
		ans += b;
		tt -= a;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define Graph vector<vector<int>>;
#define iterG(next_v, G, v) for(auto next_v : G[v]
int main(){
    ll n, tmp, ans;
    map<ll, ll> dic;
    vector<ll> a;
    cin >> n;
    rep(i, n){
        cin >> tmp;
        a.push_back(tmp);
        if(dic.count(tmp)){
            dic[tmp] = dic[tmp] + 1; // ++tamesu
        }else{
            dic[tmp] = 1;
        }
    }
    ll sums = 0;
    for (auto const& x : dic){
        sums += x.second * (x.second - 1) / 2;

    }
    ll cur;
    rep(i, n){
        tmp = a[i];
        cur = dic[tmp];
        cout << sums - (cur - 1) << endl;
    }
    return 0;
}



Measured memory_bytes: 12144
#include<bits/stdc++.h>
#define test int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
using namespace std;
int main()
{
long long n,a[100000],c=0; cin>>n;
for(long long i=1;i<=n;i++)
{
    cin>>a[i];
    if(i%2==1)
    {
        if(a[i]%2==1)
        {
            c++;
        }
    }
}
cout<<c<<endl;
}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define endl '\n'

double dp[303][303][303], sum;

int main()
{
	int n, a, f[4] = {};
	scanf("%d", &n);
	for(int i=0; i<n; i++)
	{
		cin >> a;
		f[a]++;
	}
	dp[0][0][0] = 0;
	for(int three=0; three<=f[3]; three++)
		for(int two=0; two<=f[3]+f[2]; two++)
			for(int one=0; one<=n; one++)
			{
				sum = one + two + three;
				if( sum )
					dp[three][two][one] = n / sum;
				if( one )
					dp[three][two][one] += one/sum * dp[three][two][one-1];
				if( two )
					dp[three][two][one] += two/sum * dp[three][two-1][one+1];
				if( three )
					dp[three][two][one] += three/sum * dp[three-1][two+1][one];
				//cout << three << ' ' << two << ' ' << one << " : " << dp[three][two][one] << endl;
			}

	printf("%.12lf\n", dp[f[3]][f[2]][f[1]]);
	return 0;
}

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

int main() {
	int mai,N,turi;

	cin >> N;

	mai = N % 1000;
	if (mai == 0) {
		turi = 0;
	}
	else {
		turi = 1000 - mai;
	}

	cout << turi << endl;
	return 0;
}

Measured memory_bytes: 3640
use std::io;
use std::io::prelude::*;

fn main () {
    let mut stdin = io::stdin();
    let mut buf = String::new();
    let _ = stdin.read_to_string(&mut buf);
    let mut iter = buf.split_whitespace();
    let a: u32 = iter.next().unwrap().parse().unwrap();
    let b: u32 = iter.next().unwrap().parse().unwrap();
    println!("{:032b}", a & b);
    println!("{:032b}", a | b);
    println!("{:032b}", a ^ b);
}


Measured memory_bytes: 5020
#include<bits/stdc++.h>
using namespace std;
#define Maxn 100005
int n,s,ans;
int h[Maxn];
int main() {
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> h[i];
	for(int i = 2; i <= n; i++)
		if (h[i] <= h[i - 1]) {
			s++;
			ans = max(ans,s);
		} else
			s = 0;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
n,m = map(int,input().split())
u = [[] for i in range(n)]#隣接リスト
for i in range(m):
     a,b = map(int,input().split())
     a-=1#部屋何号の0-indexedへの変換
     b-=1
     u[a].append(b)
     u[b].append(a)

from collections import deque
q = deque([0])#bfsの、「次のステップで訪問予定」をためておくキュー

dist = [-1]*n
ans = [-1]*n

count=1
while q:
    i = q.popleft()
    for j in u[i]:
        if dist[j]==-1:
            dist[j]=count
            ans[j]=i+1
            q.append(j)
    count+=1

print('Yes')
for i in range(1,n):
    print(ans[i])


Measured memory_bytes: 39080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    int n,p;
    cin >> n >> p;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i] = a[i] % 2;
    }
    int odd = 0, even = 0;
    for(int i = 0; i < n; i++){
        if(a[i] == 0){
            even++;
        }else{
            odd++;
        }
    }
    if(even == n){
        if(p == 0){
            cout << (ll)pow(2,n) << endl;
        }else{
            cout << 0 << endl;
        }
    }else{
        cout << (ll)pow(2,n-1) << endl;
    }
    
    return 0;
}





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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int a[3];
	rep(i,3)cin>>a[i];
	sort(a,a+3);
	if(a[1]==a[0]&&a[1]!=a[2])cout<<"Yes"<<endl;
	else if(a[1]==a[2]&&a[1]!=a[0])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
B=[]
C=[]
for i in range(n):
    for j in range(8):
        if (j*400)<=A[i]<((j+1)*400):
            B.append(j)
    if 3200<=A[i]:
        C.append(i)
print(max(len(set(B)),1),len(set(B))+len(C))


Measured memory_bytes: 3060
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
//////////////////////////


int main(){fastio
    ll n;cin>>n;
    ll a=-inf,b;
    while(n--){
        ll s,t;cin>>s>>t;
        if(chmax(a,s)){
            b=t;
        }
    }
    cout<<a+b<<endl;
    
    return 0;
}


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

const int INF = 1<<30;
const int maxn = 15;
int d[maxn][maxn];
int E,V;

long long sum;

void warshall_floyd(){
	for(int k=0; k<V; k++)
		for(int i=0; i<V; i++)
			for(int j=0; j<V; j++)
				d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
}

int main(){
	while(scanf("%d",&E) && E){
		memset(d, 0x3f, maxn * maxn * sizeof(int));

		for(int i=0; i<maxn; i++) d[i][i] = 0;

		V = 0;
		for(int i=0; i<E; i++){
			int u,v,w;
			scanf("%d%d%d",&u,&v,&w);
			d[u][v] = d[v][u] = w;
			V = max(V,max(v,u)+1);
		}

		warshall_floyd();

		int ans = INF, pos;
		for(int i=0; i<V; i++){
			sum = 0;
			for(int j=0; j<V; j++)
				sum += d[i][j];
			if(ans > sum){
				ans = sum;
				pos = i;
			}
		}

		printf("%d %d\n",pos,ans);
	}
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  int k;
  cin >> s >> k;
  
  ll dp[s.size() + 1][2][k + 2];
  for(int i = 0; i < s.size() + 1; i++){
    for(int j = 0; j < 2; j++){
      for(int ii = 0; ii < k + 1; ii++){
        dp[i][j][ii] = 0;
      }
    }
  }
  dp[0][0][0] = 1;
  
  for(int i = 0; i < s.size(); i++){
    for(int j = 0; j < 2; j++){
      for(int ii = 0; ii < k + 1; ii++){
        for(int d = 0; d <= (j ? 9 : (int) s[i] - '0'); d++){
          dp[i + 1][j || (d < (int) s[i] - '0')][ii + (d != 0)] += dp[i][j][ii];
        }
      }
    }
  }
  
  cout << dp[s.size()][0][k] + dp[s.size()][1][k] << '\n';
}

Measured memory_bytes: 256
# 集合A={2,3},B={2,4},C={3,5,7}がある。
# それぞれの集合から1つずつa,b,cを選ぶ。
# a+b+c = nとなる選び方は何通りあるか。
# ->    f = (x^2+x^3)*(x^2+x^4)*(x^3+x^5+x^7)とするとき、fのx^nの係数が答え
# -->   [x^n](x^2+x^3)(x^2+x^4)*(x^3+x^5+x^7)と表される。


# f = x^3 + x^4 + x^5 + ...
#[x^s]f^n
#->[x^s](for i in range(∞):f^n)

#A[n] = A[n-3] +A[n-4] +A[n-5] + ... + A[0]
#A[0] = 1

s = int(input())
MODINT = 1000000007
dp = [0]*(s+1)
dp[0] = 1

for i in range(1,s+1):
    for j in range(0,(i-3)+1):
        dp[i] += dp[j]
        dp[i] %= MODINT
print(dp[s])

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

int main()
{
    int N,M;
    cin >> N >> M;
    vector<int> city(N);
    vector<int> a(M);
    vector<int> b(M);

    for(int i = 0; i < M; i++)
    {
        cin >> a.at(i) >> b.at(i);
    }

    for(int i = 0; i < N; i++)
    {
        city.at(i) = 0;
    }

    for(int i = 0; i < M; i++)
    {
        city.at(a.at(i)-1)++;
        city.at(b.at(i)-1)++;
    }
    
    for(int i = 0; i < N; i++)
    {
        cout << city.at(i) << endl;
    }
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <iomanip>
#include <bitset>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    int n, a, b;
    cin >> n >> a >> b;
    if (!((a % 2) ^ (b % 2)))
    {
        cout << "Alice\n";
    }
    else
    {
        cout << "Borys\n";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    
   	ll a, ans;
   	double b;
   	cin >> a >> b;
   	ll k = (b * 100) + 0.01;
   	cout << (ll)((a * k) / 100);

    return 0;
}

Measured memory_bytes: 3744
#include <iostream>
#include <cmath>

using namespace std;

const int maxN = 1e5 + 10;

int f[maxN], h[maxN];
int n;

// Min cost i -> n
int calculate(int i) {
    if (i == n) return 0;
    if (f[i] != -1) return f[i];
    int ret = (int) abs(h[i] - h[i + 1]) + calculate(i + 1);
    if (i < n - 1) 
        ret = min(ret, (int) abs(h[i] - h[i + 2]) + calculate(i + 2));
    return f[i] = ret;
}

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i) scanf("%d", &h[i]);
    fill(f + 1, f + n + 1, -1);
    cout << calculate(1);
}


Measured memory_bytes: 4096
#include <iostream>
#include <deque>
#include <algorithm>
using namespace std;

int main(){
	int n,sum,t;
	deque<int> deq;
	while(cin >> n , n){
		deq.clear();
		for(int i=0;i<n;i++){
			cin >> t;
			deq.push_back(t);
		}
		
		sort(deq.begin(),deq.end());
		
		deq.pop_back();
		deq.pop_front();
		sum = 0;
		for(int i=0;i<deq.size();i++){
			sum += deq[i];
		}
		cout << sum / deq.size() << endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	vector<Int> A(N);
	for (Int i = 0; i < N; i++) {
		cin >> A[i];
	}

	vector<vector<Int>> dp(N + 1, vector<Int>(3));//（3色の組み合わせ）
	//vector<mint> ans(N + 1);//総計
	dp[0][0] = 1;
	dp[0][1] = 0;
	dp[0][2] = 0;
	//ans[0] = 3;
	mint ans = 3;

	if (A[0]!=0) {
		cout << 0 << "\n";
		return 0;
	}

	Int temp;
	Int cnt;
	for (Int i = 1; i < N; i++) {
		temp = A[i];
		cnt = 0;
		Int flag = 1;
		for (Int j = 0; j < 3; j++) {
			if (temp == dp[i - 1][j]) {
				cnt++;
				if (flag) {
					dp[i][j] = temp + 1;
					flag = 0;
				}
				else {
					dp[i][j] = dp[i - 1][j];
				}
			}
			else {
				dp[i][j] = dp[i - 1][j];
			}
		}
		//ans[i] = ans[i - 1] * cnt;
		ans *= cnt;
	}

	cout << ans << "\n";
}


Measured memory_bytes: 6528
from collections import deque

h,w = map(int,input().split())
hw = []
for i in range(h):
    hw.append(input())

todo = deque([(0,0)])
seen = [[200 for j in range(w)] for i in range(h)]
sx = 0
sy = 0
if hw[0][0] == '.':
    seen[0][0] = 0
else:
    seen[0][0] = 1




while todo:
    sx,sy = todo.popleft()
    if sx + 1 < h and seen[sx+1][sy] == 200:
        todo.append((sx+1,sy))
    if sx + 1 < h and hw[sx+1][sy] == '.' and seen[sx+1][sy] > seen[sx][sy]:
        seen[sx+1][sy] = seen[sx][sy]
    if sx + 1 < h and hw[sx+1][sy] == '#' and seen[sx+1][sy] > seen[sx][sy]+1 and hw[sx][sy] == '.':
        seen[sx+1][sy] = seen[sx][sy]+1
    if sx + 1 < h and hw[sx+1][sy] == '#' and seen[sx+1][sy] > seen[sx][sy] and hw[sx][sy] == '#':
        seen[sx+1][sy] = seen[sx][sy]
    if sy+1 < w and seen[sx][sy+1] == 200:
        todo.append((sx,sy+1))
    if sy + 1 < w and hw[sx][sy+1] == '.' and seen[sx][sy+1] > seen[sx][sy]:
        seen[sx][sy+1] = seen[sx][sy]
    if sy + 1 < w and hw[sx][sy+1] == '#' and seen[sx][sy+1] > seen[sx][sy]+1 and hw[sx][sy] == '.':
        seen[sx][sy+1] = seen[sx][sy]+1
    if sy + 1 < w and hw[sx][sy+1] == '#' and seen[sx][sy+1] > seen[sx][sy] and hw[sx][sy] == '#':
        seen[sx][sy+1] = seen[sx][sy]



print(seen[h-1][w-1])

Measured memory_bytes: 3444
# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


n = inp()

arr = inlist()
arr = sorted(arr)
n = int(n/2)
kl = int(arr[n-1])
kh = int(arr[n])
print(max(0, kh-kl))


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

int main(){
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> l(c);
    for(int i = 0; i < c; i++)  cin >> l[i];
    priority_queue<pair<int,int>> pq;
    int a, b;
    while(n-- > 0){
        cin >> a >> b;
        pq.push({b, a-1});
    }
    int cnt = 0, sum = 0;
    while(!pq.empty()){
        pair<int,int> p = pq.top(); pq.pop();
        if(cnt == m)    break;
        if(l[p.second] == 0)    continue;
        sum += p.first, cnt++, l[p.second]--;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 4252
*> AtCoder My Practice
       *> author: Leonardone @ NEETSDKASU
       *>
       IDENTIFICATION DIVISION.
       PROGRAM-ID. Answer.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
              FUNCTION ALL INTRINSIC.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
              01 Input-Values.
                     05 n      BINARY-SHORT.
                     05 arare  PIC X(200).
              01 Calc-Values.
                     05 ans    PIC X(5).
       PROCEDURE DIVISION.
       AnswerMain SECTION.
       000-Start.
       
              ACCEPT n.
              ACCEPT arare.
              
              MOVE "Three" TO ans.
              MULTIPLY 2 BY n.
              SUBTRACT 1 FROM n.
       001-LoopHead.
              IF arare(n:1) = "Y" THEN
                     MOVE "Four" TO ans
                     GO TO 002-Output
              END-IF.
              SUBTRACT 1 FROM n.
              IF n < 0 THEN
                     GO TO 002-Output
              END-IF.
              GO TO 001-LoopHead.
       002-Output.
              DISPLAY TRIM(ans).
       END PROGRAM Answer.


Measured memory_bytes: 384
import java.util.*;
import java.lang.Math;
public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int X = sc.nextInt();
      int Y = 0;
      int[] x2 = new int[50];
      for(int i=0;i<32;i++){
        x2[i]=i*i;
        if(Y<x2[i]&&x2[i]<=X){
        	Y=x2[i];
        }
      }
      for(int j=0;j<11;j++){
      	x2[j+31]=j*j*j;
        if(Y<x2[j]&&x2[j]<=X){
        	Y=x2[j];
        }
      }
      int[] a = {16,81,256,625,32,243,64,729,128,256,512};
      for(int k=0;k<11;k++){
      	if(Y<a[k]&&a[k]<=X){
        	Y=a[k];
        }
      }
          if(X==1000){System.out.println(1000);}else{System.out.println(Y);}
    }
}

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

#define ll long long
#define P pair<int, int>
#define F first
#define S second

const ll mod = 1000000007LL;

ll h, w;
ll dp[1005][1005];
string grid[1005];

void solve() {
  cin >> h >> w;
  grid[0] = string(".", w);
  for (int i = 1; i <= h; i++) {
    cin >> grid[i];
    grid[i] = '.' + grid[i];
  }

  dp[1][1] = 1;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      if (i == 1 && j == 1) continue;
      if (grid[i][j] == '#') continue;
      dp[i][j] =
          (dp[i][j] % mod + dp[i - 1][j] % mod + dp[i][j - 1] % mod) % mod;
    }
  }

  cout << dp[h][w];
}

int main(int argc, char const *argv[]) {

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

  int T = 1;
  while (T--) {
    solve();
  }

  return 0;
}

Measured memory_bytes: 12464
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;

const int mmax = 100002;
int a, b, q;
ll ans[100000];
ll s[mmax], t[mmax], x[mmax];
void calc(int a, int b, ll s[], ll t[]) {
    rep(i, q) {
        int tmp[2];
        tmp[0] = (int)(lower_bound(s, s + a + 2, x[i]) - s);
        /*
        cout << endl;
        cout << i << " " << tmp[0] << endl;
         */
        tmp[1] = tmp[0] > 1 ? tmp[0] - 1 : tmp[0];
        rep(j, 2) {
            int ttmp = (int)(lower_bound(t, t + b + 2, s[tmp[j]]) - t);
            //cout << j << " " << ttmp << endl;
            ll sum = 0;
            sum += abs(x[i] - s[tmp[j]]);
            sum += abs(s[tmp[j]] - t[ttmp]);
            ans[i] = min(ans[i], sum);
            sum -= abs(s[tmp[j]] - t[ttmp]);
            if (ttmp > 1) {
                sum += abs(s[tmp[j]] - t[ttmp - 1]);
                ans[i] = min(ans[i], sum);
            }
        }
    }
    
}
int main() {
    cin >> a >> b >> q;
    s[0] = t[0] = 0;
    s[a + 1] = t[b + 1] = 1e11;
    rrep(i, 1, a + 1) cin >> s[i];
    rrep(i, 1, b + 1) cin >> t[i];
    rep(i, q) cin >> x[i];
    rep(i, q) ans[i] = 2 * 1e10;
    calc(a, b, s, t);
    calc(b, a, t, s);
    rep(i, q) cout << ans[i] << endl;
}


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

using namespace std;
void solve(){
	int n;
	cin>>n;
	int dig = n%10;
	switch(dig){
		case 2:
		case 4:
		case 5:
		case 7:
		case 9: cout<<"hon\n"; break;
		case 0:
		case 1:
		case 6:
		case 8: cout<<"pon\n"; break;
		case 3: cout<<"bon\n"; break;

	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	
	solve();

	return 0;
}

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

if x >= 400 and x <= 599:
    s = 8
elif x >= 600 and x <= 799:
    s = 7
elif x >= 800 and x <= 999:
    s = 6
elif x >= 1000 and x <= 1199:
    s = 5
elif x >= 1200 and x <= 1399:
    s = 4
elif x >= 1400 and x <= 1599:
    s = 3
elif x >= 1600 and x <= 1799:
    s = 2
else:
    s = 1

print(s)

Measured memory_bytes: 9176
<?php
  fscanf(STDIN, "%d", $n);
  $numbers = trim(fgets(STDIN));
  $weights = explode(" ", $numbers);
  $min = 99999999;
  for($t = 0;$t < $n;$t++){
    $sum[0] = 0;
    $sum[1] = 0;
    for($i = 0;$i < $t;$i++){
      $sum[0] += $weights[$i];
    }
    for($i = $t;$i < $n;$i++){
      $sum[1] += $weights[$i];
    }
    if($min > abs($sum[0] - $sum[1])){
      $min = abs($sum[0] - $sum[1]);
    }
  }
  echo $min;
  ?>

Measured memory_bytes: 3956
import java.util.Scanner; // ?????¨?????????????????????

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

        // ????????? sc ?????? int ?????? 1 ?????\???????????????.
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println((a * b) + " " + 2 * (a + b));
    }
}

Measured memory_bytes: 26284
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a,b,c,num=0;
    a = sc.nextInt();
    b = sc.nextInt();
    c = sc.nextInt();
    while(a<=b){
      if(c%a==0) num++;
      a++;
    }
    System.out.println(num);
  }
}



Measured memory_bytes: 26264
def mul(n, cnt = 0)
  ns = []
  if n.size == 1
    return cnt
  else
    (n.size-1).times do |i|
      ns << n[0..i].to_i * n[i+1..-1].to_i
    end
    cnt += 1
    mul(ns.max.to_s, cnt)
  end
end

gets.to_i.times do
  n = gets.strip
  p mul(n)
end

Measured memory_bytes: 6104
#include <stdio.h>
#include <math.h>

int main(){
  
  unsigned long long	A, ans, M;
  long double	B, N;
  
  scanf("%llu %Lf", &A, &B);  
  ans = (unsigned long long)(A*B+0.001);  
  printf("%llu", ans);
  
  return 0;
}


Measured memory_bytes: 1756
#include<stdio.h>
int dp[50];
int fib(int n){
 if(!n||n==1)return dp[n]=1;
 if(dp[n]!=-1)return dp[n];
 return dp[n]=fib(n-1)+fib(n-2);
}
int main(){
 int n,i;
 for(i=0;i<50;i++)dp[i]=-1;
 scanf("%d",&n);
 printf("%d\n",fib(n));
 return 0;
}


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

int main() {
    string S;
    cin >> S;
    map<char, int> t;
    for (int i = 0; i < S.length(); i++)
    {
        t[S[i]]++;
    }
    if (t.size() == 2 && t[S[0]] == 2)
    {
        cout << "Yes" << endl;
    } else
    {
        cout << "No" << endl;
    }
    
    

  return 0;
}


Measured memory_bytes: 256
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=sorted(a)
d=sorted(b)
ans=c[0]+d[0]
for i in range(M):
  x,y,c=map(int,input().split())
  temp=a[x-1]+b[y-1]-c
  ans=min(ans,temp)
print(ans)


Measured memory_bytes: 24856
#include <bits/stdc++.h>
#include <cstring>
#include <ctype.h>
#include<stdlib.h>

#define flin            freopen("input.txt", "r", stdin); 
#define flout           freopen("output.txt", "w", stdout);
#define ll              long long
#define ull             unsigned long long
#define fastio          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl              '\n'
#define nll             '\0'
#define pb              push_back
#define bdyptb          return 0;
#define sorted(x)       sort(x.begin(), x.end())
#define reversed(x)     reverse(x.begin(), x.end())
#define all(x)          x.begin(), x.end()
#define mset(a, b)      memset(a, b, sizeof(a));
#define testcase        ll t,tt; cin>>tt; for(t=1;t<=tt;t++)

#define pi acos(-1.00)   
#define mx 1000007

using namespace std;
int gcd(int x,int y)
{        
    return x ? gcd(y%x,x) : y;   
}  

int main()
{
    fastio;
    int n;
    cin>>n;
    int p[n+1];
    for(int i=1; i<=n; i++)
    cin>>p[i];
    int x=30000;
    int a[n+1],b[n+1];
    for(int i=1; i<=n; i++)
    {
        a[i]=(i*x);
        b[i]=((n-i)*x);
    }

    for(int i=1; i<=n; i++)
    b[p[i]]+=i;


    for(int i=1; i<=n; i++)
    cout<<a[i]<<' ';
    cout<<nl;
    
    for(int i=1; i<=n; i++)
    cout<<b[i]<<' ';
    cout<<nl;

    bdyptb;
}

Measured memory_bytes: 3880
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(void) {
	int q;
	int l,r;
	cin >> q;
	int prime[100005],similar[100005],temp;
	for(int i=2; i<100005; i++)prime[i]=1;
	for(int i=2; i<100005; i++){
		if(prime[i]==0)continue;
		temp=i;
		while(temp+i<100005){
			temp+=i;
			prime[temp]=0;
		}
	}
	for(int i=1; i<100005; i++){
		if(i%2==1 && prime[i]==1 && prime[(i+1)/2]==1)similar[i]=similar[i-1]+1;
		else similar[i]=similar[i-1];
	}
	for(int i=0; i<q; i++){
		cin >> l >> r;
		cout << similar[r]-similar[l-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll r,g,b,n;
    std::cin >> r>>g>>b>>n;
    
    ll result = 0;
    
    for (int i = 0; i <= 3000; i++) {
        for (int j = 0; j <= 3000; j++) {
            if( n-(i*r+j*g) >= 0 &&  (n-(i*r+j*g)) % b == 0 ){
                // std::cout << i<<" "<<j<<" "<<n-(i*r+j*g)<< std::endl;
                // std::cout << i<<" "<<j<<" "<<(n-(i*r+j*g))/b<< std::endl;
                result++;
            }
        }
    }
    std::cout << result << std::endl;
}

Measured memory_bytes: 256
#include <cstdio>
typedef long long LL;
const int MAXN=1E6+10;
LL A[MAXN];
int doing() {
	int N;
	scanf("%d",&N);
	for(int i=1;i<=N;++i) {
		scanf("%lld",&A[i]);
	}
	LL X=0;
	for(int i=3;i<=N;++i) {
		X^=A[i];
	}
	LL S=A[1]+A[2];
	if((S-X)%2!=0 || S<X)return printf("-1");
	LL D=(S-X)/2;
	LL a=D;
//	printf("D:=%d\n",D);
	for(LL i=60;i>=0;--i) {
		LL Xi=(X>>i)&1;
		LL Di=(D>>i)&1;
		if(Xi==1&&Di==1)return printf("-1");
		if(Xi==1&&Di==0) {
			if(a+(1LL<<i)<=A[1])a+=(1LL<<i);
		}
	}
	if(a==0 || A[1]<a)return printf("-1");
	return printf("%lld\n",A[1]-a);
	
}
int main() {
	doing();
	return 0;
} 

Measured memory_bytes: 1736
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	int v[50];
	for(int i = 0; i < n; i++){
		cin >> v[i];
	}
	for(int i = 0; i < n; i++){
		int c;
		cin >> c;
		v[i] -= c;
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(v[i] > 0) ans += v[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <cmath>

using namespace std;

void solve()
{
	set<int> primeFactor;
	int n;
	cin >> n;
	int input = n;
	for (int i = 2; i <= sqrt(input); ++i)
	{
		while (n % i == 0)
		{
			n /= i;
			primeFactor.insert(i);
		}
	}
	if (n != 1)
	{
		primeFactor.insert(n);
	}
	double ans = input;
	set<int>::iterator it = primeFactor.begin();
	while (it != primeFactor.end())
	{
		ans *= (1 - 1.0 / *it);
		++it;
	}
	cout << (int)ans << endl;
}

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

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for( int i=a; i<b; i++ )
#define REP(i,n) rep(i,0,n)
#define INF 1000000
using lli = long long int;
using ulli = unsigned long long int;
typedef pair<int, int> P;

struct edge{ int u, v; lli cost; };
struct DirectedGraph
{
  int vertex_num;
  int edge_num;
  vector<edge> edge_list;
  vector< vector<int> > adj_list;
	vector< vector<lli> > distance_matrix;
};


template <typename T>
vector<int> argsort(const vector<T> &v) {

  // initialize original index locations
  vector<int> idx(v.size());
  iota(idx.begin(), idx.end(), 0);

  // sort indexes based on comparing values in v
  sort(idx.begin(), idx.end(),
       [&v](int i1, int i2) {return v[i1] < v[i2];});

  return idx;
}

template<typename T>
void displayVector(vector<T> v)
{
	lli n = v.size();
	REP(i,n){
		cout << v[i] << " " ;
	}
	cout << endl;
}

int main(){
  int n; cin >> n;
  vector<int> a(n);
  REP(i, n){ cin >> a[i]; }
  int res = 0;
  REP(i,n){
    if(a[i]%2 == 1 && i%2 == 0){ res++; }
  }
  cout << res << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <utility>
#include <math.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
using namespace std;

int main(void){
    int n,t,c,time,check;
    cin >> n >> t;
    vector<pair<int,int>> p(n);
    rep(i,n) {
        cin >> c >> time;
        p[i] = make_pair(c,time);
    }
    sort(p.begin(),p.end());
    check =0;
    rep(i,n) {
        if(p[i].second <= t) {
            cout << p[i].first << endl;
            check = 1;
            break;
        }
    }
    if(check == 0) cout << "TLE" << endl;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)

A = set(A)
MAX_A = 10 ** 6
X = [0] * (MAX_A + 1)
for a in A:
    for i in range(a, MAX_A + 1, a):
        X[i] += 1

ans = len([a for a in A if (X[a] == 1) and (C[a] == 1)])
print(ans)

Measured memory_bytes: 173212
double n,dp[333][333][333];
int a,cnt[4];
double dfs(i,j,k)
{
	if(i|j|k&&dp[i][j][k]==0)
	{
		dp[i][j][k]=(
			(i?i/n*(dfs(i-1,j,k)+n/(i+j+k)):0)+
			(j?j/n*(dfs(i+1,j-1,k)+n/(i+j+k)):0)+
			(k?k/n*(dfs(i,j+1,k-1)+n/(i+j+k)):0)
		)*n/(i+j+k);
	}
	return dp[i][j][k];
}
main()
{
	for(scanf("%lf",&n);~scanf("%d",&a);)cnt[a]++;
	printf("%.9f",dfs(cnt[1],cnt[2],cnt[3]));
}

Measured memory_bytes: 260224
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stdlib.h>
#include<sstream>


using namespace std;

int main(){
	int countS=0,countH=0,countC=0,countD=0;
	char s,h,c,d;
	//string w;
	int S_[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
	int H_[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
	int C_[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
	int D_[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
	vector<int> S,H,C,D;
	 int n;
	cin>>n;
	char m;
	int l;
	for(int i=0;i<n;++i){
		
		cin>>m;
		cin>>l;

		//w=m.substr(2);
		if(m=='S'){			//??\????????????????????????????????????????????????
			//s=m.substr(2);
			S.push_back(l);			//S???H???C???D??????????????????????????°????????\??????
			countS++;
		}else if(m=='H'){
			H.push_back(l);
			countH++;
		}else if(m=='C'){
			C.push_back(l);
			countC++;
		}else if(m=='D'){
			D.push_back(l);
			countD++;		
		}

	}
	sort(S.begin(),S.end());			//?????????????????????
	sort(H.begin(),H.end());
	sort(C.begin(),C.end());
	sort(D.begin(),D.end());

	if(S.size()!=13)					//S_[13]??¨????´???°???????????????????????????
		for(int i=countS;i<=13;++i){	//S[]???????????\??????
			S.push_back(0);
		}
	if(H.size()!=13)
		for(int i=countH;i<=13;++i){
			H.push_back(0);
		}
	if(C.size()!=13)
		for(int i=countC;i<=13;++i){
			C.push_back(0);
		}
	if(D.size()!=13)
		for(int i=countD;i<=13;++i){
			D.push_back(0);
		}
		bool flagS=false;
		bool flagH=false;
		bool flagC=false;
		bool flagD=false;
	//for(int i=0;i<13;++i){
	//	for(int j=0;j<13;++j){
	//		if(S_[i] == S[j])		//S_[]??¨S[]???????´??????????????????°
	//			flagS=true;			//S_?????????????????\????????????????????????
	//			break;				//?????£?????¨???????????¨
	//	}
	//	for(int j=0;j<13;++j){		//??§???S_????????¨S?????????????´????
	//		if(H_[i] == H[j])		//???????????§?????????
	//			flagH=true;			//??????????????°????????§?????????
	//			break;
	//	}
	//	for(int j=0;j<13;++j){
	//		if(C_[i] == C[j])
	//			flagC=true;
	//			break;
	//	}
	//	for(int j=0;j<13;++j){
	//		if(D_[i] == D[j])
	//			flagD=true;
	//			break;
	//	}
	//	
	//	if(flagS==false)			//????¶???????????????????????????????
	//		cout<<"S "<<S_[i]<<endl;
	//		
	//	if(flagH==false)
	//		cout<<"H "<<H_[i]<<endl;
	//		
	//	if(flagC==false)
	//		cout<<"C "<<C_[i]<<endl;
	//	
	//	if(flagD==false)
	//		cout<<"D "<<D_[i]<<endl;
	//
	//	flagS=false;
	//	flagH=false;
	//	flagC=false;
	//	flagD=false;
	//
	//} 3 4 8
		for(int i=0;i<13;++i){
			flagS=false;
			for(int j=0;j<13;++j){
				if(S_[i] == S[j]){	
					flagS=true;		
					break;			
				}
			}
			if(flagS==false)			
				cout<<"S "<<S_[i]<<endl;
			
		}
		for(int i=0;i<13;++i){
			flagH=false;
			for(int j=0;j<13;++j){	
				if(H_[i] == H[j]){
					flagH=true;		
					break;
				}
			}
			if(flagH==false)
				cout<<"H "<<H_[i]<<endl;
			
		}
		for(int i=0;i<13;++i){
			flagC=false;
			for(int j=0;j<13;++j){
				if(C_[i] == C[j]){
					flagC=true;
					break;
				}
			}
			if(flagC==false)
				cout<<"C "<<C_[i]<<endl;
			
		}
		for(int i=0;i<13;++i){
			flagD=false;
			for(int j=0;j<13;++j){
				if(D_[i] == D[j]){
					flagD=true;
					break;
				}
			}
			if(flagD==false)
				cout<<"D "<<D_[i]<<endl;
			
		}
		
	return 0;
}
	

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

int main(){
  int n, tmp;
  long long k;
  long long count = 0;
  long long count2 = 0;
  // long long ura = 0;
  vector<int> hoge;
  cin >> n >> k;
  for (int i = 0; i < n; i++){
    cin >> tmp;
    hoge.push_back(tmp);
  }
  // 個別のAでの転置数
  for (int i = 0; i < hoge.size(); i++){
    for (int v = i+1; v < hoge.size(); v++){
      if (hoge[i] > hoge[v]){
        count += 1;
      }
    }
  }
  // cout << count << "count" << endl;
  
  // 二つのAの間での転置数
  // vector <int> hoge2;
  // for (int i = 0; i < hoge.size(); i++){
  //   hoge2.push_back(hoge[i]);
  // }
  
  // for (int i = 0; i < hoge.size(); i++){
  //   hoge2.push_back(hoge[i]);
  // }
  // for (int i = 0; i < hoge2.size(); i++){
  //   cout << hoge2[i] << endl;
  // }
  for (int i = 0; i < hoge.size(); i++){
    for (int v = 0; v < hoge.size(); v++){
      if (hoge[i] > hoge[v]){
        count2 += 1;
      }
    }
  }
  
  

  // for (int i = 0; i < hoge2.size(); i++){
  //   for (int v = i+1; v < hoge2.size(); v++){
  //     if (hoge2[i] > hoge2[v]){
  //       count2 += 1;
  //     }
  //   }
  // }
  // cout << count2 << "count2" << endl;


  // cout << "count " << count << endl;
  // cout << "count2 " << count2 << endl;
  long long sum = 0;
  if (k > 1){
    long long r, x;
    k = k%1000000007;
    r = count*k%1000000007;
    // cout << "r " << r << endl;
    x = count2*((k*(k-1)/2)%1000000007);
    // cout << "x " << x << endl;
    sum = (r + x);
    cout << sum%1000000007 << endl;
  }else{
    cout << count%1000000007 << endl;
  }
  
  // for(int i = 0; i < n; i++){
  //   if (i == n - 1){
  //     // if (hoge[i] > hoge[0]){
  //     //   count += 1;
  //     // }
  //     for (int v = 0; v < n - 1; v++){
  //       if (hoge[i] > hoge[v]){
  //         ura += 1;
  //       }
  //     }
  //   }else{
  //     for (int v = i+1; v < n; v++){
  //       if (hoge[i] > hoge[v]){
  //         count += 1;
  //       }
  //     }
  //   }
    
  //   // if (i == n - 1){
  //   //   if (hoge[i] > hoge[0]){
  //   //     count += 1;
  //   //   }
  //   // }else{
  //   //   if (hoge[i] > hoge[i + 1]){
  //   //     count += 1;
  //   //   }
  //   // }
  // }

  // long long sum = 0;
  // for (long long i = 1; i <= k; i++){
  //   sum += i;
  //   sum %= 1000000007;
  // }
  // long long count2;
  // if (k > 1){
  //   cout << count << " " << ura << " " << sum << endl;
  //   cout << ((count%1000000007) * (sum%1000000007)) +((ura%1000000007) * ((sum - 1)%1000000007))  << endl;
  // }else{
  //   cout << ((count) % ((10*10*10*10*10*10*10*10*10) + 7)) * ((sum) % ((10*10*10*10*10*10*10*10*10) + 7)) << endl;
  // }
  
  // cout << count << " " << ura << " " << sum << " " << count2 << endl;
  // cout << count << endl;
  // cout << ((count) % ((10*10*10*10*10*10*10*10*10) + 7)) * ((sum) % ((10*10*10*10*10*10*10*10*10) + 7)) << endl;
}

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

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N, M;
int A[311][311];
int C[311];
int iter[311];
bool ban[311];

void MAIN() {
    scanf("%d%d", &N, &M);
    REP (i, N) REP (j, M) scanf("%d", &A[i][j]), A[i][j]--;

    int ans = N;
    while (1) {
	memset(C, 0, sizeof C);
	REP (i, N) {
	    while (iter[i] < M && ban[A[i][iter[i]]]) iter[i]++;
	    if (iter[i] >= M) goto END;
	    C[A[i][iter[i]]]++;
	}

	int k = max_element(C, C+M) - C;
	amin(ans, C[k]);
	ban[k] = true;
    }
END:;
    printf("%d\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 640
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    int n,a,b;
    scanf("%d%d%d", &n, &a, &b);
    vector<ll> h(n);
    int i;
    for(i=0; i<n; i++) {
        scanf("%lld", &h[i]);
    }

    int c=a-b;
    ll l=0, r=INF;
    while(r-l>1) {
        ll m=(l+r)/2;
        ll cnt=0;
        for(i=0; i<n; i++) {
            ll tmp=h[i]-m*b;
            if(tmp>0) cnt+=(tmp-1+c)/c;
        }
        if(cnt<=m) {
            r=m;
        }
        else {
            l=m;
        }
    }
    printf("%lld\n", r);

    return 0;
}



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

using namespace std;

#define debug(x,y) cout<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define watch(x) cout<<(#x)<<" is " << (x) << endl
#define fast ios_base::sync_with_stdio(false)
#define fie(i,a,b) for(i=a;i<b;i++)
#define MOD 1000000007
#define mod 998244353
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ll long long
#define lld long long int
#define ALL(x) (x).begin(),(x).end()

typedef vector<lld> vi;
typedef vector<vector<lld>> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<pair<lld, lld>> vpi;
typedef long long LL;


int main() {
	fast;
	cin.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	lld n, i, j, k;
	cin >> n;
	lld sum = 0;
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= n; j++) {
			for (k = 1; k <= n; k++) {
				sum += __gcd(i, __gcd(j, k));
			}
		}
	}
	cout << sum << endl;
}






Measured memory_bytes: 3652
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Collections;
import java.util.Comparator;
import java.util.NoSuchElementException;
import java.util.PrimitiveIterator.OfInt;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	static final Scanner s=new Scanner(System.in);
	public static void main(String[]__){
		ArrayList<Integer> primes=new ArrayList<>();
		new PrimeIterator(114514).forEach(primes::add);
		while(true){
			int n=s.nextInt(),p=s.nextInt();
			if(n+p==-2)return;
			ArrayList<Integer> twoPrimesSums=new ArrayList<>();
			int index=Collections.binarySearch(primes,n);
			index=index<0?~index:index+1;
			for(int i=0;i<=p;i++)
				for(int j=i;j<=p;j++)
					twoPrimesSums.add(primes.get(index+i)+primes.get(index+j));
			twoPrimesSums.sort(Comparator.naturalOrder());
			//System.out.println(twoPrimesSums);
			System.out.println(twoPrimesSums.get(p-1));
		}
	}
}
class PrimeIterator implements Iterable<Integer>,OfInt{
	private BitSet	bs;
	private int		next,lim;
	public PrimeIterator(int limit){
		lim=limit;
		bs=new BitSet(lim+1);
		next=lim<2?-1:2;
	}
	@Override
	public boolean hasNext(){
		return next>0;
	}
	@Override
	public int nextInt(){
		if(!hasNext()) throw new NoSuchElementException();
		int r=next;
		if(1L*r*r<=lim)
			IntStream.iterate(r*r,i->i+r).limit(lim/r-r+1).forEach(bs::set);
		if((next=bs.nextClearBit(r+1))>lim) next=-1;
		return r;
	}
	@Override
	public OfInt iterator(){
		return this;
	}
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  string s;
  cin >> s;
  int n = s.size();
  int ans = n;
  for (int i = 0; i < n - 1; ++i) {
    if (s[i] != s[i + 1]) {
      ans = min(ans, max(i + 1, n - 1 - (i + 1) + 1));
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 512
#include<cctype>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
using namespace std;int n,m,f[100010],x,y,now;
inline int find(int x){return x==f[x]?x:f[x]=find(f[x]);}
inline LL read()
{
	char c;LL d=1,f=0;
	while(c=getchar(),!isdigit(c)) if(c=='-') d=-1;f=(f<<3)+(f<<1)+c-48;
	while(c=getchar(),isdigit(c)) f=(f<<3)+(f<<1)+c-48;
	return d*f;
}
signed main()
{
	n=read();m=read();
	for(register int i=1;i<=n;i++) f[i]=i;
	for(register int i=1;i<=m;i++) 
	{
		x=read();y=read();
		x=find(x);y=find(y);
		if(x==y) continue;
		f[y]=x;now++;
	}
	printf("%d",n-1-now);
}

Measured memory_bytes: 1984
def main():
    n = int(input())
    p = input().split()
    frag = 0
    for i in range(1, len(p)-1):
        a = []
        a.append(int(p[i-1]))
        a.append(int(p[i]))
        a.append(int(p[i+1]))
        if max(a) == a[1]:
            continue
        elif min(a) == a[1]:
            continue
        else:
            frag += 1
    print(frag)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064