akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 200500000000000000
#define MOD 1000000007
#define N 100005
#define M 1000005
#define LOG 18
#define KOK 4000000
using namespace std;

int x,y,z,n,a;
ll b[N],c[N];
ll ans,pre[N],suf[N];
priority_queue<ll> q;
vector<int> ind;

void up(ll val) {

	if(sz(q)<y) {

		q.push(-val);

		ans+=val;

	}
	else {

		if(q.top()+val>0) {

			ans+=q.top()+val;

			q.pop();

			q.push(-val);

		}

	}

}

int main() {

	//freopen("input.txt","r",stdin);	

	scanf("%d %d %d",&x,&y,&z);

	n=x+y+z;

	ll res=0;

	for(int i=1;i<=n;i++) {

		scanf("%d %lld %lld",&a,&b[i],&c[i]);

		res+=a;

		b[i]-=a;
		c[i]-=a;

		ind.pb(i);

	}

	sort(all(ind),[](int x,int y) {

		if(b[x]-c[x]==b[y]-c[y]) return b[x]>b[y];

		return b[x]-c[x]>b[y]-c[y];

	});

	ans=0;

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

		up(b[ind[i]]);

		pre[i+1]=ans;

	}

	while(sz(q)) q.pop();

	ans=0;

	swap(y,z);

	for(int i=n-1;i>=0;i--) {

		up(c[ind[i]]);

		suf[i+1]=ans;

	}

	ans=-inf;

	swap(y,z);

	for(int i=y;i<=n-z;i++) {

		umax(ans,pre[i]+suf[i+1]);

	}

	printf("%lld",ans+res);

}



Measured memory_bytes: 4596
N, M = gets.strip.split.map(&:to_i)
votes = gets.split.map(&:to_i)
total = votes.reduce(:+)
result = 0

votes.each do |vote|
  result += 1 if total.to_f * ( 1.to_f / (4.to_f * M.to_f) ) <= vote
end
puts result >= M ? 'Yes' : 'No'

Measured memory_bytes: 1788
#include <iostream>
#include <map>

int main()
{
  int x,y;
  std::cin >> x >> y;

  std::map< int, int > mg;  
  
  mg[1] = 1;
  mg[2] = 2;
  mg[3] = 1;
  mg[4] = 3;
  mg[5] = 1;
  mg[6] = 3;
  mg[7] = 1;
  mg[8] = 1;
  mg[9] = 3;
  mg[10] = 1;
  mg[11] = 3;
  mg[12] = 1;
  
  if (mg[x] == mg[y]) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  
  return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N; cin >> N;
	vector<LL> a(N);
	repp(i,0,N) cin >> a[i];
	vector<vector<LL>> dp(N,vector<LL>(N,0));
	repp(i,0,N) dp[i][i] = a[i];
	repp(d,1,N) repp(i,0,N-d){
		int j = i+d;
		if(d&1){
			dp[i][j] = min(dp[i+1][j]-a[i],dp[i][j-1]-a[j]);
		} else {
			dp[i][j] = max(dp[i+1][j]+a[i],dp[i][j-1]+a[j]);
		}
	}
	cout << dp[0][N-1]*(N%2==0?-1:1) << endl;
	return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <stack>
#include <vector>
#include <utility>
using namespace std;

int main() {
  stack<int> S1;
  stack<pair<int, int>> S2;
  int x {0}, tmp_area {0}, total_area {0};

  char c;
  while (cin >> c) {
    tmp_area = 0;
    if (c == '\\') {
      S1.push(x);
    } else if (c == '/' && !S1.empty()) {
      int matching_x = S1.top(); S1.pop();
      tmp_area += x - matching_x;
      total_area += x - matching_x;

      while (!S2.empty()) {
        auto prev_pond = S2.top();
        if (prev_pond.first > matching_x) {
          S2.pop();
          tmp_area += prev_pond.second;
        } else {
          break;
        }
      }
      S2.push(make_pair(x, tmp_area));
    }
    x++;
    if (c == 'q') break;
  }

  vector<int> A;

  cout << total_area << endl;
  cout << S2.size();

  while (!S2.empty()) {
    A.push_back(S2.top().second);
    S2.pop();
  }

  for (int i = A.size() - 1; i >= 0; i--) {
    cout << " " << A.at(i);
  }
  cout << endl;
}



Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;cin>>n>>m;
    int L[100000],R[100000];
    for (int i = 0; i < m; i++)
    {
        /* code */
        cin>>L[i]>>R[i];
    }
    sort(L,L+m);
    sort(R,R+m);
    if (R[0]-L[m-1]<0)
    {
        /* code */
        cout<<'0'<<endl;
    }
    else
    {
        cout<<R[0]-L[m-1]+1<<endl;
    }
    
    
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    int ans = 0;
    cin >> s;
    for(int i = 0;i < s.size()/2;i++){
        if(s[i] != s[s.size()-1-i])ans++;
    }
    cout << ans<< endl;
}


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

int main() {
        int N, h;
        string S, K;
        cin >> N >> S;
        vector<int> cnt(N, 0);

        rep(n, N) {
                cin >> K;
                for (int k = 0; k <= K.size()-S.size(); k++) {
                        if (K[k] == S[0]) {
                        //      cout << endl << "k = " << k << endl;
                                for (int j = 1; K.size() > k+(j*(S.size()-1)) ;j++) {
                                //      cout << "j = " << j << endl;
                                        for (h = 0; h < S.size(); h++) {
                                        //      cout << "k = " << K.at(k+h*j) << endl;
                                                if (K.at(k+h*j) != S.at(h)) {
                                                        break;
                                                }
                                        }
                                        if (h == S.size())      cnt[n] = 1;
                                //      cout << endl << "h = " << h << endl;
                                }
                        }
                }
        }
        cout << accumulate(cnt.begin(), cnt.end(), 0) << endl;

        return 0;
}



Measured memory_bytes: 3140
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define inf 0x3f3f3f3f
using namespace std;

const ll mod = 1e9+7;
const int maxn = 100050;

struct Lucas{
    ll ff[maxn+5];
    void init(){
        ff[0]=1;
        FOR(i,1,maxn)ff[i]=(ff[i-1]*i)%mod;
    }
    ll gcd(ll a,ll b)
    {
        if(b==0)return a;
        else return gcd(b,a%b);
    }
    ll x,y;
    void Extended_gcd(ll a,ll b)
    {
        if(b==0)
        {
            x=1;
            y=0;
        }
        else
        {
            Extended_gcd(b,a%b);
            ll t=x;
            x=y;
            y=t-(a/b)*y;
        }
    }
    //计算不大的C(n,m)
    ll C(ll a,ll b)
    {
        if(b>a)return 0;
        b=(ff[a-b]*ff[b])%mod;
        a=ff[a];
        ll c=gcd(a,b);
        a/=c;b/=c;
        Extended_gcd(b,mod);
        x=(x+mod)%mod;
        x=(x*a)%mod;
        return x;
    }
    //Lucas定理
    ll Combination(ll n, ll m)
    {
        ll ans=1;
        ll a,b;
        while(m||n)
        {
            a=n%mod;
            b=m%mod;
            n/=mod;
            m/=mod;
            ans=(ans*C(a,b))%mod;
        }
        return ans;
    }
}ls;

int main(){
    int k,n;cin>>n>>k;
    ls.init();
    for(int i=1;i<=k;i++){
        ll res=ls.Combination(k-1,i-1);
        res=(res*ls.Combination(n-k+1,i))%mod;
        printf("%lld\n",res);
    }
}


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

int main(){
	ll N, h, n;
	scanf("%lld", &N);
	for(h = 1; h <= 3500; h++){
		for(n = 1; n <= 3500; n++){
			if(4 * h * n - N * n - N * h == 0) continue;
			ll w = (N * h * n) / (4 * h * n - N * n - N * h);
			if((N * h * n) % (4 * h * n - N * n - N * h) == 0 && w > 0){
				printf("%lld %lld %lld\n", h, n, w);
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	int N; cin >> N;
	string S, T;
	cin >> S >> T;
	int j = 0, k = 0; 
	for (int i = 0; i < 2 * N; i++) {
		if (i % 2 == 0) {
			cout << S.at(j);
			j++;
		}
		else {
			cout << T.at(k);
			k++;
		}
	}
	cout << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = {}
for a in A:
    if a not in B:
        B[a] = 0
    B[a] += 1

# print(B)
C = [(b, B[b]) for b in B]
C.sort(reverse=True, key=lambda x: x[0])
# print(C)

ans = []
for c in C:
    if len(ans) == 0 and c[1] >= 4:
        print(c[0]**2)
        exit()
    if c[1] >= 2:
        ans.append(c)
    if len(ans) >= 2:
        print(ans[0][0] * ans[1][0])
        exit()
print(0)


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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

vector<ll> f;

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

  f.resize(n + 1, 2);
  f.at(1) = 1;
  for (long long i = 2; i <= n; i++) {
    for (long long j = 2; i * j <= n; j++) {
      f.at(i * j) += 1;
    }
  }

  ll ans = 0;
  for (long long i = 1; i < n + 1; i++) {
    ans += i * f.at(i);
  }
  cout << ans << endl;
}


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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define ins insert
#define er erase
#define bg begin()
#define ed end()
#define X first
#define Y second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define files(name) fin(name".in"); fout(name".out")
#define enter cout << "\n"
#define space cout << " "
#define endl "\n"
#define fi(st,n) for (int i = (st); i <= (n); ++i)
#define fj(st,n) for (int j = (st); j <= (n); ++j)
#define fk(st,n) for (int k = (st); k <= (n); ++k)
#define fq(st,n) for (int q = (st); q <= (n); ++q)
#define fw(st,n) for (int w = (st); w <= (n); ++w)
#define ff(i, st, n) for (int (i) = (st); (i) <= (n); ++(i))
#define ei(st,n) for (int i = (st); i >= (n); --i)
#define ej(st,n) for (int j = (st); j >= (n); --j)
#define ek(st,n) for (int k = (st); k >= (n); --k)
#define ef(i, st, n) for (int (i) = (st); (i) >= (n); --(i))
#define ri(st,n) for (int i = (st); i < (n); ++i)
#define rj(st,n) for (int j = (st); j < (n); ++j)
#define rk(st,n) for (int k = (st); k < (n); ++k)
#define rq(st,n) for (int q = (st); q < (n); ++q)
#define rf(i, st, n) for (int (i) = (st); (i) < (n); ++(i))
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define y1 dsklmlvmd

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int inf = (int)1e9;
const dbl eps = (dbl) 1e-8;
const int mod = (int) 1e9 + 7;
const int maxn = (int) 1e6 + 5;
//const dbl M_PI = (dbl)2 * (dbl)acos(0);

//cout<<fixed<<setprecision(10);
//srand(time(0));

ll n, m;

int main() {
//    fin("t.in");
    sync;
    cin >> n >> m;
    m /= 2;
    if (n <= m)
        cout << (n + m) / 2 << endl;
    else
        cout << m << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
	int a, b, c, d;
	cin >> a >> b;
	cin >> c >> d;
	int ans = 0;
	if (d == 1)
		ans = 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll M=1e9+7, p[8];
ll f(int x){
    if(x<1)return 1;
    return p[x];
}
int main() {
    ll dp[102][8];
    int h, w, k;
    cin>>h>>w>>k;
    dp[0][0]=1;
    for(int i=1;i<w;i++)dp[0][i]=0;
    for(int i=1;i<8;i++){
        p[i]=(1<<i);
        for(int j=0;j<(1<<i);j++){
            bool t=true;
            for(int u=0;u<i-1;u++){
                if(((j>>u)&1)==1&&((j>>(u+1))&1)==1)t=false;
            }
            if(!t)p[i]--;
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=0;j<w;j++){
            ll t=0;
            t+=(dp[i-1][j]*(f(j-1)*f(w-j-2)%M))%M;
            if(j>0)t+=(dp[i-1][j-1]*(f(j-2)*f(w-j-2)%M))%M;
            if(j<w-1)t+=(dp[i-1][j+1]*(f(j-1)*f(w-j-3)%M))%M;
            dp[i][j]=t%M;
        }
    }
    cout<<dp[h][k-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define rep(i,n) REP(i,0,n-1)
#define FORD(i,b,a) for(int i=b,_a=a;i>=_a;i--)
#define ford(i,n) FORD(i,n-1,0)
#define sqr(x) ((x)*(x))
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define add push_back
#define len(arr) arr.size()
#define print(x) cout<<(x)<<endl
using namespace std;

int a[105];


int main(){
	//freopen("1_004.txt","r",stdin);
	int n, sum = 0, res = 0;
	cin >> n;
	rep(i, n){
		cin >> a[i];
		sum += a[i];
	}
	
	int d = sum % n > n / 2 ? sum / n  + 1 : sum / n;
	rep(i, n) res += (a[i] - d) * (a[i] - d);
	print(res);
	
	return 0;
}


Measured memory_bytes: 256
A,B,K = map(int,input().split())
c = 0
S = []
if B - A <= K:
    for i in range(A,B+1):
        print(i)
    exit()
for i in range(A,B+1):
    if c == K:
        break
    print(i)
    S.append(i)
    c += 1
for i in range(B-K+1,B+1):
    if i not in S:        
        print(i)


Measured memory_bytes: 9068
mod = 10**9+7
MAX_N = 10**6

fact = [1]
fact_inv = [0]*(MAX_N+4)
for i in range(MAX_N+3):
    fact.append(fact[-1]*(i+1)%mod)

fact_inv[-1] = pow(fact[-1],mod-2,mod)
for i in range(MAX_N+2,-1,-1):
    fact_inv[i] = fact_inv[i+1]*(i+1)%mod


def mod_comb_k(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod
X,Y = map(int,input().split())
if (2*Y-X) % 3 != 0 or (2*X-Y) % 3  != 0 or 2*Y-X <0 or 2*X-Y<0:
    print(0)
else:
    A = int((2*Y-X)/3)
    B = int((2*X-Y)/3)
    print(mod_comb_k(A+B,A,mod))

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

vector<long long int> q;
long long int pre[100001];

long long int t[100001];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,Q;
	cin>>n>>Q;
	q.emplace_back(n);
	for(int i=1;i<=Q;i++){
		long long int x;
		cin>>x;
		while(!q.empty()&&x<=q.back())	q.pop_back();
		q.emplace_back(x);
	}
	int now=q.size()-1;
	t[now]=1;
	while(now>=0){
		long long int k=q[now];
		while(k>0){
			int x=lower_bound(q.begin(),q.end(),k)-q.begin();
			x--;
			if(x==-1)	break;
			t[x]+=k/q[x]*t[now];
			k%=q[x];
		}
		pre[1]+=t[now];pre[1+k]-=t[now];
		now--;
	}
	for(int i=1;i<=n;i++)
		pre[i]+=pre[i-1];
	for(int i=1;i<=n;i++)
		cout<<pre[i]<<'\n';
}


Measured memory_bytes: 4212
'use strict'
function Main(input) {
    let Nums = input.trim().split(' ').map(x => x*1);
  	// 2数の最大公約数gcdを求める式
  	let gcd = (a1,a2) => {
    	return a2 == 0 ? a1 : gcd(a2 , a1 % a2);
    }
    
    // 最大公約数を求める
  	let targetNum = gcd( Nums[0] , Nums[1]);
  
  	let answer = 1;
  
  	// 最大公約数を素因数分解
    for(let i = 2; i*i <=  targetNum; i++) {
        if(targetNum % i === 0) {
            answer++;
          	// 素因数が2乗以上の時を考慮した処理
          	while(targetNum % i === 0){
            	targetNum /= i;
            }
        }
    }
  
	if(targetNum !== 1){
    	answer++;
    }
      
  	// 回答の出力
   	console.log(answer);
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 10188
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
-- end of templete


main = getInt >>= flip replicateM getLine >>= mapM_ (putStrLn . intercalate "Hoshina" . splitOn "Hoshino")

Measured memory_bytes: 4168
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long int ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}
int main(){
  IOS;
  ll n,x,ans;cin>>n>>x;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  ans=Svec(v);
  if(v[0]>x) v[0]=x;
  rep(i,n-1){
    if(v[i]+v[i+1]>x){
      v[i+1]=x-v[i];
    }
  }
  cout<<ans-Svec(v)<<endl;
}

Measured memory_bytes: 1804
N,K = map(int,input().split())
d = []
A = []
kan = [0 for i in range(N)]


for i in range(K):
    d.append( int(input()))
    A.append(list(map(int,input().split())))

for i in range(K):
    syu  = A[i]
    for j in syu:
        kan[j-1] = -1


print(kan.count(0))

Measured memory_bytes: 9204
n,k=map(int,input().split())
a=[-1]+list(map(int,input().split()))

count=[0]*(n+1)
cnt=0
i=1
while count[i]==0:
    count[i]=cnt
    if cnt==k:
        print(i)
        exit()
    cnt+=1
    i=a[i]

if cnt==k:
    print(i)
    exit()



loop=cnt-count[i]
#print("loop",loop)
goal=(k-cnt)%loop
#print(loop,goal)
if goal==0:
    print(i)
else:    
    print(count.index(count[i]+goal))



Measured memory_bytes: 92860
N = gets.to_i
s = N.times.map { gets.to_i }
sum = s.inject(:+)
if sum % 10 != 0
  p sum
  exit
end
s = s.reject { |i| i % 10 == 0 }
parts = []
s.each do |i|
  parts += [i] + parts.map { |j| i+j }
  parts.uniq!
end
m = parts.sort.find { |i| i % 10 != 0 }
p m.nil? ? 0 : sum - m


Measured memory_bytes: 8444
import sys, itertools, collections, fractions
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))

a, b, c, d = lmi()
p = b//c - (a-1)//c
q = b//d - (a-1)//d
g = c * d // fractions.gcd(c,d)
u = b//g - (a-1)//g
# print(p,q,u,g)
print(b-a+1-p-q+u)


Measured memory_bytes: 5228
import sys
from decimal import Decimal

def main():
    for input_line in sys.stdin:
        x1 = int(input_line.split(' ')[0])
        y1 = int(input_line.split(' ')[1])
        p = int(input_line.split(' ')[2])
        x2 = int(input_line.split(' ')[3])
        y2 = int(input_line.split(' ')[4])
        q = int(input_line.split(' ')[5])
        multiplicand1, multiplicand2 = calculate1(x1, x2)
        after_y1, after_y2, after_p, after_q = calculate2(y1, y2, p, q, multiplicand1, multiplicand2)
        calculate3(after_y1, after_y2, after_p, after_q, x1, y1, p)
    
def calculate1(x1, x2):
    if (x1 >= 0 and x2 >= 0) or (x1 < 0 and x2 < 0):
        multiplicand1 = -x2
        multiplicand2 = x1
        return multiplicand1, multiplicand2
    else:
        multiplicand1 = abs(x2)
        multiplicand2 = abs(x1)
        return multiplicand1, multiplicand2
    
def calculate2(y1, y2, p, q, multiplicand1, multiplicand2):
    after_y1 = Decimal(y1 * multiplicand1)
    after_y2 = Decimal(y2 * multiplicand2)
    after_p = Decimal(p * multiplicand1)
    after_q = Decimal(q * multiplicand2)
    return after_y1, after_y2, after_p, after_q

def calculate3(after_y1, after_y2, after_p, after_q, x1, y1, p):
    y = Decimal(after_p + after_q) / Decimal(after_y1 + after_y2)
    y = round(y, 3)
    x = Decimal(p - y1 * y) / Decimal(x1)
    x = round(x, 3)
    print('%.3f %.3f' % (x, y))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 5912
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main(){

	double a, b, c;
	double s, l, h, rad;

	cin >> a >> b >> c ;

	rad = 3.14159265358979 * c / 180;

	s = a * b * sin(rad) / 2;
	l = a + b + sqrt(a*a + b*b - 2*a*b*cos(rad));
	h = s * 2 / a;


	printf("%.8lf\n" ,s);
	printf("%.8lf\n" ,l);
	printf("%.8lf\n" ,h);

 }

Measured memory_bytes: 1244
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
ll kaijo[2000000];
void init() {
	kaijo[0] = 1;
	for (ll i = 1;i < 2000000;i++)kaijo[i] = (kaijo[i - 1] * i) % N;
}


ll inv(ll x) {
	ll res = 1;
	ll k = N - 2;
	ll y = x;
	while (k) {
		if (k & 1)res = (res*y) % N;
		y = (y%N*y%N) % N;
		k /= 2;
	}
	return res;
}

ll Comb(ll n, ll k) {
	//if (n < 0 || k < 0 || (n - k) < 0)return 0;
	ll b = kaijo[n];
	ll c = kaijo[n - k];
	ll d = kaijo[k];
	ll cd = (c*d) % N;
	return ((b%N)*(inv(cd)) % N) % N;
}

int main(void){
    init();
    ll x,y,ans=0;
    cin>>x>>y;
    if((2*y-x)<0){
        cout<<0<<endl;
        return 0;
    }
    else{
        if(2*x-y<0){
            cout<<0<<endl;
            return 0;
        }
        else{
            if((2*y-x)%3!=0){
                cout<<0<<endl;
                return 0;
            }
            else{
                if((2*x-y)%3!=0){
                    cout<<0<<endl;
                    return 0;
                }
            }
        }
    }
    ll n=(2*x-y)/3;
    ll m=(2*y-x)/3;
    cout<<Comb(n+m,m)<<endl;
    return 0;
}


Measured memory_bytes: 15872
#!/usr/bin/env python3
import os
from sys import stdin, stdout
    
    
def solve(tc):
    s = stdin.readline().strip()
    t = stdin.readline().strip()

    ans = 0
    for i in range(len(t)):
        if s[i] != t[i]:
            ans += 1

    for i in range(1, len(s)-len(t)):
        cnt = 0
        for j in range(len(t)):
            if s[i+j] != t[j]:
                cnt += 1
        ans = min(ans, cnt)
    print(ans)



    
tcs = 1
tc = 1
while tc <= tcs:
    solve(tc)
    tc += 1

Measured memory_bytes: 72848
#include <algorithm>
#include <iostream>
#include <numeric>
#include <set>
#include <vector>
using namespace std;

int64_t gcd(int64_t a, int64_t b) {
  if (a < 0) return gcd(b, -a);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}

int64_t find_large_a(int64_t a, int64_t b, int64_t g) {
  if (g > b) return a;
  a = find_large_a(a, b, g << 1);
  if (a + g < b) return a + g;
  return a;
}

bool solve() {
  int64_t a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a < b) return false;
  if (d < b) return false;
  if (b <= c) return true;
  d %= b;

  // check whether there is k s.t. (a + d*k) % b > c
  // (max (a + dk) % b) > c
  int64_t g = gcd(d, b);
  // (a + g * k') % b > c
  a = find_large_a(a % b, b, g);
  return a <= c;

  // set<int64_t> s;
  // while (true) {
  //   if (s.count(a)) return true; s.insert(a);
  //   a %= b;
  //   if (a > c) return false;
  //   a += d;
  // }
  return false;
}

int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    if (solve()) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}


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

using namespace std;

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

    vector<vector<char> > arr(3, vector<char>(3));

    for(int i = 0; i < 3; ++i)
        for(int j = 0; j < 3; ++j)
            cin >> arr[i][j];

    string ans = "";

    for(int i = 0; i < 3; ++i)
        for(int j = 0; j < 3; ++j)
            if(i == j)
                ans += arr[i][j];

    cout << ans << '\n';
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	static long dp[][];

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		String str[] = br.readLine().split(" ");
		int a[] = new int[n];
		dp = new long[n + 1][n + 1];

		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(str[i]);
		}

		long s[] = new long[n];
		s[0] = a[0];

		for (int i = 0; i < n - 1; i++) {
			s[i + 1] = s[i] + a[i + 1];
		}
		for (int i = 0; i < dp.length; i++) {
			Arrays.fill(dp[i], -1);
		}
		System.out.println(solve(0, n - 1, s, a));
	}

	static long solve(int l, int r, long s[], int a[]) {
		if (l >= r)
			return 0;
		if (dp[l][r] != -1)
			return dp[l][r];
		long ans = Long.MAX_VALUE;
		for (int k = l; k < r; k++) {
			ans = Math.min(ans, solve(l, k, s, a) + solve(k + 1, r, s, a) + sum(l, r, a));
		}
		return dp[l][r] = ans;
	}

	static long sum(int i, int j, int arr[]) {
		long ans = 0;
		for (int k = i; k <= j; k++) {
			ans += arr[k];
		}
		return ans;
	}
}


Measured memory_bytes: 24488
#include <iostream>

using namespace std;

int bubblesort(int *arr, int n);

int main(void) {
    int n, scount;

    cin >> n;
    int *arr = new int[n];

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

    scount = bubblesort(arr, n);
    for (int i = 0; i < n - 1; i++) {
        cout << arr[i] << " ";
    }
    cout << arr[n - 1] << "\n";
    cout << scount << "\n";

    delete[] arr;

    return 0;
}

int bubblesort(int *arr, int n) {
    int flag = 1;
    int temp;
    int scount = 0;

    while (flag) {
        flag = 0;
        for (int i = (n - 1); i > 0; i--) {
            if (arr[i] < arr[i - 1]) {
                temp = arr[i];
                arr[i] = arr[i - 1];
                arr[i - 1] = temp;
                flag = 1;
                ++scount;
            }
        }
    }

    return scount;
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
int gcd1(int a, int b) 
{ 
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
   
    if (a == b) 
        return a; 
    if (a > b) 
        return gcd1(a-b, b); 
    return gcd1(a, b-a); 
} 
   
int main(){
  FIO;
  // ifstream cin("input");
  int n;
  cin>>n;
  int ans=0;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      for(int k=1;k<=n;k++){
        ans+= gcd1(gcd1(i,j),k);    
      }
    }  
  }
  cout<<ans<<endl;
  return 0;  
}

Measured memory_bytes: 3652
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

void solve(long long x){
    auto eratosthenes = []{
        constexpr int N = 2e6;
        bitset<N> not_prime(3);
        for(int i = 2; i < N; ++i)
            if(!not_prime[i])
                for(int j = 2 * i; j < N; j += i)
                    not_prime.set(j);
        return not_prime;
    };

    auto v = eratosthenes();
    for(int i = x;; ++i){
        if(!v[i]){
            cout << i << endl;
            return ;
        }
    }
}


signed main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main (){
	int n;
	long long int result = 0;
	scanf("%d", &n);
	
	for(int i = 1; i <= n; i++){
		if(i%3 != 0 && i%5 != 0){
			result += i;
		}
	}
	printf("%lld", result);
	return 0;
}

Measured memory_bytes: 1668
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();
            int X = in.nextInt();
            int[] A = new int[M];
            for (int i = 0; i < M; i++) {
                A[i] = in.nextInt();
            }

            int[] costs = new int[N + 1];
            for (int i = 0; i < M; i++) {
                costs[A[i]]++;
            }

            int min = (int) 1e9;
            {
                int cost = 0;
                for (int x = X; x <= N; x++) {
                    cost += costs[x];
                }
                min = Math.min(min, cost);
            }
            {
                int cost = 0;
                for (int x = X; x >= 0; x--) {
                    cost += costs[x];
                }
                min = Math.min(min, cost);
            }

            System.out.println(min);
        }
    }
}


Measured memory_bytes: 26784
#include <iostream>
using namespace std;
int main(void){
    
    // 変数：２つの数字 a, b を定義
    int a, b;
    
    // 変数：演算子 op を定義
    char op;
    
    //各変数を入力
    cin >> a >> op >> b;
    
    //演算子の判定
    while(op != '?'){
        switch (op){
            case '+':
            cout << a + b << endl;
            break;
            case '-':
            cout << a - b << endl;
            break;
            case '*':
            cout << a * b << endl;
            break;
            case '/':
            cout << a / b << endl;
            break;
        }
    //ループを繰り返しする為に各変数を入力     
    cin >> a >> op >> b;
        
    }
        
    return 0;
        
}



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

using namespace std;

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i < 10; i++)
    {
        for (int j = 1; j < 10; j++)
        {
            if (i * j == n)
            {
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 1000000005
#define MOD 1000000007
#define N 200005
#define M 27000
#define LOG 1000000
#define KOK 650
#define EPS 0.000000001
using namespace std;

int h,w,n,r,c;
int dp[N];
int f[N],inv[N];

int fe(int x,int y) {

	if(y==0) return 1;

	int res=fe(x,y>>1);

	res=1ll*res*res%MOD;

	if(y&1) res=1ll*res*x%MOD;

	return res;

}

int C(int x,int y) {

	if(y>x || x<0 || y<0) return 0;

	return 1ll*f[x]*(1ll*inv[y]*inv[x-y]%MOD)%MOD;

}

void pre() {

	int mx=h+w;

	f[0]=inv[0]=1;

	for(int i=1;i<=mx;i++) {

		f[i]=1ll*f[i-1]*i%MOD;

		inv[i]=fe(f[i],MOD-2);

	}

}

int main() {

	//freopen("input.txt","r",stdin);	

	vector<ii> v;

	scanf("%d %d %d",&h,&w,&n);

	for(int i=1;i<=n;i++) {

		scanf("%d %d",&r,&c);

		v.pb({r,c});

	}

	++n;

	v.pb({h,w});

	sort(all(v));

	pre();

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

		auto x=v[i];

		dp[i]=C(x.st+x.nd-2,x.st-1);

		for(int j=0;j<i;j++) {

			auto y=v[j];

			dp[i]=(1ll*dp[i]-1ll*dp[j]*C(x.st-y.st+x.nd-y.nd,x.st-y.st)%MOD+MOD)%MOD; 

		}

	}

	printf("%d",dp[n-1]);

}


Measured memory_bytes: 2048
#include <stdio.h>
#include <ctype.h>

int main(){
    int c;
    
    while((c = getchar()) != EOF){
        if(isupper(c)){
            putchar(tolower(c));
        }
        
        else if(islower(c)){
            putchar(toupper(c));
        }
        
        else {
            putchar(c);
        }
    }
    
    return 0;
}

Measured memory_bytes: 524
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int sum = 0;
			String x = sc.next();
			if (x.equals("0"))
				break;
			for (int i = 0; i < x.length(); i++) {
				char ch = x.charAt(i);
				sum += Character.getNumericValue(ch);
			}
			System.out.println(sum);
		}
	}

}



Measured memory_bytes: 26384
#include<bits/stdc++.h>
using namespace std;
#define free diofkhedo
string s;
bool free[26];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>s;
	memset(free,true,sizeof(free));
	for(int i=0;i<s.size();i++)
		free[s[i]-'a']=false;
	if(s.size()!=26){
		for(int i=0;i<26;i++){
			if(free[i]){
				cout<<s<<(char)(i+'a')<<endl;
				return 0;
			}
		}
	}
	int pos=s.size()-1;
	while(pos>=0){
		pos--;
		free[s[pos+1]-'a']=true;
		for(int i=s[pos+1]+1-'a';i<26;i++){
			if(free[i]){
				cout<<s.substr(0,pos+1)<<(char)(i+'a')<<endl;
				return 0;
			}
		}
	}
	cout<<-1<<endl;
	return 0;
}


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

using namespace std;

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

  vector<int> h(n);

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

  //1が連続するところのカウント
  //区間分割

  int res = 0;

  while(true){
    if(*max_element(h.begin(),h.end()) == 0) break;
    int i = 0;
    while(i < n){
      if(h[i] == 0)i++;
      else{
        res++;
        while(i < n && h[i] > 0){
          --h[i]; //高さを1引く
          i++;
        }
      }
    }

  }
  cout <<  res << endl;

}


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

int main() {
	int n, t, u;
	cin >> n >> t >> u;
	int s = t;
	for (int i = 1; i < n; i++) {
		int a;
		cin >> a;
		s += min(t, a - u);
		u = a;
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N;cin>>N;
  VEC<string>S(N);
  map<string, int>a;
  int ma=0;
  REP(i,0,N){
    cin>>S[i];
    a[S[i]]++;
    ma=max(ma, a[S[i]]);
  }
  for(auto v:a){
    if(v.second==ma){
      cout<<v.first<<endl;
    }
  }

  return 0;
}


Measured memory_bytes: 26880
#include<iostream>
using namespace std;
int main(){
	int W,H;
	for(;;){
	cin>>W>>H;
	if(W==0&&H==0){
		break;
	}
	for(int i=0;i<W;i++){
		for(int j=0;j<H;j++){
			cout<<"#";
		}
		cout<<endl;
	}
		cout<<endl;
	}

	return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <ctime>
#include <functional>
#include <iomanip>
using namespace std;

#define LL long long
const int maxn = 100;
struct Node {
    int x, y;
    Node() {}
    Node(int xx, int yy) {
        x = xx;
        y = yy;
    }
};
int n, m, sum;
char str[maxn][maxn];
int step[maxn][maxn];
queue<Node> que;
const int dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

bool in(int x, int y) {
    return x >= 0 && x < n && y >= 0 && y < m;
}

int bfs() {
//    if(str[0][0] == '#' || str[n - 1][m - 1] == '#') {
//        return -1;
//    }
    memset(step, -1, sizeof(step));
    while(!que.empty()) {
        que.pop();
    }
    step[0][0] = 0;
    que.push(Node(0, 0));
    while(!que.empty()) {
        Node tmp = que.front();
        que.pop();
        for(int i = 0; i < 4; ++i) {
            int xx = tmp.x + dir[i][0];
            int yy = tmp.y + dir[i][1];
            if(in(xx, yy) && str[xx][yy] != '#' && step[xx][yy] == -1) {
                step[xx][yy] = step[tmp.x][tmp.y] + 1;
                que.push(Node(xx, yy));
            }
        }
    }
    int ret = step[n - 1][m - 1];
    if(ret != -1) {
        ret = sum - ret - 1;
    }
    return ret;
}

int main() {
    #ifdef LOCAL
    freopen("test.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    #endif // LOCAL
    ios::sync_with_stdio(false);

    while(scanf("%d%d", &n, &m) != EOF) {
        sum = 0;
        for(int i = 0; i < n; ++i) {
            scanf("%s", str[i]);
            for(int j = 0; j < m; ++j) {
                if(str[i][j] == '.') {
                    ++sum;
                }
            }
        }
        printf("%d\n", bfs());
    }

    return 0;
}


Measured memory_bytes: 384
#include <iostream>

int main()
{
  int A, B;
  int cnt = 0;

  std::cin >> A;
  std::cin >> B;

  if (B > 1)
  {
    B = B - A;
    cnt++;
    if (B > 0)
    {
      cnt += B / (A - 1);
      if (B % (A - 1) != 0)
      {
        cnt++;
      }
    }
  }

  std::cout << cnt;

  return 0;
}

Measured memory_bytes: 256
n = int(input())
ixy = [[i] + list(map(int, input().split())) for i in range(n)]

ixy.sort(key=lambda x: x[1])

roads = []
for i in range(n - 1):
    i1, x1, y1 = ixy[i]
    i2, x2, y2 = ixy[i + 1]
    roads.append((x2 - x1, i1, i2))

ixy.sort(key=lambda x: x[2])
for i in range(n - 1):
    i1, x1, y1 = ixy[i]
    i2, x2, y2 = ixy[i + 1]
    roads.append((y2 - y1, i1, i2))

p = [i for i in range(n)]


def f_p(x):
    if x == p[x]:
        return x
    p[x] = f_p(p[x])
    return p[x]


roads.sort()
total_c = 0
for c, i1, i2 in roads:
    p1 = f_p(i1)
    p2 = f_p(i2)
    if p1 != p2:
        p[p1] = p2
        total_c += c

print(total_c)


Measured memory_bytes: 52076
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mx 500010
#define pb push_back

ll arr[mx];
ll brr[mx];
ll mk=1e9+7;

int main()
{
ios_base::sync_with_stdio(false);

ll n;
cin>>n;
string s;
cin>>s;
map<char,ll>m;
for(ll i=0;i<n;i++)
{
    char a=s[i];
    m[a]++;
}
ll ans=1;
for(auto it=m.begin();it!=m.end();it++)
{
    ans*=(it->second+1)%mk;
    ans=ans%mk;
;
}
cout<<ans-1<<endl;
//cout << fixed << showpoint;
//cout << setprecision(12);
}


Measured memory_bytes: 512
/*
                                Shahriar Hasan
                          "University of Chittagong"
                                CSE 18 Batch
*/
#include <bits/stdc++.h>
using namespace std;

#define nln puts("")                    // newline
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))    //max/min from 3 input

#define even(x) x%2==0                  //even odd
#define odd(x) x%2!=0

#define PI acos(-1)                     // constant + math
#define lcm(a,b) (a*b/gcd(a,b))

#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)          // algorithm habijabi
#define srt(a,n) sort(a,a+n)
#define srtt sort(a.begin(),a.end())
#define cnt(x) count(a,a+n,x)
#define F first
#define S second
#define all(p) p.begin(),p.end()

#define for0(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(ull i=1;i<=n;i++)         //loop
#define forr(i,n) for(int i=n-1;i>=0;i--)
#define mem(a,b) memset(a, b, sizeof(a))
#define fill(a,b) fill(a.begin(),a.end(),b)
#define fill_n(a,n,b) fill_n(a.begin(),n,b)
                        //input
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define print0(a) for(int i=0;i<a.size();i++)cout<<a[i]<<endl;
#define print1(a) for(int i=1;i<=a.size();i++)cout<<a[i]<<endl;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef set<int> si;
typedef vector<ll> vl;
typedef pair<int,int> pii;           // datatype
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

///////////////////////////////////////////////////////////
//long long： -9223372036854775808~9223372036854775807
//int： -2147483648~2147483647
//double： -1.7*10^-308~1.7*10^308，15~16位有效数字
//long double： -1.2*10^-4932~1.2*10^4932，18~19位有效数字
///////////////////////////////////////////////////////////


int gcd(int a, int b)               //gcd
{if(b==0)return a;return gcd(b,a%b);}

ull power(int a,int n)              // to the power
{ll multi=1;for(int i=1;i<=n;i++)multi=multi*a; return multi;}
bool isPrime(ull n)                // prime number check
{if(n==2||n==3)return true;else{ull m=power(2,n-1);if(m%n==1 && n%2==1)return true;else return false;}}
vi getdiv(ll n){vi div;int i;
    for(i=1;i*i<n;i++)
    {if(n%i==0){div.pb(i);div.pb(n/i);}}if(i*i==n)div.pb(i);            // divisor nirnoy kora
    //sort(div.begin(),div.end());
    return div;}
bool isPalindrome(int n){int num=n,sum=0,mod;
    while(n){mod=n%10;n=n/10;sum=sum*10+mod;}
    if(sum==num)return true;else return false;}
////////////////////////////////////////////////////end///////////////////////////////////////////////////////////
////////////////////////////////////////////////////end///////////////////////////////////////////////////////////

int main()
{
    string s;
    cin >> s;
    if(s=="SUN")cout<<7<< endl;
    else if(s=="MON")cout<<6<< endl;
    else if(s=="TUE")cout<<5<< endl;
    else if(s=="WED")cout<<4<< endl;
    else if(s=="THU")cout<<3<< endl;
    else if(s=="FRI")cout<<2<< endl;
    else if(s=="SAT")cout<<1<< endl;

    return 0;
}



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

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

#define max_n 100

int N;
string S;

int main() {

	cin >> N >> S;

	if(N%2==1)
	{
		cout << "No" << endl;
		return 0;
	}

	rep(i, (N / 2)) {
		if(S.at(i)!=S.at(i+(N/2)))
		{
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;	
}

Measured memory_bytes: 256
local N = io.read("n")
local A = {}
for i=1,N do
  A[i] = io.read("n")
end
for i=1,N do
  if A[i] % 2 == 0 then
    if A[i] % 3 == 0 or A[i] % 5 == 0 then
      
    else
      print("DENIED")
      return
    end
  end
end
print("APPROVED")

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {

  int N;
  string S;
  cin >> N;
  cin >> S;
  vector<int> v;
  vector<int> east_accum;
  vector<int> west_accum;

  // 0 -> N (W)
  west_accum.push_back(0);
  int accum_w = 0;
  for(int i=0;i<N-1;i++){
    string person_direction = S.substr(i,1);
    if(person_direction == string("W")){
      accum_w++;
    }
    west_accum.push_back(accum_w);
  }

  // N -> 0 (E)
  east_accum.push_back(0);
  int accum_e = 0;
  // cout << east_accum[0] << endl;
  for(int i=N-1;i>0;i--){
    string person_direction = S.substr(i,1);
    if(person_direction == string("E")){
      accum_e++;
    }
    east_accum.push_back(accum_e);
  }
  reverse(east_accum.begin(), east_accum.end());

  int min_count = 10000000;
  int count;
  for(int i=0;i<N;i++){
    count = west_accum[i] + east_accum[i];
    if (min_count > count){
      min_count = count;
    }
  }

  cout << min_count << endl; // answer

  // cout << "west" << endl;
  // for(int i=0;i<N;i++){
  //   cout << west_accum[i] << " ";
  // }
  // cout << endl;
  // cout << "east" << endl;
  // for(int i=0;i<N;i++){
  //   cout << east_accum[i] << " ";
  // }
  // cout << endl;

  return 0;
}

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

int main()
{
    int n, q;
    cin >> n;
    ll s = 0;
    map<int, int> A;
    rep(i, n)
    {
        int a;
        cin >> a;
        A[a]++;
        s += a;
    }

    cin >> q;
    vector<pair<int, int>> BC;
    rep(i, q)
    {
        int b, c;
        cin >> b >> c;
        BC.emplace_back(b, c);
    }

    rep(i, q)
    {
        ll b = BC[i].first;
        ll c = BC[i].second;
        A[c] += A[b];
        s = s - b * A[b] + c * A[b];
        cout << s << endl;
        A[b]=0;
    }
}

Measured memory_bytes: 8352
#include <bits/stdc++.h>
int main(void)
{
  int n, t[2] = {}, x[2] = {}, y[2] = {};
  std::cin >> n;
  for(int i = 0; i != n; i++){
    std::cin >> t[1] >> x[1] >> y[1];
    int dr = std::abs(x[1] - x[0]) + std::abs(y[1] - y[0]), dt = t[1] - t[0];
    if(dr % 2 != dt % 2 || dr > dt){
      std::cout << "No" << std::endl;
      return 0;
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define int long long
using namespace std;
signed main()
{
  int a, b, k;
  cin >> a >> b >> k;
  if(a>0){
    if(a-k>0){
      a -= k;
    }else{
      k -= a;
      a = 0;
      if(b-k>0){
        b -= k;
      }else{
        b = 0;
      }
    }
  }else if(b>0){
    if(b-k>0){
      b -= k;
    }else{
      b = 0;
    }
  }
  cout << a << " " << b << endl;
  return 0;
}

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


int main(){
  int a,b;scanf("%d%d",&a,&b);
  double ret=0;
  for(int i=1;i<=a;i++){
double tmp=1.0/a; int now=i; while(now<b){
now*=2;
tmp/=2; }
ret+=tmp; }
printf("%.12f\n",ret); }

Measured memory_bytes: 3812
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

def Partition(A,p,r):
    x = A[r]
    i = p - 1
    for j in range(p,r):
        if A[j] <= x:
            i = i + 1
            tmp = A[i]
            A[i] = A[j]
            A[j] = tmp
    tmp2 = A[i+1]
    A[i+1] = A[r]
    A[r] = tmp2
    return i + 1
if __name__ == "__main__":
    n = int(input())
    A = list(map(int,input().split()))
    q = Partition(A,0,n-1)
    for i in range(n):
        if i:
            print(" ",end = "")
        if i == q:
            print("[",end = "")
        print(str(A[i]),end = "")
        if i == q:
            print("]",end = "")
    print()


Measured memory_bytes: 17056
x,n = map(int, input().split())
if n == 0:
    print(x)
else:
    lst = list(map(int, input().split()))
    
    left = x
    right = x
    while left>= -1 and right <= 101:
        if left not in lst:
            print(left)
            break
        if right not in lst:
            print(right)
            break
         
        left -= 1
        right += 1


Measured memory_bytes: 9184