akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }

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

int nmax=200000; // 2*(10^5)
vvec g(nmax);

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

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n-1) cin >> a[i];
    map<int,int> mp;
    rep(i,n-1) mp[a[i]]++;
    rep(i,n){
        cout<<mp[i+1]<<endl;
    }

}

Measured memory_bytes: 22004
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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;
}

class ModCom {
    public:
        ModCom(int _n, long long _mod){
            assert(_n>=2);
            n = _n+1;
            mod = _mod;
            fac.assign(n,0);
            finv.assign(n,0);
            inv.assign(n,0);
            init();
        }
        vector<long long> inv;
        vector<long long> fac;
        vector<long long> finv;

        long long com(int _n, int k){
            if(_n < k){return 0;}
            if(_n < 0 || k < 0){return 0;}
            return fac.at(_n) * (finv.at(k) * finv.at(_n - k) % mod) % mod;
        }

    private:
        int n;
        long long mod;

        void init(void){
            fac.at(0) = fac.at(1) = 1;
            finv.at(0) = finv.at(1) = 1;
            inv.at(1) = 1;
            for(int i = 2;i < n; i++){
                fac.at(i) = fac.at(i - 1) * i % mod;
                inv.at(i) = mod - inv.at(mod % i) * (mod / i) % mod;
                finv.at(i) = finv.at(i - 1) * inv.at(i) % mod;
            }
            return;
        }
};

ModCom com(int(1e+6) + 200,MOD);

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while(n > 0) {
        if(n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

vector<long long> eratosthenes(long long n) {
    vector<long long> ret;
    vector<bool> check(n+100,false);
    if (n<2) {
        return ret;
    }
    long long idx = 2;
    while(idx*idx<=n) {
        if (!check[idx]) {
            ret.push_back(idx);
            for (int i=idx; i<=n; i+=idx) {
                check[i] = true;
            }
        }
        idx++;
    }
    for(int i=idx;i<=n;i++) {
        if (!check[i]) {
            ret.push_back(i);
        }
    }
    return ret;
}


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    vector<ll> a(n);
    vector<ll> ps = eratosthenes(1000000+10);
    vector<ll> mp(1000000+10,0);
    rep(i,n) cin>>a[i];
    rep(i,n) {
        ll target = a[i];
        for(auto x:ps) {
            ll cnt = 0;
            if (x*x>a[i])break;
            while(target%x==0) {
                cnt++;
                target /= x;
            }
            chmax(mp[x], cnt);
        }
        if (target!=1) {
            chmax(mp[target], 1LL);
        }
    }
    ll lcm = 1;
    rep(i,1000000+10){
        if (mp[i]==0)continue;
        lcm *= modpow(i,mp[i],MOD);
        lcm %= MOD;
    }
    ll res = 0;
    rep(i,n) {
        res += lcm * com.inv[a[i]];
        res %= MOD;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 32500
#include <iostream>
#include <string>
#include <vector>

using namespace std;

const long long int MOD=1e9+7;
const long long int BASE=37;

struct RollingHush {
    vector<long long int> pow;
    vector<long long int> hush;
    
    RollingHush(string str) : pow(str.size()+1), hush(str.size()+1) {
        pow[0] = 1;
        hush[0] = 0;
        for(int i=1; i<=str.size(); i++) {
            pow[i] = (pow[i-1]*BASE)%MOD;
            hush[i] = ((hush[i-1]*BASE)%MOD + (long long int)(str[i-1]-'a'))%MOD;
        }
    }
    
    long long int take_lr(int l, int r) {
        return ((hush[r]-hush[l]*pow[r-l])%MOD + MOD)%MOD;
    }
};

int main() {
    int N;
    cin >> N;
    string s, t;
    cin >> s >> t;
    
    RollingHush s_rh(s);
    RollingHush t_rh(t);
    
    int ans=2*N;
    for(int n=N; n>=0; n--) {
        if(s_rh.take_lr(s.size()-n, s.size())==t_rh.take_lr(0, n)) {
            ans -= n;
            break;
        }
    }

    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

template<typename T>
vector<T> dijkstra(int s, vector<vector<pair<int, T>>>& G) {
	const int n = G.size();
	vector<T> d(n, numeric_limits<T>::max());
	vector<int> b(n, -1);
	priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> q;
	d[s] = 0;
	q.emplace(d[s], s);
	while (!q.empty()) {
		pair<T, int> p = q.top();
		q.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (auto& e : G[v]) {
			int u = e.first;
			T c = e.second;
			if (d[u] > d[v] + c) {
				d[u] = d[v] + c;
				b[u] = v;
				q.emplace(d[u], u);
			}
		}
	}
	return d;
}

int main() {
	int H, W; cin >> H >> W;
	vector<string> s(H);
	for (int i = 0; i < H; ++i)
		cin >> s[i];
	vector<vector<pair<int, int>>> g(H * W);
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			int idx = W * i + j;
			if (j < W - 1) { // 右へ
				int idx_right = idx + 1;
				if (s[i][j] == '.' && s[i][j + 1] == '#')
					g[idx].emplace_back(idx_right, 1);
				else g[idx].emplace_back(idx_right, 0);
			}
			if (i < H - 1) { // 下へ
				int idx_under = idx + W;
				if (s[i][j] == '.' && s[i + 1][j] == '#')
					g[idx].emplace_back(idx_under, 1);
				else g[idx].emplace_back(idx_under, 0);
			}
		}
	}
	int res = dijkstra<int>(0, g)[H * W - 1];
	if (s[0][0] == '#') ++res;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 896
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

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

    int N;
    cin >> N;

    cout << "ABC" + to_string(N) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n, k;
	cin >> n >> k;
	int p[n + 1], c[n + 1];
	for(int i = 1; i <= n; i++) {
		cin >> p[i];
	}
	for(int i = 1; i <= n; i++) {
		cin >> c[i];
	}
	bool vis[n + 1] = {0};
	vector<vi> v;
	for(int i = 1; i <= n; i++) {
		if(!vis[i]) {
			vi tmp;
			int cur = i;
			while(!vis[cur]) {
				vis[cur] = 1;
				tmp.pb(cur);
				cur = p[cur];
			}
			v.pb(tmp);
		}
	}
	int sz = v.size();
	int sum[sz] = {0};
	for(int i = 0; i < sz; i++) {
		for(auto it : v[i]) {
			sum[i] += c[it];
		}
	}
	int ans = *max_element(c + 1, c + n + 1);
	for(int i = 0; i < sz; i++) {
		if(sum[i] <= 0) {
			int cur = v[i].size();
			for(int j = 0; j < cur; j++) {
				v[i].pb(v[i][j]);
			}
			multiset<int> s;
			int ss[v[i].size()];
			s.insert(0);
			for(int j = 0; j < v[i].size(); j++) {
				if(j == 0) {
					ss[j] = c[v[i][0]];
				}
				else {
					ss[j] = ss[j - 1] + c[v[i][j]];
				}
				if(j >= k) {
					if(j == k) {
						s.erase(s.find(0));
					}
					else {
						s.erase(s.find(ss[j - (k + 1)]));
					}
				}
				ans = max(ans, ss[j] - (*s.begin()));
				s.insert(ss[j]);
			}
		}
		else {
			int cur = v[i].size();
			int score = (k / cur) * sum[i];
			int left = (k % cur);
			if(left == 0) {
				left = cur;
				score -= sum[i];
			}
			for(int j = 0; j < cur; j++) {
				v[i].pb(v[i][j]);
			}
			int mmx = 0;
			multiset<int> s;
			int ss[v[i].size()];
			s.insert(0);
			for(int j = 0; j < v[i].size(); j++) {
				if(j == 0) {
					ss[j] = c[v[i][0]];
				}
				else {
					ss[j] = ss[j - 1] + c[v[i][j]];
				}
				if(j >= left) {
					if(j == left) {
						s.erase(s.find(0));
					}
					else {
						s.erase(s.find(ss[j - (left + 1)]));
					}
				}
				mmx = max(mmx, ss[j] - (*s.begin()));
				s.insert(ss[j]);
			}
			score += mmx;
			ans = max(ans, score);
		}
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 4132
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) a[i] = scanner.nextInt();

    int[] lgcd = new int[N];
    int[] rgcd = new int[N];
    for (int i = 1; i < N; i++) lgcd[i] = gcd(lgcd[i - 1], a[i - 1]);
    for (int i = N - 2; i >= 0; i--) rgcd[i] = gcd(rgcd[i + 1], a[i + 1]);

    int max = 1;
    for (int i = 0; i < N; i++) max = Math.max(max, gcd(lgcd[i], rgcd[i]));
    System.out.println(max);
  }

  static int gcd(int i, int j) {
    if (i > j) return gcd(j, i);
    while (i > 0) {
      int r = j % i;
      j = i;
      i = r;
    }
    return j;
  }
}


Measured memory_bytes: 51236
#include<stdio.h>
int binarysearch(void);
int S[1000000000],n,key;
int binarysearch(){
    int left,right,mid;
    left=0;right=n;
    while(left<right){
        mid=(left+right)/2;
        if(key==S[mid]){
            return 1;
        }
        else if(key>S[mid]){
            left=mid+1;
        }
        else if(key<S[mid]){
            right=mid;
        }
    }
    return 0;
}
int main(void){
    int q,i,j,count=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&S[i]);
    }
    scanf("%d",&q);
    for(j=0;j<q;j++){
        scanf("%d",&key);
        if(binarysearch()){
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
#define PII pair<int,int>
#define ll long long
#define maxn 1000010
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll h, cnt = 1, s = 0;
	cin >> h;
	while (h)
	{
		h = floor(h / 2);
		s += cnt;
		cnt *= 2;
	}
	cout << cnt - 1;
}


Measured memory_bytes: 256
import bisect
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}
# b = list(map(lambda x: math.ceil(x/10)*10, a))


k, s = map(int, input().split())
ans = 0
for i in range(k+1):
    if s-i > 2*k or s-i < 0:
        continue
    temp = s-i
    for j in range(k+1):
        if temp-j > k or temp - j < 0:
            continue
        ans += 1
print(ans)


Measured memory_bytes: 3060
n=int(input())
temp=[1,1]+[0]*(n-2)
for i in range(3,n+1):
    for j in range(2,i):
        while i%j==0:
            i=i//j
            temp[j-1]+=1
    if i!=1:
      temp[i-1]+=1
ans=1
for i in range(n-1):
    ans=(ans*(temp[i+1]+1))%(10**9+7)
print(ans)


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

int main() {
    int n;
    cin>>n;
    vector<long> a(n);
    long ans=0;
    rep(i,n){
        cin>>a[i];
        if(i==0) continue;
        long a1=a[i-1];
        long a2=a[i];
        if(a1>a2){
            ans=ans+a1-a2;
            a[i]=a1;
        }
    }
    cout<<ans<<endl;
}

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
#define guard(x) if( not ( x ) ) continue;
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      Int h, w; scan(h, w);
      for(Int y = 0; y < h; ++y) {
         for(Int x = 0; x < w; ++x) {
            std::string ss; scan(ss);
            if( ss == "snuke" ) {
               printf("%c%ld\n", (char)(x+'A'), y+1);
               return;
            }
         }
      }
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1 << 30;

int main(){
    int A, B, m;
    cin >> A >> B >> m;
    vector<int> a(A), b(B), x(m), y(m), c(m);
    int min_a = INF, min_b = INF, min_sum = INF;
    rep(i, A){
        cin >> a.at(i);
        min_a = min(a.at(i), min_a);
    }
    rep(i, B){
        cin >> b.at(i);
        min_b = min(b.at(i), min_b);
    }
    min_sum = min_a + min_b;
    rep(i, m){
        cin >> x.at(i) >> y.at(i) >> c.at(i);
        --x.at(i); --y.at(i);
        min_sum = min(min_sum ,a.at(x.at(i))+b.at(y.at(i))-c.at(i));
    }
    cout << min_sum << endl;
    return 0;
}

Measured memory_bytes: 2176
_, Q = gets.split.map &:to_i
$parent = []

def trace_parent i
  stack = []
  t = i
  while $parent[t]
    stack << t
    t = $parent[t]
  end
  stack.each{|e|
    $parent[e] = t
  }
  t
end

Q.times{
  com, s, t = gets.split.map &:to_i
  if com == 0
    if $parent[s] == nil
      if $parent[t] == nil
        $parent[t] = s
      else
        root = trace_parent t
        $parent[s] = root unless s == root
      end
    elsif $parent[t] == nil
      root = trace_parent s
      $parent[t] = root unless t == root
    else
      s_root = trace_parent s
      t_root = trace_parent t
      $parent[t_root] = s_root unless s_root == t_root
    end
  else
    puts trace_parent(s) == trace_parent(t) ? 1 : 0
  end
}

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

#define pb push_back
#define io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define clr(v) v.clear()
vector<ll>v;
pair<ll,ll>p;
map<ll,ll>mp;
set<ll>st;
deque<ll>dq;
priority_queue<ll>pq;
#define f(i,b) for(i=0;i<b;i++)
#define f1(i,b) for(i=1;i<=b;i++)
#define fr(i,b)for(i=b-1;i>=0;i--)
ll mn=INT_MAX,mx=INT_MIN;
ll n,m,tc,i,j,tmp,sum,cn,ans,res,pos,flag;

string s;


ll a[200007],b[200007];
int main()
{

   io;

cin>>n;
f(i,n)
{
    cin>>a[i];
    sum+=a[i];
    mp[a[i]]++;
}
ll q;
cin>>q;
while(q--)
{
ll x,y;
    cin>>x>>y;
    ll dif=y-x;
    sum+=mp[x]*dif;
    mp[y]+=mp[x];
    mp[x]=0;
    cout<<sum<<endl;
}

return 0;
}





Measured memory_bytes: 10204
#include <iostream>

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

using namespace std;




/** Problem0158 : Collatz's Problem **/
int main()
{
	int n;
	
	while (cin>>n, n!=0) {
		int i=0;
		while (n!=1) {
			if (n%2==0)
				n/=2;
			else
				n=n*3+1;
			i++;
		}
		cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import decimal,math
from collections import Counter,defaultdict
from fractions import gcd
from bisect import bisect_right,bisect_left
decimal.getcontext().prec = 10
N=int(raw_input())

arr=map(int,raw_input().split())
arr=sorted(arr)
# l = float(pow(2,N-1))
# ans=(arr[0]+arr[1])/l
# print ans
for i in range(1,N):
	arr[i] = (arr[i]+arr[i-1])/2.0
	# print arr
print arr[-1]	


Measured memory_bytes: 34792
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
long long n,k,ans,t;
int main()
{
    cin>>n>>k;
    ans=n/k;
    ans=ans*ans*ans;
    if(!(k&1))
	{
		t=(n+k/2)/k;
		t=t*t*t;
	}
    cout<<ans+t;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <array>
using namespace std;

int N, M;
bool data[10][10] = {};
int way = 0;
array<bool, 10> arr;

void dfs(int now, array<bool, 10> a){
    a[now] = true;
    bool check = true;
    for(int i = 0; i < N; ++i){
        if(!a[i]){
            check = false;
        }
    }
    if(check){
        way++;
        return;
    }
    for(int i = 0; i < N; ++i){
        if(data[now][i] && !a[i]){
            dfs(i, a);
        }
    }
}

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

    cin >> N >> M;

    for(int i = 0; i < M; ++i){
        int a, b;
        cin >> a >> b;
        --a, --b;
        data[a][b] = true;
        data[b][a] = true;
    }

    dfs(0, arr);
    cout << way << endl;

    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.datetime;
import std.numeric;
import std.math;
import std.string;

string my_readln() { return chomp(readln()); }

void main()
{
	auto tokens = my_readln().split();
	auto H = tokens[0].to!ulong;
	auto W = tokens[1].to!ulong;
	string[] a;
	foreach (i; 0..H)
	{
		a ~= my_readln();
	}

	long[1010][1010] memo;
	foreach (ref e; memo) foreach (ref ee; e) ee = -1;
	ulong mod = pow(10, 9) + 7;

	ulong search(long i, long j)
	{
		if (i == W || j == H) return 0;
		if (memo[i][j] != -1) return memo[i][j];
		if (a[j][i] == '#') return 0;
		if (i == W - 1 && j == H - 1) return 1;

		ulong r;
		r = (r + search(i+1, j)) % mod;
		r = (r + search(i, j+1)) % mod;

		//stderr.writeln(i, " ", j, " ", r);
		memo[i][j] = r;
		return r;
	}

	ulong ans = search(0, 0);

	writeln(ans);
	stdout.flush();
}

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

using namespace std;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  vector<int> v;
  v.push_back(A);
  v.push_back(B);
  v.push_back(C);

  sort(v.begin(), v.end(), std::greater<int>());
  int sum = v[0] * 10 + v[1] + v[2];
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N, L;
  cin >> N >> L;

  long eat = L;
  long sum = 0;

  rep (i, N) {
    long tmp = L + i;
    sum += tmp;
    if (abs(eat) > abs(tmp)) eat = tmp;
    //cout << "sum: " << sum << ", eat:" << eat << endl;
  }

  sum -= eat;
  cout << sum << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#----------
A,B,C,D = list(map(int, input().rstrip().split()))
#----------
time_start = max(A,C)
time_end = min(B,D)

if time_start <= time_end:
    ans = time_end - time_start
else:
    ans = 0

print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
    #define ll long long int
    #define MOD 1000000007
    #define mod 998244353
    #define pi 3.1415926535
    #define fi first
    #define se second
    #define vll vector<ll>
    #define vpll vector<pair <ll,ll> >
    #define vvll vector< vll >
    #define str string
    #define umap unordered_map
    #define uset unordered_set
    #define rep(i,n) for(ll i=0;i<n;i++)
    #define repA(i,s,n) for(ll i=s;i<=n;i++)
    #define repD(i,s,n) for(ll i=s;i>=n;i--)
    #define pb push_back
    #define mp make_pair
    #define lb lower_bound
    #define ub upper_bound
    #define elif else if
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define ALL(v) v.begin(),v.end()
    #define sortA(v) sort(ALL(v))
    #define sortD(v) sort(ALL(v),greater <ll> ())
    #define print(v) for(auto itr:v) cout<<*itr<<" ";
    #define sz size()
    #define nl cout<<"\n";
    using namespace std;
    ll factorial(ll n){return (n==1||n==0)?1:n*factorial(n-1);}
    ll power(ll x,ll y){ll res=1;while(y>0){if(y&1)res=res*x;y=y>>1;x=x*x;}return res;}
    ll powerMod(ll x,ll y,ll m){if(y==0)return 1;ll p=powerMod(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
    ll modInverse(ll a,ll m){return powerMod(a,m-2,m);}

    int main(){
        fast
        ll x=0,y=0;
        cin>>x>>y;
        if(y>4*x  || y< 2*x){cout<<"No";return 0;}
        if(  ((y-(4*x))%2==0)  &&  ((y-(4*x))/2<=x)) cout<<"Yes";
        else cout<<"No";
        return 0;
    }

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

const int N = 105;
char s[N][N];
int r[N][N], c[N][N];
int f[N * N >> 2][N * N >> 2];
int h, w, X, Y;

int encode(int l, int r, int M) {return r * M + l;}  // 编码

void chkmax(int& x, int v) {
    x = max(x, v);
}

int dfs(int lX, int rX, int lY, int rY) {
    int cX = encode(lX, rX, X), cY = encode(lY, rY, Y);
    if (f[cX][cY] >= 0) return f[cX][cY];
    f[cX][cY] = 0;
    if (lX < X - 1)
        chkmax(f[cX][cY], dfs(lX + 1, rX, lY, rY) + (rX + 1 <= X - lX - 1 ? max(0, r[X - lX - 1][min(Y + rY, w - lY)] - r[X - lX - 1][max(Y - lY, rY + 1) - 1]) : 0));
    if (rX < h - X)
        chkmax(f[cX][cY], dfs(lX, rX + 1, lY, rY) + (X + rX + 1 <= h - lX ? max(0, r[X + rX + 1][min(Y + rY, w - lY)] - r[X + rX + 1][max(Y - lY, rY + 1) - 1]) : 0));
    if (lY < Y - 1)
        chkmax(f[cX][cY], dfs(lX, rX, lY + 1, rY) + (rY + 1 <= Y - lY - 1 ? max(0, c[min(X + rX, h - lX)][Y - lY - 1] - c[max(X - lX, rX + 1) - 1][Y - lY - 1]) : 0));
    if (rY < w - Y)
        chkmax(f[cX][cY], dfs(lX, rX, lY, rY + 1) + (Y + rY + 1 <= w - lY ? max(0, c[min(X + rX, h - lX)][Y + rY + 1] - c[max(X - lX, rX + 1) - 1][Y + rY + 1]) : 0));
    return f[cX][cY];
}

int main() {
    scanf("%d%d", &h, &w);
    for (int i = 1; i <= h; i++) scanf("%s", s[i] + 1);
    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++)
            if (s[i][j] == 'E') X = i, Y = j;
    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++) {
            r[i][j] = r[i][j - 1] + (s[i][j] == 'o');
            c[i][j] = c[i - 1][j] + (s[i][j] == 'o');
        }
    memset(f, -1, sizeof(f));
    printf("%d\n", dfs(0, 0, 0, 0));
    return 0;
}


Measured memory_bytes: 30080
import sys
input=sys.stdin.readline
n=int(input())
Edge=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  Edge[a-1].append((b-1,i))
  Edge[b-1].append((a-1,i))
m=int(input())
M=[]
for i in range(m):
  M.append(tuple(map(int,input().split())))

inf=float("inf")
path=[-1]*n #根から各点までのパスが通過する辺をbitで管理したもの
path[0]=0
stack=[0]
while stack:
  cur=stack.pop()
  for next,num in Edge[cur]:
    if path[next]==-1:
      path[next]=path[cur]|(1<<num)
      stack.append(next)

def popcount(x):
  return bin(x).count("1")

passing=[] #Mの各u,vについて、通過する辺をbitで持ったもの
for u,v in M:
  passing.append((path[u-1]^path[v-1]))

ans=2**(n-1)
#Mのすべての部分集合について符号付で足し合わせる
for i in range(1,2**m):
  i_ct=popcount(i)#満たすべき条件の数、これで符号を決める
  condition=0
  for j in range(m):
    if i&(1<<j):#j番目の条件を満たす
      condition=condition|passing[j]
  cond_ct=popcount(condition) #iが表すMの部分集合の条件をすべて満たす場合にすべて白になる辺集合の要素数

  ans+=pow((-1),i_ct)*pow(2,n-1-cond_ct)
print(ans)

Measured memory_bytes: 43924
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll N,M;
  cin>>N>>M;
  vector<ll> x(M);
  for(ll i=0;i<M;i++){
    cin>>x.at(i);
  }
  if(N>=M){cout<<0<<endl;}
  else{
    sort(x.begin(),x.end());
    vector<ll> sa(M-1);
    for(ll i=0;i<M-1;i++){
      sa.at(i)=x.at(i+1)-x.at(i);
    }
    sort(sa.begin(),sa.end());
    ll ans=0;
    for(ll i=0;i<M-N;i++){
      ans+=sa.at(i); 
    }
    cout<<ans<<endl;
  }
}

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

const bool DEBUG = false;

string S;
int Q;
int T, F;
char C;

void input() { cin >> S >> Q; }

int main(int argc, char const* argv[]) {
  input();

  bool reversed = false;

  for (size_t i = 0; i < Q; i++) {
    cin >> T;
    if (T == 1) {
      reversed = !reversed;
    } else {
      cin >> F >> C;
      if ((F == 1) ^ (reversed)) {
        S.insert(0, 1, C);
      } else {
        S.insert(S.end(), 1, C);
      }
    }
  }

  if (reversed) {
    reverse(S.begin(), S.end());
  }

  cout << S << endl;

  return 0;
}

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

const int INF = 1e+8;

int main(){	
	int N;
	bool is_goto[100] = {false};
	string s[100];
	map<string,int> m;
	
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> s[i];
		if( s[i] == "goto" ){
			cin >> s[i];
			s[i][s[i].size()-1] = ':';
			is_goto[i] = true;
		}else{
			m[s[i]] = i;
		}
	}
	
	int g[110][110];
	for(int i = 0; i < 110; i++){
		for(int j = 0; j < 110; j++){
			g[i][j] = (i == j)? 0 : INF;
		}
	}
	
	for(int i = 0; i < N; i++){
		if( is_goto[i] ){
			g[i][m[s[i]]] = 0;
			g[i][i+1] = min(g[i][i+1], 1);
		}else{
			g[i][i+1] = 0;
		}
	}
	for(int k = 0; k <= N; k++){
		for(int i = 0; i <= N; i++){
			for(int j = 0; j <= N; j++){
				g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
			}
		}
	}
	cout << g[0][N] << endl;
}

Measured memory_bytes: 1276
K,N = map(int,input().split())
A = list(map(int,input().split()))
base = 0
ans = 0

maxdis = 0
for i in range(N):
    if i == N-1:
        maxdis = max(maxdis,K-A[i]+A[0])
    else:
        maxdis = max(maxdis,A[i+1]-A[i])
ans = K- maxdis
print(ans)


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

int main()
{
 long long n,  C = 1000;
 cin >> n;
 int a[n];
 for (int i = 1; i <= n; i++) cin >> a[i];
 for (int i = 1; i <= n - 1; i++) {
 long long Stocks = 0;
 if (a[i] < a[i + 1]) Stocks = C / a[i];
 C += (a[i + 1] - a[i]) * Stocks;

}
 cout << C<< endl;
 return 0;
}


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

const int MOD=1000000007;
//~ const int MOD=998244353;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	int n;cin>>n;
	int a=0,w=0,t=0,r=0;
	rep(i,n){
		string s;cin>>s;
		if(s=="AC")a++;
		else if(s=="WA")w++;
		else if(s=="TLE")t++;
		else r++;
	}
	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<w<<endl;
	cout<<"TLE x "<<t<<endl;
	cout<<"RE x "<<r<<endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int di[4] = {0, 1, 0, -1};
int dj[4] = {1, 0, -1, 0};

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> S(H, vector<char>(W));
  rep(i, H) {
    rep(j, W) {
      cin >> S[i][j];
    }
  }

  vector<vector<bool>> visited(H, vector<bool>(W, false));

  typedef pair<int, int> P;

  ll ans = 0;
  rep(h, H) {
    rep(w, W) {
      if (visited[h][w])
        continue;

      queue<P> q;
      map<char, ll> m;
      q.push(P(h, w));
      visited[h][w] = true;
      m[S[h][w]]++;

      while (!q.empty()) {
        P now = q.front();
        q.pop();

        rep(d, 4) {
          int i = now.fi;
          int j = now.se;
          int ni = i + di[d];
          int nj = j + dj[d];
          if (ni < 0 || ni >= H || nj < 0 || nj >= W || visited[ni][nj])
            continue;
          if (S[i][j] == S[ni][nj])
            continue;

          m[S[ni][nj]]++;
          visited[ni][nj] = true;
          q.push(P(ni, nj));
        }
      }
      ans += m['#'] * m['.'];
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

import static java.lang.Integer.parseInt;

/**
 * Treasure Hunt
 * Java 1.6 later
 */
public class Main {

	static final int MIN = -1_000_000_001;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		line = br.readLine();

		int n, m;
		n = parseInt(line.substring(0, line.indexOf(' ')));
		m = parseInt(line.substring(line.indexOf(' ') + 1));

		int[][] xy = new int[n + 1][2];

		NavigableMap<Integer, Integer> x = new TreeMap<>();
		NavigableMap<Integer, Integer> y = new TreeMap<>();

		//xy
		xy[0][0] = MIN;
		xy[0][1] = MIN;
		x.put(MIN, 0);
		y.put(MIN, 0);
		for (int i = 1; i <= n; i++) {
			line = br.readLine();
			xy[i][0] = parseInt(line.substring(0, line.indexOf(' ')));
			xy[i][1] = parseInt(line.substring(line.indexOf(' ') + 1));
			x.put(xy[i][0], 0);
			y.put(xy[i][1], 0);
		}

		//x
		int _i;
		_i = 0;
		for (Map.Entry<Integer, Integer> e : x.entrySet()) {
			e.setValue(_i);
			_i++;
		}

		//y
		_i = 0;
		for (Map.Entry<Integer, Integer> e : y.entrySet()) {
			e.setValue(_i);
			_i++;
		}

		//sum
		int[][] map = new int[x.size()][y.size()];
		for (int i = 1; i <= n; i++) {
			map[x.get(xy[i][0])][y.get(xy[i][1])]++;
		}
		for (int i = 1; i < map.length; i++) {
			for (int j = 1; j < map[0].length; j++) {
				map[i][j] += (map[i][j - 1] + map[i - 1][j] - map[i - 1][j - 1]);
			}
		}

		//answer queries
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < m; i++) {
			words = br.readLine().split(" ");
			int x1, y1, x2, y2;
			x1 = x.lowerEntry(parseInt(words[0])).getValue();
			y1 = y.lowerEntry(parseInt(words[1])).getValue();
			x2 = x.floorEntry(parseInt(words[2])).getValue();
			y2 = y.floorEntry(parseInt(words[3])).getValue();
			int c = map[x2][y2] - map[x1][y2] - map[x2][y1] + map[x1][y1];
			sb.append(c).append('\n');
		}
		System.out.print(sb.toString());

	} //end main
}

Measured memory_bytes: 263092
A, B, C, X, Y = map(int, input().split())

# ABピザ以外で考えると
ans = A * X + B * Y

# ABピザを全探索して考える
for i in range(2, max(2*X,2*Y)+1, 2):
    x = X - i // 2
    y = Y - i // 2
    ans = min(ans, A * max(0,x) + B * max(0,y) + C * i)

print(ans)


Measured memory_bytes: 39280
#include<vector>
#include<iostream>
#include<queue>
#include<functional>
using namespace std;

struct edge {
	int from, to, cost;
	bool operator>(const edge& other)const {
		return cost > other.cost;
	}
};

using edges = vector<edge>;
using graph = vector<edges>;

void add_edge(graph& g, int from, int to, int cost)
{
	g[from].push_back(edge{ from,to,cost });
	g[to].push_back(edge{ to,from,cost });
}

edges prim(graph& g)
{
	const int N = g.size();
	vector<bool>visited(N, false);
	visited[0] = true;
	priority_queue<edge, vector<edge>, greater<edge>>p_que;
	for (auto e : g[0])
	{
		p_que.push(e);
	}
	edges mst;
	while (!p_que.empty())
	{
		auto e = p_que.top();
		p_que.pop();
		if (visited[e.to])
		{
			continue;
		}
		mst.push_back(e);
		visited[e.to] = true;
		for (auto new_e : g[e.to])
		{
			p_que.push(new_e);
		}

	}
	return mst;
}

int main()
{
	int V, E;
	cin >> V >> E;
	graph g(V);
	for (int i = 0; i < E; i++)
	{
		int from, to, cost;
		cin >> from >> to >> cost;
		add_edge(g, from, to, cost);
	}
	auto mst = prim(g);
	int ans = 0;
	for (auto e : mst) {
		ans += e.cost;
	}
	cout << ans << endl;





	return 0;
}


Measured memory_bytes: 10160
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();

    auto S = new long[](N + 1);
    foreach (i; 1 .. N + 1)
    {
        S[i] = S[i - 1] + A[i - 1];
    }
    long ans = long.max;
    foreach (i; 1 .. N)
    {
        ans = ans.min(abs(S[i] - (S[N] - S[i])));
    }
    writeln(ans);
}


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

#define ll long long
#define pll pair<ll,ll> 

const ll N=5e5+5;
const ll mod=1e9+7;
vector<ll> F(N, 0);

void fact(ll n){
	F.assign(n, 0);
	F[0]=F[1]=1;
	for(ll i=2;i<n;i++)
		F[i]=(i*F[i-1])%mod;
}

ll mpow(ll a, ll b){
	ll x=1;
	while(b>0){
		if(b&1)
			x=(x*a)%mod;
		b>>=1;
		a=(a*a)%mod;
	}
	return x%mod;
}
ll P(ll n, ll r){
	ll x=F[n];
	ll y=F[n-r];
	y=mpow(y, mod-2);
	return (x*y)%mod;
}

ll C(ll n, ll r){
	ll x=P(n, r);
	ll y=F[r];
	y=mpow(y, mod-2);
	return (x*y)%mod;
}


int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll n, m;
	cin>>n>>m;
	fact(m+1);
	ll ans=0;
	for(ll i=0;i<=n;i++){
		if(i%2==0){
			ans+=P(m-i, n-i)*C(n, i);
			ans%=mod;
		} else{
			ans-=P(m-i,n-i)*C(n, i);
			ans=(ans%mod+mod)%mod;
		}
	}
	ans=ans*P(m, n)%mod;
	cout<<ans<<endl;
}




Measured memory_bytes: 6972
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int A, B, K;

int main() {
	cin >> A >> B >> K;
	REP(i, K) {
		int wa = 0, wb = 0;
		if (i % 2 == 0) {

			if (A % 2 == 1) {
				A--;
			}
			wa = A / 2;
			A = wa;
		}
		else {

			if (B % 2 == 1) {
				B--;
			}
			wb = B / 2;
			B = wb;
		}

		A += wb;
		B += wa;
	}
	cout << A << " " << B << endl;
}

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

int main() {
  int N;
  cin >> N;
  int H[N];
  bool f[N];
  int ans = 0;
  for(int i=0; i<N; i++) cin >> H[i];
  for(int i=0; i<N-1; i++){
    f[i] = (H[i+1] <= H[i]);
  }
  int tmp = 0;
  for(auto a : f){
    if(a) tmp++;
    else{
      if(tmp > ans) ans = tmp;
      tmp = 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 768
#include <stdio.h>

int main(){
  int N;
  scanf("%d",&N);
  int p[N];
  int i;
  for(i=0;i<N;i++) scanf("%d",&p[i]);

  //最大金額を求める
  int max=0;
  int i_max;
  for(i=0;i<N;i++){
    if(p[i]>max){
      max=p[i];
      i_max=i;
    }
  }

  //合計金額を求める．
  int sum=0;
  for(i=0;i<N;i++){
    if(i==i_max) sum+=p[i]/2;
    else sum+=p[i];
  }

  printf("%d\n",sum);
  return 0;
}

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

int main()
{
    int n, m, x, mi = 1001, tot = 0;
    cin >> n >> m;
    for(int i = 1; i <= n; i ++){
        scanf("%d", &x);
        mi = min(mi, x);
        tot += x;
    }
    m -= tot;
    int ans = n;
    ans += m / mi;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
    fastio;
    int m;
    cin >> m;
    cout << (24 - m) + 24 << endl;
}

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

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int n, m;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  //stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  //if (stream2 == NULL) return 0;
#endif
  cin >> n >> m;
  int ans = 1;
  for (int i = 1; i * i <= m; i++) {
    if (m % i == 0) {
      if (i >= n) ans = max(ans, m / i);
      if (m / i >= n) ans = max(ans, i);
    }
  }
  cout << ans << endl;
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll mod = 1000000007;
void solve()
{
	int x;
	cin >> x;
	cout << (x == 0 ? 1 : 0) << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	//cin >> t;
	t = 1;
	for (int tt = 1; tt <= t; tt++)
	{

		solve();
	}
	return 0;
}

Measured memory_bytes: 3644
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B = list(map(int, sys.stdin.buffer.readline().split()))
    print((A+B)//2 if (A+B)%2 == 0 else 'IMPOSSIBLE')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n]; // 街のX座標
		int[] y = new int[n]; // 街のY座標

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

		double sum = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				sum += Math.sqrt(Math.pow(x[i] - x[j], 2) + Math.pow(y[i] - y[j], 2));
			}
		}

		double average = sum / n;
		System.out.println(average);

		sc.close();
	}

}


Measured memory_bytes: 23892
fun main(args: Array<String>) {
    abc093b()
}

fun abc093b() {
    val (a, b, k) = readLine()!!.split(" ").map { it.toLong() }

    val answer = ((a..a + k - 1) + (b - k + 1..b)).filter { it in a..b }.toSortedSet()

    println(answer.joinToString(separator = System.lineSeparator()))
}


Measured memory_bytes: 37824
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    while(cin >> n >> m, n | m)
    {
        vector<int> G[n];
        for(int i = 0; i < m; i++)
        {
            int a, b; cin >> a >> b;
            a--, b--;
            G[a].push_back(b);
            G[b].push_back(a);
        }
        set<int> st;
        for(int u = 0; u < G[0].size(); u++)
        {
            int p = G[0][u];
            st.insert(p);
            for(int v = 0; v < G[p].size(); v++)
            {
                st.insert(G[p][v]);
            }
        }
        st.erase(0);
        //for(auto x : st) cout << x << " "; cout << endl;
        cout << st.size() << endl;
    }
    return 0;
}




Measured memory_bytes: 3276
#include <stdio.h>

int main()
{
	int i, n=1, pm, pe, pj;
	float a2, a3;
	
	while(n) {
		scanf("%d", &n);
		
		if (n!=0) {
			for (i=1; i<=n; i++) {
				scanf("%d %d %d", &pm, &pe, &pj);

				a2 = (pm + pe)/2;
				a3 = (pm + pe + pj)/3;
		
				if	(pm==100 || pe==100 || pj==100 || a2>=90 || a3>=80) printf("A\n");
				else if (a3>=70 || (a3>=50 && (pm>=80 || pe>=80)))	printf("B\n");
				else printf("C\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
template <typename T> 
using lim = numeric_limits<T>;
template <typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using indexed_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

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

    ll k; cin >> k;
    int found = -1;
    ll curr = 7%k;
    if (curr == 0){
        found = 1;
    }
    for (int i = 2; i < 1e6 && found == -1; i++){
        curr = (curr*10)%k;
        curr = (curr+7)%k;
        if (curr == 0){
            found = i;
            break;
        }
    }

    cout << found << "\n";
}

Measured memory_bytes: 3652
#include<iostream>
#include<cmath>
using namespace std;
static const int MAX_N=10e5;
#define INF 10e10
int cost[MAX_N];
long dp[MAX_N];
int main(void){
	int N,K;
		cin >> N >> K;
	for(int i=0;i<N;i++){
		cin >> cost[i];
		dp[i]=INF;
	}
	
	dp[0]=0;
	for(int i=1;i<N;i++){
		for(int j=i-1;(j>=0) && (i-j<=K);j--)
			dp[i]=min(dp[i],dp[j]+abs(cost[i]-cost[j]));
	}
	
	cout << dp[N-1] << endl;
	return 0;
}

Measured memory_bytes: 5120
while True:
    A, B, C = map(str, input().split())
    a = int(A)
    b = int(C)
    if B=="?":
        break
    elif B=="+":
        print(a+b)
    elif B==("-"):
        print(a-b)
    elif B=="*":
        print(a*b)
    elif B==("/"):
        print(a//b)

Measured memory_bytes: 7512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> x(n);
    rep(i, n) cin >> x[i];

    int ans = INF;
    rep(i, n-k+1) {
        if (x[i] * x[i+k-1] >= 0) { //同符号
            int m = max(abs(x[i]), abs(x[i+k-1]));
            ans = min(ans, m);
        } else {
            int m = max(abs(x[i]), abs(x[i+k-1]));
            int mi = min(abs(x[i]), abs(x[i+k-1]));
            ans = min(ans, mi*2 + m);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(){
	vector<int> dice(6);
	string str;
	for(auto &a: dice){
		cin >> a;
	}
	cin >> str;
	int top = 1,n = 5,e = 3,w = 4,s = 2;
	for(int i = 0; i < str.length(); i++){
		if(str[i] == 'S'){
			s = top;
			top = n;
			n = 7 - s;
		}else if(str[i] == 'E'){
			e = top;
			top = w;
			w = 7 - e;
		}else if(str[i] == 'W'){
			w = top;
			top = e;
			e = 7 - w;
		}else{
			n = top;
			top = s;
			s = 7 - n;
		}
	}
	cout << dice[top-1] << endl;
	return 0;
}	

Measured memory_bytes: 3224
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)

int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    FAST
    cin>>n;
    ll total = 0;
    for(i=1;i<=n;i++)
    {
        total+= i*(n-i+1);
    }
    for(i=1;i<n;i++)
    {
        cin>>x>>y;
        if(x>y)
            swap(x,y);
        k = x*(n-y+1);
        total-= k;
    }
    cout<<total<<endl;
    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(long int I=X;I<Y;I++)
#define REP(I,X,Y) for(long int I=Y-1;I>=X;I--)
#define INF 1000000007
using namespace std;

int check(char c){
  string s = "abcdefghijklmnopqrstuvwxyz";
  FOR(i,0,s.size())if(s[i] == c)return 1;
  return 0;
}

int main(){
  int a,b,c;
  string S,T;
  cin >> S;
  bool ans1 = 0,ans2 = 0,ans3 = 1;
  if(S[0] == 'A')ans1 = 1;
  FOR(i,2,S.size()-1){
    if(S[i] == 'C'){
      if(ans2)ans1 = 0;
      ans2 = 1;
      a = i;
    }
  }
  FOR(i,1,S.size()){
    if(!check(S[i]) && i != a){
      ans3 = 0;
    }
  }
  if(ans1 && ans2 && ans3)cout << "AC" << endl;
  else cout << "WA" << endl;
}


Measured memory_bytes: 256