akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef int64_t Int;
using namespace std;

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

    if(N == 1){
        cout << "Hello World" << endl;
    } else {
        int A, B; cin >> A >> B;
        cout << A+B << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
using namespace std ;

ll n, m ; 

void upd(ll &res, ll x, ll y, ll z) {
	ll mx = max(max(x, y), z) ;
	ll mn = min(min(x, y), z) ;
	res = min(res, mx - mn) ;
}

int main() {
	scanf("%lld%lld", &n, &m) ;
	ll ans = 1e17, x, y, z ;
	rep(i, 1, n - 1) {
		x = m * i ;
		y = (n - i) / 2 * m ;
		upd(ans, x, y, n * m - x - y) ;
		y = m / 2 * (n - i) ;
		upd(ans, x, y, n * m - x - y) ;
	}
	rep(i, 1, m - 1) {
		x = n * i ;
		y = (m - i) / 2 * n ;
		upd(ans, x, y, n * m - x - y) ;
		y = n / 2 * (m - i) ;
		upd(ans, x, y, n * m - x - y) ; 
	}
	printf("%lld\n", ans) ;
	return 0 ;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
using namespace std;
int max(int i1, int i2){
	return i1 > i2 ? i1 : i2;
}
int vacation(int ans[][3], int a[], int b[], int c[], int n, int i, int j){
	if(i >= n)
		return 0;
	if(ans[i][j] != -1)
		return ans[i][j];
	switch(j){
		case 0:
			return ans[i][j] = a[i] + max(vacation(ans, a, b, c, n, i + 1, 1), vacation(ans, a, b, c, n, i + 1, 2));
			break;
		case 1:
			return ans[i][j] = b[i] + max(vacation(ans, a, b, c, n, i + 1, 0), vacation(ans, a, b, c, n, i + 1, 2));
			break;
		case 2:
			return ans[i][j] = c[i] + max(vacation(ans, a, b, c, n, i + 1, 0), vacation(ans, a, b, c, n, i + 1, 1));
	}
}
int main(){
	int n;
	scanf("%d", &n);
	int i, a[n], b[n], c[n];
	for(i = 0; i < n; i++)
		scanf("%d %d %d", a + i, b + i, c + i);
	int ans[n][3];
	memset(ans, -1, sizeof(int) * 3 * n);
	int sol = 0;
	sol = max(sol, vacation(ans, a, b, c, n, 0, 0));
	sol = max(sol, vacation(ans, a, b, c, n, 0, 1));
	sol = max(sol, vacation(ans, a, b, c, n, 0, 2));
	printf("%d\n", sol);
	return 0;
}

Measured memory_bytes: 13424
def main():
    N = int(input())
    R = [int(input()) for _ in range(N)]

    ans = R[1] - R[0]
    
    current_min = min(R[0], R[1])

    for i in range(2, N):
        ans = max(ans, R[i] - current_min)
        current_min = min(current_min, R[i])

    print(ans)

main()


Measured memory_bytes: 13600
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1000000007;
constexpr int  mod = mo;
constexpr ll inf = 1ll<<62;
int main(){
    int k,x;
    cin>>k>>x;
    for(int i=max(-1000000,x-k+1),count = 0;i<min(1000001,x+k);++i,++count){
        if(count)cout << " ";
        cout << i;
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
var ans = 0
for X in 0...input[0] {
    for Y in 0...input[0] {
        if 0...input[0] ~= input[1]-X-Y {
            ans += 1
        }
    }
}
print(ans)

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

int main() {
	double dis,speed,tim;
	cin>>dis>>tim>>speed;
	double ans=dis/speed;
	if(ans<=tim){
	    cout<<"Yes";
	}
	else
	{
	    cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;



signed main()
{
    ll a, b, x;
    cin >> a >> b >> x;

    ll ans;
    if (a >= 1) {
        ans = b / x - (a - 1) / x;
    } else {
        ans = b / x + 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
// Libraries
fun string(): String = readLine()!!
fun int(): Int = readLine()!!.toInt()
fun long(): Long = readLine()!!.toLong()
fun stringList(): List<String> = readLine()!!.split(" ")
fun intList(): List<Int> = readLine()!!.split(" ").map(String::toInt)
fun longList(): List<Long> = readLine()!!.split(" ").map(String::toLong)

// 最大公約数(ユーグリットの互除法)
tailrec fun gcd(a: Int, b: Int): Int = when {
    a < b -> gcd(b, a)
    b == 0 -> a
    else -> gcd(b, a % b)
}

fun min(a: Int, b: Int): Int = if(a < b) a else b
fun min(a: Long, b: Long): Long = if(a < b) a else b
fun max(a: Int, b: Int): Int = if(a > b) a else b
fun max(a: Long, b: Long): Long = if(a > b) a else b

fun main(args: Array<String>) {
    val N = int()
    println((N + 1) / 2)
}

Measured memory_bytes: 31812
S = input()
T = input()

ans = int(10**10)
# 10**3文字以下なので、O(N**2)でも間に合う
for i in range(len(S) - len(T)+1):
    part = S[i:i+len(T)]
    #print(part, T)
    cnt = 0
    for j, c in enumerate(part):
        if T[j] != c:
            cnt += 1
    ans = min(ans, cnt)
print(ans)

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

int main(){
  int64_t N, A, B;
  cin >> N >> A >> B;
  if((B-A)%2==1){
    swap(A,B);
    if(A<(N-B+1)) A = -(A-1);
    else B = 2*N-B+1;
  }
  cout << (B-A)/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <stdio.h>
using namespace std;
#define maxx 110000
typedef long long ll;
string a;

int main()
{
    int k,n;
    cin>>n>>a>>k;
    char t = a[k-1];
    for(int i=0;i<n;i++)
    if(a[i]!=t) cout<<'*';
    else cout<<a[i];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>



struct Card
{
	int vaule;
	char s[10];
	int sign;
};

//struct Card L[100010 / 2], R[100010 / 2];

//void merge(struct Card A[], int left, int mid, int right)
//{
//	int n1, n2;
//	n1 = mid - left;
//	n2 = right - mid;
//	for (int i = 0; i < n1; i++) L[i] = A[left + i];
//	for (int i = 0; i < n2; i++) R[i] = A[mid + i];
//	L[n1].vaule = R[n2].vaule = 0x7fffffff;
//
//	for (int k = left, i = 0, j = 0; k < right; k++)
//	{
//		if (L[i].vaule <= R[j].vaule)
//			A[k] = L[i++];
//		else
//			A[k] = R[j++];
//	}
//}

//void mergeSort(struct Card A[], int left, int right)
//{
//	if (left + 1 < right)
//	{
//		int mid = (left + right) / 2;
//		mergeSort(A, left, mid);
//		mergeSort(A, mid, right);
//		merge(A, left, mid, right);
//	}
//}

int partition(struct Card A[], int left, int right)
{
	int x = A[right].vaule;
	int i;
	i = left - 1;
	for (int j = left; j < right; j++)
	{
		if (A[j].vaule <= x)
		{
			i++;
			struct Card t = A[j];
			A[j] = A[i];
			A[i] = t;
		}
	}
	struct Card t = A[i + 1];
	A[i + 1] = A[right];
	A[right] = t;
	return i + 1;
}

void quickSort(struct Card A[], int left, int right)
{
	if (left < right)
	{
		int p = partition(A, left, right);
			quickSort(A, left, p - 1);
			quickSort(A, p + 1, right);
	}
}

int main()
{
	//struct Card A[100010], B[100010];
	struct Card B[100010];
	int n, stable = 1;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		//scanf("%s%d", A[i].s, &A[i].vaule);
		//A[i].sign = i;
		//B[i] = A[i];
		scanf("%s%d", B[i].s, &B[i].vaule);
		B[i].sign = i;
	}
	//mergeSort(A, 0, n);
	quickSort(B, 0, n - 1);
	for (int i = 0; i < n - 1; i++)
	{
		if (B[i].vaule == B[i + 1].vaule && B[i].sign > B[i + 1].sign)
		{
			stable = 0;
			break;
		}
	}
	printf("%s", stable ? "Stable\n" : "Not stable\n");
	for (int i = 0; i < n; i++)
		printf("%c %d\n", B[i].s[0], B[i].vaule);
}


Measured memory_bytes: 3660
import sys

input = sys.stdin.readline

n = int(input())
s = list(input())
res = 10 ** 9

cta = 0
ctb = 0
a = [0] * n
b = [0] * n
for i in range(n):
    if s[i] == ".":
        cta += 1
    else:
        ctb += 1
    a[i] = cta
    b[i] = ctb
for i in range(n):
    res = min(res, b[i] + a[-1] - a[i])
res = min(res, a[-1], b[-1])
print(res)

Measured memory_bytes: 14184
from collections import Counter

def solve():
    N = int(input())
    A = list(map(int, input().split()))

    m = max(A)

    dic = {}
    for n in range((m+1)//2, m+1):
        dic[n] = 0

    for a in A:
        if not a in dic.keys():
            return False
        else:
            dic[a] += 1

    if m % 2 == 0:
        half = m//2
        if dic[half] != 1:
            return False
    else:
        half = m//2+1
        if dic[half] != 2:
            return False
    for n in range(half+1, m+1):
        if dic[n] < 2:
            return False
    return True


if __name__ == "__main__":
    if solve():
        print('Possible')
    else:
        print('Impossible')

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    LL a,b,c,d;
    cin>>a>>b>>c>>d;
    LL ans = max(a*c, a*d);
    ans = max(ans,b*c);
    ans = max(ans,b*d);
    cout<<ans<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n)
        {
            cin>>a[i];
        }
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n)
    {
        cin>>a[i];
    }
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


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

const int INF = 1e9 + 10;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<P>>g(n);
    rep(i, m) {
        int l, r, d;
        cin >> l >> r >> d;
        l--, r--;
        g[l].push_back({r, d});
        g[r].push_back({l, -d});
    }
    vector<int>v(n, INF);
    rep(i, n) {
        if (v[i] == INF) {
            v[i] = 0;
            queue<int>que; que.push(i);
            while(!que.empty()) {
                int now = que.front(); que.pop();
                int from = now, cost = v[now];
                for(P x : g[now]) {
                    int to = x.first, ncost = x.second;
                    if (v[to] == INF) {
                        que.push(to);
                        v[to] = cost + ncost;
                    }
                    else {
                        if (cost + ncost != v[to]) {
                            cout << "No" << endl;
                            return 0;
                        }
                    }
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 12300
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>

typedef long long ll;
using namespace std;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;

const double EPS = 1e-8;

int main()
{
	ll N=0;

	cin >> N;

	cout << 800*N-(N/15)*200;
	
	return 0;
}


Measured memory_bytes: 764
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    if ((a + b) % 2 == 0) cout << (a + b) / 2 << endl;
    else cout << "IMPOSSIBLE" << endl;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

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

	while(true) {
		int n,m;cin>>n>>m;
		if(n==0) break;
		int cnt[m]={};
		REP(i,n) {
			REP(j,m) {
				int a;cin>>a;
				cnt[j]+=a;
			}
		}
		vector<int> v[n+1];
		REP(i,m) {
			v[cnt[i]].pb(i+1);
		}
		vector<int> ans;
		for(int i=n;i>=0;i--) {
			if(v[i].size()==0) continue;
			sort(ALL(v[i]));
			for(auto x:v[i]) ans.pb(x);
		}
		REP(i,m) cout<<ans[i]<<(i==m-1?'\n':' ');
	}

	return 0;
}



Measured memory_bytes: 3192
n,m=map(int,input().split())
a,b=[],[]
for i in range(n):
    a.append(list(input()))
for i in range(m):
    b.append(list(input()))
num=n-(m-1)
ok=0 #一致したやつが０
def check(y,x):
    c=1 #一致した
    for i in range(m):
        for j in range(m):
            if a[y+i][x+j]!=b[i][j]:
                c=0
                break
        if c==0:
            break
    return c
for i in range(num):
    for j in range(num):
        #print(str(i)+str(j))
        if check(i,j)==1:
            ok=1
            break
    if ok==1:
        break
            
print("Yes" if ok==1 else "No")

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

int main()
{
	long long a = 0, b = 0, c = 0, d = 0;

	std::cin >> a >> b >> c >> d;
	
	long long answer = std::max({ a * c, a * d, b * c, b * d });

	std::cout << answer << std::endl;
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i=0; i < n; i++)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
const ll INF = 1LL << 60;
//cout << fixed << setprecision(10);

int main(){
    ll n, cnt=0, a, b; cin>>n;
    vector<ll> v(n), p(n), q(n);
    rep(i,n) v[i]=i+1;
    rep(i,n) cin>>p[i];
    rep(i,n) cin>>q[i];
    bool findp=0, findq=0;
    do{
        cnt++;
        if(findp && findq) break;
        if(!findp){
            rep(i,n){
                if(v[i]!=p[i]) break;
                if(i==n-1) findp=1, a=cnt;
            }
        }
        if(!findq){
            rep(i,n){
                if(v[i]!=q[i]) break;
                if(i==n-1) findq=1, b=cnt;
            }
        }
    }while(next_permutation(all(v)));
    cout<<abs(a-b);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	int N;
	cin >> N;

	REP(i, 1, 3500) {
		REP(j, i, 3500) {
			int low = 0;
			int high = 3501;
			int mid = (low + high) / 2;
			while (high - low > 1) {
				int upper = 4 * i * j * mid;
				int lower = (i * j + j * mid + mid * i);
				if (lower * N == upper) {
					cout << i << " " << j << " " << mid << endl;
					return 0;
				}
				if (lower * N < upper) {
					high = mid;
				} else {
					low = mid;
				}
				mid = (low + high) / 2;
			}
		}
	}

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=200000+100;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int n,p[N],pos[N],f[N];

int main()
{
    n=read();
    rep(i,1,n) {p[i]=read();pos[p[i]]=i;}
    rep(i,1,n) f[i]=f[pos[p[i]-1]]+1;
    int ans=0;
    rep(i,1,n) ans=max(ans,f[i]);
    printf("%d",n-ans);
    return 0;
}

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

#define double long double

const int EPS = 1e-9;
int n;
vector<double> A;
double pd[3000][1500];
double dp(int id,int q){
	if(id==n) return 1.0;
	if(fabs(pd[id][q])>EPS)
		return pd[id][q];
	double n_esc = A[id]*dp(id+1,q);
	if(q){
		double esc = (1.0-A[id])*dp(id+1,q-1);
		return pd[id][q]= esc+n_esc;
	}
	return pd[id][q]= n_esc;
}

int32_t main(){
	cin >> n;
	A = vector<double> (n);
	for(auto &a:A) cin >> a;
	int q = (n%2==0)?((n/2)-1):(n/2);
	cout << fixed << setprecision(10) << dp(0,q) << '\n';
	
}

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

int main() {
  int n, x;
  vi m(110);
  cin >> n >> x;
  int sum = 0;
  int min_m = 20000;
  rep(i, n) {
    cin >> m[i];
    sum += m[i];
    if (min_m > m[i]) min_m = m[i];
  }

  int leftovers = x - sum;
  int cnt = 0;
  if (leftovers != 0) {
    while(leftovers >= 0) {
      cnt++;
      leftovers -= min_m;
    }
    cnt--;
  }

  cout << n+cnt << endl;


  return 0;
}

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

void solve() {
  int64_t n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  int64_t ans = (a + d) * 60;
  using Entry = tuple<int64_t, int64_t>;
  priority_queue<Entry, vector<Entry>, greater<Entry>> q;
  unordered_map<int64_t, int64_t> vis;

  auto Add = [&](int64_t dis, int64_t val) {
    if (dis >= ans) return;
    if (vis.count(val) && vis[val] <= dis) return;
    vis[val] = dis;
    q.emplace(dis, val);
    auto tmp = (LLONG_MAX - dis) / d;
    if (val <= tmp)
      ans = min(ans, dis + val * d);
  };

  Add(0, n);
  while (q.size()) {
    auto entry = q.top(); q.pop();
    auto [dis, v] = entry;
    if (dis >= ans) {
      break;
    }
    for (auto x = v - 4; x <= v + 4; ++x) {
      if (x % 2 == 0 && abs(v - x) < 2) {
        Add(dis + abs(v - x) * d + a, x / 2);
      }
      if (x % 3 == 0 && abs(v - x) < 3) {
        Add(dis + abs(v - x) * d + b, x / 3);
      }
      if (x % 5 == 0 && abs(v - x) < 5) {
        Add(dis + abs(v - x) * d + c, x / 5);
      }
    }
  }
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t-->0) solve();
  return 0;
}



Measured memory_bytes: 4168
N = int(input())
A = list(map(int,input().split()))

ans = sum(A)

imin = min(A)-N
imax = max(A)+N

def calcAns(b):
        global A
        return sum([abs(A[i]-(b+i+1)) for i in range(N)])

while True:
        if imin == imax:
                break
        else:
                imid = imin + (imax - imin)//2
                tmp = calcAns(imid)
                if calcAns(imid+1)<tmp:
                        imin = imid+1
                elif calcAns(imid-1)<tmp:
                        imax = imid-1
                else:
                        imin = imid
                        imax = imid

print(calcAns(imin))

Measured memory_bytes: 26180
import java.util.Scanner;

public class Main {

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

        String str =out.nextLine();
        String[] sss=str.split(" ");
        int a= Integer.parseInt(sss[0]);
        int b= Integer.parseInt(sss[1]);
        int c= Integer.parseInt(sss[2]);
        if(a<b&&b<c){
            System.out.println("Yes");
        }else{
            System.out.println("No");

        }




    }
}

Measured memory_bytes: 26024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    vector<ll> l(n);
    for(int i = 0; i < n; ++i)  cin >> l[i];
    int ans = 0;
    for(int i = 0; i < n - 2; ++i){
        for(int j = i + 1; j < n - 1; ++j){
            if(l[i] == l[j])    continue;
            for(int k = j + 1; k < n; ++k){
                if(l[k] == l[i] || l[k] == l[j])    continue;
                if(l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j])  ++ans;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3660
import java.util.Scanner;

class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        double c;
        
        c = a * b / 3.305785;
        
            System.out.printf("%.6f\n",c);
            
        }

        
    }




Measured memory_bytes: 26544
def main():
    H, W = map(int, input().split())
    S = [list(input()) for _ in range(H)]
    dx_dy = [[1, 0], [-1, 0], [0, 1], [0, -1], [1, -1], [1, 1], [-1, -1], [-1, 1]]
    ans = []
    for nx in range(H):
        l = ''
        for ny in range(W):
            if S[nx][ny] == '.':
                cnt = 0
                for i in range(8):
                    x, y = nx + dx_dy[i][0], ny + dx_dy[i][1]
                    if 0  <= x < H and 0 <= y < W:
                        if S[x][y] == '#':
                            cnt += 1
                l += str(cnt)
            else:
                l += '#'
        ans.append(l)
    for a in ans:
        print(a)
                            
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 40560
N = int(input())
l_str = input().split()
L = [0]*N
for i in range(N):
    L[i] = int(l_str[i])

#最長辺を最初に出す
L.sort()
L.reverse()

#最長辺以外の辺の長さの和を求める
sum = 0
for j in range(1,N):
    sum += L[j]

if L[0] < sum:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	ll N;
	scanf("%lld",&N);

	if(N == 0){

		printf("0\n");
		return 0;
	}

	stack<ll> S;

	while(N != 0){

		if(N%2 != 0){
			N--;
			S.push(1);
		}else{

			S.push(0);
		}
		N /= -2;
	}

	while(!S.empty()){

		printf("%lld",S.top());
		S.pop();
	}

	printf("\n");

	return 0;
}


Measured memory_bytes: 3776
# coding: utf-8

def showBuilding(mansion):
    for i, building in enumerate(mansion):
        for line in building:
            for room in line:
                print(' ' + str(room), end='')
            print()
        if i != 3:
            print('####################')

if __name__ == '__main__':
    mansion = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]
    
    for _ in range(int(input())):
        b, f, r, v = map(int, input().split())
        mansion[b-1][f-1][r-1] += v

    showBuilding(mansion)



Measured memory_bytes: 5632
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
string s;
signed main() {
	cin >> s;
	if (s == "AAA" || s == "BBB")puts("No");
	else puts("Yes");
	ggr
}


Measured memory_bytes: 256
from sys import stdin, stdout # only need for big input

MOD = int(1e9+7)

def pow_mod(a , p , m):
    if p < 2:
        ans = 1
        for _ in range(p):
            ans *= a
            if ans >= m:
                ans = ans % m
        return ans
    ans = pow_mod(a , p //2 , m)
    ans = ans * ans

    if ans >= m :
        ans = ans % m
    if p % 2 :
        ans = ans * a 
        if ans >= m :
            ans = ans % m 
    return ans

    

def solve():
    n = int(input())
    A = [int(inp) for inp in input().split()]
    count_1 = [0] * 61 
    pow_2 = [pow_mod(2, i, MOD) for i in range(61)]
    for a in A :
        x = a
        while x :
           for i in range(61):
               if x & 1 :
                   count_1[i] += 1
               x = x >> 1
    # print(count_1)
    # print(pow_2)
    sum = 0
    # print(len(pow_2))
    # print(len(count_1))
    # for a in A:
    #     x = a
    #     while x :
    #         for i in range(61):
    #             # print(i)
    #             if x & 1:
    #                 sum += pow_2[i] * (n - count_1[i])
    #             else:
    #                 sum += pow_2[i] * (count_1[i])

    #             if sum >= MOD:
    #                 sum = sum % MOD
    #             x = x >> 1 
    for i in range(61):
        sum += pow_2[i] * count_1[i] * ( n - count_1[i])
        if sum >= MOD:
            sum = sum % MOD
    # print(sum)
    #sum = (sum * pow_mod(2, MOD - 2, MOD) ) % MOD
    print(sum)


def main():
    solve()


if __name__ == "__main__":
    main()

Measured memory_bytes: 115660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var < (end); var++)
#define RFOR(var, begin, end) for (int var = (begin) - 1; var >= (end); var--)
#define REP(var, length) FOR(var, 0, length)
#define RREP(var, length) RFOR(var, length, 0)
#define SORT(vector) sort(vector.begin(), vector.end())

const ll MOD = 1e9 + 7;

void solve(istream& cin, ostream& cout) {
  string s;
  cin >> s;
  if (s == "Sunny") {
    cout << "Cloudy" << endl;
  } else if (s == "Cloudy") {
    cout << "Rainy" << endl;
  } else {
    cout << "Sunny" << endl;
  }
}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


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

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̕ϐ� (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    vector<int> ans('z' + 1);

    rep(i, n) {
        vector<int> a('z' + 1);
        rep(j, s[i].size()) {
            a[s[i][j]]++;
        }
        for (int j = 'a'; j < 'z' + 1; j++) {
            if (i == 0)
                ans[j] = a[j];
            else
                ans[j] = min(ans[j], a[j]);
        }
    }

    for (char i = 'a'; i <= 'z'; i++) {
        rep(j, ans[i]) {
            cout << i;
        }
    }

    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 3604
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        System.out.println(Math.min(a, b) + " " + Math.max(0, a + b - n));
    }
}

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

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    h.push_back(1e9+7);
    for(int i = 0, l = 0; i < n; i++){
        if(h[i] >= h[i+1]) continue;
        ans = max(ans, i - l);
        l = i + 1;
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
 int n;
 double x1,x2,x3;
 double y1,y2,y3;
 double dx,dy;
 double tx,ty,r;
 double a1,b1,c1,a2,b2,c2;
 
 scanf("%d",&n);
 while(n>0){
  n--;
  scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
  dx=x1;
  dy=y1;
  
  //SÀWðßé
  a1=2*(x2-x1);
  b1=2*(y2-y1);
  a2=2*(x3-x1);
  b2=2*(y3-y1);
  x1*=x1;
  x2*=x2;
  x3*=x3;
  y1*=y1;
  y2*=y2;
  y3*=y3;
  c1=x1-x2+y1-y2;
  c2=x1-x3+y1-y3;
  tx=(b1*c2-b2*c1)/(a1*b2-a2*b1);
  ty=(c1*a2-c2*a1)/(a1*b2-a2*b1);
  
  //¼aðßé
  dx=dx-tx;
  dx*=dx;
  dy=dy-ty;
  dy*=dy;
  r=sqrt(dx+dy);
  
  printf("%.3lf %.3lf %.3lf\n",tx,ty,r);
 }
 
 return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();
    int count = 0;
    for(int i = 0; i < s.length(); i++) {
      if(s.charAt(i) != t.charAt(i)) {
        count++;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 41260
/*----- || Hare Krishna || -----*/

/*  "WHY DO WE FALL, BRUCE?"  */

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define elif else if
#define pb push_back
#define pf push_front
#define PI 3.1415926535897932384
#define MOD 1000000007
using namespace std;

char alpha[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

string s;
int t;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n;
    cin >> n;
    
    ll cnt=0;
    
    for(ll i=1; i<=n; i++){
    	for(ll j=i; i*j<=n ; j++){
    		ll c = n - (i*j);
    		if(c>0){
    			if(i==j)cnt++;
    			else cnt+=2;
			}
		}
	}
	cout << cnt << endl;
    
}


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

int main(){
    ll k;
    cin >> k;

    ll l = 0;
    if(k % 7 == 0){
        l = 9 * k / 7;
    }else{
        l = 9 * k;
    }


    if(l % 2 != 0 && l % 5 != 0 && l % 10 != 0){
        ll ans = 1;
        ll now = 10;
        while(1){
            if(now % l == 1){
                break;
            }
            now = now % l;
            now *= 10;
            ans++;
        }
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }

}

Measured memory_bytes: 3568
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    [as,bs] <- transpose <$> replicateM n getIntList
    let ma = med $ sort as
        mb = med $ sort bs
    print $ mb - ma + 1

med as | odd m = head $ drop (m `div` 2) as
       | even m = sum . take 2 $ drop (m `div` 2 - 1) as 
    where m = length as

Measured memory_bytes: 141796
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;
int N;
int V[20];
int C[20];
int ans = 0;

signed main(void) {
    cin >> N;
    rep(i,N){
        cin >> V[i];
    }
    rep(i,N){
        cin >> C[i];
    }

    rep(i,N){
        int a;
        a = V[i]-C[i];
        if(a>0){
            ans+=a;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define N 2001
#define WHITE 1
#define GRAY -1
#define BLACK 2

int n,A[N][N],pi[N],d[N],color[N],min;

int prim(void){
  int i,u,v,sum=0;

  for(u=0;u<n;u++){
    d[u]=N;
    pi[u]=NULL;
    color[u]=WHITE;
  }

  d[0]=0;

  while(1){
    min=N;
    u=-1;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && d[i]<min){
	min=d[i];
	u=i;
      }
    }

    if(u==-1) break;

    color[u]=BLACK;

    sum+=d[u];

    for(v=0;v<n;v++){
      if(color[v]!=BLACK && A[u][v]<d[v] && A[u][v]>-1){
	pi[v]=u;
	d[v]=A[u][v];
      }
    }
  }

  return sum;
}
int main(){
  int i,j,w;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&A[i][j]);
    }
  }

  w=prim();

  printf("%d\n",w);

  return 0;
}



Measured memory_bytes: 2236
#include<bits/stdc++.h>
#define N 1000005
#define LL long long
using namespace std;
const int mo=998244353;
int n,m,fc[N],xf[N],ans;
LL C(int n,int m){ return 1LL*fc[n]*xf[m]%mo*xf[n-m]%mo;}
LL fpm(LL x,LL y){ LL s=1; while(y){ if(y&1) s=(s*x)%mo; y>>=1,x=(x*x)%mo;} return s;}
int main()
{
	int i;
	scanf("%d %d",&n,&m);
	if(n<m) swap(n,m);
	fc[0]=xf[0]=1;
	for(i=1;i<N;i++) fc[i]=(1LL*fc[i-1]*i)%mo;
	xf[N-1]=fpm(fc[N-1],mo-2);
	for(i=N-2;i>=1;i--) xf[i]=(1LL*xf[i+1]*(i+1))%mo;
	for(i=1;i<=m;i++)
		ans=(ans+C(2*i,i)*C(n+m-2*i,n-i))%mo;
	ans=ans*fpm(2*C(n+m,n)%mo,mo-2)%mo;
	ans=(ans+n)%mo;
	cout<<ans;
	return 0;
}


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

#define reps(i,a,b) for(int i=a; i<b; i++)
#define rep(i,n) reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1e9)

int main(){
  int N,M,Q;
  cin >> N >> M >> Q;
  int x[510][510]={};
  rep(i,M){
    int l,r;
    cin >> l >> r;
    x[l][r]++;
  }

  int sum[510][510]={};
  reps(i,1,N+1){
    reps(j,1,N+1){
      sum[i][j] += sum[i][j-1]+x[i][j];
    }
  }

  rep(i,Q){
    int p,q;
    cin >> p >> q;
    int ans = 0;
    reps(j,p,q+1){
      ans += sum[j][q]-sum[j][p-1];
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 2944
#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O20")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#define iss std::cin
#endif
#include "bits/stdc++.h"
#define rep(i, times) for(ll i = 0; i < (times); ++i)
#define p(x) (cout << x << "\n")
using ll = long long; using ld = long double; using namespace std;

#ifndef __GNUC__
string text =
R"X(19
3141592653589793238)X";
stringstream iss{text};
#endif

const string z9 = "0123456789";
class LuckyPIN{
	ll N{0}, cnt{0};
	string ls;
	void inp( ) {
		iss >> N >> ls;
	}
	void counting( ) {
		for (auto c1 : z9) {
			for (ll a = 0; a < N - 2; ++a) {
				if (c1 == ls[a]) {
					for (auto c2 : z9) {
						for (ll b = a + 1; b < N - 1; ++b) {
							if (c2 == ls[b]) {
								for (auto c3 : z9) {
									for (ll c = b + 1; c < N; ++c) {
										if (c3 == ls[c]) {
											cnt++;
											//cout << c1 << c2 << c3 << "\n";
											break;
										}				
									}
								}
								break;
							}
						}
					}
					break;
				}
			}
		}
	}
public:
	void procedures( ) {
		inp();
		counting( );
		p(cnt);
	}
};

int main( ) {
	cin.tie(0);	ios::sync_with_stdio(0);
	class LuckyPIN a; a.procedures( );
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
const long long inf=0x3f3f3f3f;
const double eps=1e-6;
const long long mod=1000000007;
typedef long long ll;
struct matrix{
	long long n=50,a[55][55]={},k;
	void input(){
		cin>>n>>k;
		for(long long i=0;i<n;i++)
			for(long long j=0;j<n;j++)
				cin>>a[i][j];
	}
	matrix operator*(matrix b){
		matrix ret;
		for(long long i=0;i<n;i++){
			for(long long k=0;k<n;k++){
				for(long long j=0;j<n;j++){
					ret.a[i][j]+=(1ll*a[i][k]*b.a[k][j]%mod);
					ret.a[i][j]%=mod;
				}
			}
		}
		return ret;
	}
	matrix fastpow(matrix x,ll y){
		if(y==1)return x;
		matrix ret=fastpow(x,y/2);
		ret=ret*ret;
		if(y&1)ret=ret*x;
		return ret;
	}
	long long answer(){
		if(k==0)return n;
		matrix mat=fastpow(*this,k);
		ll ans=0;
		for(long long i=0;i<n;i++)
			for(long long j=0;j<n;j++)
				ans=(ll)(ans+mat.a[i][j])%mod,cerr<<mat.a[i][j]<<(j==n-1?'\n':' ');
		return ans%mod;
	}
}graph;
signed main(){
	graph.input();
	cout<<graph.answer()<<endl;
	return 0;
}
/*
10 1000000000000000000
0 0 1 1 0 0 0 1 1 0
0 0 0 0 0 1 1 1 0 0
0 1 0 0 0 1 0 1 0 1
1 1 1 0 1 1 0 1 1 0
0 1 1 1 0 1 0 1 1 1
0 0 0 1 0 0 1 0 1 0
0 0 0 1 1 0 0 1 0 1
1 0 0 0 1 0 1 0 0 0
0 0 0 0 0 1 0 0 0 0
1 0 1 1 1 0 1 1 1 0
*/

Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); ++i)
 
int main(void) {
    string s;
    int K;
    cin >> s >> K;
    rep(i, s.size()) {
        int p = 'z'-s[i]+1;
        if(s[i] != 'a' && K >= p) {
            s[i] = 'a';
            K -= p;
        }
        if(i == s.size()-1 && K>0) {
            s[i] += K%('z'-'a'+1);
            if(s[i] > 'z') s[i]-='z';
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
const long INF = 1L<<60;

int main() {
    int N, K;
    while (cin >> N >> K) {
        if (N == 0) break;
        vector<long> a(N);
        for (int i = 0; i < N; ++i) cin >> a[i];

        vector<int> s(N+1, 0);
        for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];

        long res = -INF;
        for (int i = 0; i <= N-K; ++i) {
            long val = s[K+i] - s[i];
            if (res < val) res = val;
        }
        cout << res << endl;
    }
}


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

int main(){
  long long n,b,ans;
  int a;
  cin >> n;
  for(a=1; a<=pow(n,0.5); a++){
    b=n/a;
    if(a*b==n){
      ans=a+b-2;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. 124A.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP PIC X(10).
01 A   PIC 9(2).
01 B   PIC 9(2).
01 OUT PIC Z9.
*>
PROCEDURE DIVISION.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ' '
      INTO A B.
*>
  EVALUATE TRUE
    WHEN A = B
      COMPUTE OUT = A * 2
    WHEN A > B
      COMPUTE OUT = A * 2 - 1
    WHEN A < B
      COMPUTE OUT = B * 2 - 1
  END-EVALUATE.
*>
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.
 

Measured memory_bytes: 636
#include <stdio.h>

int main(void)
{
	int a[11000],n,i,max,min;
	long long int sum;
	scanf("%d %d",&n,&a[1]);
	max=a[1];
	min=a[1];
	sum=a[1];
	for(i=2;i<=n;i++){
		scanf("%d",&a[i]);
		if(max<a[i]){
			max=a[i];
		}
		if(min>a[i]){
			min=a[i];
		}
		sum=sum+a[i];
	}
	printf("%d %d %lld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 644
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,K=map(int,input().split())
    A=list(map(int,input().split()))
    l=[0]*(len(str(bin(K)))-2)
    for a in A:
        for i in range(len(str(bin(a)))-2):
            if len(l)<=i:
                l.append(0)
            if (a >> i) & 0b1 == 1:
                l[i]+=1
    ans=0
    for j in reversed(range(max(len(l),len(str(bin(a)))-2))):
        if (K >> j) & 0b1 == 1:
            ans+=max(l[j],N-l[j])*(2**j)
        else:
            ans+=l[j]*(2**j)
    for i in range(len(bin(K))-3,0,-1):
        if (K >> i) & 0b1 == 1:
            tmp=0
            f=False
            for j in reversed(range(max(len(l),len(str(bin(a)))-2))):
                if j==i:
                    tmp+=l[j]*(2**j)
                    f=True
                else:
                    if f==True or (K >> j) & 0b1 == 1:
                        tmp+=max(l[j],N-l[j])*(2**j)
                    else:
                        tmp+=l[j]*(2**j)
            ans=max(ans,tmp)
    print(ans)
    
            

if __name__ == '__main__':
    main()


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

signed main()
{
	string s;
	cin >> s;
	int n = s.size();

	int ans = 0, cnt = 0;
	rep(i, 0, n-1){
		if(s[i] == 'B' and s[i+1] == 'C'){
			ans += cnt;	
			i++;
		}else if(s[i] == 'A'){
			cnt++;	
		}else{
			cnt = 0;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);

using namespace std;

pair<int, bool> gr[3][3];

bool bin() {
    if (gr[0][0].second && gr[1][1].second && gr[2][2].second) return true;
    if (gr[0][2].second && gr[1][1].second && gr[2][0].second) return true;
    for (int i = 0; i < 3; ++i) {
        int sum = 0;
        for (int j = 0; j < 3; ++j) {
            sum += gr[i][j].second;
        }
        if (sum == 3) return true;
    }

    for (int i = 0; i < 3; ++i) {
        int sum = 0;
        for (int j = 0; j < 3; ++j) {
            sum += gr[j][i].second;
        }
        if (sum == 3) return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    for (int i = 0; i < 3; ++i) {
        for (int j = 0, a; j < 3; ++j) {
            cin >> a;
            gr[i][j] = {a, false};
        }
    }

    cin >> n;
    for (int i = 0, a; i < n; ++i) {
        cin >> a;
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (gr[j][k].first == a) gr[j][k].second = true;
            }
        }
    }

    bool win = bin();
    cout << (win ? "Yes" : "No") << endl;
    return 0;
}



Measured memory_bytes: 256