akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}


int main(){
  
  int a,b,c;
  cin>>a>>b>>c;
  if(a == b && b == c){
    if(a%2 == 0){
      cout<<-1<<endl;
    }else{
      cout<<0<<endl;
    }
    return 0;
  }
  int ans = 0;
  while(a%2 == 0 && b%2 == 0 && c%2 == 0){
    if(a == b && b == c){
      ans = -1;
      break;
    }
    int d[3];
    d[0] = a;
    d[1] = b;
    d[2] = c;
    a = d[1]/2 + d[2]/2;
    b = d[2]/2 + d[0]/2;
    c = d[0]/2 + d[1]/2;
    ans++;
  }
  cout<<ans<<endl;
  return 0; 
}


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

#define ll long long

int main()
{
    int n, w;
    cin >> n >> w;
    
    ++w;
    
    int arr[n][2];
    for (int i = 0; i < n; ++i)
        cin >> arr[i][0] >> arr[i][1];
        
    ll dp[n][w] = {};
    bool vis[n][w] = {};
    
    dp[0][0] = 0, vis[0][0] = 1;
    dp[0][arr[0][0]] = arr[0][1], vis[0][arr[0][0]] = 1;
    
    for (int i = 1; i < n; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            if (vis[i - 1][j])
            {
                dp[i][j] = max(dp[i][j], dp[i - 1][j]);
                vis[i][j] = 1;
                
                if (j + arr[i][0] < w)
                {
                    dp[i][j + arr[i][0]] = max(dp[i][j + arr[i][0]], dp[i - 1][j] + arr[i][1]);
                    vis[i][j + arr[i][0]] = 1;
                }
            }
        }
    }
    
    ll ans = 0;
    
    for (int i = 0; i < w; ++i)
        ans = max(ans, dp[n - 1][i]);
    
    cout << ans;
    
    return 0;
}

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

int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);

    int ans = a[2] - a[1];
    int sub = a[2] - (a[0] + ans);
    if(sub > 0){
        ans += sub / 2;
        if(sub % 2 != 0) ans += 2;
    }

    cout << ans << endl;

    return 0;
}   

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, m, ans[100010];
vector<P> shi[100010];
int main(void){
    // Your code here!
    cin >> n >> m;
    for (ll i = 1; i <= m; i++){
        ll p, y;
        cin >> p >> y;
        shi[p].push_back(P(y, i));
    }
    for (ll i = 1; i <= n; i++){
        sort(shi[i].begin(), shi[i].end());
    }
    for (ll i = 1; i <= n; i++){
        for (ll j = 0; j < shi[i].size(); j++){
            ans[shi[i][j].second] = i * 1000000 + j + 1;
        }
    }
    for (ll i = 1; i <= m; i++){
        ll t = 4;
        while(pow(10, t) < ans[i]){
            t++;
        }
        for (ll j = 0; j < 12 - t; j++) cout << '0';
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 8192
//外積を使う

#include<iostream>
#include<string>
#include<stdio.h>
#include<vector>

using namespace std;


int main(){
	
	vector<int> stack;

	int i = 0;
	int ret;

	while (scanf("%d", &ret) != EOF){
		if (ret != 0){
			stack.push_back(ret);
		}
		else{
			cout << stack[stack.size()-1]<< endl;
			stack.pop_back();
		}
	}


	return 0;
}

Measured memory_bytes: 1228
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] KS = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            int cnt = 0;
            for (int x = 0; x <= KS[0]; x++)
            {
                for (int y = 0; y <= KS[0]; y++)
                {
                    if (KS[1] < x + y)
                    {
                        continue;
                    }
                    int z = (int)KS[1] - x - y;
                    if (x + y + z == KS[1] && 0 <= z && z <= KS[0]) 
                    {
                        cnt++;
                    }
                }
            }
            Console.WriteLine(cnt);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


//Console.WriteLine(ans);


Measured memory_bytes: 28228
#include<bits/stdc++.h>
namespace ZDY{
#define fir freopen("2.in","r",stdin)
#define ll long long
#define Fur(i,x,y) for(int i=(x);i<=(y);i++)
#define fur(i,x,y) for(i=x;i<=y;i++)
#define Fdr(i,x,y) for(int i=x;i>=y;i--)
#define in2(x,y) in(x),in(y)
#define in3(x,y,z) in2(x,y),in(z)
#define in4(a,b,c,d) in2(a,b);in2(c,d)
#define clr(x,y) memset(x,y,sizeof(x))
#define cpy(x,y) memcpy(x,y,sizeof(x))
#define fl(i,x) for(ll i=head[x],to;to=e[i].to,i;i=e[i].next)
#define inf 2147483647
}
namespace FAST{
#define pob (fwrite(fob::b,sizeof(char),fob::f-fob::b,stdout),fob::f=fob::b,0)
#define pc(x) (*(fob::f++)=(x),(fob::f==fob::g)?pob:0)
#define gc ((*fib::f)?(*(fib ::f++)):(fgets(fib::b,sizeof(fib::b),stdin)?(fib::f=fib::b,*(fib::f++)):-1))
namespace fib{char b[300000]= {},*f=b;}namespace fob{char b[300000]= {},*f=b,*g=b+300000-2;}struct foce{~foce(){pob;fflush(stdout);}} _foce;namespace ib{char b[100];}template<class T>inline void in(T &x){x=0;char c;bool f=0;while((c=gc)>'9'||c<'0')if(c=='-')f=!f;x=c-48;while((c=gc)<='9'&&c>='0')x=x*10+c-48;if(f)x=-x;}template<class T>inline void out(T x){if(x==0){pc(48);return;}if(x<0){pc('-');x=-x;}char *s=ib::b;while(x) *(++s)=x%10,x/=10;while(s!=ib::b) pc((*(s--))+48);}template<class T>inline void outn(T x){out(x);pc('\n');}
inline char sc(){char c=gc;while(!(('A'<=c&&c<='Z')||('a'<=c&&c<='z')||('0'<=c<='9')))c=gc;return c;}
template<class T>inline T ABS(T x){return x>0?x:-x;}
template<class T>inline T MAX(T x,T y){return x>y?x:y;}
template<class T>inline T MIN(T x,T y){return x<y?x:y;}
template<class T>inline T GCD(T x,T y){return y?GCD(y,x%y):x;}
template<class T>inline void SWAP(T x,T y){T t=x;y=t;x=y;}
}using namespace FAST;using namespace ZDY;using namespace std;
int a;
int main(){
	in(a);
	if(a<1200)printf("ABC\n");
	else if(a<2800)printf("ARC\n");
	else printf("AGC\n");
}

Measured memory_bytes: 256
from collections import deque



H,W=map(int,input().split())
S=[]
for i in range(H):
    temp=list(input())
    S.append(temp)

step=[[1,0],[-1,0],[0,1],[0,-1]]

mx=0
for h in range(H):
    for w in range(W):
        if S[h][w]=="#":continue
        chk=[[False]*W for i in range(H)]
        q=deque([[h,w,0]])
        chk[h][w]=True
        while q:
            y,x,c=q.popleft()
            for dh,dw in step:
                if not (0<=y+dh<H and 0<=x+dw<W):continue
                if S[y+dh][x+dw]=="#":continue
                if chk[y+dh][x+dw]==False:
                    chk[y+dh][x+dw]=True
                    q.append([y+dh,x+dw,c+1])
                else:
                    mx=max(mx,c)

print(mx)




Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const ll INF = LLONG_MAX/3;

/*-----Library-----*/

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

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
    vector<int> sizeuf; //要素数
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n); sizeuf.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
            sizeuf[i]=1;
        }
    }

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

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

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        sizeuf[x]+=sizeuf[y];
        return true;
    }

    int size(int x){
        return sizeuf[root(x)];
    }
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}

long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}
//コンビネーション
/*
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 */
/*-----Library-----*/
const int MOD=1234567;
signed main(){
	int n;
	cin>>n;
	int mi=1;
	int a[110000];
	rep(i,n){
		cin>>a[i];
		if(i>0&&a[i-1]>=a[i])mi++;
	}
	cout<<mi<<endl<<n<<endl;
}



Measured memory_bytes: 3888
#include <iostream>
#include <fstream>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <list>
#include <array>
#include <cstdlib>
#include <stack>
#include <string>
#include <queue>
#include <chrono>
#include <functional>
#include <limits>
#include <cmath>
#include <algorithm>
#include <random>
#include <regex>
#include <tuple>
#include <numeric>
#include <cassert>
#include <utility>
#include <bitset>
#include <complex>
#include <iomanip>
#include <ostream>
#include <sstream>
#include <ctime>
using namespace std;
#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define V vector<int>
#define VP vector<pair<int, int> >
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define index INDEX
#ifndef ONLINE_JUDGE
#define print(x) PRINT(x, #x)
template<typename T> void PRINT(T VARIABLE, const string& NAME) {
	cerr << NAME << " = " << fixed << VARIABLE << "\n";
}
#else
#define print(x) 0 
#endif
int generate_random() {
	const int MAX_RANDOM = (int)1e6;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	return uniform_int_distribution<int>(0, MAX_RANDOM)(rng);
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll INFLL = 2 * (ll)1e18 + 100;
#define int ll
#ifdef int 
const int INFINT = INFLL;
#else
const int INFINT = 2 * (int)1e9 + 100;
#endif
const double PI = atan(1) * 4;
const double EPS = 1e-6;
const int SEED = (int)1e3 + 7;
const int MOD = (int)1e9 + 7;
const int NMAX = (int)1e6 + 5;

int v[NMAX];
int dp[NMAX];

int32_t main() {
#ifndef ONLINE_JUDGE
	double START_PROGRAM = clock();
#endif
	srand(time(NULL));
	cout << setprecision(20) << fixed;
	FASTIO;
    int n;
    cin >> n;
    for1(i, n)
    {
        cin >> v[i];
    }
    dp[1] = 0;
    dp[2] = abs(v[1] - v[2]);
    for(int i = 3; i <= n; i++)
    { 
        dp[i] = min(dp[i - 1] + abs(v[i] - v[i - 1]), dp[i - 2] + abs(v[i] - v[i - 2]));
    }
    cout << dp[n];







#ifndef ONLINE_JUDGE
	double END_PROGRAM = clock();
	double ELAPSED_TIME = (END_PROGRAM - START_PROGRAM) / CLOCKS_PER_SEC;
	cerr << "\n\nElapsed Time: " << ELAPSED_TIME * 1000 << "\n";
#endif
	return 0;
}







Measured memory_bytes: 5120
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){
    double x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    double d=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    printf("%lf\n",d);
    return 0;
}


Measured memory_bytes: 3296
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#include <atcoder/all>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int T;
	cin >> T;
	rep(t, T) {
		ll N, M, A, B;
		cin >> N >> M >> A >> B;
		ll ans = floor_sum(N, M, A, B);
		cout << ans << endl;
	}
	return 0;
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).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;}
const int MOD = 1000000007;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int mx = max({a, b, c});
    if (a % 2 == 0 && b % 2 == 0 && c % 2 == 0 || a % 2 == 1 && b % 2 == 1 && c % 2 == 1){
        cout << (mx - a) / 2 + (mx - b) / 2 + (mx - c) / 2 << endl;
    } else {
        if ((a - b) % 2 == 0) {
            a++;
            b++;
        } else if ((a - c) % 2 == 0) {
            a++;
            c++;
        } else {
            b++; c++;
        }
        mx = max({a, b, c});
        cout << (mx - a) / 2 + (mx - b) / 2 + (mx - c) / 2 + 1 << endl;
    }
}


Measured memory_bytes: 256
using System;

namespace ABC058C
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Int32.Parse(Console.ReadLine());
            string[] s = new string[n];
            for (int i = 0; i < n; i++)
            {
                s[i] = Console.ReadLine();
            }

            string tmp = String.Empty;

            for (int i = 0; i < s[0].Length; i++)
            {
                bool contain = true;

                for (int j = 1; j < n; j++)
                {
                    int idx = s[j].IndexOf(s[0][i]);
                    if (idx < 0)
                    {
                        contain = false;
                        break;
                    }
                    else
                    {
                        s[j] = s[j].Remove(idx,1);
                    }
                }

                if (contain)
                {
                    tmp += s[0][i];
                }

            }

            if (tmp != String.Empty)
            {
                char[] res = tmp.ToCharArray();
                Array.Sort(res);

                Console.WriteLine(res);
            }
            else
            {
                Console.WriteLine();
            }
        }
    }
}


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

int dp[3010][3010];
P pre[3010][3010];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	string s, t;
	cin >> s >> t;

	int N = s.size(), M = t.size();
	fill((int*)begin(dp), (int*)end(dp), -1);
	dp[0][0] = 0;
	for(int i = 0; i <= N; i++){
		for(int j = 0; j <= M; j++){
			if(dp[i][j] == -1) continue;
			if(s[i] == t[j]){
				if(dp[i + 1][j + 1] < dp[i][j] + 1){
					dp[i + 1][j + 1] = dp[i][j] + 1;
					pre[i + 1][j + 1] = { i, j };
				}
			}
			if(dp[i + 1][j] < dp[i][j]){
				dp[i + 1][j] = dp[i][j];
				pre[i + 1][j] = { i, j };
			}
			if(dp[i][j + 1] < dp[i][j]){
				dp[i][j + 1] = dp[i][j];
				pre[i][j + 1] = { i, j };
			}
			if(dp[i + 1][j + 1] < dp[i][j]){
				dp[i + 1][j + 1] = dp[i][j];
				pre[i + 1][j + 1] = { i, j };
			}
		}
	}

	string ans;
	int n = N, m = M;
	while(n + m){
		int nn = pre[n][m].first;
		int nm = pre[n][m].second;
		if(dp[n][m] - 1 == dp[nn][nm]){
			ans += s[nn];
		}
		n = nn, m = nm;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
}


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

#define ll long long
using namespace std;

int main() {
    int w, h, n;
    cin >> w >> h >> n;
    vector<ll> x(n);
    vector<ll> y(n);
    vector<vector<ll>> house(n, vector<ll>(2));
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        house[i][0] = x[i];
        house[i][1] = y[i];
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    ll misum = 1145141919810364364;
    ll retx, rety;
    for (int a = (n - 1) / 2; a <= n / 2; a++) {
        for (int b = (n - 1) / 2; b <= n / 2; b++) {
            ll nx = x[a];
            ll ny = y[b];
            if (1 <= nx && nx <= w && 1 <= ny && ny <= h) {
                ll sum = 0;
                ll ma = 0;
                for (int i = 0; i < n; i++) {
                    ll dis = abs(house[i][0] - nx) + abs(house[i][1] - ny);
                    ma = max(ma, dis);
                    sum += dis * 2;
                }
                sum -= ma;
                if (misum > sum) {
                    misum = sum;
                    retx = nx;
                    rety = ny;
                }
            }
        }
    }
    cout << misum << endl << retx << " " << rety << endl;
    return 0;
}


Measured memory_bytes: 10016
#include<iostream>
#include<cmath>
using namespace std;
bool pal(string s)
{
    for(int i = 0; i < s.size(); i ++)  if(s[i] != s[s.size() - 1 - i]) return 0;
    return true;
}
int a[100100], b[100100];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    string s1;
    for(int i = 0; i < s.size(); i ++)
    {
        if(s[i] != 'x') s1 += s[i];
    }
    if(!pal(s1))
    {
        cout << -1;
        return 0;
    }
    if(s1.size() == 0)
    {
        cout << 0;
        return 0;
    }
    int curr = 0, j = 0;
    for(int i = 0; i < s.size(); i ++)
    {
        if(s[i] == 'x') curr++;
        else
        {
            b[j++] = curr;
            curr = 0;
        }
    }
    curr = 0;
    j = s1.size() - 1;
    for(int i = s.size() - 1; i >= 0; i --)
    {
        if(s[i] == 'x') curr++;
        else
        {
            a[j--] = curr;
            curr = 0;
        }
    }
    for(int i = 0; i < s1.size(); i ++)
    {
        //cout << b[i] << " " << a[i] << endl;
    }
    int ans = 0;
    for(int i = 0; i < s1.size(); i ++)
    {
        if(a[i] > b[s1.size() - 1 - i])
        {
            //cout << "a" << i << endl;
            ans += a[i] - b[s1.size() - 1 - i];
            if(s1.size() - 2 - i > 0) a[s1.size() - 2 - i] = a[i];
        }
        if(a[i] < b[s1.size() - 1 - i])
        {
            ans += b[s1.size() - 1 - i] - a[i];
            if(i + 1 < s1.size()) b[i + 1] = b[s1.size() - 1 - i];
        }
    }
    cout << ans;
}


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i) // ROF(i,n,0)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで降順
#define pb push_back
#define eb emplace_back
#define fst first
#define snd second
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>T add(const T &a, const T &b){return (a+b)%mod;}

const double EPS = 1e-8;

signed main(){
  int n, d; cin >> n >> d;
  vvi x(n,vi(d));
  rep(i,n) rep(j,d) cin >> x[i][j];
  int ans = 0;
  rep(i,n) FOR(j,i+1,n){
    int tmp = 0;
    rep(k,d) tmp += (x[i][k]-x[j][k]) * (x[i][k]-x[j][k]);
    int s = sqrt(tmp);
    if(s * s == tmp) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
if __name__ == "__main__":
    H, W = map(int, input().split())
    
    bomb = "#"
    empty = "."
    empty_W = empty * (W + 2)
    
    s = []
    s.append(empty_W)
    for i in range(H):
        s_sub = input()
        s_sub = empty + s_sub + empty
        s.append(s_sub)
    s.append(empty_W)
    
    t = ["" for i in range(H)]
    for i in range(1, H + 1):
        for j in range(1, W + 1):
            if s[i][j] == empty:
                sij = 0
                for k in range(i - 1, i + 2):
                    for l in range(j - 1, j + 2):
                        if s[k][l] == bomb:
                            sij += 1
                t[i - 1] = t[i - 1] + str(sij)
            else:
                t[i - 1] = t[i - 1] + bomb
            
    for i in range(H):
        print(t[i])

Measured memory_bytes: 3064
#include<iostream>

int main()
{
    int a, b, k;
    std::cin >> a >> b >> k;
    if (k > b - a + 1){
        k = b - a + 1;
    }
    for(int i = 0;i < k; i++){
        std::cout << a + i << std::endl;
    }
    if(b - a + 1 < 2 * k){
        k = b - a - k + 1;
    }
    for(int i = 0;i < k; i++){
        std::cout << b - k + i + 1 << std::endl;
    }
}

Measured memory_bytes: 256
#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++)

int main() {
    string s;
    cin >> s;   
    cout << (s == "ABC" ? "ARC" : "ABC") << endl;
    return 0;    
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>

int main()
{
    char S[11], T[12];
    scanf("%s%s", S, T);

    int i, length = strlen(S);

    int n = strncmp(S, T, length);

    if(n == 0 && strlen(T) == length+1)
        printf("Yes\n");

    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 1708
// alt + tab to switch tab


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 


using namespace __gnu_pbds;
using namespace std ;


typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

#define ll long long
#define int long long
#define pb push_back
#define p1da(a,n) for(int i=0;i<(n);i++) cout << *( (a) + (i)) << " "; cout<<endl;
#define g1da(a,n) for(int i=0;i<(n);i++) cin >> *( (a) + (i)) ;
#define fi first
#define se second
#define f(i,n) for(int (i)=0;(i)<(n) ; (i)++ )
#define fr(i,s,e) for(int (i)=s;(i)<=(e) ; (i)++ )
#define pii pair <int,int>
#define p2da(a,row,col) f(i,row){f(j,col) cout << a[(i)][(j)]  <<" "; cout<<endl; }
#define g2da(a,row,col) f(i,row) f(j,col) cin >> a[(i)][(j)] ;
#define p1dv(v) f(i,v.size())cout<<v[(i)]<<" "; cout << endl ;
#define g1dv(v) f(i,v.size()) cin>>v[i] ;
#define debug(...)       dbg (#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void dbg(const char* n, Arg1&& arg1) {cerr << n << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void dbg(const char* n, Arg1&& arg1, Args&&... args) {const char*c = strchr(n + 1, ','); cerr.write(n, c - n) << " : " << arg1 << " || "; dbg(c + 1, args...);}
clock_t startTime ; void mainstart(); void mainEnd() ;
#define mod  998244353
#define N 50001



signed main()
{
  mainstart() ;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);


  int tt = 1 ;
  //cin >> tt ;
  //   https://www.guru99.com/node-js-tutorial.html

// int tc = 1 ;

  while (tt--)
  {
    int n,m ;
    cin >> n >> m ;
    int s = 0 ;
    while(m--)
    {
      int temp; 
      cin >> temp ;
      s += temp ;
    }
    if( s > n ) cout << -1 << endl ;
    else cout << n-s<<endl ;


  }

  mainEnd() ;
  return 0 ;
}

void mainstart()
{
#ifndef ONLINE_JUDGE
  freopen("Input.txt", "r", stdin) ;
  freopen("Output.txt", "w", stdout) ;
#endif
  startTime = clock() ;
}
void mainEnd()
{
  fclose (stdout);
  fclose (stdin);
  clock_t endTime = clock() ;
  cerr << "Run Time is : " << (float)( endTime - startTime ) / CLOCKS_PER_SEC << endl ;
}

Measured memory_bytes: 3812
import sys
readline = sys.stdin.readline
from collections import Counter
LIMIT = 2200
M = LIMIT**2
prime = [0]*M
for i in range(2, M):
    if prime[i]:
        continue
    for j in range(i, M, i):
        if not prime[j]:
            prime[j] = i


def prsh(N):
    prime = [2]
    for L in range(3,N):
        for p in prime:
            if not L % p:
                break
            if p > L**(1/2):
                prime.append(L)
                break
    return prime

PRIME = prsh(LIMIT)
SP = set(p for p in range(1, M) if prime[p] == p)
SP2 = Counter({p**2: p for p in SP})
MAXS = 10**10
N = int(readline())

L = []

match = Counter()
table = Counter()
for i in range(N):
    s = int(readline())
    ctr = 1
    res = 1
    for p in PRIME:
        if s == 1:
            break
        cnt = 0
        while s%p == 0:
            s //= p
            cnt += 1
        if cnt % 3:
            res *= p**(3 - cnt%3)
            ctr *= p**(cnt%3)
        if res > MAXS:
            res = 0    
    if s != 1:
        ctr *= s
        if s in SP:
            res *= s**2
        elif SP2[s]:
            res *= SP2[s]
        else:
            res = 0
    match[ctr] = res
    table[ctr] += 1

ans = 0
seen = set()
for k, v in table.copy().items():
    if k == 1:
        ans += min(v, 1)
        continue
    if k in seen:
        continue
    ans += max(v, table[match[k]])
    seen.add(match[k])
    seen.add(k)
print(ans)


Measured memory_bytes: 155720
use std::io::Read;

fn main() {
    let mut buff = String::new();
    std::io::stdin().read_to_string(&mut buff).unwrap();

    let mut iter = buff.split_whitespace();
    let n: i32 = iter.next().unwrap().parse().unwrap();

    for i in 1..10 {
        if n <= 111 * i {
            println!("{}", 111 * i);
            break;
        }
    }

    ()
}


Measured memory_bytes: 4352
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll dp[15][100010];
int main()
{
    int w;
    scanf("%d",&w);

    vector<int> weight;
    for(int i = 1; i <= w; i *= 6)
    weight.emplace_back(i);
    for(int i = 9; i <= w; i *= 9)
    weight.emplace_back(i);
    int n = (int)weight.size();

    for(int i = 0; i < 15; i++){
        for(int j = 0; j < 100010; j++){
            dp[i][j] = 1145141919810;
        }
    }
    for(int i = 0; i <= n; i++)
    dp[i][0] = 0;

    for(int i = 0; i < n; i++){
        for(int j = 0; j <= w; j++){
            dp[i + 1][j] = min(dp[i + 1][j],dp[i][j]);
            if(j >= weight[i]) dp[i + 1][j] = min(dp[i + 1][j],dp[i + 1][j - weight[i]] + 1);
        }
    }
    printf("%lld\n",dp[n][w]);
}

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


int main(){

    int N, K;
    cin >> N >> K; 


    long ans = pow( (int) (N/K), 3 );

    if( K % 2 == 0 ) ans += pow( (int) ((N+K/2)/K), 3 );
    
    cout << ans << endl;

    return 0;

}

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

int Mask[2], dp[2][1 << 13], T;

bool cal(int i, int mask){
    if (dp[i][mask] != -1) return dp[i][mask];
    if ((mask&Mask[i^1]) == Mask[i^1]) return dp[i][mask] = false;
    dp[i][mask] = 1; bool ck = 1;
    for (int j = 0; j < 13; j++){
        if (mask&(1 << j)) continue;
        if ((j > 0 && mask&(1 << (j-1))) || (j < 12 && mask&(1 << (j+1)))){
            if (Mask[i]&(1 << j)) dp[i][mask] &= cal(i^1, mask|(1 << j)), ck = 0;
        }
    }
    if (ck == true) dp[i][mask] &= cal(i^1, mask);
    dp[i][mask] ^= 1;
    return dp[i][mask];
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> T;
    while (T--){
        Mask[0] = 0;
        for (int i = 1; i <= 6; i++){
            int a; cin >> a; Mask[0] ^= 1 << (a-1);
        }
        Mask[1] = ((1 << 13)-1) ^ Mask[0] ^ (1 << 6);
        for (int i = 0; i < (1 << 13); i++) dp[0][i] = dp[1][i] = -1;
        cout << ((cal(0, 1 << 6) == 1) ? "yes" : "no") << "\n";
    }
}



Measured memory_bytes: 3236
#from collections import deque
import sys

readline = sys.stdin.readline
sys.setrecursionlimit(10**6)

#def mypopleft(que, index):
#    if len(que) > index:
#        return que.pop(index)
#    else:
#        return []


def main():
    # input
    n = int(input())

    graph = []
    for i in range(n):
        u, k, *tmp = [int(i) for i in readline().split()]
        graph.append(tmp)
    
    #print(graph)
    d = [-1]*n
    #que = deque([1])
    que = [1]
    #count = 0
    d[0] = 0
    check = []

    while True:
        v = que.pop(0)
        #print(v)
        #count += 1
        #print(d)
        for u in graph[v-1]:
            #print(u)
            if d[u-1] == -1:
                d[u-1] = d[v-1] + 1
                que.append(u)
        if len(que) == 0:
            break
    
    for i in range(n):
        print("{} {}".format(i+1, d[i]))


if __name__ == "__main__":
    main()



Measured memory_bytes: 5616
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
using namespace std;
#define foreach(i,v) for(int i=0;i<(int)v.size();i++)

const int N=55;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
char mz[N][N];
int con[N][N],on[N][N],off[N][N];
int pre[N][N],dis[N][N];
int tl[N*N];
struct point
{
    int x,y;
    point(){}
    point(int _x,int _y)
    :x(_x),y(_y){}
};
point task[1010];
vector<int> load;
queue<point> q;
int n,m;
void bfs(int sx,int sy,int ex,int ey)
{
    while(!q.empty()) q.pop();
    memset(pre,-1,sizeof(pre));
    memset(dis,-1,sizeof(dis));
    dis[sx][sy]=0;
    q.push(point(sx,sy));
    while(!q.empty())
    {
        point u=q.front(); q.pop();
        int x=u.x, y=u.y;
        if(x==ex && y==ey) break;
        for(int d=0;d<4;d++)
        {
            int nx=x+dx[d], ny=y+dy[d];
            if(nx<0 || nx>=n || ny<0 || ny>=m) continue;
            if(dis[nx][ny]!=-1 || mz[nx][ny]=='#') continue;
            dis[nx][ny]=dis[x][y]+1;
            pre[nx][ny]=x*m+y;
            q.push(point(nx,ny));
        }
    }
    int ntl=0;
    for(int x=ex,y=ey;pre[x][y]!=-1;)
    {
        int t=pre[x][y];
        tl[ntl++]=t;
        x=t/m; y=t%m;
    }
    for(int i=ntl-1;i>=0;i--) load.push_back(tl[i]);
}
int main()
{
//freopen("in.txt","r",stdin);
    int q;
    while(~scanf("%d%d%d",&n,&m,&q))
    {
        for(int i=0;i<n;i++) scanf("%s",mz[i]);
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++) scanf("%d",&con[i][j]);
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++) scanf("%d",&on[i][j]);
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++) scanf("%d",&off[i][j]);
        for(int i=0;i<q;i++) scanf("%d%d",&task[i].x,&task[i].y);
        load.clear();
        for(int i=1;i<q;i++) bfs(task[i-1].x,task[i-1].y,task[i].x,task[i].y);
        load.push_back(task[q-1].x*m+task[q-1].y);
        memset(pre,-1,sizeof(pre));
        int ans=0;
        foreach(i,load)
        {
            int l=load[i];
            int x=l/m, y=l%m;
            if(pre[x][y]==-1)
            {
                ans+=on[x][y];
                ans+=off[x][y];
            }
            else
            {
                int tmp=(i-pre[x][y])*con[x][y];
                tmp=min(on[x][y]+off[x][y],tmp);
                ans+=tmp;
            }
            pre[x][y]=i;
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 11220
#include<stdio.h>
#define NIL -1
#define MAX 500000
int root = NIL;
int key[MAX];
int left[MAX];
int right[MAX];
//int T[MAX];
int p[MAX];
void tree_insert(int z){
  int y = NIL;
  int x = root;
  while(x!=NIL){
    y = x;
    if(key[z] < key[x])x = left[x];
    else x = right[x];
  }
  p[z] = y;
  if(y == NIL)root = z;
  else if(key[z]<key[y])left[y] = z;
  else right[y] = z;
  
}
void preorder(int t){
  if(t==NIL)return;
  printf(" %d",key[t]);
  preorder(left[t]);
  preorder(right[t]);
}

void inorder(int t){
  if(t==NIL)return;
  inorder(left[t]);
  printf(" %d",key[t]);
  inorder(right[t]);
}

void print(){
  inorder(root);
  printf("\n");
  preorder(root);
  printf("\n");
}

int tree_find(int t){
  int i=0;
  int y=NIL;
  int x=root;
   while(x!=NIL){
     if(key[x]==t)return 1;
    y = x;
    if(t < key[x])x = left[x];
    else x = right[x];
  }
   return 0;
}

int main(){
  
  int i,n,x;
  int z = 0;
  char A[10];
  scanf("%d",&n);
  for(i=0;i<MAX;i++){
    key[i]=NIL;
    left[i]=NIL;
    right[i]=NIL;
    //   T[MAX]=NIL;
    p[i]=NIL;
  }
  for(i=0;i<n;i++){
    scanf("%s", A);
    if(A[0]=='i'){
      scanf("%d",&x);
      key[z]=x;
      tree_insert(z);
      z++;
    }
    else if(A[0]=='p')print();
    else if(A[0]=='f'){
       scanf("%d",&x);
       if(tree_find(x)==1)printf("yes\n");
       else printf("no\n");
    }
  }
  
  return 0;
}

Measured memory_bytes: 8236
main(){float a,b,c,d,e,f,x,y;for(;~scanf("%f%f%f%f%f%f",&a,&b,&c,&d,&e,&f);printf("%.3f %.3f\n",((e*c-f*b==0)?0:(e*c-f*b)/(e*a-b*d)),((a*f-c*d)==0?0:(a*f-c*d)/(a*e-b*d))));}

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

using namespace std;

typedef long long ll;
#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))

const double pi=acos(-1);
const int maxn=1e6+10;
const int mod=1e9+7;
double a[maxn];
int main()
{
    int n,k;
    sint2(n,k);
    a[0]=0;
    for(int i=1;i<=n;i++)
    {
        double b;
        scanf("%lf",&b);
        a[i]=(1+b)*b/(b*2)+a[i-1];
    }
    double ma=0;
    for(int i=k;i<=n;i++)
        ma=max(a[i]-a[i-k],ma);
    printf("%f",ma);
    return 0;
}


Measured memory_bytes: 1792
from math import ceil

n, k = map(int, input().split())
logs = list(map(int, input().split()))


def is_ok(num):
  t = 0
  for log in logs:
    if log <= num:
      continue
    t += ceil(log / num) - 1
  return t <= k

ng = 0
ok = 10 ** 9

while ok - ng > 1 :
  m = (ok + ng) // 2
  
  if is_ok(m):
    ok = m
  else:
    ng = m

print(ceil(ok))

Measured memory_bytes: 104300
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
using namespace std;

typedef pair <int, int> pii;
typedef pair <int, pii> ppi;

const int MAX_N = 2e5 + 10, MOD = 1e9 + 7;
int n,m,  V, U;
pii Arr[4 * MAX_N];
int L, R;
int dis[3][MAX_N];
vector <int> G[MAX_N];

void bfs (int v) {
	memset(dis, 127, sizeof dis);
	dis[0][v] = 0;
	Arr[R++] = {0, v};

	while (L < R) {
		int mod = Arr[L].first;
		int u = Arr[L++].second;

		for (int h: G[u])
			if (1 + dis[mod][u] < dis[(mod + 1) % 3][h]) {
				dis[(mod + 1) % 3][h] = 1 + dis[mod][u];
				Arr[R++] = {(mod + 1) % 3, h};
			}
	}
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int v, u;
		cin >> v >> u;
		v--, u--;

		G[v].push_back(u);
	}

	cin >> V >> U;
	V--, U--;
	bfs(V);

	if (4 * n < dis[0][U]) {
		cout << "-1\n";
		return 0;
	}

	cout << dis[0][U] / 3 << "\n";
	return 0;
}

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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int s;
  cin >> s;
  vector<ll> dp(s + 1);
  dp[0] = 1;
  for (int i = 3; i <= s; ++i) {
    for (int j = 3; j <= s; ++j) {
      if (0 <= i - j) {
        dp[i] += dp[i - j];
        dp[i] %= MOD;
      }
    }
  }
  cout << dp[s] << endl;
  return 0;
}

Measured memory_bytes: 3588
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            String S = in.next();
            int k = Integer.parseInt(in.next());

            char tmp = S.charAt(k - 1);
            String ans = "";

            for (int i = 0; i < n; i++) {
                if (S.charAt(i) == tmp) ans += S.charAt(i);
                else ans += "*";
            }
            // 出力
            out.println(ans);

        }

    }
}



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

int dp[1<<22][22];
int a[22][22];
int N=0;
ll mod=1000000007;

void solve(int n, int m)
{
    if(dp[n][m]!=-1)
        return;
    dp[n][m]=0;
   
    if(m==N-1)
    {
        for(int i=0; i<N; i++)
        {

            if( a[m][i]==1 && (n&(1<<i))==(1<<i))
            {
                dp[n][m]=1;
                dp[n][m]%=mod;
                return;
            }
        }
    }

    for(int i=0; i<N; i++)
    {

        if( a[m][i]==1 && (n&(1<<i))==(1<<i))
        {
            solve(n^(1<<i), m+1);
            dp[n][m]+=dp[n^(1<<i)][m+1];
            dp[n][m]%=mod;
        }
    }

}

int main()
{
    cin >> N;
    for(int i=0; i<N; i++)
    {
        for(int j=0; j<N; j++)
        {
            cin >> a[i][j];

        }
    }
    for(int i=0; i < (1<<N); i++)
    {
        for(int j=0; j<N; j++)
        {
            dp[i][j]=-1;
        }
    }


    solve( (1<<N) - 1, 0);
    cout << dp[ (1<<N) -1][0];
    
}

Measured memory_bytes: 183860
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

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

using namespace std;

typedef unsigned long long LL;

LL N;
vector<LL> D;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int X;
	cin >> X;

	int ans = 0;
	while(true){
		if((X * ans) % 360 == 0 && ans != 0){
			break;
		}
		ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3748
//
//Created by BLUEBUFF 2016/1/9
//Copyright (c) 2016 BLUEBUFF.All Rights Reserved
//

#pragma comment(linker,"/STACK:102400000,102400000")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/hash_policy.hpp>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdio>
#include <time.h>
#include <cstdlib>
#include <cstring>
#include <sstream> //isstringstream
#include <iostream>
#include <algorithm>
using namespace std;
//using namespace __gnu_pbds;
typedef long long LL;
typedef pair<int, LL> pp;
#define REP1(i, a, b) for(int i = a; i < b; i++)
#define REP2(i, a, b) for(int i = a; i <= b; i++)
#define REP3(i, a, b) for(int i = a; i >= b; i--)
#define CLR(a, b)     memset(a, b, sizeof(a))
#define MP(x, y)      make_pair(x,y)
template <class T1, class T2>inline void getmax(T1 &a, T2 b) { if (b>a)a = b; }
template <class T1, class T2>inline void getmin(T1 &a, T2 b) { if (b<a)a = b; }
const int maxn = 200010;
const int maxm = 100010;
const int maxs = 10;
const int maxp = 1e3 + 10;
const int INF  = 1e9;
const int UNF  = -1e9;
const int mod  = 1e9 + 7;
//int gcd(int x, int y) {return y == 0 ? x : gcd(y, x % y);}
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>order_set;
//head

//map <LL, LL> mp;
//LL f(LL n)
//{
//    return mp[n] ? mp[n] : ((mp[n] = (f(n / 2) + f((n - 1)/ 2)) % mod + f((n - 2) / 2) % mod) % mod);
//}
//int main()
//{
//    LL n;
//    mp[0] = 1;
//    mp[1] = 2;
//    scanf("%lld", &n);
//    printf("%lld\n", f(n));
//}

inline void add(int &x, int y)
{
    if((x += y) >= mod) x -= mod;
    if(x < 0) x += mod;
}
inline int cmp(int x, int y)
{
    return (x < y ? 0 : (x > y ? 2 : 1));
}

int num[65], dp[65][3][3][2];

int main()
{
    LL n;
    scanf("%lld", &n);
    //从低位到高位
    for(int i = 1; i <= 60; i++){
        num[i] = n % 2; n /= 2;
    }
    //初始化
    dp[0][1][1][0] = 1;
    //转移
    for(int i = 1; i <= 60; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                for(int l = 0; l < 2; l++){
                    //枚举第i为a, b分别填什么
                    for(int p = 0; p < 2; p++){
                        for(int q = 0; q <= p; q++){
                            int tj = cmp(p^q, num[i]);
                            int tk = cmp((p + q + l) % 2, num[i]);
                            if(tj == 1) tj = j;
                            if(tk == 1) tk = k;
                            int tl = (p + q + l) / 2;
                            add(dp[i][tj][tk][tl], dp[i-1][j][k][l]);
                        }
                    }
                }
            }
        }
    }
    int res = 0;
    for(int j = 0; j < 2; j++){
        for(int k = 0; k < 2; k++){
            add(res, dp[60][j][k][0]);
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
D, G = map(int, input().split())
PC = [list(map(int, input().split())) for _ in range(D)]

P, C = [], []
for p, c in PC:
  P.append(p)
  C.append(c)
  
answer = []
for i in range(2 ** D):
  tmp = 0
  cnt = 0
  for j in range(D):
    if (i >> j) & 1:
      tmp += P[j] * (j + 1) * 100 + C[j]
      cnt += P[j]
  if tmp >= G:
    answer.append(cnt)
  else:
    for j in range(D - 1, -1, -1):
      if (i >> j) & 1 == 0:
        if -(-(G - tmp) // ((j + 1) * 100)) <= P[j] - 1:
          cnt += -(-(G - tmp) // ((j + 1) * 100))
          answer.append(cnt)
        else:
          tmp += (P[j] - 1) * (j + 1) * 100
          cnt += (P[j] - 1)
          
print(min(answer))

Measured memory_bytes: 40560
#include <stdio.h>

int main(){

	int i, taka, aoki, k;

	scanf("%d%d%d",&taka,&aoki,&k);

	for(i=0;i<k;i++){
		if(i%2 == 0){
		taka /= 2;
		aoki += taka;
		
		}else{
		aoki /= 2;
		taka += aoki;
		}
	}

	printf("%d %d",taka,aoki);
	return 0;
}


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

typedef unsigned long long LL;

LL S[10000];
LL T[500];

int main() {
    int n, q;
    LL count=0;
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> S[i];
    }
    cin >> q;
    for (int i=0; i<q; i++) {
        cin >> T[i];
    }
    for (int i=0; i<q; i++) {
        for (int j=0; j<n; j++) {
            if (T[i] == S[j]) {
                count++;
                break;
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3076
N, Y = map(int, input().split())

res10000 = -1
res5000 = -1
res1000 = -1
for i in range(N+1):
    for j in range(N-i+1):
        k = N - i - j
        if(10000*i+5000*j+1000*k == Y):
            res10000 = i
            res5000 = j
            res1000 = k


print('{} {} {}'.format(res10000, res5000, res1000))




Measured memory_bytes: 3060
//Never stop chasing!-MdSourav.
#include <bits/stdc++.h>

#define yes            cout<<"YES"<<endl
#define no             cout<<"NO"<<endl
#define sz(x)          x.size()
#define ll                    long long int
#define ls             long int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)7           __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>())
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>())
#define asrt(a,n)      sort(a,a+n)
#define fact(n)        ll x=1;for(ll i=1;i<=n;i++){x=(x*i);}
#define F              first
#define S              second
#define deb(x)         cout << #x << ": " << x << endl;
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define INF 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;

double pi=3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664 ;
typedef vector<ll> vll ;
typedef vector<int> vii ;

// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}

void solve()
{

     int n,k;cin>>n>>k;
     vector<ll>v;
     enter(v,n);
     rsrt(v);
     if(k>=n)
	 {
	 	cout << "0";
	 }
	 else
	 {
	 	ll ans=0;
	 	for(int i=k;i<n;i++)
		{
			ans=ans+v[i];
		}
		cout << ans << endl;
	 }


}

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

	return 0;
}

Measured memory_bytes: 5324
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n; cin>>n;
    int v[n], c[n];
    for(int i=0;i<n;i++) cin>>v[i];
    for(int i=0;i<n;i++) cin>>c[i];
    int ans=0;
    for(int i=0;i<n;i++){
        if((v[i]-c[i])>0) ans+=v[i]-c[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#import<iostream>
#import<atcoder/all>
long i,N,Q,w,e,r,a;using namespace std;int main(){cin>>N>>Q;atcoder::fenwick_tree<long>b(N);for(;i<N;i++)cin>>a,b.add(i,a);while(Q--){cin>>w>>e>>r;if(w)cout<<b.sum(e,r)<<'\n';else b.add(e,r);}}

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



int main(){
    int N, K, R, S, P, Sum;
    string T;

    cin >> N >> K >> R >> S >> P >> T;
    int* Val = new int[N];

    for (int i = 0; i < N; i++) {
        if (T[i] == 'r') {
            Val[i] = P;
        }
        else if (T[i] == 's') {
            Val[i] = R;
        }
        else {
            Val[i] = S;

        }

    }
  
    for (int i = 0; i < N; i++) {

        if ((i - K) >= 0) {
            if (T[i] == T[i - K] && Val[i-K] != 0) {
                Val[i] = 0;
            }

       }
    }
    Sum = 0;
    for (int i = 0; i < N; i++) {
        
        Sum += Val[i];
      
    }

    cout << Sum;
    return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
#include <string.h>

int main(){
    char *mark = "SHCD";
    int card[4][13] = { 0 };
    
    int i, j;
    int n, t;
    char c;
    
    scanf("%d", &n);
    
    for(i = 0; i < n; ++i){
        scanf(" %c %d", &c, &t);
        card[strchr(mark, c) - mark][t - 1] = 1;
    }
    
    for(i = 0; i < 4; ++i){
        for(j = 0; j < 13; ++j){
            if(!card[i][j]){
                printf("%c %d\n", mark[i], j + 1);
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(1){
        c-=b;
        if(c<=0) {
            cout <<"Yes" << endl;
            return 0;
        }
        a-=d;
        if(a<=0) {
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3600