akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std ;

/*                        [Template]                        */
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define let auto
#define of :
#define all(y) y.begin(), y.end()
#define present( x, y ) x.find( y ) != x.end()
#define _matrix(T) vector<vector<T>>
template<class T>
auto matrix( int r, int c, T v ){
	return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
int mod = (int)1e9 + 7 ;

/************************************************************/

int common( string &s, string &t, int &l, int &r ){
	int cnt = 0 ;
	int k = 0 ;
	for( int i = l ; i <= r ; i++ ){
		if( s[i] == t[k++] ){
			cnt++ ;
		}
	}
	return cnt ;
}


signed main(){
	string s, t ;
	cin >> s >> t ;
	int lens = s.size(), lent = t.size() ;
	int left = 0, right = lent - 1 ;
	int mx = 0 ;
	while( right < lens ){
		int x = common( s, t, left, right ) ;
		mx = max(mx, x) ;
		++left, ++right ;
	}
	cout << lent - mx ;
	return 0 ;
}

Measured memory_bytes: 3616
N, K, Q = map(int, input().split())
A = [int(input()) for q in range(Q)]

acc = [0]*N
for a in A:
    acc[a-1] += 1

for corr_num in acc:
    if K - (Q - corr_num) <= 0:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 55896
/*
Union-Find木で解ける
*/
#include <iostream>
#include <vector>
using namespace std;

// Nはグラフの頂点数
struct UnionFind {
    vector<int> parent, rank;

    UnionFind(int N) {
        parent.resize(N+1);
        rank.resize(N+1);
        /*
        // 0 origin
        for(int i=0; i<N; i++) {
            parent[i] = i;
            rank[i] = 0;
        }
        */
        // 1 origin
        for(int i=1; i<=N; i++) {
            parent[i] = i;
            rank[i] = 0;
        }
    }

    int root(int x) {
        if(parent[x] == x) {
            return x;
        } else {
            return parent[x] = root(parent[x]);
        }
    }

    bool unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) {
            return false;
        }

        if (rank[rx] < rank[ry]) {
            parent[rx] = ry;
        } else {
            parent[ry] = rx;
            if (rank[rx] == rank[ry]) {
                rank[rx]++;
            }
        }
        return true;
    }

    bool isSame(int x, int y) {
        return root(x) == root(y);
    }
};

int main() {
    int n, m, ans;
    cin >> n >> m;
    vector<int> x(m);
    vector<int> y(m);
    for(int i=0; i<m; i++){
        int tmp;
        cin >> x[i] >> y[i] >> tmp;
    }

    ans = n;
    UnionFind uf(n);
    for (int i=0; i<m; i++) {
        if(uf.unite(x[i], y[i])) {
            ans--;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a*b;
        int length =2*(a+b);
        System.out.println(area + " " + length);
    }
}


Measured memory_bytes: 26252
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int n;
int a[100'000];
int cnt[100'001];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    memset(cnt, 0, sizeof cnt);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
        cnt[a[i]-1]++;
        cnt[a[i]+1]++;
    }
    int max_cnt = 0;
    for(int i = 1; i <= 100'000; i++) {
        max_cnt = max(max_cnt, cnt[i]);
    }
    cout << max_cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
// ??????????????? http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2254&lang=jp

#include <iostream>
#include <algorithm>
using namespace std;

const int INF = 1<<20;

int n;
int t[20][20];
int dp[1<<17];

int b(int s, int i) {
	int dt = t[i+1][0];
	for(int j=0;j<n;j++) {
		if(s&(1<<j)) dt = min(dt, t[i+1][j+1]);
	}
	return dt;
}

int a(int s) {
	int &dt = dp[s];
	if(dt<INF) return dt;

	for(int i=0;i<n;i++) {
		int ns = s & ~(1<<i);
		if(ns==s) continue;
		dt = min(dt, a(ns)+b(ns, i));
	}
	return dt;
}

int main() {
	while(true) {
		cin >> n;
		if(n==0) break;

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

		fill(dp, dp+sizeof(dp)/sizeof(int), INF);
		dp[0]=0;
		cout << a((1<<n)-1) << endl;
	}
	return 0;
}

Measured memory_bytes: 3556
/*@author Vipen Loka*/
#include <bits/stdc++.h>
#define endl '\n'
#define ff first
#define ss second
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define deb(x) cout << #x << ':' << x << '\n';

using namespace std;

void solve(){
	int i,j;
	int d,t,s;
	cin >> d >> t >> s;

	if(t*s>=d){
		puts("Yes");
	}
	else{
		puts("No");
	}
}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    
	int T=1;
	// cin >> T;
	while (T--){
		solve();
	}
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m, int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
	return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t, sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;

map<string, int> memo;

using P=pair<int, int>;

/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value, vector<ll> a)
{

	for (ll i = 0; i < (ll)a.size(); i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}



const int INF = 1001001001;



int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int x;
	x = max({a,b,c})- min({ a,b,c });
	cout << x;


	
	return 0;
}













Measured memory_bytes: 256
n = int(input())
tp = []
tmp = 10**15
for _ in range(5):
    a = int(input())
    if tmp > a:
        tmp = a
    tp.append(a)

if tmp >= n:
    print(5)
    exit()

cnt = n//tmp
mod = n%tmp

if mod > 0:
    print(5+cnt)
else:
    print(5+cnt-1)

Measured memory_bytes: 9116
S = input()

n = len(S)
l = S[:(n-1)//2]
r = S[(n+3)//2 - 1:]
if S[::-1] == S:
    if r == r[::-1] and l == l[::-1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3060
a, b, c, d = [c for c in input()]
candids = []
for i in range(8):
    candid = []
    for k in range(3):
        if i >> k & 1 > 0:
            candid.append("+")
        else:
            candid.append("-")
        
    candids.append(candid)
#print(candids)
for op1, op2, op3 in candids:
    if eval(a+op1+b+op2+c+op3+d) == 7:
        print (a+op1+b+op2+c+op3+d+"=7")
        break

Measured memory_bytes: 61604
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

N = ii()
N_f = float(N)
A = li()

cnt = [0, 0, 0]
for a in A:
    cnt[a-1] += 1

#dp = dp3(0.0, cnt[2]+1, cnt[1]+cnt[2]+1, N+1)
#dp = dp3(0.0, N+1, N+1, N+1)
dp = dp3(0.0, 301, 301, 301)
dp[0][0][0] = 0

for k in range(cnt[2]+1):
    for j in range(cnt[1]+cnt[2]+1-k):
        for i in range(N+1-j-k):
            if i+j+k == 0:
                continue
            num = i+j+k
            dp[i][j][k] = N_f
            if i > 0:
                dp[i][j][k] += dp[i-1][j][k] * i
            if j > 0:
                dp[i][j][k] += dp[i+1][j-1][k] * j
            if k > 0:
                dp[i][j][k] += dp[i][j+1][k-1] * k
            dp[i][j][k] /= num

print(dp[cnt[0]][cnt[1]][cnt[2]])

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

int main(){
	ll n; cin >> n;
	ll c[10][10];
	rep(i,10){
		rep(j,10){
			c[i][j] = 0;
		}
 	}
	rep(i,n){
		ll p = (i+1)%10;
		ll q = i+1;
		while(q>9)q/=10;
		c[p][q]++;
	}
	ll ans = 0;
	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
			ans += c[i][j]*c[j][i];
		}
	}
	cout << ans << endl;
}

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

int main(){
int N;
string S;
cin >> N;
cin >> S;
int count = 0;
for(int i= 0;i<=N-3;i++){
  if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C')
    count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;

int main() {

	long N; cin >> N;
	vector<long> A(N); for (int i = 0; i < N; i++) cin >> A[i];

	multiset<long> colormax;//各色の最大値
    colormax.insert(A[0]);
    
	for (int i = 1; i < N; i++) {
		if (A[i] <= * colormax.begin()) { colormax.insert(A[i]); continue; }

		auto IterA = colormax.lower_bound(A[i]);
        IterA--;
		colormax.erase(IterA);
		colormax.insert(A[i]);
	}
    
	cout << colormax.size() << endl;
}

Measured memory_bytes: 5760
import java.io.*;
import java.util.*;

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(bu.readLine());
        String ans="";
        n=n%10;
        if(n==0 || n==1 || n==6 || n==8) ans="pon";
        else if (n==2 || n==4 || n==5 || n==7 || n==9) ans="hon";
        else ans="bon";
        System.out.print(ans);
    }
}


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

int main()
{
    long N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;

    vector<long> T ={ A, B, C, D, E };

    long T_min = *min_element(T.begin(), T.end());

    long cnt = 4 + N / T_min;
    if (N % T_min != 0) {
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3608
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

void sputs(){}
template <class Head, class... Tail>
void sputs(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(Tail) == 0) { cout << endl; }
  else { cout << " "; }
  sputs(std::move(tail)...);
}

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

signed main() {
  string s,t;cin>>s>>t;
  int n = sz(s); int m = sz(t);

  vi acnt_s(n+1);
  rep(i, n){
    if (s[i]=='A') acnt_s[i+1]=1;
    acnt_s[i+1] += acnt_s[i];
  }
  vi acnt_t(m+1);
  rep(i, m){
    if (t[i]=='A') acnt_t[i+1]=1;
    acnt_t[i+1] += acnt_t[i];
  }


  int Q;cin>>Q;
  rep(q, Q){
    int a,b,c,d;cin>>a>>b>>c>>d;
    int a1 = acnt_s[b] - acnt_s[a-1];
    int b1 = (b-a+1)-a1;
    int a2 = acnt_t[d] - acnt_t[c-1];
    int b2 = (d-c+1)-a2;
    dump(a1,b1);
    dump(a2,b2);
    if ((b1+(2*a1))%3 == (b2+(2*a2))%3){ cout << "YES" << endl; }
    else{ cout << "NO" << endl; }
    
  }
  return 0;
}


Measured memory_bytes: 2512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  for(int i = 0; i < S.size(); i++){
    S[i] = S[i] + N;
    if(S[i] > 'Z'){
      S[i] = S[i] - 26;
    }
  }
  cout << S << endl;
}


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


int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	ll a,b;
	cin>>a>>b;
	if(a==1||b==1)cout<<1;
	else {
		ll sum=b*(a/2);
		if(a%2) sum+=ceil(b/2.0);
		cout<<sum;
	}

} 


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define INF 1010001000

using namespace std;

int dp[(1 << 16)], n;

int main() 
{
    while (cin >> n, n) {
        int noitem[n], input[n][n];
        for (int i = 0; i < n; i++) {
            cin >> noitem[i];
            for (int j = 0; j < n; j++) {
                cin >> input[i][j];
            }
        }
        for (int i = 0; i < (1 << n); i++) {
            dp[i] = INF;
        }
        dp[0] = 0;

        for (int i = 0; i < (1 << n); i++) {
            for (int j = 0; j < n; j++) {
                if (!((i>>j) & 1)) {
                    dp[i|(1<<j)] = min(dp[i|(1<<j)], dp[i]+noitem[j]);
                    for (int k = 0; k < n; k++) {
                        if ((i >> k) & 1) {
                            dp[i|(1<<j)] = min(dp[i|(1<<j)],
                                    dp[i] + input[j][k]);
                        }
                    }
                }
            }
        }
        cout << dp[(1 << n) -1] << endl;
    }
    return 0;
}

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

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double
#define PI 3.14159265358979323846264338327950288419

#define PII pair<int,int>
#define PLL pair<LL,LL>
#define mp make_pair
#define fi first
#define se second

using namespace std;

int n, s[205], ans;

int main(){
	scanf("%d", &n);
	FI(i, 1, n + n) scanf("%d", &s[i]);
	sort(s + 1, s + n + n + 1);
	FI(i, 1, n + n){
		ans += s[i];
		i++;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char a[2005],b[2005];
int n,pre[2005],nxt[2005],ans=1e9,mx[2005];
void solve(){
	for(int i=0;i<n;i++){
		pre[i]=nxt[i]=0;
		for(int p=0;p<n;pre[i]++,p++) if(b[(i-p+n)%n]=='1') break;
		for(int p=0;p<n;nxt[i]++,p++) if(b[(i+p)%n]=='1') break;
	}
	for(int i=0;i<n;i++){
		int tot=0;
		memset(mx,0,sizeof(mx));
		for(int p=0;p<n;p++) if(a[p]!=b[(p+i)%n])
			tot++,mx[pre[p]]=max(mx[pre[p]],nxt[p]);
		int mn=1e9,cnt=i;
		for(int p=n-1;~p;p--)
			mn=min(mn,cnt+p),cnt=max(cnt,mx[p]);
		ans=min(ans,2*mn-i+tot);
	}
}
int main(){
	scanf("%s%s",a,b);
	n=strlen(a);
	int suma=0,sumb=0;
	for(int i=0;i<n;i++) suma+=a[i]-'0',sumb+=b[i]-'0';
	if(!sumb&&!suma) return puts("0"),0;
	if(!sumb) return puts("-1"),0;
	solve();
	for(int i=0;i+i<n;i++) swap(a[i],a[n-i-1]),swap(b[i],b[n-i-1]);
	solve();
	printf("%d",ans);
	return 0;
}

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

int main(void){
	int m, n;
	char a[50][50], b[50][50];
	bool flag;

	cin >> n >> m;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < m; i++){
		for (int j = 0; j < m; j++){
			cin >> b[i][j];
		}
	}

	for (int i = 0; i <= n - m; i++){
		for (int j = 0; j <= n - m; j++){
			flag = true;
			for (int k = 0; k < m; k++){
				for (int l = 0; l < m; l++){
					if (a[i + k][j + l] != b[k][l]){
						flag = false;
					}
				}
			}
			if (flag == true){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
import math

n,m = [int(i) for i in input().split()]
table = [[int(i) for i in input().split()] for n in range(n)]

count = 0

for i in range(n):
    for j in range(i+1,n,1):
        distance = 0
        total = 0
        for k in range(m):
            total += (table[i][k] - table[j][k]) ** 2
        distance = math.sqrt(total)
        if distance.is_integer() == True:
            count += 1

print(count)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
auto Piii(int b,int c,int a){
    return make_pair(b,pii(c,a));
}
signed main(){
    int a,b; cin >> a >> b;
    cout << fixed << setprecision(10)<< (b*b*b)*4.0/3*acos(-1) << endl;
    /*
    int N;
    cin >> W >> H >> N;
    vector<pii>pass(N);
    erep(e,pass) cin >> e.first >> e.second;
    pass.push_back(pii(1,1));
    pass.push_back(pii(W,H));
    int source = N;
    int sink  = source + 1;
    vector<vector<pii>>edge(N+2,vector<pii>());
    rep(i,pass.size())rep(j,pass.size()){
        if(i == j )continue;
        int cost = abs(pass[i].first - pass[j].first)  + abs(pass[i].second - pass[j].second);
        edge[i].push_back(pii(j,cost));
    }
    vector<int>d(N+2,INF);
    d[source] = 0;
    priority_queue<piii,vector<piii>,greater<piii>>que;
    que.push(Piii(0LL,source,0));
    while(!que.empty()){
        piii now = que.top();
        que.pop();
        int td = now.first; int nv = now.second.first;
        if(td >  d[nv])continue;
        rep(i,edge[nv].size()){
            int next = edge[nv][i].first;
            int cost = edge[nv][i].second;
            if(cost + td >= d[next]) continue;
            d[next] = cost + td;
        }
    }
    cout << d[sink] << endl;
     */
}





Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
const ll waru = 1e9 + 7;
const int intmax = 0x7fffffff, intmin = ~intmax;

int main() {
  int n, tm, re = 0x7fffffff;
  cin >> n >> tm;
  for (int i = 0; i < n; i++) {
    int c, t;
    cin >> c >> t;
    if (t <= tm) re = min(re, c);
  }
  if (re == intmax) {
    cout << "TLE" << endl;
  } else {
    cout << re << endl;
  }
}


Measured memory_bytes: 256
let rec make_list n l =
	match n with
	|0 -> l
	|_ -> Scanf.sscanf(read_line()) "%s %d" (fun x y -> make_list (n-1) ((x,y)::l));;

let suits = ["S";"H";"C";"D"];;
let nums = [1;2;3;4;5;6;7;8;9;10;11;12;13];;

let find l =
	let rec search l tup =
		match l with
		|[] -> false
		|x::xs -> if x = tup then true else search xs tup
	in
	let rec find_n l su nus res =
		match nus with
		|[] -> res
		|x::xs -> if search l (su,x) then find_n l su xs res else find_n l su xs ((su,x)::res)
	in
	let rec find_s l sus nus res = 
		match sus with
		|[] -> res
		|x::xs -> let res2 = find_n l x nus res in find_s l xs nus res2
	in
	find_s l suits nums [];;

let rec print_tups l =
	match l with
	|[] -> ()
	|(s,n)::ts -> print_tups ts;Printf.printf "%s %d\n" s n;;

let n = Scanf.sscanf(read_line()) "%d" (fun x -> x)
in
print_tups (find (make_list n []));;



Measured memory_bytes: 2452
f :: [Int]->Int->Int->Int
f [] _ ans=ans
f (x:xs) d ans=let ans1=ans+ (length (takeWhile (<= d) [1,(1+x)..]))
               in f xs d ans1

main = do
       e<-getLine
       e2<-getLine
       e3<-getContents
       let as=map read (lines e3)::[Int]
           n= read e ::Int
           (d:x:[])=map read (words e2)::[Int]
       putStrLn $ show $  (f as d 0)+x

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

void spinface(vector<string> &a){
    swap(a[0], a[1]);
    swap(a[1], a[2]);
    swap(a[2], a[3]);
    swap(a[4], a[5]);
    swap(a[5], a[6]);
    swap(a[6], a[7]);
}

void spindiag(vector<string> &a){
    swap(a[1], a[3]);
    swap(a[3], a[4]);
    swap(a[2], a[7]);
    swap(a[7], a[5]);
}

void turnupdown(vector<string> &a){
    swap(a[0], a[4]);
    swap(a[1], a[7]);
    swap(a[2], a[6]);
    swap(a[3], a[5]);
}

int main(){
    vector<string> s(8);
    while(cin >> s[0]){
        for(int i=1; i<8; i++) cin >> s[i];
        map<vector<string> ,bool> cases;
        sort(s.begin(), s.end());
        do{
            bool used = false;
            for(int i=0; i<8; i++){
                for(int j=0; j<3; j++){
                    if(cases.count(s)!=0){
                        used = true;
                    }
                    spindiag(s);
                }
                spinface(s);
                if(i%4==3){
                    turnupdown(s);
                }
            }
            if(!used){
                cases[s] = true;
            }
        }while(next_permutation(s.begin(), s.end()));
        cout << cases.size() << endl;
    }
    return 0;
}



Measured memory_bytes: 3404
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
auto f(pii a,pii b){return a.second < b.second;}
signed main(){
    int n,m; cin >> n >> m;
    vector<pii>v(m);
    erep(e,v) cin >> e.first >> e.second;
    sort(all(v),f);
    int ans = 0;
    int maxi = 0;
    erep(e, v){
        if (e.first <= maxi){
        } else {
            ans++;
            maxi = e.second - 1;
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int c;

	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);

	if (a < b && b < c)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    float d, s, gt, t;
    cin >> d >> s >> gt;

    t = d/s;
    if(t <= gt)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }

}



Measured memory_bytes: 3732
package main

import (
	"fmt"
	"math"
)

func intMin(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

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

	DP := make([]int, N+1)
	for i := 1; i <= N; i++ {
		DP[i] = int(math.Pow10(6))
	}

	for i := 1; i <= N; i++ {
		for j := 1; j <= i; j *= 6 {
			DP[i] = intMin(DP[i], DP[i-j]+1)
		}
		for j := 1; j <= i; j *= 9 {
			DP[i] = intMin(DP[i], DP[i-j]+1)
		}
	}
	fmt.Println(DP[N])
}


Measured memory_bytes: 2660
if __name__ == "__main__":
    s = input()

    while s != '':
        if s[-5:] == 'dream':
            s = s[:-5]
        elif s[-7:] == 'dreamer':
            s = s[:-7]
        elif s[-5:] == 'erase':
            s = s[:-5]
        elif s[-6:] == 'eraser':
            s = s[:-6]
        else:
            print('NO')
            exit()

    print('YES')


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define MAXN 2000005
using namespace std;
using namespace __gnu_pbds;  

ll n,k;

void solve()
{
    cin>>n>>k;
    ll p=n%k;
    ll q=n%k-k;
    ll r=abs(q)-k;
    q=abs(q),r=abs(r);
    cout<<min(min(p,q),r)<<endl;
}

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


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var n, k int 
  fmt.Scan(&n, &k)
  res := 1
  for i := 0; i < n; i++ {
    if res <= k {
      res *= 2
    } else {
      res += k
    }
  }
  fmt.Println(res)
}

Measured memory_bytes: 512
// --------------
// Tejas Pandey  |
// 26 - 01 - 20  |
// ATCODER #153  |
// --------------

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define lim 100000000000000000
#define vi vector<int>
typedef long long int ll;

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		ll n,d,a;
		cin >> n >> d >> a;
		vector<pair<ll,ll>> nd(n);
		for(int i = 0;i < n;i++)
			cin >> nd[i].first >> nd[i].second;
		sort(nd.begin(),nd.end());
		ll cur = 0,cnt = 0;
		queue<pair<ll,ll>> qt;
		for(int i = 0;i < n;i++){
			while(!qt.empty() && qt.front().first < nd[i].first) cur -= qt.front().second,qt.pop();
			ll ti = 0;
			if(cur < nd[i].second)
				ti = (ll)ceil((nd[i].second - cur)/(a*1.0));
			cur += ti*a;
			cnt += ti;
			qt.push({nd[i].first + d + d,ti*a});
		}
		cout << cnt << "\n";
	}
	return 0;
}

Measured memory_bytes: 6656
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


yn = 'YNeos'
ynflg = False
cnt = 0
ans = None

def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas


N = intinput()
As = list(mulinputs())
As = list(filter(lambda x: x%2 == 0, As))

As2 = list(filter(lambda x: x%3 == 0 or x%5==0, As))

if len(As2) == len(As):
    print('APPROVED')
else:
    print('DENIED')






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

using namespace std;

int main(){

	double a,b;
	while(cin>>a>>b){
		if(a<35.5&&71.0>b){
			cout<<"AAA"<<endl;
		}
		else if(a<37.5&&77.0>b){
			cout<<"AA"<<endl;
		}
		else if(a<40.0&&83.0>b){
			cout<<"A"<<endl;
		}
		else if(a<43.0&&89.0>b){
			cout<<"B"<<endl;
		}
		else if(a<50.0&&105.0>b){
			cout<<"C"<<endl;
		}
		else if(a<55.0&&116.0>b){
			cout<<"D"<<endl;
		}
		else if(a<70.0&&148.0>b){
			cout<<"E"<<endl;
		}
		else
			cout<<"NA"<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

int main()
{
    int N; cin >>N;
    vector<string> s(N);
    vector<int> t(N);
    rep(i, N) {
        cin >> s[i] >> t[i];
    }
    string X; cin >> X;
    rep(i, N) {
        if (X == s[i]) {
            i++;
            int tsum = 0;
            for (;i < N; i++) {
                tsum += t[i];
            }
            cout << tsum << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N, M, Q;
    cin >> N >> M;
    vector<int> es[N];
    rep(i, M){
        int a, b;
        cin >> a >> b;
        a--, b--;
        es[a].pb(b), es[b].pb(a);
    }
    rep(i, N){
        es[i].pb(i);
    }
    cin >> Q;
    //dp[u][i]:=uから距離iの点を塗る操作が最後に行われたのは何回目か
    int dp[N][11];
    fill(dp[0], dp[N], -1);
    int c[Q];
    rep(i, Q){
        int v, d;
        cin >> v >> d >> c[i];
        v--;
        dp[v][d] = i;
    }
    rep3(i, 9, 0){
        rep(u, N){
            for(auto &v: es[u]){
                dp[u][i] = max(dp[u][i], dp[v][i+1]);
            }
        }
    }
    rep(u, N){
        if(dp[u][0] == -1) cout << 0 << endl;
        else cout << c[dp[u][0]] << endl;
    }
}

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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,a,b;
	cin>>n>>a>>b;
	if((b-a)&1)
		cout<<"Borys"<<endl;
	else
		cout<<"Alice"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
char a[100005];
int x,y,ans;
int main()
{
    std::cin>>a;
    for(int i=0;i<sizeof(a);i++)
    if(x==y){x++;if(a[i]=='p')ans--;}
    else{y++;if(a[i]=='g')ans++;}
    std::cout<<ans<<std::endl;
}

Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))
for a in A:
    if a % 2 == 1:
        continue
    elif a % 2 == 0:
        if a % 3 != 0 and a % 5 != 0:
            print("DENIED")
            exit()
print("APPROVED")


Measured memory_bytes: 61936
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = long long;
using u32 = unsigned long long;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vstr = vector<string>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  char c;
  cin >> c;
  switch (c) {
    case 'A': cout << 'T' << endl; break;
    case 'T': cout << 'A' << endl; break;
    case 'C': cout << 'G' << endl; break;
    case 'G': cout << 'C' << endl; break;
  }
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];

    int all = pow(3, n);
    int bad = 1;
    rep(i, n) if (a[i] % 2 == 0) bad *= 2;

    cout << all - bad << endl;
    return 0;
}

Measured memory_bytes: 4000
object Main extends App {
    scala.io.StdIn.readLine()
    val ary = scala.io.StdIn.readLine().split(" ").map(_.toInt)
    val comp = Array(
        (x:Int) => 1 <= x && x <= 399,
        (x:Int) => 400 <= x && x <= 799,
        (x:Int) => 800 <= x && x <= 1199,
        (x:Int) => 1200 <= x && x <= 1599,
        (x:Int) => 1600 <= x && x <= 1999,
        (x:Int) => 2000 <= x && x <= 2399,
        (x:Int) => 2400 <= x && x <= 2799,
        (x:Int) => 2800 <= x && x <= 3199
        )
    def cnt(ary: Array[Int], f: Array[(Int) => Boolean]): Array[Int] = {
        for (func <- f) yield ary.count(func(_))
    }
    val ret = cnt(ary, comp).count(_>0)
    val min = if (ret==0) 1 else ret
    val max = ret+ary.count(_>=3200)
    println(min+" "+max)
}


Measured memory_bytes: 25512
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int n = sc.nextInt();
        if (m ==n) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 22996
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int xo(int a, int b) {
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		if (a % 2 == b % 2 and b % 2 == 1) {
			ans = 1;
		}
		a = a / 2;
		b = b / 2;
	}
	return ans;
}
int main() {
	vector<int> y(8, 0);
	y[1] = 1;
	vector<int> yy = y;
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> pe(n);
	vector<int> rui(3);
	string jo = "JOI";
	rui[0] = 1; rui[1] = 2; rui[2] = 4;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			if (jo[j] == s[i]) {
				pe[i] = rui[j];
			}
		}
	}
	vector<int> zer(8, 0);
	for (int i = 0; i < n; i++) {
		yy = y;
		y = zer;
		int x = pe[i];
		for (int j = 0; j < 8; j++) {
			if (xo(j, x) == 1) {
				for (int k = 0; k < 8; k++) {
					if (xo(j, k) == 1) {
						y[j] = (y[j] + yy[k]) % 10007;
					}
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < 8; i ++ ) {
		ans += y[i];
	}
	cout << ans % 10007 << endl;
	return 0;
}



Measured memory_bytes: 3164
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }

void solve()
{
    long long a,b,c,d;
    cin >> a >> b >> c >> d;

    if (b > a || b > d)
    {
        cout << "No\n";
        return;
    }

    if (c >= b)
    {
        cout << "Yes\n";
        return;
    }

    long long x = (a - c) / b;
    if (x > 0)
        a -= x * b;

    while (a > c)
        a -= b;

    if (a < 0)
    {
        cout << "No\n";
        return;
    }

    long long y = d % b;


    long long k = __gcd(b, y);
    long long step = (c - a) / k;
    a += step * k;
    for(int iter = 0; iter < 10; ++iter)
    {
        a += k;
        while (a > c)
            a -= b;


        if (a < 0)
        {
            cout << "No\n";
            return;
        }
    }

    cout << "Yes\n";
}

int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("output.txt", "w", stdout);
//    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);

    int T;
    cin >> T;
    while (T--)
        solve();

}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for (int i=(a); i<=(b); ++i)
#define int long long
 
vector<int> mai;
vector<int> pras;
 
signed main(){
    int n,k;cin>>n>>k;
	pras.push_back(0);
	FOR(i,0,n-1)
	{
		int a;cin>>a;
		if(a<0) mai.push_back(a);
		else if (a > 0) pras.push_back(a);
		else k--;
	}
	
	if(k == 0)
	{
		cout << 0 << endl;
		return 0;
	}
	mai.push_back(0);
	reverse(mai.begin(),mai.end());
	
	int ans = 123456789012345;
 
	FOR(i,0,k)
	{
		
		if(i > mai.size()-1 || k-i > pras.size()-1) continue;
		ans = min(ans,-mai[i]+pras[k-i]+min(-mai[i],pras[k-i]));
		
	}
	
	cout << ans << endl;
	
}

Measured memory_bytes: 1656
# -*- coding: utf-8 -*-
import sys
from collections import deque

H,W=map(int, sys.stdin.readline().split())
N=input()
A=map(int, sys.stdin.readline().split())


L=[]

cnt=0
flag="r"
q=deque([]) 
for i,a in enumerate(A):
	for u in range(a):
		cnt+=1
		#print "u,i,a :::: ",u,i+1,a,cnt,flag
		if flag=="r":
			q.append(i+1)
		elif flag=="l":
			q.appendleft(i+1)

		if cnt==W:
			cnt=0
			L.append(q)
			q=deque([]) 
			if flag=="r": flag="l"
			elif flag=="l": flag="r"

for u in L:
	for x in u:
		print x,
	print



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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    static uint32_t a[1<<18 | 1], ans[1<<18 | 1];
    cin >> n;
    for(int i=0;i<(1<<n);++i) cin >> a[i];

    static pair<uint32_t, uint32_t> dp[1<<18][19];
    auto merge = [&](pair<uint32_t, uint32_t> x, pair<uint32_t, uint32_t> y){
        if(a[y.first] > a[x.first]){ x.second = x.first; x.first = y.first; }
        else if(a[y.first] > a[x.second]) x.second = y.first;
        if(a[y.second] > a[x.first]){ x.second = x.first; x.first = y.second; }
        else if(a[y.second] > a[x.second]) x.second = y.second;
        return x;
    };

    for(int s=0;s<(1<<n);++s) dp[s][0] = { s, 1<<18 };
    for(int k=1;k<=n;++k){
        for(int s=0;s<(1<<n);++s){
            if((s>>k-1) & 1) dp[s][k] = merge(dp[s][k-1], dp[s-(1<<k-1)][k-1]);
            else dp[s][k] = dp[s][k-1];
        }
    }
    for(int i=1;i<(1<<n);++i){
        auto p = dp[i][n];
        ans[i] = max(ans[i-1], a[p.first] + a[p.second]);
        cout << ans[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 44032
import sys
from itertools import accumulate

input = lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60

N, M, Q = map(int, input().split())
G = [[0] * N for _ in range(N)]
for _ in range(M):
    l, r = map(int, input().split())
    G[l - 1][r - 1] += 1

csum = [[0] * (N + 1) for _ in range(N + 1)]
for i in range(N):
    for j in range(N):
        csum[i + 1][j + 1] = csum[i + 1][j] + csum[i][j + 1] - csum[i][j] + G[i][j]

ans = []
for _ in range(Q):
    p, q = map(int, input().split())
    ans.append(csum[q][q] - csum[q][p - 1] - csum[p - 1][q] + csum[p - 1][p - 1])

print(*ans, sep='\n')


Measured memory_bytes: 21184
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K,X,Y,fee;
  cin >> N;
  cin >> K;
  cin >> X;
  cin >> Y;
  
  if(N > K){
    fee = X * K + Y * (N - K);
  }
  else{
    fee = X * N;
  }
  cout << fee << endl;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll N;
  cin >> N;
  vector<ll> a(N);
  rep(i,N)
    cin>>a[i];
  sort(begin(a), end(a));

  ll ok = N-1, ng = -1; // okは条件を満す最小の index
  while(ng+1<ok){
    ll m = (ok+ng)/2;
    bool t = true;
    ll siz = 0;
    for (ll i=0; i<=m; i++)
      siz += a[i];
    for (ll i=m+1; i<N; i++) {
      if (a[i] > 2*siz) {
        t = false;
        break;
      } else {
        siz += a[i];
      }
    }
    (t ? ok : ng) = m;
  }
  cout << (N-ok) << endl;
  return 0;
}


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

int main(){
  int a,b;
  cin >>a >>b;
  if(a<=8 && b<=8) cout << "Yay!" << endl;
  else cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int n;
    cin >> n;
    string s;
    cin >> s;

    vector<int> v;

    if(n == 1) {
        pr(0);
        return 0;
    }

    if(s[0] == '#') v.pb(0);

    int tmp = 0;
    int rw = 0; //右の白
    Rep(i, 1, n){
        tmp++;
        if(s[i-1] != s[i]){
            v.pb(tmp);
            if(v.size() % 2) rw += tmp;
            tmp = 0;
        }
    }
    v.pb(++tmp);
    if(v.size() % 2) rw += tmp;
    if(s[s.size()-1] == '#') v.pb(0);

    int lb = 0;
    vector<int> ans;
    REP(i, v.size()){
        if(i%2==0){ //siro
            rw -= v[i];
        }else{
            lb += v[i];
        }
        ans.pb(lb+rw);
    }

    SORT(ans);
    pr(ans.size() == 0?0:ans[0]);
}

Measured memory_bytes: 2808
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;

pair<ll,ll> row[300001],col[300001];

int main(){
  for(int i=1;i<300001;i++){row[i].second=i;col[i].second=i;}
  ll h,w,m,a,b;
  set<pair<ll,ll>> o;
  cin>>h>>w>>m;
  for(int i=0;i<m;i++){
    cin>>a>>b;
    row[a].first++;
    col[b].first++;
    o.insert({a,b});
  }
  sort(row,row+300001);
  reverse(row,row+300001);
  sort(col,col+300001);
  reverse(col,col+300001);
  ll ans=0,mxr=row[0].first,mxc=col[0].first,ri=0,flg=0;
  while(row[ri].first==mxr){
    ll ci=0;
    while(col[ci].first==mxc){
      ans=max(ans,row[ri].first+col[ci].first-(o.count({row[ri].second,col[ci].second})? 1 : 0));
      if(!o.count({row[ri].second,col[ci].second})){flg=1;break;}
      ci++;
    }
    if(flg)break;
    ri++;
  }
  cout<<ans<<endl;
}


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

using namespace std;

const int N=2005,M=4005,P=1e9+7;

int n,m,K,t;
int f[M][N];
long long ans;

int main(){
	scanf("%d%d%d",&n,&m,&K);
	t=(n+m-1)/(K-1);
	for(int i=1;i<K;i++)f[1][i]=1;
	for(int i=2;i<=t;i++)for(int j=1;j<=n;j++){
		int&w=f[i][j];
		w=(f[i][j-1]+f[i-1][j])%P;
		if(j>=K)w=(w-f[i-1][j-K]+P)%P;
	}
	for(int i=1;i<=t;i++)for(int j=n,k=max(0,i*(K-1)-m)+1;j>=k;j-=K-1)ans+=f[i][j];
	printf("%lld\n",ans%P);
	return 0;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define fup(i,a,b) for(int i=a;i<=b;++i)
#define fdw(i,a,b) for(int i=a;i>=b;--i)
#define sync ios::sync_with_stdio(false);cin.tie(0)
#define cl(a) memset(a,0,sizeof(a))
#define gcd __gcd
#define fi first
#define se second
#define pb push_back
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
//ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//ll ksm(ll a,ll b,ll mod){ll res=1;a%=mod;for(;b;b>>=1){if(b&1) res=res*a%mod;a=a*a%mod;}return res;}
//ll oula(ll n){ ll res=n;for(ll i=2;i*i<=n;i++){if(n%i==0){ res=res-res/i;while(n%i==0) n/=i;}}if(n>1) res=res-res/n;return res;}
//bool MRT(ll x){if(x==2)return true;fup(i,1,50){ll now=rand()%(x-2)+2;if(ksm(now,x-1,x)!=1)return false;}return true;}
//void shai(int n)fup(i,2,n){if(isprime[i]){v.push_back(i);for(int j=2*i;j<=10000;j+=i)isprime[j]=0;}}//"埃氏筛筛选素数"
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const double eps=1e-7;
const int N=4e5+10;
int main()
{

    sync;
    string s;
    cin>>s;
    int t1=0,t2=0;
    fup(i,0,2)
    {
        if(s[i]=='A')
            t1++;
        else t2++;
    }
    if(t1&&t2)
    {
        cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
MOD = 1000000007
N = int(input())
S = list(map(str, input()))
S = list(map(str, input()))
lst = [0]
i = 0
ans = 1
while i < N:
	if i == N - 1:
		lst.append(1)
		break
	if S[i] == S[i + 1]:
		lst.append(2)
		i += 2
	else:
		lst.append(1)
		i += 1
		

for i in range(len(lst) - 1):
	cur = lst[i]
	nxt = lst[i + 1]
	if cur == 0:
		if nxt == 1:
			ans *= 3
			ans %= MOD
		else:
			ans *= 6
			ans %= MOD
	elif cur == 1:
		if nxt == 1:
			ans *= 2
			ans %= MOD
		else:
			ans *= 2
			ans %= MOD
	else:
		if nxt == 1:
			ans *= 1
		else:
			ans *= 3
			ans %= MOD
			
print(ans)

Measured memory_bytes: 38384