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

typedef int64_t s64;

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int dp[2][101][256];
int main() {
	int n = ri();
	int k = ri();
	int a[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	
	dp[0][0][0] = 1;
	dp[0][1][a[0]] = 1;
	for (int i = 0; i < n - 1; i++) {
		memset(dp[(i+1)%2], 0x00, sizeof(int) * 101 * 256);
		for (int j = 0; j <= n; j++) {
			for (int k = 0; k < 256; k++) {
				dp[i%2^1][j][k] += dp[i%2][j][k];
				if (dp[i&1^1][j][k] >= 1000000007)
					dp[i&1^1][j][k] -= 1000000007;
				dp[i&1^1][j+1][k^a[i+1]] += dp[i%2][j][k];
				if (dp[i&1^1][j+1][k^a[i+1]] >= 1000000007)
					dp[i&1^1][j+1][k^a[i+1]] -= 1000000007;
			}
		}
	}
	int fact[101];
	fact[1] = 1;
	for (int i = 2; i <= 100; i++) fact[i] = fact[i-1] * ((s64)i) % 1000000007;
	int res = 0;
	for (int i = 1; i <= 100; i++) {
		res = (res + ((s64)dp[n&1^1][i][k]) * fact[i]) % 1000000007;
	}
	std::cout << res << std::endl;
		
	return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3");
            WillReturn.Add("3 1 4");
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("5");
            WillReturn.Add("1 1 1 1 1");
            //5
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("6");
            WillReturn.Add("40 1 30 2 7 20");
            //4
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        long[] AArr = InputList[1].Split(' ').Select(X => long.Parse(X)).ToArray();
        Array.Sort(AArr);

        long Ruisekiwa = 0;
        bool HasBundan = false;
        int BundanInd = 0;
        for (int I = 0; I <= AArr.GetUpperBound(0) - 1; I++) {
            Ruisekiwa += AArr[I];

            if (Ruisekiwa * 2 < AArr[I + 1]) {
                HasBundan = true;
                BundanInd = I;
            }
        }
        if (HasBundan) Console.WriteLine(AArr.Length - BundanInd - 1);
        else Console.WriteLine(AArr.Length);
    }
}


Measured memory_bytes: 33628
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
for i in range(n):
    if i == 0:
        ans += b[a[0]-1]
    else:
        if a[i-1] + 1 == a[i]:
            ans += b[a[i]-1] + c[a[i]-2]
        else:
            ans += b[a[i]-1]
print(ans)

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

int main(){
  int n;
  cin >>n;
  vector<int> a(n);
  rep(i,n) cin >>a[i];
  vector<int> ans(n);
  rep(i,n) ans[a[i]-1] = i+1;
  rep(i,n) cout << ans[i] << " ";
  cout << endl;
  return 0;
}

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

void dfs(int group_num, int now, vector<vector<int>> &fr, vector<int> &group){
    /*深さ有線探索
    group_num:見る頂点のグループ番号
    now:見る頂点の頂点番号
    fr:友人関係のグラフの隣接リスト表現
    group:頂点のグループ番号を格納した配列
    */
    group.at(now) = group_num;
    for(auto p : fr.at(now)){
        //nowと友人関係にある頂点を探索
        if(group.at(p) == -1){
            //まだグループ分けされていない
            dfs(group_num, p, fr,group);
        }
    }
    return;
}

int main(){
    int n,m,k;
    cin >> n>>m>>k;
    /*
    fr:友人関係のグラフの隣接リスト表現
    fr_num:それぞれの人の友人の数
    bl:ブロック関係をまとめた配列
    */
    vector<vector<int>> fr(n);
    vector<int> fr_num(n,0);
    vector<pair<int, int>> bl(k);
    for(int i=0; i<m; i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        fr.at(a).push_back(b);
        fr.at(b).push_back(a);
        fr_num.at(a)++;
        fr_num.at(b)++;
    }
    for(int i=0; i<k; i++){
        int c,d;
        cin >> c >> d;
        c--;
        d--;
        pair<int, int> p;
        p.first=c;
        p.second=d;
        bl.at(i) = p; 
    }
    // group: 各頂点のグループ番号を格納する配列。-1で初期化
    vector<int> group(n,-1);
    for(int i=0; i<n; i++){
        if(group.at(i) == -1){
            dfs(i, i, fr, group);
        }
    }
    // group_num:各グループにいくつの頂点が含まれているか
    vector<int> group_num(n,0);
    for(int i=0; i<n; i++){
        group_num.at(group.at(i))++;
    }
    // ans:答えを格納する配列
    vector<int> ans(n);
    for(int i=0; i<n; i++){
        //自分のグループの要素数　-　すでに友達の人数　- 自分
        ans.at(i) = group_num.at(group.at(i))- fr_num.at(i) - 1;
    }

    for(int i=0; i<k; i++){
        int c,d;
        //ブロック関係にあるけど同じグループの人を引く。
        c = bl.at(i).first;
        d = bl.at(i).second;
        if(group.at(c) == group.at(d)){
            ans.at(c)--;
            ans.at(d)--;
        }
    }
    for(int i=0; i<n; i++){
        cout << ans.at(i) << ' ';
    }
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

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

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) ++res[i], n /= i;
  }
  if (n != 1) res[n] = 1;
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  auto v=divisor(m);
  ll ans=0;
  for(auto e: v){
    if(n*e<=m){
      chmax(ans,e);
    }
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 256
//#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};

int main(){
    int r; cin >> r;
    cout << 2 * r * acos(-1) << endl;
    return 0;
}

Measured memory_bytes: 3776
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <functional>

#define ll long long int
#define loop(a, n) for(int a = 0; a < n; ++a)
#define INF 114514//1919810
#define OUT std::cout
#define IN std::cin
#define itn int
#define fro for
#define sdt std

#define MAX_D 1234
#define MAX_N 12345

ll N, C;
ll s, t, c;

ll Data[6234567] = { 0 };
bool video[50][6234567];
int main()
{

	IN >> N >> C;

	for(ll a = 0; a < N; ++a)
	{
		IN >> s >> t >> c;

		for (ll b = s * 4 - 2; b < t * 4; ++b)
		{
			if (video[c - 1][b] == false)
			{
				Data[b]++;
				if (b != t - 1)
					video[c - 1][b] = true;
			}
		}

	}
	ll ans = 0;

	loop(a, 6234567)
	{
		ans = std::max(ans, Data[a]);
	}

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 80512
#include <iostream>

int main(){
    int a, b, c;
    std::cin >> a >> b >> c;

    std::string ans = "No";
    if((a == b && a != c)|| (b == c && b != a)|| (c == a && c != b)){
        ans = "Yes";
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<map>
#define sqr(x) (x)*(x)
using namespace std;
int n,m,i,j,vis[15],vis2[15];
string st[15],st2[15],st3[15];
void check()
{
//	for (i=1;i<=n;i++) cerr<<st2[i]<<endl;
//	cerr<<endl;
	int i,j;
	for (i=1;i<=m;i++) st3[i]="";
	for (i=1;i<=m;i++)
	{
		for (j=1;j<=n;j++)
		{
			st3[i].push_back(st2[j][i-1]);
		}
	}
	memset(vis2,0,sizeof(vis2));
	for (i=1;i<=m;i++)
	{
		for (j=1;j<=m;j++)
		{
			if (vis2[j]) continue;
			if (i==j) continue;
			string t=st3[j];
			reverse(t.begin(),t.end());
			/*cerr<<st[i]<<endl;
			cerr<<t<<endl;*/
			if (st3[i]==t)
			{
				vis2[j]=1;
				break;
			}
		}
	}
	int cnt=0;
	for (i=1;i<=m;i++)
	{
		if (!vis2[i])
		{
			cnt++;
			string t=st3[i];
			reverse(t.begin(),t.end());
			if (st3[i]!=t) return;
		}
	}
	if (cnt>1) return;
	cout<<"YES";
	exit(0);
}
void dfs(int x,int y)
{
	if (x<=n) dfs(x+1,y);
	if (vis[x])
	{
		return;
	}
	if (x>n)
	{
		if (n%2==1&&y==(n+1)/2)
		{
			int cnt=0;
			for (i=1;i<=n;i++)
			{
				if (!vis[i])
				{
					cnt++;
					st2[y]=st[i];
				}
			}
			if (cnt<2) check();
		}
		if (y==(n+1)/2+1) check();
		return;
	}
	int i;
	for (i=x+1;i<=n;i++)
	{
		if (vis[i]) continue;
		st2[y]=st[x];
		st2[n-y+1]=st[i];
		vis[x]=1;
		vis[i]=1;
		dfs(x+1,y+1);
		vis[i]=0;
		vis[x]=0;
	}
	if (n%2==1&&y==(n+1)/2)
	{
		int cnt=0;
		for (i=1;i<=n;i++)
		{
			if (!vis[i])
			{
				cnt++;
				st2[y]=st[i];
			}
		}
		if (cnt<2) check();
	}
	vis[x]=0;
}
int main()
{
	cin>>n>>m;
	for (i=1;i<=n;i++) cin>>st[i];
	dfs(1,1);
	cout<<"NO";
	return 0;
}


Measured memory_bytes: 384
X = int(input())
if X >= 100*101:
  print(1)
else:
  N1 = X//105
  N2 = X//100
  ans = 0
  for n in range(N1, N2 + 1):
    if (X >= 100*n)&(X <= 105*n):
      ans = 1
  print(ans)

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

int main(){
	ll x, count=0, mo=100;
	
	cin >> x;
	
	for(int i=0; mo<x; i++){
	    mo+=mo*0.01;
	    count++;
	}
	cout << count << endl;
	
	return 0;
}

Measured memory_bytes: 3652
n = int(input())

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0

for i in range(n):
    ans += b[a[i]-1]
    if i == 0: 
        continue
    if a[i] - a[i-1] == 1:
        ans += c[a[i]-2]

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>

using namespace std;

void Swap(long long x[], int i, int j)
{
	int temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}

void QSort(long long x[], long long y[], int left, int right)
{
	int i, j;
	int pivot;

	i = left;                      /* ソートする配列の一番小さい要素の添字 */
	j = right;                     /* ソートする配列の一番大きい要素の添字 */

	pivot = x[(left + right) / 2]; /* 基準値を配列の中央付近にとる */

	while (1) {                    /* 無限ループ */

		while (x[i] < pivot)       /* pivot より大きい値が */
			i++;                   /* 出るまで i を増加させる */

		while (pivot < x[j])       /* pivot より小さい値が */
			j--;                   /*  出るまで j を減少させる */
		if (i >= j)                /* i >= j なら */
			break;                 /* 無限ループから抜ける */

		Swap(x, i, j);             /* x[i] と x[j]を交換 */
		Swap(y, i, j);             /* x[i] と x[j]を交換 */
		i++;                       /* 次のデータ */
		j--;
	}

	if (left < i - 1)              /* 基準値の左に 2 以上要素があれば */
		QSort(x, y, left, i - 1);     /* 左の配列を Q ソートする */
	if (j + 1 <  right)            /* 基準値の右に 2 以上要素があれば */
		QSort(x, y, j + 1, right);    /* 右の配列を Q ソートする */
}

int main() {
	int N;
	long long A[200000], B[200000];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
	}
	QSort(B, A, 0, N - 1);
	long long clock = 0;
	for (int i = 0; i < N; i++) {
		clock += A[i];
		if (B[i] < clock) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3456
n = int(input())
h = list( map(int,input().split()) )
dp = [0] * n

dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2,n):
  dp[i] = min( abs(h[i] - h[i-2]) + dp[i-2] , abs(h[i] - h[i-1]) + dp[i-1])

print(dp[n-1])

Measured memory_bytes: 13980
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>

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

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


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

    int ans = 0;
    rep(i, 3) if (s[i] == '1') ans += 1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
N, K = map(int, input().split())
Xn = list(map(int, input().split()))

Ln = [0] * N
for i in range(N-1):
    Ln[i+1] = abs(Xn[i+1] - Xn[i]) + Ln[i]

Rn = [0] * N
for i in range(1, N)[::-1]:
    Rn[i-1] = abs(Xn[i] - Xn[i-1]) + Rn[i]

ans = float("inf")
for i in range(N-K+1):
    ans = min(ans, abs(Xn[i]) + Ln[i+K-1] - Ln[i])

for i in range(K-1, N)[::-1]:
    ans = min(ans, abs(Xn[i]) + Rn[i-K+1] - Rn[i])

print(ans)


Measured memory_bytes: 15452
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX;
const ll MOD = 1e9+7;

template <ll mod>
struct ModCombination{
    ll N;
    vector<ll> fact,inv,finv;

    ModCombination(ll n):N(n){
        fact.assign(n+1, 1);
        inv.assign(n+1, 1);
        finv.assign(n+1,1);
        for(int i=1;i<n;i++){
            fact[i+1] = fact[i]*(i+1)%mod;
            inv[i+1] = inv[mod%(i+1)]*(mod-mod/(i+1))%mod;
            finv[i+1] = finv[i]*inv[i+1]%mod;
        }
    }

    ll Comb(ll n,ll k){
        return (fact[n]*finv[k]%mod)*finv[n-k]%mod;
    }
};

struct CentroidGraph{
  int n;
  vector<vector<int>> g;
  vector<int> centroid;
  vector<int> size;
  CentroidGraph(int n_):n(n_),g(n_),size(n_){}
  void add_edge(int a,int b){
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<int> findCentroid(){
          function<void (int, int)> dfs = [&](int u, int prev) {
                  size[u] = 1;
                  bool is_centroid = true;
                  for (auto v : g[u]) if (v != prev) {
                          dfs(v, u);
                          size[u] += size[v];
                          if (size[v] > n / 2) is_centroid = false;
                  }
                  if (n - size[u] > n / 2) is_centroid = false;
                  if (is_centroid) centroid.push_back(u);
          };
          dfs(0, -1);
          return centroid;
  }
  vector<int> operator[](const int& k){
    return g[k];
  }
};

ll dp[5010][5010];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;cin>>N;
  ModCombination<MOD> C(N);
  CentroidGraph g(N);
  repeat(i,N-1){
    int x,y;cin>>x>>y;
    x--;y--;
    g.add_edge(x,y);
  }
  vint c = g.findCentroid();
  if(c.size()==2){
    cout << C.fact[N/2]*C.fact[N/2]%MOD << endl;
    return 0;
  }
  dp[0][0]=1;
  int K=0;
  for(int u:g[c[0]]){
    //debug(u);
    int size=g.size[u];
    if(size>N/2)size = N-g.size[c[0]];
    //debug(size);
    repeat(x,N+1){
      repeat(y,size+1){
        dp[K+1][x+y] = (dp[K+1][x+y]+dp[K][x]*C.Comb(size,y)%MOD*C.Comb(size,y)%MOD*C.fact[y]%MOD)%MOD;
      }
    }
    K++;
  }
  //debug(K);
  //debugArray(dp[K],N);
  ll ans = 0;
  repeat(x,N){
    ans = (ans+C.fact[N-x]*dp[K][x]%MOD*(1-2*(x&1))+MOD)%MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 196352
#include<stdio.h>

int main(void){ 

int a, b, c; 

int count = 0; 

int i; 

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

for(i=a; i<=b; i++){  

if(c%i==0){

count++;

} 

} 

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

return 0;

}
  

Measured memory_bytes: 596
n, a, b = gets.chomp.split.map(&:to_i)
if (b - a) % 2 == 0
  puts (b - a) / 2
else
  res = []
  a1 = a - 1
  res << 1 + a1 + (b - a1 - 1) / 2
  bn = n - b
  res << 1 + bn + (n - a - bn - 1) / 2
  puts res.min
end

Measured memory_bytes: 1788
from fractions import gcd
import sys
input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    A = list(map(lambda x: int(x) // 2, input().split()))

    X = A[0]
    for i in range(1, N):
        a, b = X, A[i]
        X = a * b // gcd(a, b)
        if X > M:
            print(0)
            exit(0)

    cnt = 0
    tmp = X
    while tmp % 2 == 0:
        tmp = tmp // 2
        cnt += 1
    for a in A:
        if a % (2 ** cnt) == 0 and a % (2 ** (cnt + 1)) != 0:
            continue
        else:
            print(0)
            exit(0)
    print((M // X + 1) // 2)


if __name__ == '__main__':
    main()


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

ll id;
int N, c;
string s;

const ll MAX = 2000000;

struct Node {
	ll v, len;
	string s;
	vector<Node*> children;
	Node() : v(1), len(0), s(string()) {}
};

int readNum(){
	int n = 0;
	while(c < N && isdigit(s[c])) {
		n = n * 10 + (s[c] - '0');
		c++;
	}
	return n;
}

string readS(){
	string ret;
	assert(s[c] != '(' && s[c] != ')');
	while(c < N && 'A' <= s[c] && s[c] <= 'Z') {
		ret += s[c];
		c++;
	}
	return ret;
}

char ans;

Node* f(){
	Node* node = new Node();
	if(isdigit(s[c])) {
		int n = readNum();
		node->v = n;

		if(s[c] != '(') {
			Node* res = f();
			node->children.push_back(res);
			node->len = min(MAX, node->len + res->len * res->v);
			return node;
		}

		while(c < N) {
			if(s[c] == '(') {
				c++;
			}

			Node* res = f();
			node->children.push_back(res);
			node->len = min(MAX, node->len + res->len * res->v);

			if(c < N && s[c] == ')') {
				c++;
				return node;
			}
		}
		return node;
	}

	//assert('A' <= s[c] && s[c] <= 'Z');

	if(!('A' <= s[c] && s[c] <= 'Z')) {
		int x = 0;
	}

	node->s = readS();
	node->len = min(MAX, (ll)node->s.size());

	//if(ans == 0) {
	//	if(ss.size() * v <= id) {
	//		id -= ss.size() * v;
	//		return;
	//	}

	//	while(id >= ss.size()) id -= ss.size();
	//	ans = ss[id];
	//}
	return node;
}

void g(Node* node){
	if(node->children.size() == 0) {
		assert(id < node->s.size());
		ans = node->s[id];
		return;
	}

	while(!(id < node->len)) id -= node->len;

	for(auto child : node->children) {
		if(child->len * child->v <= id) {
			id -= child->len * child->v;
		}
		else{
			g(child);
			assert(ans);
			return;
		}
	}
}

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

	while(cin >> s >> id, s != "0") {
		N = s.size();
		c = 0;
		ans = 0;
		while(c < N && ans == 0){
			Node* res = f();
			if(res->len * res->v <= id) {
				id -= res->len * res->v;
			}
			else {
				g(res);
				break;
			}
		}

		if(ans) cout << ans << endl;
		else cout << 0 << endl;
	}
}

Measured memory_bytes: 3516
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define all(vec) vec.begin(),vec.end()
#define ggr getchar(); getchar();return 0;
#define ll long long
#define P pair<int,int>
#define S second
#define F first
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;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int n, m, a[100], b[100];
vector<int> g[10];
vector<int> ta;
int ans;
int mu;
int cnt = 1;

signed main() {
	cin >> n >> m;
	rep(i, m) {
		cin >> a[i] >> b[i];
		g[a[i]].push_back(b[i]);
		g[b[i]].push_back(a[i]);
	}
	for (int i = 2; i <= n; i++) {
		ta.push_back(i);
	}
	int c, d;
	do {
		c = 1;
		d = ta[0];
		cnt = 1;
		rep(i, ta.size()) {
			mu = 0;
			rep(j, g[c].size()) {
				if (g[c][j] == d)mu++;
			}
			cnt *= mu;
			c = d;
			if (i != ta.size() - 1)d = ta[i + 1];
		}
		ans += cnt;
	} while (next_permutation(all(ta)));
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define MAXN 20006
using namespace std;
int a[MAXN],cnt,n;
int main()
{
	scanf("%d",&n);
	if(n==3)
	{
		printf("2 5 63");
		return 0;
	}
	cnt=4;
	n-=4;
	a[1]=3;
	a[2]=9;
	a[3]=2;
	a[4]=4;
	while(n>=2&&a[cnt]+6<=30000)
	{
		n-=2;
		cnt++;
		a[cnt]=a[cnt-1]+4;
		cnt++;
		a[cnt]=a[cnt-1]+2;
	}
	while(n>=2&&(a[cnt]%2==0||a[cnt]+4*3<=30000))
	{
		n-=2;
		cnt++;
		if(a[cnt-1]%2==0) a[cnt]=15;
		else a[cnt]=a[cnt-1]+6;
		cnt++;
		a[cnt]=a[cnt-1]+6;
	}
	while(n>=1&&(a[cnt]%6!=0||a[cnt]+6<=30000))
	{
		n--;
		cnt++;
		if(a[cnt-1]%6!=0) a[cnt]=6;
		else a[cnt]=a[cnt-1]+6;
	}
	sort(a+1,a+1+cnt);
	for(int i=1;i<=cnt;i++)
		printf("%d ",a[i]);
}

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

int main() {
    int sum, sub;
    while (cin >> sum, sum) {
        sub = 0;
        for (int i = 1, j; i < 10; i++) cin >> j, sub += j;
        cout << sum - sub << endl;
    }

    return 0;
}

Measured memory_bytes: 2940
#include <iomanip>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int64_t A, B, C, K;
  cin >> A >> B >> C >> K;

  int64_t answer = min(A, K);
  if (A < K) {
    K -= A;
    if (B <= K) {
      K -= B;
      K = max(0L, K);
      answer -= K;
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3652
{-# LANGUAGE BangPatterns #-}

module Main where

import Data.Char
import Data.List
import Control.Monad
import Control.Monad.ST
import Data.Array.ST
import Data.Array.Unboxed
import Control.Applicative
import Text.Printf


readInt :: IO Int
readInt = read <$> (input `seq` input)
    where input = do
            !c <- getChar
            if isDigit c || c == '-'
                then (c :) <$> input
                else return []

prints :: Show a => [a] -> IO ()
prints as = putStrLn $ concat $ intersperse " " $ map show as

main = do
    n <- readInt
    records <- replicateM n (replicateM 4 readInt)
    let res = go records
    forM_ [1..4] $ \bldg -> do
        forM_ [1..3] $ \flr -> do
            forM_ [1..10] $ \room -> putStr (" " ++ show (res ! (bldg, flr, room)))
            putStrLn ""
        when (bldg /= 4) (putStrLn (replicate 20 '#'))


go :: [[Int]] -> UArray (Int, Int, Int) Int
go records = runSTUArray $ do
    arr <- newArray ((1,1,1), (4,3,10)) 0
    forM_ records $ \[b,f,r,v] -> writeArray arr (b,f,r) . (+v) =<< (readArray arr (b,f,r))
    return arr



Measured memory_bytes: 4380
#include <bits/stdc++.h>
using namespace std;
#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 ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int main() {
  int a;
  cin>>a;
  cout << a*a <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <numeric>

typedef long long ll;
const ll INF = 1e18;


int main(int argc, char* argv[])
{
  std::vector< int > vi(3, 0);
  std::cin >> vi[0] >> vi[1] >> vi[2];

  std::sort(vi.begin(), vi.end());

  if (vi[0] == 5 && vi[1] == 5 && vi[2] == 7) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod = 1000000007;
struct mint{
	ll x;
	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{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

// 2^n
mint f(int n){
	if(n == 0) return 1;
	mint x = f(n/2);
	x *= x;
	if(n%2 == 1) x *= 2;
	return x;
}

// nCa
mint choose(int n, int a){
	mint x = 1, y = 1;
	rep(i,a){
		x *= n-i;
		y *= i+1;
	}
	return x / y;
}

struct Combination{
	vector<mint> fact, ifact;
	Combination(int n):fact(n+1),ifact(n+1){
		assert(n < mod);
		fact[0] = 1;
		for(int i = 1; i <= n; i++) fact[i] = fact[i-1]*i;
		ifact[n] = fact[n].inv();
		for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i]*i;
	}
	mint operator()(int n, int k){
		if(k < 0 || k > n) return 0;
		return fact[n]*ifact[k]*ifact[n-k];
	}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    Combination comb(n+1);
    for(int i = 1; i <= k; ++i){
        mint ans = comb(n-k+1, i) * comb(k-1, i-1);
        cout << ans.x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define all(v) v.begin(),v.end()
#define PI acos(-1)
#define EPS 1e-15


 
int main(){
	int n;
	cin >> n;
	map<ll, int> m;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		m[a]++;
	}
	int cnt = 0;
	for(auto i : m){
		if(i.second % 2 != 0)
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std ;
int main(){
    int N,L;
    cin >> N >> L;
  	vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }
    // for (auto&& Si: S) {
    //     cin >> Si;
    // }
    sort(S.begin(),S.end());

    for(int i = 0; i<N; i++){
        cout << S[i];
    }
    cout << endl;
}

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

int main(){
	int N, Y;

	cin >> N >> Y;

	int sum=0, flag=0;
	int i,j,k;
	for(i=0; i<=N; i++){
		for(j=0; j<=N-i; j++){
			k = N-i-j;
			sum = 10000*i + 5000*j + 1000*k;
			
			if(sum == Y){
				flag=1;
				break;
			}
		}
	  if(flag==1){
			break;
		}
	}

	if(flag==1){
		cout << i << " " << j << " " << k << endl;
	}else{
		cout << -1 << " " << -1 << " " << -1 <<  endl;
	}

	return 0;
}

				


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

int main(){
    int num;
    vector<int> nums;
    for (int i=0; i<3; i++){
        cin >> num;
        if (find(nums.begin(), nums.end(), num)==nums.end()) nums.push_back(num);
    }
    cout << nums.size() << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2 2");
            //6
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("5 15");
            //1
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();

        int K = wkArr[0];
        int S = wkArr[1];

        //場合の数[合計]なDP表
        int[] PrevDP = new int[S + 1];
        PrevDP[0] = 1;

        for (int N = 1; N <= 3; N++) {
            int[] CurrDP = new int[S + 1];

            for (int I = 0; I <= S; I++) {
                if (PrevDP[I] == 0) continue;
                for (int J = 0; J <= K; J++) {
                    int NewInd = I + J;
                    if (I + J > S) break;
                    CurrDP[NewInd] += PrevDP[I];
                }
            }
            PrevDP = CurrDP;
        }
        Console.WriteLine(PrevDP[S]);
    }
}


Measured memory_bytes: 2904
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
//i64 mod = 1000000007;
i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;

vector<i64> fibo(50);


void simulation_once(const vector<i64>& in, vector<i64>& out) {
    i64 sz = in.size();
    for (i64 i=0; i<sz; ++i) {
        i64 num = in[i];
        i64 left = max((i64)0, i-num);
        i64 right = min(sz-1, i+num);
        ++out[left];
        if (right+1 <sz) --out[right+1];
    }
    for (i64 i=1; i<sz; ++i) {
        out[i] = out[i-1] + out[i];
    }
}

void print_v(const vector<i64>& v) {
    for (auto i : v) {
        cout << i << " ";
    }
    cout <<endl;
}
void print_diff(const vector<i64>& v, const vector<i64>& v2) {
    for (size_t i=0; i<v.size(); ++i) {
        cout << (v[i]-v2[i]) << " ";
    }
    cout <<endl;
}

int main(int argc, char **argv) {
    i64 n,k;
    cin >> n >> k;

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

    vector<i64> b=a, c(n, 0);


    for (int k1=0; k1<k && k1*k1<n; ++k1) {
        vector<i64> tmp(n, 0), tmp2(n,0);
        simulation_once(b, tmp);
        b = std::move(tmp);
    }

    print_v(b);

    return 0;
}

Measured memory_bytes: 11144
h, w, d = map(int, input().split())
amd = {}
for i in range(h):
  al = map(int, input().split())
  for j, a in enumerate(al):
    amd[a] = (j+1, i+1)

dsum = [0 for _ in range(d+1)]
for i in range(d+1, h*w+1):
  dsum.append(dsum[-d] + abs(amd[i][0]-amd[i-d][0]) + abs(amd[i][1]-amd[i-d][1]))

q = int(input())
for _ in range(q):
  ans = 0
  l, r = map(int, input().split())
  print(dsum[r] - dsum[l])

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

using namespace std;

string s, t;
vector<vector<int> > DP;
vector<bool> result;


string res = "";
void getResult(int i, int j)
{
    if(i == 0 || j == 0)
    {
        return;
    }
    if(s[i-1] == t[j-1])
    {
        res = s[i-1] + res;
        getResult(i-1, j-1);
    }
    else
    {
        if(DP[i-1][j] > DP[i][j-1])
        {
            getResult(i-1, j);
        }
        else
        {
            getResult(i, j-1);
        }
    }
}
int main() 
{
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> s >> t;

    DP.resize(s.size() + 1, vector<int>(t.size() + 1, -1));

    for(int i=0; i <= s.size(); i++)
    {
        for(int j=0; j<= t.size(); j++)
        {
            if(i == 0 || j == 0)
            {
                DP[i][j] = 0;
            } 
            else if(s[i-1] == t[j-1])
            {
                DP[i][j] = 1 + DP[i-1][j-1];
            }   
            else
            {
                DP[i][j] = max(DP[i-1][j], DP[i][j-1]);
            }
        }
    }
    
    getResult(s.size(), t.size());

    cout<<res;
    
    return 0;
}

Measured memory_bytes: 35840
#include <iostream>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    long long H, W;
    cin >> H >> W;

    if (H == 1 || W == 1) {
        cout << 1 << endl;
    } else {
        cout << (H * W + 1) / 2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(final String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    sc.close();

    int o = -1;
    for (int i = 1;i< (int)(100/0.08)+1;i++) {
      if ((int)(i*0.08)== a && (int)(i*0.1) == b) {
        o = i;
        break;
      }
    }

    System.out.println(o);
  }
}

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


typedef long long ll;

int main() {
  int n; cin >> n;
  string s; cin >> s;
  ll ans = 0;
  ll nb = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'B') ++nb;
  }
  for (int i = 0; i < n; ++i) {
    if (s[i] != 'R') continue;
    for (int j = 0; j < n; ++j) {
      if (s[j] != 'G') continue;
      int mi = min(i,j);
      int ma = max(i,j);
      if ((ma-mi)%2 == 0 && s[(ma+mi)/2] == 'B') ans -= 1;
      int n2 = mi-(ma-mi);
      if (n2 >= 0 && s[n2] == 'B') ans -= 1;
      int n3 = ma+(ma-mi);
      if (n3 < n && s[n3] == 'B') ans -= 1;
      ans += nb;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3612
package main

import (
	"fmt"
)

func main() {
  	var n int
  	var sum int
  	fmt.Scan(&n)
 	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}

	for {
		flag := false
		for i := 0; i < n; i++ {
			if nums[i] % 2 == 1 { flag = true }
		}

		if flag { break }

		for i := 0; i < n; i++ {
			nums[i] = nums[i] / 2
		}
		sum++
	}
	fmt.Println(sum)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int siz=2e5+1;
const long inf=1e9;
int main(){
	int X; cin>>X;
	cout<<(X >= 30 ? "Yes" : "No")<<endl;
}

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

int n, a, b, k, mod = 998244353;

int factorialNumInverse[300003], naturalNumInverse[300003], fact[300003];

void InverseofNumber(int mod) 
{ 
        naturalNumInverse[0] = naturalNumInverse[1] = 1; 
        for (int i = 2; i <= 300000; i++) {
                naturalNumInverse[i] = naturalNumInverse[mod % i] * (mod - mod / i) % mod; 
        }
}

void InverseofFactorial(int mod) 
{ 
        factorialNumInverse[0] = factorialNumInverse[1] = 1; 
        for (int i = 2; i <= 300000; i++) {
                factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % mod;
        }
} 
  
void factorial(int mod) 
{ 
        fact[0] = 1;
        for (int i = 1; i <= 300000; i++) { 
                fact[i] = (fact[i - 1] * i) % mod;
        } 
}

int nCr(int N, int R) { 
        return ((fact[N] * factorialNumInverse[R]) % mod * factorialNumInverse[N - R]) % mod; 
}

signed main() {
	InverseofNumber(mod); 
    InverseofFactorial(mod); 
    factorial(mod);
    int ans = 0;
	cin >> n >> a >> b >> k;
	for(int x = 0; x <= n; x++) {
		int y = (k - a * x) / b;
		if(y >= 0 && y <= n && a * x + b * y == k) {
			ans = (ans + (nCr(n, x) * nCr(n, y)) % mod) % mod;
		}
	}
	cout << ans << '\n';
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const ll mod = 1e9+7;
const ll maxn = 1000 * 1001;

ll n , m , k;
vector<ll> g[maxn], topol , sefr , bg[maxn];
ll deg[maxn];
ll dp[maxn];

void topol_sort(ll u)
{
    topol.push_back(u);
    if(bg[u].size())
        for(ll i = 0; i < bg[u].size(); i++)
        {
            deg[bg[u][i]]--;
            if(deg[bg[u][i]] == 0)
                sefr.push_back(bg[u][i]);
        }
    if(sefr.size())
    {
        ll x = sefr.back();
        sefr.pop_back();
        topol_sort(x);
    }
}

int main()
{
    cin>> n >> m;
    for(ll i = 1; i <= m; i++)
    {
		ll x , y;
		cin >> x >> y;
		g[x].push_back(y);
		bg[y].push_back(x);
		deg[x]++;
	}

	for(ll i = 1; i <= n; i++)
        if(deg[i] == 0)
            sefr.push_back(i);
    ll x = sefr.back();
    sefr.pop_back();
    topol_sort(x);

    ll ans = 0;
    for(ll i = 1; i < topol.size(); i++)
    {
        ll v = topol[i];
        if(g[v].size())
            for(ll j = 0; j < g[v].size(); j++)
                dp[v] = max(dp[v], dp[g[v][j]]+1);
        ans = max(ans, dp[v]);
    }
    cout<< ans;
}

















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

int A,B,C;

int main()
{
    scanf("%d%d%d",&A,&B,&C);
    if(B - A == C - B)
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 8)


def lowLink(N: int, Adj: list):
	articulation = []
	bridge = []
	order = [None] * N
	lowest = [1 << 100] * N

	def _dfs(cur, pre, k):
		order[cur] = lowest[cur] = k
		is_articulation = False
		cnt = 0
		for nxt in Adj[cur]:
			if order[nxt] is None:
				cnt += 1
				_dfs(nxt, cur, k + 1)
				if lowest[cur] > lowest[nxt]:
					lowest[cur] = lowest[nxt]
				is_articulation |= pre >= 0 and lowest[nxt] >= order[cur]
				if order[cur] < lowest[nxt]:
					if cur < nxt:
						bridge.append((cur, nxt))
					else:
						bridge.append((nxt, cur))
			elif nxt != pre and lowest[cur] > order[nxt]:
				lowest[cur] = order[nxt]
		is_articulation |= pre < 0 and cnt > 1
		if is_articulation:
			articulation.append(cur)

	_dfs(0, -1, 0)
	return articulation, bridge


def main():
	n, m, *L = map(int, open(0).read().split())
	adj = [[] for _ in range(n)]
	for s, t in zip(*[iter(L)] * 2):
		adj[s] += t,
		adj[t] += s,
	_, bridge = lowLink(n, adj)
	for x, y in sorted(bridge):
		print(x, y)


if __name__ == '__main__':
	main()



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

void  cal(int t)
{
	int answer[50];
	for (int i = 0;i < t;++i) {
		int n, k, a[1000000], b[1000000], sum = 0;
		cin >> n >> k;
		for (int j = 0;j < n;++j) {
			cin >> a[j];
		}
		for (int j = 0;j < n - 1;++j) {
			b[j] = a[j + 1] - a[j];
		}
		sort(b, b + n - 1);
		for (int j = n - 2;n - k - 1 < j;--j) {
			sum += b[j];
		}
		answer[i] = a[n - 1] - a[0] - sum;
	}
	for (int i = 0;i < t;++i) {
		cout << answer[i] << endl;
	}
}

int main()
{
	int t;
	cin >> t;
	cal(t);
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define sync ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,n) for(int i=0; i<int(n); ++i)
#define repp(i,a,n) for(int i=a; i<int(n); ++i)
#define sz(x) int((x).size())
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define mp make_pair

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T> &input){for (auto const& i: input) {os << i << " ";}return os;}
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T> &input){for (auto const& i: input) {os << i << " ";}return os;}
template<class T, size_t n> std::ostream& operator<<(std::ostream& os, const std::array<T, n> &input){for (size_t i=0; i<n; ++i) {os << input[i] << " ";}return os;}
template<class T1, class T2> std::ostream& operator<<(std::ostream& os, const std::pair<T1,T2> &input){os << "(" << input.first << ", " << input.second << ')';return os;}
template<class T1, class T2> std::ostream& operator<<(std::ostream& os, const std::unordered_map<T1,T2> &input){for (auto const& i: input) {os << i << " ";}return os;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << H;debug_out(T...);}
#ifdef LOCAL
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

double startTime;
double getCurrentTime(){return ((double)clock() - startTime) / CLOCKS_PER_SEC;}

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<pi> vp;
typedef vector<ll> vl;
typedef vector<vi> vvi;

// === temeplate ===

const int maxn = 50;

void solve(){
	int n, m; cin >> n >> m;
	int x,y,xx,yy; cin >> x >> y >> xx >> yy; --x,--y,--xx,--yy;
	vector<string> s(n);
	rep(i,n) cin >> s[i];
	queue<pi> Q; while(sz(Q)) Q.pop();
	Q.push({x,y});
	vvi vis(n, vi(m,0));
	vvi ans(n, vi(m,0));
	vis[x][y] = 1;
	
	
	queue<pi> q;

	while(sz(Q)){
		auto p = Q.front(); Q.pop();

		while(sz(q)) q.pop();
		q.push(p);
		while(sz(Q)){
			int x, y; tie(x,y) = Q.front();
			if(ans[x][y] == ans[p.first][p.second]){
				q.push(Q.front());
				Q.pop();
			}
		}
		

		vp tmp(0);

		while(sz(q)){
			int x, y; tie(x,y) = q.front(); q.pop();
			tmp.pb({x,y});
			for(auto dlt: vp({{1,0},{0,1},{-1,0},{0,-1}})){
				int dx,dy; tie(dx,dy) = dlt;
				int x2 = x + dx, y2 = y + dy;
				if(x2 >= 0 && x2 < n && y2 >= 0 && y2 < m && s[x2][y2]=='.' && !vis[x2][y2]){
					vis[x2][y2] = 1;
					ans[x2][y2] = ans[x][y];
					q.push({x2,y2});
				}
			}
		}

		for(auto p: tmp){
			int x,y; tie(x,y)=p;
			rep(i,5)rep(j,5){
				int x2 = x + i - 2, y2 = y + j - 2;
				if(x2 >= 0 && x2 < n && y2 >= 0 && y2 < m && s[x2][y2]=='.' && !vis[x2][y2]){
					vis[x2][y2] = 1;
					ans[x2][y2] = ans[x][y] + 1;
					Q.push({x2,y2});
				}
			}
		}

		if(vis[xx][yy]) break;
	}

	cout <<(vis[xx][yy]? ans[xx][yy]:-1)<<endl;

}

int main(){
    sync;
    int cas = 1;
    // cin >> cas;
    rep(ca, cas) solve();
    return 0;
}

Measured memory_bytes: 12716
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    char c;
    cin >> c;
    cout << char(c + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}

int dp[2050];

void solve()
{
    dp[0] = 1;
    
    for(int i=3;i<=2000;i++)
    {
        for(int j=i-3;j>=0;j--)
        {
            dp[i] = (dp[i] + dp[j])%MOD;
        }
    }
    
    int s;
    cin >> s;
    cout << dp[s];
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 3668
#include <string>
#include <iostream>

using namespace std;

int main()
{
	string S, T;

	cin >> S >> T;

	if (S.size() >= T.size())
	{
		for (int i = 0; i <= S.size() - T.size(); i++)
		{
			if (T == S.substr(i, T.size()))
			{
				cout << i << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3224
#include <stdlib.h>
#include <stdio.h>

int counter = 0;

int Bin(int arr[], int n, int k)
{
    int left = 0;
    int right = n - 1;
    int mid;

    while (left <= right)
    {
        mid = (left + right) / 2;
        if (arr[mid] == k){
            counter++;
            return mid;
        }
        if (arr[mid] > k)
            right = mid - 1;
        else
            left = mid + 1;
    }
}

int main() {
    int n1, n2;
    scanf("%d", &n1);
    int A[n1];
    for(int i=0; i<n1; i++){
        scanf("%d", &A[i]);
    }

    scanf("%d", &n2);
    int B[n2];
    for(int i=0; i<n2; i++){
        scanf("%d", &B[i]);
    }

    int key;
    for(int j=0; j<n2; j++){
        key = B[j];
        Bin(A, n1, key);
    }

    printf("%d\n", counter);
}



Measured memory_bytes: 2272
def abss(x, y):
    return abs(x-y)**2

def main():
    N = int(input())
    l = list(map(int, input().split()))
    ans = 10000000
    min_l = min(l)
    max_l = max(l)
    for y in range(min_l, max_l+1):
        temp = 0
        for x in l:
            temp += abss(x, y)
        ans = min(ans, temp)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064