akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int n;
    cin >> n;

    vector<int> b(n);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        a--;

        b[a] = i;
    }

    set<int> st;
    st.insert(-1);
    st.insert(n);

    int64_t r = 0;
    for (int i = 0; i < n; i++) {
        auto i0 = st.insert(b[i]).first;
        auto i1 = i0;
        int b0 = *--i0;
        int b1 = *++i1;
        r += (int64_t)(b[i] - b0) * (b1 - b[i]) * (i + 1);
    }

    cout << r << endl;

    return 0;
}

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

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

  int a, b, c;
  cin >> a >> b >> c;

  string ans = "bust";
  if (a + b + c <= 21) {
    ans = "win";
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
	int N, K;
	cin >> N >> K;
	vector<long long> p(N);
	for (int i = 0; i < N; ++i) cin >> p[i];
	sort(p.begin(), p.end());
	long long res = 0;
	for (int i = 0; i < K; ++i) res += p[i];
	cout << res << endl;
}

















Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

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

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int x; 
    cin >> x;
    int r = x % 100;
    int cm = x / 100;
    
    for(int i = 5; i > 0; --i) {
        int ri = r / i;
        if ((cm-ri)<0) {
            cout << 0 << endl;
            return 0;
        }
        r -= ri;
    }
    cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 256
D = int(input())
C = list(map(int, input().split()))
S = []
for i in range(D):
    a = list(map(int, input().split()))
    S.append(a)
last_d = [0] * 26  # それぞれのタイプでのd - last(d,i)
threshould = 30  # Ci*(last_d) / sqrt(Ci) がこれを超えたら対処する
for i in range(D):
    idx = 1
    tmp_max = 0
    for j in range(26):
        # もし閾値を超えるやつがあればそれをすぐに使う
        if C[j] * (i + 1 - last_d[j]) / ((C[j] + 0.1) ** 0.5) >= threshould:
            idx = j
            break
        if tmp_max <= S[i][j]:
            tmp_max = S[i][j]
            idx = j

            # print("a", idx)
    print(idx + 1)
    last_d[idx] = i + 1  # i+1日目に最後に使われた



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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
    int n,k;
    cin >> n >> k;
    vector<LL> x(n);
    int start_plus = -1;
    cin >> x[0];

    if (x[0] >= 0) {
        start_plus = 0;
    }
    for (int i = 1; i < n; i++) {
        cin >> x[i];
        if (x[i-1] < 0 and x[i] >= 0) {
            start_plus = i;
        }
    }

    if (start_plus == -1) {
        start_plus = x.size();
    }

    LL ans = INT64_MAX;
    if (start_plus + k <= x.size()) {
        ans = min(ans,x[start_plus+k-1]);
    }
    if (start_plus - k >= 0) {
        ans = min(ans,-x[start_plus-k]);
    }

    for (int i = 0; i < x.size() - k + 1; i++) {
        if (x[i] < 0 and x[i+k-1] >= 0) {
            ans = min(ans,min(-x[i],x[i+k-1])*2+max(-x[i],x[i+k-1]));
        }
    }

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
#define ff first
#define ss second
#define endl '\n'
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)


int32_t main(){
	boost;

    int n,r;
    cin>>n>>r;
    if(n>=10)
        cout<<r<<endl;
    else
        cout<<r+100*(10-n)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "Local_Debug.h"
using namespace std;
#define Endl endl
#define debug(x) cout << #x << " = " << (x) << endl
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)2e5 + 5;
double n, x[10], y[10];
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(10);
	while (cin >> n)
	{
		vector<ll> path;
		for (ll i = 1; i <= n&&cin >> x[i] >> y[i]; ++i) path.emplace_back(i);
		double ans = 0;
		do
		{
			for (ll i = 1; i < n; ++i)
			{
				double xx = abs(x[path[i - 1]] - x[path[i]])*abs(x[path[i - 1]] - x[path[i]]);
				double yy = abs(y[path[i - 1]] - y[path[i]])*abs(y[path[i - 1]] - y[path[i]]);
				ans += sqrt(xx + yy);
			}
		} while (next_permutation(path.begin(), path.end()));
		ll cnt = 1;
		for (ll i = 1; i <= n; ++i)
			cnt *= i;
		cout << ans / double(cnt) << endl;
	}
}
/*
3
0 0
1 0
0 1

2
-879 981
-866 890

8
-406 10
512 859
494 362
-955 -475
128 553
-986 -885
763 77
449 310
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  char c,d;
    cin>>c>>d;
  int a=c,b=d;
  if(a==b)cout<<"=";
  else if(a<b)cout<<"<";
  else cout<<">";
}

Measured memory_bytes: 256
var log = console.log;
if (typeof process != "undefined") {
    var input = "";
    process.stdin.resume();
    process.stdin.setEncoding('utf8');
    process.stdin.on('data', function (chunk) {
        input += chunk;
    });
    process.stdin.on('end', function () {
        var lines = input.split("\n");
        main(lines);
    });
}
 
//-----
 
function main(lines) {
    lines.shift();
    while (lines.length > 0) {
        var dataset = lines.slice(0, 2);
        dataset = dataset.map(function (row) {
            return row.split("").filter(function (e) {
                var code = e.charCodeAt(0);
                return (97 <= code && code <= 122)||(65 <= code && code <= 90);
            }).join("");
        });
        processDataset(dataset);
        lines = lines.slice(2);
    }
}
 
function processDataset(dataset) {
    var A = [];
    var f = dataset[0];
    var s = dataset[1];
    for (var i = 0; i < f.length; i++) {
        A[i] = [];
        for (var j = 0; j < s.length; j++) {
            if (f.charAt(i) == s.charAt(j)) {
                A[i][j] = 1;
            } else {
                A[i][j] = 0;
            }
            if (i == 0 && j == 0) {
                A[i][j] += 0;
            } else if (i == 0) {
                A[i][j] = Math.max(A[i][j - 1], A[i][j]);
            } else if (j == 0) {
                A[i][j] = Math.max(A[i - 1][j], A[i][j]);
            } else {
                if(f.charAt(i) == s.charAt(j)){
                    A[i][j] = A[i-1][j-1]+1;
                }else{
					A[i][j] = Math.max(A[i][j-1],A[i-1][j]);
				}
            }
            if(i == f.length - 1 && j == s.length - 1){
                log(A[i][j]);
            }
        }
    }
}

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

const int MAX_N=100010;

int dp[MAX_N];

int f(int n){
  if(n==0) return 0;
  if(dp[n]!=-1) return dp[n];

  int res=n;

  for(int k6=1;k6<=n;k6=k6*6){
    res=min(res,f(n-k6)+1);
  }
  for(int k9=1;k9<=n;k9=k9*9){
    res=min(res,f(n-k9)+1);
  }
  return dp[n]=res;
}

int main(){
  int n,i;
  cin >> n;
  for(i=0;i<MAX_N;++i){
    dp[i]=-1;
  }
  cout << f(n) << endl;
  return 0;
}


Measured memory_bytes: 3712
//#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>

using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using intpv=vector<intpair>;
using llpair=pair<ll,ll>;
using llpv=vector<llpair>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;
using pairmat=vector<llpv>;

template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353

#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define iter(name) decltype(name)::iterator
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())
#define matin(mat,H,W) for(int i__=0; i__<H; i__++)for(int j__=0; j__<W; j__++) cin>>mat[i__][j__]
#define out(n) cout<<n<<endl

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;
}

template<class T>
inline void outmat(T& a, int y, int x) {
	for(int i=0; i<y; i++) {
		for(int j=0; j<x; j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
}

template<class T>
inline void init(T& v) {
	for(auto &a__: v) cin>>a__;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a__: v) cin>>a__;
}

template<class N> void resiz(N n) {} // empty
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll GCD(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll binpow(ll a, ll ex, ll p) { //繰り返し二乗法
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}

ll Fact(ll x, ll p) { //階乗
	ll f=1;
	for(ll i=2; i<=x; i++) {
		f*=i;
		f%=p;
	}
	return f;
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll div=1LL;
	while(n/div) {
		digit++;
		div*=10;
	}
	return digit;
}



int N;
ll X;
ll pnum[51];

void input() {
	cin>>N>>X;
}

ll rec(int n, ll x) {
	if(n==0) {
		return x;
	}

	if(x<=1) return 0;
	if(x<pnum[n]) return rec(n-1,x-1);
	if(x<pnum[n]*2-1) return pnum[n-1]+1+rec(n-1,x-pnum[n]);
	return pnum[n];
}

void solve() {
	pnum[0]=1ll;
	for(int i=1; i<=50; i++) pnum[i]=pnum[i-1]*2+1;
	cout<<rec(N,X)<<endl;
}

int main() {
	while(1) {
		input();
		solve();
		break;
	}
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

int powM(int x, int n){
    if(n == 0){
        return 1;
    }
    if(n % 2 == 0){
        return powM(x * x % MOD, n / 2);
    }
    return powM(x, n-1) * x % MOD;
}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    auto dp = initVec2<int>(1 << 20, 2);
    vector<int> cnt(1 << 20);
    int sum = 0;
    int x = 0;
    set<int> s;

    rep(i, 1 << 20){
        dp[i][0] = 1;
    }

    rep(i, n){
        x ^= a[i];
        s.insert(x);
        if(x == 0){
            sum++;
        }else{
            dp[x][0] += dp[x][1] * (sum - cnt[x]) % MOD;
            dp[x][0] %= MOD;
            dp[x][1] += dp[x][0];
            dp[x][1] %= MOD;
            cnt[x] = sum;
        }
    }

    if(x == 0){
        int ans = 0;
        for(int x : s){
            ans += dp[x][1];
            ans %= MOD;
        }
        ans += powM(2, sum - 1);
        ans %= MOD;
        cout << ans << endl;
    }else{
        cout << dp[x][0] << endl;
    }

    return 0;
}


Measured memory_bytes: 83200
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var N = vals[0];
            var M = vals[1];
            var data = new long[N][];
            foreach(var i in Enumerable.Range(0, N))
            {
                data[i] = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            }

            if(M==0)
            {
                Console.WriteLine(0);
                return;
            }

            long maxpoints = 0;
            int[] currentIndices = null;
            foreach (var s in Enumerable.Range(0, 8))
            {
                int[] coef;
                switch (s)
                {
                    case 0:
                        coef = new int[] { 1, 1, 1 }; break;
                    case 1:
                        coef = new int[] { 1, 1, -1 }; break;
                    case 2:
                        coef = new int[] { 1, -1, 1 }; break;
                    case 3:
                        coef = new int[] { 1, -1, -1 }; break;
                    case 4:
                        coef = new int[] { -1, 1, 1 }; break;
                    case 5:
                        coef = new int[] { -1, 1, -1 }; break;
                    case 6:
                        coef = new int[] { -1, -1, 1 }; break;
                    case 7:
                        coef = new int[] { -1, -1, -1 }; break;
                    default:
                        coef = new int[] { 0, 0, 0 }; break;
                }

                var filter = Enumerable.Range(0, N)
                    .Select(x => new { Index = x, Sum = data[x][0] * coef[0] + data[x][1] * coef[1] + data[x][2] * coef[2] })
                    .OrderByDescending(x => x.Sum)
                    .Take(M);
                var currentPoint = filter.Select(x => x.Sum).Sum();

                if(maxpoints < currentPoint)
                {
                    currentIndices = filter.Select(x => x.Index).ToArray();
                    maxpoints = currentPoint;
                }
            }

            //再計算
            long x1 = 0; long x2 = 0; long x3 = 0;
            if (currentIndices != null)
            {
                foreach (var i in currentIndices)
                {
                    x1 += data[i][0];
                    x2 += data[i][1];
                    x3 += data[i][2];
                }
            }
            var result = Math.Abs(x1) + Math.Abs(x2) + Math.Abs(x3);

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13712
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout(n) cout << fixed << setprecision(n)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acosl(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int N, K;
int a[20];


signed main(){
    cin >> N >> K;
    rep(i, 0, N) cin >> a[i];

    int ans = INF;
    rep(i, 0, 1<<N){
        if(__builtin_popcount(i) < K) continue;
        int s = 0;
        int mh = a[0];
        rep(j, 1, N){
            if(mh >= a[j] and (i>>j)&1) s += mh+1-a[j], mh++;
            else if(mh < a[j]) mh = a[j];
        }
        chmin(ans, s);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>

using namespace std;

typedef pair<int,bool> Pair;

int main(){

  int ans = 0;
  int N;
  bool flg = false;
  cin >> N;

  for(int i = 1; i <= 9 && !flg; ++i){

    for(int j = 1; j <= 9 && !flg; ++j){

      if(i*j == N){

		flg = true;
	
      }

    }

  }

  if(flg) cout << "Yes" << endl;
  else    cout << "No"  << endl;
  
  
  return 0;

}

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

int main() {
	int a, b, c;
  	cin >> a >> b >> c;
  	int d1 = abs(a - b), d2 = abs(a - c), d3 = abs(b - c);
  	if(d1 > d2) swap(d1, d2);
  	if(d2 > d3) swap(d2, d3);
  	cout << d1 + d2;
}

Measured memory_bytes: 256
(function(input) {
    var p = input.split('\n');
    var n = Number(p.shift());
    var s = p.shift().split(' ', n).map(Number);
    var q = Number(p.shift());
    var t = p.shift().split(' ', q).map(Number);

    var c = 0;
    for (var i = 0; i < t.length; i++) {
        if (s.indexOf(t[i]) !== -1) {
            c++;
        }
    }
    console.log(c);
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 23808
import itertools

def main():
    N, M, Q = list(map(int, input().split()))
    a = []
    b = []
    c = []
    d = []

    for i in range(Q):
        ai, bi, ci, di = list(map(int, input().split()))
        a.append(ai)
        b.append(bi)
        c.append(ci)
        d.append(di)

    ans = 0
    for A in list(itertools.combinations_with_replacement(range(1, M+1), N)):
#    print(A)                                                                                          
        score = 0
        for i in range(Q):
            if A[b[i]-1] - A[a[i]-1] == c[i]:
                score += d[i]
        if ans < score:
            ans = score

    print(ans)

if __name__ == "__main__":
    main()


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

using namespace std;

char grid[1003][1003];

long long dp[1003][1003];

long long solve(int n, int m){
  	swap(n,m);
	dp[m-1][n-1] = 1;
    for (int slice = (m+n-2); slice >=0; --slice) {
        //printf("Slice %d: ", slice);
        int z1 = slice < n ? 0 : slice - n + 1;
        int z2 = slice < m ? 0 : slice - m + 1;
        for (int j = slice - z2; j >= z1; --j) {
          		int curx = j;
          		int cury = slice-j;
          		if(grid[curx][cury]!='.'){
                	dp[curx][cury] = 0;
                  	continue;
                }
          		if(curx+1<m){
                	dp[curx][cury]  += dp[curx+1][cury];
                }
          		if(cury+1<n){
                	dp[curx][cury]  += dp[curx][cury+1];
                }
          		dp[curx][cury] = dp[curx][cury]%1000000007;
        }
    }
  	return dp[0][0];
}

int main(){
	int n,m;
  	scanf("%d %d",&n,&m);
    for(int i = 0; i<n; ++i){
    	scanf("%s",grid[i]);
    }
  	long long ans = solve(n,m);
  	cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 9088
n=int(input())
a=list(map(int,input().split()))
from itertools import accumulate
s=list(accumulate(a))
a_sum=sum(a)
ans=10**18
if n==2:
  print(abs(a[0]-a[1]))
  exit(0)
for i in range(1,n-1):
  x=s[i]
  y=a_sum-x
  ans=min(ans,abs(x-y))
print(ans)
  


Measured memory_bytes: 24636
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1},
};

fn main() {
   input! {x:usize}
   let mut d = 0;
   let mut y = 100;
   while y < x {
      y = y + (y / 100);
      d += 1;
   }
   println!("{}", d);
}

Measured memory_bytes: 2108
#include<iostream>

using namespace std;



int main(){
  int n;
  
  cin >> n;
  int a,b;
  int max=0;
  int minp;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    if(a>max){
      max=a;
      minp=b;
    }
  }

  cout << max+minp << endl;

  return 0;
}
  


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

#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(s, i, n) for (i = s; i < n; i++)
using namespace std;

int main()
{
  double D, T, S;
  cin >> D >> T >> S;
  if (D / S <= T)
    cout << "Yes" << endl;
  else
  {
    cout << "No" << endl;
  }

  return 0;
}

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

typedef long long int   ll;
#define int             ll
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
#define scan(n)         scanf("%lld",&n)
#define pb              push_back
#define PI              3.1415926535897932384626433832795
#define rep0            for(int i=0;i<n;i++)
#define rep1            for(int i=1;i<=n;i++)
#define inputar0(ar)    for(int i=0;i<n;i++)cin>>ar[i]
#define inputar1(ar)    for(int i=1;i<=n;i++)cin>>ar[i]
#define showar0(ar)     for(int i=0;i<n;i++)cout<<ar[i]<<" "
#define showar1(ar)     for(int i=1;i<=n;i++)cout<<ar[i]<<" "
int mod=1000000007;
int maxn=200001;
int binpow(int a,int b,int mod){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
int binpow(int a,int b){int res=1;while(b>0){if(b%2){res=(res*a);b--;}a=(a*a);b/=2;}return res;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

void solve(int n) {
    string str;

    while (n > 0) {
        int rem = n % 26;
        if (rem == 0) {
            str+='z';
            n = (n / 26) - 1;
        }
        else  {
            str += (rem - 1) + 'a';
            n = n / 26;
        }
    }
    reverse(str.begin(),str.end());
    cout << str << endl;
}

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


Measured memory_bytes: 3580
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  int n;
  while(true){
    cin >> n;
    if(n == 0)break;
    vector<ll> a, sum;
    rep(i, n){
      ll x;
      cin >> x;
      a.pb(x);
      if(i > 0)sum.pb(sum[i-1] + x);
      else sum.pb(x);
    }
    ll res = - inf;
    rep(i, n){
      FOR(j, i, n){
        ll tmp = sum[j];
        if(i > 0)tmp -= sum[i - 1];
        res = max(res, tmp);
      }
    }
    cout << res << endl;
  }
	return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for(i=0;i<n;i++)
int main() {
	int n,mx=0,temp=0,i,j;
	string s;
	cin>>n;
	cin>>s;
	set<char> s1,s2;
	for(i=1;i<n-1;i++) {
		for(j=0;j<i;j++) s1.insert(s[j]);
		for(j=i;j<n;j++) s2.insert(s[j]);
		set<char> ::iterator it;
		for(it=s1.begin();it!=s1.end();it++) {
			if(s2.count(*it)) temp++;
		}
		if(temp>mx)	mx=temp;
		temp=0;
		s1.clear();
		s2.clear();	
	}
	cout<<mx<<"\n";
	return 0;
}

Measured memory_bytes: 256
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os
    import re
    with open(__file__) as f:
        source = f.read().split('###''nbacl')
    for s in source[1:]:
        s = re.sub("'''.*", '', s)
        sp = s.split(maxsplit=1)
        if os.path.dirname(sp[0]):
            os.makedirs(os.path.dirname(sp[0]), exist_ok=True)
        with open(sp[0], 'w') as f:
            f.write(sp[1])
import numpy as np
from numpy import int64
from numba import njit
from numba.types import i8
import nbacl.segtree as seg


@njit((i8, i8, i8[:]), cache=True)
def solve(N, K, A):
    dp = np.zeros(300_001, dtype=int64)
    d = seg.segtree(dp, max, 0)
    for i in range(N):
        x = seg.prod(d, max, (A[i] - K) if A[i] > K else 0, (A[i] + K + 1) if A[i] + K < 300_000 else 300_001) + 1
        seg.set(d, max, A[i], x)
    return seg.all_prod(d)


f = open(0)
N, K = [int(x) for x in f.readline().split()]
A = np.fromstring(f.read(), dtype=int64, sep=' ')
ans = solve(N, K, A)
print(ans)

'''
###nbacl nbacl/segtree.py
import numpy as np
from numba import njit
from numba.types import i8


@njit
def ceil_pow2(n):
    x = 0
    while (1 << x) < n:
        x += 1
    return x


@njit
def segtree(a, op, e):
    log = ceil_pow2(a.shape[0])
    size = 1 << log
    d = np.empty(size * 2, dtype=a.dtype)
    d[size:size + len(a)] = a
    d[size + len(a):] = e
    # e
    d[0] = e
    for i in range(size - 1, 0, -1):
        update(d, i, op)
    return d


@njit
def update(d, k, op):
    d[k] = op(d[2 * k], d[2 * k + 1])


@njit
def set(d, op, p, x):
    p += d.shape[0] // 2
    d[p] = x
    while p > 1:
        p >>= 1
        update(d, p, op)


@njit
def get(d, p):
    return d[p + d.shape[0] // 2]


@njit
def prod(d, op, left, right):
    size = d.shape[0] // 2
    sml = d[0]
    smr = d[0]
    left += size
    right += size

    while left < right:
        if left & 1:
            sml = op(sml, d[left])
            left += 1
        if right & 1:
            right -= 1
            smr = op(d[right], smr)
        left >>= 1
        right >>= 1

    return op(sml, smr)


@njit
def all_prod(d):
    return d[1]

'''


Measured memory_bytes: 119316
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include <utility>
#include<algorithm>
using namespace std;
string a,b;
int main(){
  cin>>a>>b;
  for(int i=0;i<3;i++){
    if(a[i]!=b[2-i]){cout<<"NO"<<endl;return 0;}
  }
  cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 256
import numpy as np

N, M, X = map(int, input().split())
Cs, As = [], []
ans = float("inf")

for _ in range(N):
    row = list(map(int, input().split()))
    C, A = row[0], row[1:]
    Cs.append(C)
    As.append(A)

As = np.array(As)

for i in range(2 ** N):
    tmp_A = np.array([0] * M)
    tmp_ans = 0
    for j in range(N):
        if (i >> j) & 1:
            tmp_ans += Cs[j]
            tmp_A += As[j]
    cnt = 0
    for j in range(M):
        if tmp_A[j] >= X:
            cnt += 1
    if cnt == M:
        ans = min(ans, tmp_ans)

if ans == float("inf"):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 27244
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [10**100]*n
dp[0] = 0
for i in range(1,n):
    for j in range(1,k+1):
        if i-j >= 0:
            dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]),dp[i])
        else:
            break
print(dp[-1])

Measured memory_bytes: 53472
a = input("")
a, b = a.split()
a, b = int(a), int(b)
c, d = 0, 0
while d < b:
    if a == 0:
        break
    c += 1
    d = a * c - (c - 1)
if b == 1:
  c = 0
print(c)

Measured memory_bytes: 2940
n = int(input())
count=0
check_flag = False
for i in range(n):
    s,t = map(int,input().split())
    if s==t:
        count+=1
    else:
        count=0
    if count == 3:
        check_flag = True
if check_flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define int long long int
using namespace std;
main() 
{
	// int t;
	// cin >> t;
	// while(t--)
	// {
		int n, m;
		cin >> n >> m;
		// vector<int> vec[n+1];
		int height[n+1];
		for(int i=1;i<=n;i++)
			cin >> height[i];
		int con[n+1] = {0}, grt[n+1] = {0};
		while(m--)
		{
			int x, y;
			cin >> x >> y;
			if(height[x]>height[y])
			{
				grt[x] += 1;
			}
			else if(height[x]<height[y])
			{
				grt[y] += 1;
			}
			con[x] += 1;
			con[y] += 1;
		}
		int ans = 0;
		for(int i=1;i<=n;i++)
		{
			if(con[i]==grt[i])
				ans++;
		}
		cout << ans << endl;
	// }
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    string S; cin >> S;
    int a = count(ALL(S), '1');
    int b = count(ALL(S), '0');

    int N = S.size();

    int num0 = N;
    int num1 = N;
    REP(i,N){
        if(S[i]=='0') num0 = min(num0, max(i,N-i-1));
        else num1 = min(num1, max(i,N-i-1));
    }
    bool same = true;
    REP(i,N){
        if(S[i]!='0') same = false;
    }
    if(same){
        cout << N << endl;
        return 0;
    }

    same = true;
    REP(i,N){
        if(S[i]!='1') same = false;
    }
    if(same){
        cout << N << endl;
        return 0;
    }

    cout << max(num0, num1) << endl;
    
    return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int h[n],cost[n],temp,min = 1000000000;
	for(int i=0; i<n; i++)
		cin>>h[i];
	cost[0]=0;
	cost[1]=abs(h[1]-h[0]);
	for(int i=1; i<n; i++)
	{
		min = 1000000000;
		for(int j=1; j<=k; j++)
		{
			if(i-j<0)continue;
			//cout<<"i,j : "<<i<<","<<j<<endl;
			//cout<<"Cost[i-j] : "<<cost[i-j]<<" Added more: "<<abs(h[i]-h[])
			temp = cost[i-j] + abs(h[i] - h[i-j]);
			//cout<<"Temp : "<<temp<<endl;
			if(temp < min)
			{
				min = temp;
				cost[i] = temp;
				//cout<<"Cost of "<<i<<" :"<<cost[i]<<endl;
			}
		}
	}
	//cout<<cost[1]<<endl;
	cout<<cost[n-1]<<endl; 
}

Measured memory_bytes: 1024
n = gets.to_i
t = gets.split.map(&:to_i).unshift(0)
v = gets.split.map(&:to_i).unshift(0)

for i in 0..n-1
  t[i+1] += t[i]
end

b = Array.new(2*t[n]+1){|i|[i,2*t[n]-i].min*0.5}

for i in 1..n
  for j in t[i-1]*2..t[i]*2
    b[j] = [b[j],v[i]].min
  end
  temp = 0.0
  (t[i-1]*2).downto(0) do |j|
    b[j] = [b[j],v[i]+temp].min
    temp += 0.5
  end
  temp = 0.0
  for j in t[i]*2..2*t[n]
    b[j] = [b[j],v[i]+temp].min
    temp += 0.5
  end
end
puts b.inject(:+)/2

Measured memory_bytes: 2172
# D - Replacing
def main():
    N, *X = map(int, open(0).read().split())
    A, BC = X[:N], X[N + 1 :]
    cnt = [0] * (10 ** 5 + 1)
    for a in A:
        cnt[a] += 1
    total = sum(A)
    res = []
    for b, c in zip(*[iter(BC)] * 2):
        total += (c - b) * cnt[b]
        res.append(total)
        cnt[c] += cnt[b]
        cnt[b] = 0
    print("\n".join(map(str, res)))


if __name__ == "__main__":
    main()


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

#define ll long long
#define ld long long
#define pi 3.14159265359

int main() {
    ll X; cin >> X;
    ll a = 0, b = 0;
    for (ll i = -500; i < 501; i++) {
        for (ll j = -500; j < 501; j++) {
            if (pow(i, 5) - pow(j, 5) == X) {
                a = i;
                b = j
            ;}
        }
    }
    cout << a << ' ' << b << endl;
}

Measured memory_bytes: 4020
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){
  int N,k,n=0,cnt=0;
  cin>>N;
  int a[N];
  for(int i=0;i<N;i++) cin>>a[i];
  for(int i=0;i<=N;i++){
    k=a[n];
    if(n==1){
      cout<<cnt<<endl;
      break;
    }
    n=k-1;
    cnt++;
    if(i==N) cout<<"-1"<<endl;
  }
} 


Measured memory_bytes: 640
s = input()
s_list = list(s)
check = False
if s_list == s_list[::-1]:
  s_list_mae = s_list[ : len(s_list)//2 ]
  s_list_usiro = s_list[len(s_list)//2 + 1 : ]
  if s_list_mae == s_list_mae[::-1] and s_list_usiro == s_list_usiro[::-1]:
    check = True
if check == True:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include<stdio.h>
#include<limits.h>

int count,L[250002],R[250002];

void merge(int *,int,int,int);
void mergeSort(int *,int,int,int);

int main(){
  int A[500000],i,n;
  count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  mergeSort(A,n,0,n);
  for(i=0;i<n;i++){
    if(i!=0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",count);
  
  return 0;
}

void merge(int *A,int left,int mid,int right){
  int i,j,k;
  int n1 = mid-left;
  int n2 =right-mid;
  for(i=0;i<n1;i++) L[i]=A[left+i];
  for(i=0;i<n2;i++) R[i]=A[mid+i];
  L[n1]=R[n2]=INT_MAX;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    count++;
    if(L[i]<=R[j]){
      A[k]=L[i++];
    }
    else{
      A[k]=R[j++];
    }
  }
}

void mergeSort(int *A,int n,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,left,mid,right);
  }
}



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

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

    vector<ll> cnt(26, 0);
    for (int i = 0; i < N; i++) {
        cnt[S[i] - 'a']++;
    }

    ll ans = 1;
    ll mod = 1e9 + 7;
    for (int i = 0; i < 26; i++) {
        if (cnt[i] == 0)
            continue;

        ans *= (cnt[i] + 1);
        ans %= mod;
    }
    cout << --ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1 << 30 - 1;
constexpr long long LLINF = 1LL << 60;
constexpr long long MOD = 1000000007;

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


int main()
{
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  S.PB('#');
  vector<pair<char, int>> v;
  vector<int> bi;
  int cnt = 1;
  REP(i, N) {
    if (S[i] != S[i + 1]) {
      v.PB(MP(S[i], cnt));
      cnt = 1;
      if (S[i] == '0') {
        bi.PB(v.size() - 1);
      }
    } else {
      cnt++;
    }
  }

  vector<int> rui(v.size());
  REP(i, v.size()) rui[i] = v[i].SE;
  REP(i, v.size() - 1) rui[i + 1] += rui[i];

  int ans = 0;
  REP(i, v.size()) {
    if (v[i].FI == '1') ans = max(v[i].SE, ans);
  }
  auto psum = [&](int l, int r) {
    if (l <= 0) return rui[r];
    else return rui[r] - rui[l-1];
  };
  for (int i = 0; i < bi.size(); i++) {
    int l = bi[max(0, i-K+1)];
    int r = bi[i];
    int sum = psum(l, r);
    if (r+1 < v.size()) sum += v[r+1].SE;
    if (l-1 > 0) sum += v[l-1].SE;
    
    ans = max(ans, sum);
  }
  cout << ans << endl;

  return 0;
}

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

int main() {
 int a=0,b=0;
int N;
cin >>N;
long int A[N+10];
long int k =114514810;
int l =-114514810;
int z;
int T;
for(int u=1;u<=N;u++){ cin>>A[u];}
for(int j=0;j<=N;j++){
for(int i=1;i<=N;i++){
      if(i<j){a+=A[i];
      }
      else if(i>=j){b+=A[i];
}}
if(k>abs(a-b)){k=abs(a-b);}
a=0;b=0;
}
cout<<k<<endl;
}


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

int main(){
  string S;
  cin >> S;
  int ans=0;
  int ACGT=0;
  for (int i=0;i<S.size();i++){
    if(S[i]=='A' or S[i]=='C' or S[i]=='G' or S[i]=='T'){
      ACGT++;
    }
    else{
      ans=max(ACGT,ans);
      ACGT=0;
    }
  }
  ans=max(ACGT,ans);
  cout << ans << endl;
}


Measured memory_bytes: 256
-- Ball
import Control.Monad

main = readLn
  >>= (\ n -> replicateM n getLine)
  >>= putStr . solve

solve :: [String] -> String
solve = unlines . map(tellYesNo . dfs 0 0 . map read . words)

dfs :: Int -> Int -> [Int] -> Bool
dfs _ _ [] = True
dfs l r (x:xs)
  | l < x && r < x = dfs x r xs || dfs l x xs
  | l < x = dfs x r xs
  | r < x = dfs l x xs
  | otherwise = False

tellYesNo :: Bool -> String
tellYesNo b
  | b == True = "YES"
  | otherwise = "NO"

Measured memory_bytes: 4084
n = int(input())
h = [ int(x) for x in input().split() ]

cnt = 0
while True:
    if max(h) == 0:
        break
    idx = 0
    while idx < n:
        if h[idx] == 0:
            idx += 1
        else:
            cnt += 1
            while idx < n and h[idx] != 0:
                h[idx] -= 1
                idx += 1

print(cnt)


Measured memory_bytes: 3060
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


m, d = li()
ans = 0
for mi in range(1, m+1):
    for di in range(1, d+1):
        if di%10 >= 2 and di//10 >= 2:
            if (di%10) * (di//10) == mi:
                ans += 1

print(ans)

Measured memory_bytes: 3064
/**
 *    Author: "Robin Singh" !!
 *    rob_in_1
**/
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define MP make_pair
#define sz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)
#define nl "\n"
typedef pair<int, int> pii;
typedef vector <int> vi;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } 
template <typename A>
string to_string(A v) {
  bool first = true; 
  string res = "{";
  for (const auto &x : v) {
    if (!first) res += ", ";
    first = false;
    res += to_string(x);
  }
  res += "}"; 
  return res;
}
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  dbg_out(T...);
}
#ifdef LOCAL
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", dbg_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

const long double eps = 1e-9;
const int mod = 1e9+7;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

//===================================================================================================!!

const int nn = 2e5+5;

void solve(){
  int a, b;
  cin >> a >> b;
  int k = (a + b)/2;
  if((a+b)%2) cout << "IMPOSSIBLE";
  else cout << k;
}

int32_t main(){
  #ifdef LOCAL 
    // freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
  #endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_set>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1ll << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

int main() {
	ll n, m;
	cin >> n >> m;
	vector<P> v;
	REP(i, m) {
		ll a, b;
		cin >> a >> b;
		a--;
		v.push_back(P(a, b));
	}
	REP(i, 11000) {
		string s = to_string(i).c_str();
		if (s.size() != n)continue;
		bool ok = true;
		REP(i, m) {
			if (s[v[i].first] - '0' != v[i].second)ok = false;

		}
		if (ok) {
			cout << i << endl;
			return 0;
		}

	}
	cout << -1 << endl;
}



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

public class Main{
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] t = br.readLine().split(" ");
    int n = Integer.parseInt(t[0]);
    int q = Integer.parseInt(t[1]);
    ArrayDeque<P> Q = new ArrayDeque<P>();
    for(int i = 0; i < n; i++){
      t = br.readLine().split(" ");
      P p = new P();
      p.name = t[0];
      p.time = Integer.parseInt(t[1]);
      Q.addLast(p);
    }
    int sumTime = 0;
    StringBuilder sb = new StringBuilder();
    while(!Q.isEmpty()){
      P p = new P();
      p = Q.pollFirst();
      if(p.time - q <= 0){
        sumTime += p.time;
        sb.append(p.name).append(" ").append(sumTime).append("\n");
      }else{
        p.time = p.time - q;
        Q.addLast(p);
        sumTime = sumTime + q;
      }
    }
    System.out.print(sb);
  }
}

class P{
  String name;
  int time;
}

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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
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;}

int main(){
	int n;
	vi v;
	cin >> n;
	REP(i,n*2){
		int  t;
		cin >> t;
		v.pb(t);
	}
	sort(All(v),greater<int>());
	ll int res = 0;
	REP(a,n){
		res += min(v[2*a],v[2*a+1]);
	}
	cout << res << endl;	
}

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

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;
}

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;
  if (u == s) a--;
  if (u == t) b--;
  cout << a << " " << b << endl;
  return 0;
}

Measured memory_bytes: 256
nums = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())

print(nums[K-1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
char s[100100],t[100100];
int c[100100];
int main(){
	int n,m=0,lst=1;
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;++i)if(s[i]!='x')t[++m]=s[i],c[m]=i-lst,lst=i+1;
	c[m+1]=n+1-lst;
	for(int i=1;i<=m+1-i;++i)if(t[i]!=t[m+1-i])return puts("-1"),0;
	if(m&1){
		int ans=0;
		for(int i=1;i<=m/2+1;++i)
			ans+=abs(c[i]-c[m+2-i]);
		printf("%d",ans);
	} else {
		int ans=0;
		for(int i=1;i<=m/2;++i)
			ans+=abs(c[i]-c[m+2-i]);
		printf("%d",ans);
	}
}

Measured memory_bytes: 768
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
	int i,j;
	double n,x,q;
	for(;scanf("%lf",&n)&&n+1;){
		q=n;x=q/2.0;
		for(;1;){
			x=x-((x*x*x-q)/(3.0*x*x));
			if(fabs(x*x*x-q)<0.00001*q){
				printf("%lf\n",x);break;
			}
		}
	}
	exit(0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+10;
int n;
int a[maxn];
int c[maxn];
inline int R_Int(){
	int ch,a;
	while(ch=getchar(),ch<'0'||ch>'9');a=ch^48;
	while(ch=getchar(),ch>='0'&&ch<='9')a=a*10+(ch^48);
	return a;
}

inline int Gcd(int a,int b){
	return b?Gcd(b,a%b):a;
}
bool usd[maxn];
inline bool Sieve(){
	for(int i=2;i<=1e6;i++)if(!usd[i]){
		int cnt=0;
		for(int j=1;i*j<=1e6;j++){
			int tmp=i*j;
			usd[tmp]=1,cnt+=c[tmp];
			if(cnt>1)return 0;
		}
	}
	return 1;
}

int main(){
	n=R_Int();
	int G;
	for(int i=1;i<=n;i++){
		c[a[i]=R_Int()]++;
		G=(i==1)?a[i]:Gcd(G,a[i]);
	}
	if(Sieve()){
		printf("pairwise coprime\n");
		return 0;
	}
	if(G==1)printf("setwise coprime\n");
	else printf("not coprime\n");
	return 0;
}


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

#define MAX_LENGTH 32

int main(void)
{
        char line[MAX_LENGTH];
        char op;
        int a,b;

        while (1) {
                fgets(line, sizeof(line), stdin);
                sscanf(line, "%d %c %d", &a, &op, &b);

                if (op == '?')
                        break;

                switch (op) {
                case '+':
                        printf("%d\n", a + b);
                        break;
                case '-':
                        printf("%d\n", a - b);
                        break;
                case '*':
                        printf("%d\n", a * b);
                        break;
                case '/':
                        printf("%d\n", a / b);
                        break;
                }
        }

        return 0;
}

Measured memory_bytes: 612