akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,w,h) rep(j,h)rep(i,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> a(n);rep(i,n)std::cin >> a[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    string s;
    std::cin >> s;
    if(s=="SUN")std::cout << 7 << std::endl;
    if(s=="MON")std::cout <<  6<< std::endl;
    if(s=="TUE")std::cout << 5 << std::endl;
    if(s=="WED")std::cout << 4 << std::endl;
    if(s=="THU")std::cout <<  3<< std::endl;
    if(s=="FRI")std::cout << 2 << std::endl;
    if(s=="SAT")std::cout <<1  << std::endl;
    
}

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

const ll MAXN = 100;

ll N, ans=0, tmp=0;
vector<ll> A, B, C;

signed main(){
    cin >> N;
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        tmp = max(tmp, a);
        A.push_back(a);
    }
    if(tmp>N) {
        cout << -1 << endl;
        return 0;
    }
    reverse(A.begin(), A.end());
    for(int i=0;i<tmp;i++) {
        B.push_back(A.back());
        A.pop_back();
    }
    while(C.size()!=N) {
        ll flag=0;
        for(int i=tmp-1;i>=0;i--) {            
            if(B[i]==i+1&&flag==0) {
                for(int j=i;j<tmp-1;j++) {
                    B[j] = B[j+1];
                }
                if(!A.empty()) {
                    B[tmp-1] = A.back();
                    A.pop_back();
                }
                else {
                    B[tmp-1] = 0;
                }
                C.push_back(i+1);
                flag=1;
            }
        }
        if(!flag) {
            cout << -1 << endl;
            return 0;
        }
    }
    for(int i=C.size()-1;i>=0;i--) {
        cout << C[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def c_gcd(x, y):
    if y == 0:
        return x
    else:
        return c_gcd(y, x % y)


a, b = map(int, input().split())
c = list(map(int, input().split()))
c.append(b)
c.sort()
d = -1
for i in range(1, len(c)):
    if i == 1:
        d = c[i] - c[i-1]
    else:
        d = c_gcd(c[i] - c[i-1], d)
print(d)


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

using namespace std;

using ll = long long;

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int inf = (int) 1e9;
const int mod = (int) 1e9 + 7;

template<class T>
bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}

template<class T>
bool chmin(T &a, const T &b) {
	if (b < a) {
		a = b;
		return 1;
	}
	return 0;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	ll a[n];
	int pos[n];
	rep(i, n) {
		cin >> a[i];
		pos[a[i] - 1] = i;
	}
	
	set<int> st;
	st.insert(-1);
	st.insert(n);
	
	ll sum = 0;
	rep(i, n) {
		auto iter = st.lower_bound(pos[i]);
		ll right = (*iter) - pos[i];
		iter--;
		ll left = pos[i] - (*iter);
		sum += a[pos[i]] * left * right;
		st.insert(pos[i]);
	}
	
	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 12032
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  string S;
  cin >> N >> S;

  F0R(i, S.size()) {
    S[i] += N;
    if (S[i] > 'Z') S[i] = S[i] - 'Z' - 1 + 'A';
  }

  cout << S;
}
#endif


Measured memory_bytes: 256
import heapq
n, m = map(int, input().split())
a = list(map(lambda x: -int(x), input().split()))
heapq.heapify(a)

if n == 1:
    print(-a[0]//2**m)
    exit()

for _ in range(m):
    heapq.heappush(a, -1*(-heapq.heappop(a)//2))

print(-sum(a))

Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e9
#define EPS 1e-9
#define int long long
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<int, int, hash<int>> ht; // while using, comment #define int long long  */

void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
using namespace std;
#define MAX 3009
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("in5.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int T=1;
    // cin >> T;
    FOR1(tt, T){
        // cout << "Case #" << tt << ": ";
        string n; cin >> n;
        int s = 0;
        for(char ch : n){
            s += ch-'0';
        }
        if(s % 9 == 0) cout << "Yes";
        else cout << "No";
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 3756
//============================================================================
// Name        : template.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <vector>
#include <string.h> // for memset in CF judge.
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

int A() {
    int a , b; string c;
    cin >> a >> c >> b;
    if(c == "+")  cout << a + b;
    else cout << a - b;
return 0;
}
int main() {
    int N; cin >> N;
    int t[N];
    forn(i, N) cin >> t[i];
    int m; cin >> m;
    while(m--) {
        int p, x;
        cin >> p >> x;
        int sum = 0;
        for(int i  = 1; i <= N; i++) {
            if(i==p) sum += x;
            else sum += t[i-1];
        }
        cout << sum << "\n";
    }
    return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
template <class T>
using VVV = V<V<V<T>>>;

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define rep1(i, n) rep1(i, 1, n + 1)

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()  //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    int n;
    cin >> n;
    V<int> s(n), l(n), p(n);
    rep(i, n) cin >> s[i] >> l[i] >> p[i];

    int m;
    cin >> m;

    V<int> dp(401, 0);
    rep(i, n) {
        rep2(j, s[i], l[i] + 1) {
            rep(k, 400) {
                if (k + j > 400) break;
                dp[k + j] = max(dp[k + j], dp[k] + p[i]);
            }
        }
    }
    V<int> ans;
    rep(t, m) {
        int w;
        cin >> w;
        if (dp[w] == 0) {
            cout << -1 << endl;
            return 0;
        }
        ans.push_back(dp[w]);
    }

    for (auto a : ans) {
        cout << a << endl;
    }
    return 0;
}



Measured memory_bytes: 3224
import java.util.*;

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

		int n = sc.nextInt();

		while (n > 0) {
			int count[] = new int[10];

			for (int i = 0; i < n; ++i) {
				int ice = sc.nextInt();
				count[ice]++;
			}

			for (int ice = 0; ice < 10; ++ice) {
				if (count[ice] == 0) {
					System.out.println("-");
				} else {
					for (int j = 0; j < count[ice]; ++j) {
						System.out.print("*");
					}
					System.out.println();
				}
			}

			n = sc.nextInt();
		}
	}
}



Measured memory_bytes: 62180
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main()
{
    int A, B;
    cin >> A >> B;
    if(1<=A&&A<=9&&1<=B&&B<=9)
        cout << A * B << endl;
    else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue
#include <map>
#include <set> //multiset set<int,greater<int>>大到小
#include <vector>// vector<int>().swap(v);清空释放内存
#include <stack>
#include <cmath> // auto &Name : STLName  Name.
#include <utility>
#include <sstream>
#include <string>//__builtin_popcount(ans);//获取某个数二进制位1的个数
#define mod 1000000007
#define mod9 998244353
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
typedef long double ld;
const db eps=1e-10;
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
#define rep(i,be,en) for (int i=be;i<=en;i++)
#define per(i,be,en) for (int i=en;i>=be;i--)
using namespace std;
const int N=1e6+7;

int t,n,m,k=0,fl=0;
db a;
int main(){
    scanf("%lf",&a);
    printf("%.3lf\n",2*3.1415*a);

    return 0;
}

Measured memory_bytes: 3232
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {
	
	string p;
	cin >> p;
	bool a = 0, b = 0, c=0;
	for (int i = 0; i < p.size(); i++) {
		if (p[i] == 'a')a++;
		if (p[i] == 'b')b++;
		if (p[i] == 'c')c++;

	}
	if (a&&b&&c)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;
#define FIN freopen("in.txt", "r", stdin);

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a, b, c;
    cin >> a >> b >> c;
    ll ans;
    if(a == 0) 
    ans = b/c + 1;
    if(a > 0) 
    {
        a--;
        ans = (b/c) - (a/c);
    }
    cout << ans  << endl;
}

Measured memory_bytes: 256
type SortDataType=Longint;
function SortCmp(const a,b:SortDataType):Boolean;forward;
procedure SortImpl(var A:Array of SortDataType;L,R:Longint);
var
	tmp:SortDataType;
	mid,il,ir:Longint;
begin
	if R-L<20 then begin
		for ir:=R-1 downto L+1 do for il:=L to ir-1 do if SortCmp(A[il+1],A[il])then begin
			tmp:=A[il];
			A[il]:=A[il+1];
			A[il+1]:=tmp;
		end;
	end else begin
		mid:=(L+R)div 2;
		if SortCmp(A[mid],A[L])then begin
			tmp:=A[mid];
			A[mid]:=A[L];
			A[L]:=tmp;
		end;
		if SortCmp(A[R-1],A[mid])then begin
			tmp:=A[R-1];
			A[R-1]:=A[mid];
			A[mid]:=tmp;
			if SortCmp(A[mid],A[L])then begin
				tmp:=A[mid];
				A[mid]:=A[L];
				A[L]:=tmp;
			end;
		end;
		il:=L;
		ir:=R-1;
		while il<=ir do begin
			while SortCmp(A[il],A[mid])do inc(il);
			while SortCmp(A[mid],A[ir])do dec(ir);
			if il<ir then begin
				tmp:=A[il];
				A[il]:=A[ir];
				A[ir]:=tmp;
				if mid=il then mid:=ir else if mid=ir then mid:=il;
				inc(il);
				dec(ir);
			end else if il=ir then begin
				inc(il);
				dec(ir);
			end;
		end;
		SortImpl(A,L,il);
		SortImpl(A,il,R);
	end;
end;
procedure Sort(var A:Array of SortDataType;size:Longint);
begin
	SortImpl(A,0,size);
end;
function SortCmp(const a,b:SortDataType):Boolean;
begin
	SortCmp:=a>b;
end;
var
	X,Y,A,B,C,i:Longint;
	p,q,r:Array[1..100000]of Longint;
	s:Array[1..300000]of Longint;
	ans:int64;
begin
	read(X,Y,A,B,C);
	for i:=1 to A do read(p[i]);
	for i:=1 to B do read(q[i]);
	for i:=1 to C do read(r[i]);
	Sort(p,A);
	Sort(q,B);
	for i:=1 to X do s[i]:=p[i];
	for i:=1 to Y do s[X+i]:=q[i];
	for i:=1 to C do s[X+Y+i]:=r[i];
	Sort(s,X+Y+C);
	for i:=1 to X+Y do inc(ans,s[i]);
	writeln(ans);
end.


Measured memory_bytes: 2304
#include<iostream>

using namespace std;

int main(){
  int N,M,P;
  cin>>N>>M>>P;
  int u[123],v[123];
  for(int i=0;i<M;i++){
    cin>>u[i]>>v[i];
    u[i]--;
    v[i]--;
  }
  double dp[1<<14]={0,1};
  for(int i=2;i<1<<N;i++){
    if(!(i&1))continue;
    dp[i]=1;
    for(int j=1;j<i;j=(j+1+~i)&i){
      double d=dp[j];
      for(int k=0;k<M;k++){
	if(i>>u[k]&1&&i>>v[k]&1&&j>>u[k]&1^j>>v[k]&1){
	  d*=P/100.;
	}
      }
      dp[i]-=d;
    }
  }
  cout.precision(9);
  cout<<fixed<<dp[(1<<N)-1]<<endl;
}

Measured memory_bytes: 1372
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};

int mod_pow(int x, int n, int mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % mod;
		x = 1LL * x * x % mod;
		n >>= 1;
	}
	return res;
}

typedef vector<vector<Edge>> Graph;

signed main(void) {

	int m, d;
	cin >> m >> d;
	int cou = 0;

	rep(i,1, m + 1) {
		rep(j,1, d + 1) {
			if ((j%10) >= 2 && (j/10) >= 2 && (j % 10) * (j / 10) == i) {
				cou++;
			}
		}
	}
	cout << cou << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	string a;
	cin>>a;
	int b=0;
	fo(i,a.sz-1){
		if(a[i]=='A'&&a[i+1]=='C')
			b=1;
	}
	if(b)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
time = 0

if A != B:
    if A < 0:
        time += C * (-A)
        time += D
        time += E * B
    if A == 0:
        time += D
        time += E * B
    if A > 0:
        time += E * (B - A)
elif A == B:
    time = B

print(time)

Measured memory_bytes: 7696
ss=input()
k=int(input())
s=[int(i) for i in ss ]
#ls=len(s)
j=0
q=0
w=0
while q==0:
    if s[j]==1:
        w+=1
        if k<=w:
            print(1)
            q=1
        j+=1
    else:
        print(s[j])
        q=1

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  set<string> a;
  rep(i,0,n){
    string s;
    cin>>s;
    a.insert(s);
  }
  cout<<a.size()<<endl;
}

Measured memory_bytes: 19120
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int a, b;
	cin >> a >> b;
	cout << a * b << " " << (2 * a) + (2 * b) << endl;
}




Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
int n;
int a[109];
bool rsn(int h){
	bool f=0;
	for(int i=0;i<n;i++){
		if(a[i]==h){
			f=1;
		}
	}
	return f;
}
int main() {
	int x;
	cin>>x>>n;
	for(int i=0;i<n*2;i++){
		cin>>a[i];
	}
	int k=x;
	while(1){
		if(!rsn(k))break;
		k--;
	}
	int l=x;
	while(1){
		if(!rsn(l))break;
		l++;
	}
	if((x-k)<=(l-x))
	cout<<k;
	if((x-k)>(l-x))
	cout<<l;
	return 0;
}

Measured memory_bytes: 3556
def main():
  N, K, Q = map(lambda i: int(i), input().split(' '))
  points = [K] * N
  for q in range(Q):
    A = int(input())
    points[A - 1] += 1
  for point in points:
    if point - Q <= 0:
      print('No')
    else:
      print('Yes')

main()


Measured memory_bytes: 6532
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N, K; cin >> N >> K;
	vector<int>V(N); rep(i, 0, N) { cin >> V[i]; }

	int ans = 0;
	for (int x = 0; x <= min(K, N); x++) {
		for (int y = 0; x + y <= min(N, K); y++) {
			vector<int>w, v;
			int sum = 0;
			int k = K;
			rep(i, 0, x) {
				sum += V[i];
				if (V[i] < 0) {
					w.eb(V[i]);
				}
				else {
					v.eb(V[i]);
				}
				k--;
			}
			rep(i, 0, min(K - x, y)) {
				sum += V[N - 1 - i];
				if (V[N - 1 - i] < 0) {
					w.eb(V[N - 1 - i]);
				}
				else {
					v.eb(V[N - 1 - i]);
				}
				k--;
			}
			sort(all(w));
			rep(i, 0, min(k, (int)w.size())) {
				sum -= w[i];
			}
			dump(x, y, sum, k, v, w, sum);
			chmax(ans, sum);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

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

int main() {
	string S;
	int K;
	cin>>S>>K;
	int N = S.size();
	vector<string> vs;
	for (int i = 0; i < N; ++i){
		for (int j = 0; i+j <= N&& j <=K; ++j){
			vs.push_back(S.substr(i,j));
		}
	}

	set<string> ss(all(vs));
	vector<string> vs2(all(ss));
	sort(all(vs2));
	cout<<vs2[K]<<endl;
}


Measured memory_bytes: 2428
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;

ll g[205][205];
int n, m, r;
int l[10];
ll dp[10][1<<10];

void solve() {
  cin >> n >> m >> r;
  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= n; j++) {
      g[i][j] = 1e18;
    }
    g[i][i] = 0;
  }
  for(int i = 0; i < r; i++) cin >> l[i];
  while(m--) {
    int a, b;
    ll c;
    cin >> a >> b >> c;
    g[a][b] = min(g[a][b], c);
    g[b][a] = min(g[b][a], c);
  }
  for(int k = 1; k <= n; k++) for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
  for(int i = 0; i < r; i++) for(int j = 0; j < (1<<r); j++) dp[i][j] = 1e18;
  for(int i = 0; i < r; i++) dp[i][1<<i] = 0;
  for(int mask = 1; mask < (1<<r); mask++) {
    for(int i = 0; i < r; i++) {
      for(int j = 0; j < r; j++) {
        dp[j][mask | (1<<j)] = min(dp[j][mask | (1<<j)], dp[i][mask] + g[l[i]][l[j]]);
      }
    }
  }
  ll ret = 1e18;
  for(int i = 0; i < r; i++) ret = min(ret, dp[i][(1<<r)-1]);
  cout << ret << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
  solve();
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int A, B; cin >> A >> B;
  string s; cin >> s;

  int res = true;
  if (s.size() != A+B+1) {
    res = false;
  }
  for (int i = 0; i < s.size(); ++i) {
    if (i < A) {
      int c = s[i] - '0';
      if (c < 0 || c > 9) {
        res = false;
      }
    } else if (i == A) {
      if (s[i] != '-') {
        res = false;
      }
    } else {
      int c = s[i] - '0';
      if (c < 0 || c > 9) {
        res = false;
      }
    }
  }
  auto ans = res ? "Yes" : "No";
  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  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 Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



int main(){
    int n;
    cin >> n;
    V<int> l(n);
    rep(i,n) cin >> l[i];
    int ans = 0;
    rep(i,n)rep(j,n)rep(k,n) {
        if(i == j || j == k || k == i) continue;
        if(l[i] < l[j] && l[j] < l[k]) {
            int sum = l[i] + l[j] + l[k];
            if(sum-max({l[i],l[j],l[k]}) > max({l[i],l[j],l[k]}))
                ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<cstring>
using namespace std;
#define MAXN 100000
int n,m;
struct node
{
	int num,cl;
}box[MAXN+5];
int read()
{
	int x=0,f=1;
	char c=getchar();
	while('0'>c||c>'9'){if(c=='-') f=-1;c=getchar();}
	while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
int main()
{
	n=read(),m=read();
	box[1].cl=1;
	for(int i=1;i<=n;i++)
		box[i].num=1;
	for(int i=1;i<=m;i++)
	{
		int f=read();
		int t=read();
		if(box[f].cl==1)
		{
			if(box[f].num>1)
			{
				box[f].num--;
				box[t].cl=1;
				box[t].num++;
			}
			else 
			{
				box[f].num--;
				box[f].cl=0;
				box[t].cl=1;
				box[t].num++;
			}
		}
		else 
		{
			box[f].num--;
			box[t].num++;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	if(box[i].cl)
	{
		ans++;
	}
	printf("%d",ans);
}


Measured memory_bytes: 896
import sys

# utils
def read_numbers():
    return [int(num) for num in sys.stdin.readline().split()]
def read_string():
    return sys.stdin.readline().rstrip('\r\n')
def list2str(*array):
    return ' '.join([str(i) for i in array])

def main(nums):
    A, B, C, D, E, F = nums
    def density(sugar, water):
        if sugar + water == 0:
            return 0.0
        return sugar / (sugar + water)
    cache = {}
    def recurse(sugar, water):
        if (sugar, water) in cache:
            return cache[(sugar, water)]
        if sugar + water > F:
            return (0.0, 0, 0)
        if density(sugar, water) > density(E, 100):
            return (0.0, 0, 0)
        result = max(
            (density(sugar, water), sugar, water),
            recurse(sugar, water+100*A),
            recurse(sugar, water+100*B),
            recurse(sugar+C, water),
            recurse(sugar+D, water),
        )
        cache[(sugar, water)] = result
        return result
    dens, sugar, water = recurse(0,0)
    return "%d %d" % (sugar+water, sugar)




def parse_stdin():
    # N = read_numbers()
    # data = []
    # for i in range(N):
    #    data.append(read_numbers())
    nums = read_numbers()
    return nums

def test_main():
    """run pytest stdin.py to test"""
    assert main([17, 19, 22, 26, 55, 2802]) == "2634 934"

if __name__ == '__main__':
    nums = parse_stdin()
    result = main(nums)
    print(result)

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<utility>
using namespace std;

int h, w;
vector<string>a0, a1;
string black, wthite;
queue<pair<int, int>> memo;
int dx[4] = { -1, 1, 0, 0 };
int dy[4] = { 0, 0,-1, 1 };

void wTob(int x, int y) {
	for (int i = 0; i < 4; i++) {
		int nx = x + dx[i];
		int ny = y + dy[i];
		if (0 <= nx && nx < w && 0 <= ny && ny < h && a1[ny][nx] == '.') {
			a1[ny][nx] = '#';
			memo.emplace(ny, nx);
		}
	}
	return;
}

int main(void) {
	cin >> h >> w;
	black = string(w, '#');
	a0 = vector<string>(h);
	for (int i = 0; i < h; i++) {
		cin >> a0[i];
		for (int j = 0; j < w; j++) {
			if (a0[i][j] == '#')
				memo.emplace(i, j);
		}
	}

	a1 = a0;
	int ret = -1;
	pair<int, int> tmp;
	while (!memo.empty()) {
		cout << endl;
		int size = memo.size();
		for (int i = 0; i < size; i++) {
			tmp = memo.front();
			wTob(tmp.second, tmp.first);
			memo.pop();
		}
		ret++;
		a0 = a1;
	}

	cout << ret << endl;
	return 0;
}


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

int res = 0;
int n, s;

void solve(int p, int sum, int q)
{
	if(p == n && sum == s){
		res++;
		return;
	}

	if(sum > s) return;

	for(int i=q; i<10; i++)
		solve(p+1, sum+i, i+1);
}

int main(void)
{
	while(cin >> n >> s)
	{
		if(n==0 && s==0) break;

		solve(0, 0, 0);

		cout << res << endl;
		res = 0;
	}
	return 0;
}

Measured memory_bytes: 0
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void solve() {
		double[] fact = new double[9];
		fact[1]=1;
		for(int i=2;i<=8;i++) {
			fact[i]=fact[i-1]*i;
		}
		int n=s.nextInt();
		x=new double[n];
		y = new double[n];
		visited=new boolean[n];
		for(int i = 0;i<n;i++) {
			x[i]=s.nextDouble();
			y[i]=s.nextDouble();
		}
		for(int i=0;i<n;i++) {
			visited[i]=true;
			Possible_Paths(x[i], y[i], 1, 0.0);
			visited[i]=false;
		}
		out.println(sum/fact[n]);
	}
	
	public static double sum = 0;
	public static double[] x;
	public static double[] y;
	public static boolean[] visited;
	
	
	public static void Possible_Paths(double curr_x,double curr_y,int used,double distance) {
		int n = x.length;
		if(used == n-1) {
			double n_x=0 ,n_y=0;
			for(int i=0;i<n;i++) {
				if(!visited[i]) {
					n_x = x[i];
					n_y = y[i];
				}
			}
			double temp = Math.sqrt((curr_x-n_x)*(curr_x-n_x) + (curr_y-n_y) * (curr_y-n_y));
			sum += distance+temp;
			return;
		}
		double n_x=0 ,n_y=0;
		for(int i=0;i<n;i++) {
			if(!visited[i]) {
				n_x = x[i];
				n_y = y[i];
				visited[i]=true;
				double temp = Math.sqrt((curr_x-n_x)*(curr_x-n_x) + (curr_y-n_y) * (curr_y-n_y));
				Possible_Paths(n_x,n_y,used+1,distance+temp);
				visited[i]=false;
			}
		}
	}
	
	public static void main(String[] args) {
		out = new PrintWriter(new BufferedOutputStream(System.out));
		s = new FastReader();
		solve();
		out.close();
	}

	public static FastReader s;
	public static PrintWriter out;

	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	
}


Measured memory_bytes: 22068
#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{
    int n = 0;
    int q = 0;
    cin >> n;
    
    int s[n];
    for (int i = 0; i < n; i++) {
        scanf("%d",&s[i]);
    }
    cin >> q;
    int t[q];
    for (int i = 0; i < q; i++) {
        scanf("%d",&t[i]);
    }
    int sum = 0;
    for (int i = 0; i < q; i++) {
        for (int j = 0; j < n; j++) {
            if (s[j] == t[i]) {
                sum++;
                break;
            }
        }
    }
    printf("%d\n",sum);
    return 0;
}

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

#define ll long long
using namespace std;

struct Line {
    mutable ll k, m, p;
    bool operator<(const Line &o) const { return k < o.k; }
    bool operator<(ll x) const { return p < x; }
};

struct LineContainer : multiset<Line, less<>> {
    const ll inf = LLONG_MAX;
    ll div(ll a, ll b) {
        return a / b - ((a ^ b) < 0 && a % b);
    }
    bool isect(iterator x, iterator y) {
        if(y == end()) { x->p = inf; return false; }
        if(x->k == y->k) x->p = x->m > y->m ? inf : -inf;
        else x->p = div(y->m - x->m, x->k - y->k);
        return x->p >= y->p;
    }
    void add(ll k, ll m) {
        auto z = insert({k, m, 0}), y = z++, x = y;
        while(isect(y, z)) z = erase(z);
        if(x != begin() && isect(--x, y)) isect(x, y = erase(y));
        while((y = x) != begin() && (--x)->p  >= y->p)
            isect(x, erase(y));
    }
    ll query(ll x) {
        if(empty()) return LLONG_MIN;
        auto l = *lower_bound(x);
        return l.k * x + l.m;
    }
};

const int N = 2e5 + 5;
int n;
ll c, h[N], dp[N];
LineContainer l;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> c;
    for(int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    l.add(2 * h[1], -h[1] * h[1]);
    for(int i = 2; i <= n; i++) {
        dp[i] = c + h[i] * h[i] - l.query(h[i]);
        l.add(2 * h[i], -h[i] * h[i] - dp[i]);
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 15872
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int q,a,b,c,d,len;
bool check(int cnta)
{
	int cntb=(cnta-1)/len;
	if((b-cntb)>1ll*(a-cnta+1)*len)return 0;
	return 1;
}
int main()
{
	scanf("%d",&q);
	while(q--)
	{
		scanf("%d %d %d %d",&a,&b,&c,&d);
		len=a>b?(a+b)/(b+1):(a+b)/(a+1);
		int l=0,r=a,mid;
		while(l<r)
		{
			mid=l+r+1>>1;
			if(check(mid))l=mid;
			else r=mid-1;
		}
		int p=l/len*(len+1)+l%len;
		for(int i=c;i<=d;++i)
		{
			if(i<=p)
			{
				if(i%(len+1)==0)putchar('B');
				else putchar('A');
			}
			else
			{
				if((a+b-i+1)%(len+1)==0)putchar('A');
				else putchar('B');
			}
		}
		putchar('\n');
	/*	for(int i=1;i<=a+b;++i)
		{
			if(check(cnta,cntb,lcnt,lst,len))
			{
				++cnta;
				if(lst==0)++lcnt;
				else lst=0,lcnt=1;
				if(i>=c&&i<=d)putchar('A');
			}
			else
			{
				++cntb;
				if(lst==1)++lcnt;
				else lst=1,lcnt=1;
				if(i>=c&&i<=d)putchar('B');
			}
		}
		putchar('\n');*/
	}
	return 0;
}


Measured memory_bytes: 256
def SCC_Tarjan(g):
    n = len(g)
    order = [-1]*n # 負なら未処理、[0,n) ならpre-order, n ならvisited
    low = [0]*n
    ord_now = 0
    parent = [-1]*n
    gp = [0]*n
    gp_num = 0
    S = []
    q = []
    for i in range(n):
        if order[i] == -1:
            q.append(i)
            while q:
                v = q.pop()
                if v >= 0:
                    if order[v] != -1: continue
                    order[v] = low[v] = ord_now
                    ord_now += 1
                    S.append(v)
                    q.append(~v)
                    for c in g[v]:
                        if order[c] == -1: 
                            q.append(c)
                            parent[c] = v
                        else:
                            low[v] = min(low[v], order[c])
                else:
                    v = ~v
                    if parent[v] != -1:
                        low[parent[v]] = min(low[parent[v]], low[v])
                    if low[v] == order[v]:
                        while True:
                            w = S.pop()
                            order[w] = n
                            gp[w] = gp_num
                            if w==v: break
                        gp_num += 1


    scc = [[] for _ in range(gp_num)]
    for i in range(n):
        gp[i] = gp_num-gp[i]-1
        scc[gp[i]].append(i)
    
    #print(gp)
    return scc

###########################################################################                        
###########################################################################                        

# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,m = [int(i) for i in readline().split()]

g = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int, readline().split())
    g[a].append(b)

scc = SCC_Tarjan(g)
print(len(scc))
for lst in scc:
    print(*([len(lst)]+lst))



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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



int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int a,p;
    cin>>a>>p;
    p += a*3;
    cout << p/2 << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
using namespace std;
const int N = 2e5 + 500, INF = 1e9 + 500;
int dp[N], a[N], n, k;
int main(){
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 2; i <= n; i++){
		dp[i] = INF;
		for(int j = max(i - k, 1); j < i; j++){
			dp[i] = min(dp[i], dp[j] + abs(a[j] - a[i]));
		}
	}
	cout << dp[n] << endl;
}

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

using ll = long long;
#define pb push_back
#define f first
#define s second
int dp[1000000];
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
        dp[i] = 1e9;
    }
    
    dp[0] = 0;
    for(int i = 0; i < n-1; i++){
        if(i!=n-2)
        dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]));
        dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]));
    }
    cout << dp[n-1];
}

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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

//const int INF=1e9;
const double INF=1e100;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int n;cin>>n && n;){
		vi a(n);
		rep(i,n) cin>>a[i];
		
		vvd dp(n+1,vd(200000,INF));
		dp[0][1]=0;
		rep(i,n) repi(j,1,dp[i].size())
			for(int k=j;k<dp[i].size();k+=j)
				dp[i+1][k]=min(dp[i+1][k],max(dp[i][j],1.*abs(k-a[i])/a[i]));
		printf("%.12f\n",*min_element(all(dp[n])));
	}
}

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

using namespace std;

typedef long long ll;

int main() {
  int n;
  cin>>n;
  vector<int> w(n + 1,0),sums(n + 1, 0);
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    cin>>w[i];
    sums[i] = w[i] + sums[i - 1];
    sum += w[i];
  }
  int ans = 1e5 + 1;
  for (int i = 1; i <= n; i++) {
    int tmp = sum - sums[i];
    int res = abs(sums[i] - tmp);
    ans = min(ans, res);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
// input: 'A　B'
const inputList = input.split(' '); // 空白文字に注意
const inputNumberList = inputList.map(Number);
const a = inputNumberList[0];
const b = inputNumberList[1];
const c = inputNumberList[2];
const d = inputNumberList[3];

if (a <= c &&  d <= b) {
  console.log(d - c);
} else if (a <= c && c <= b && b <= d) {
  console.log(b - c);
} else if (c <= a && a <= d && d <= b) {
  console.log(d-a);
} else if (c <= a && b <= d) {
  console.log(b - a);
} else {
  console.log(0);
}

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main(){
  int a,b;
  cin >> a >> b;
  cout << max({a+b,2*a-1,2*b-1}) << endl;


  return 0;
}


Measured memory_bytes: 256