akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 998244353
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

ll calc(vector<int> &A, vector<pair<ll, ll>> &B, bool l) {
    ll cur = 0;
    ll tmp = 0;
    int N = (int)A.size();
    rep(i, N - 1) {
        auto b = B[A[i]];
        if((b.first - cur) * (b.second - cur) > 0) {
            if(l) {
                if(i % 2 == 0) {
                    tmp += abs(cur - b.first);
                    cur = b.first;
                }
                else {
                    tmp += abs(cur - b.second);
                    cur = b.second;
                }
            }
            else {
                if(i % 2 == 1) {
                    tmp += abs(cur - b.first);
                    cur = b.first;
                }
                else {
                    tmp += abs(cur - b.second);
                    cur = b.second;
                }
            }
        }
//        cout << i << ":" << b.first << "," << b.second << ":";
//        output(cur);
    }
    auto b = B[A[N - 1]];
    if(b.first * b.second <= 0) tmp += abs(cur);
    else {
        tmp += min(abs(cur - b.first) + abs(b.first), abs(cur - b.second) + abs(b.second));
    }
    return tmp;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<vector<pair<pair<ll, ll>, int>>> A(2, vector<pair<pair<ll, ll>, int>>(N));
    vector<pair<ll, ll>> B(N);
    
    rep(i, N) {
        ll l, r;
        cin >> l >> r;
        A[0][i] = mp(mp(l, r), i);
        A[1][i] = mp(mp(r, l), i);
        B[i] = mp(l, r);
    }
    sort(all(A[0])); sort(all(A[1]));
    reverse(all(A[0]));
    vector<int> vis(N, 0);
    vector<vector<int>> L(2);
    int ind[2] = {0, 0};
    rep(i, N) {
        while(vis[A[i % 2][ind[i % 2]].second]) ind[i % 2]++;
        vis[A[i % 2][ind[i % 2]].second] = 1;
        L[0].pb(A[i % 2][ind[i % 2]].second);
    }
    vis.assign(N, 0);
    ind[0] = 0; ind[1] = 0;
    rep(i, N) {
        int j = (i + 1) % 2;
        while(vis[A[j][ind[j]].second]) ind[j]++;
        vis[A[j][ind[j]].second] = 1;
        L[1].pb(A[j][ind[j]].second);
    }
    ll ans1 = calc(L[0], B, true);
    ll ans2 = calc(L[1], B, false);
    output(max(ans1, ans2));

    return 0;
}


Measured memory_bytes: 8152
#include <bits/stdc++.h>
using namespace std;
int h, w, n, x, y;
long long c[10];
map<pair<int, int>, int> g;
int main() {
	scanf("%d%d%d", &h, &w, &n);
	c[0] = (long long)(h - 2) * (w - 2);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &x, &y);
		for (int j = x; j < x + 3; j++) {
			for (int k = y; k < y + 3; k++) {
				if (3 <= j && j <= h && 3 <= k && k <= w) {
					c[g[make_pair(j, k)]]--;
					c[++g[make_pair(j, k)]]++;
				}
			}
		}
	}
	for (int i = 0; i < 10; i++) {
		printf("%lld\n", c[i]);
	}
	return 0;
}

Measured memory_bytes: 56448
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);

	void run(){

		int n= sc.nextInt();

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

			char[] buf = String.valueOf(sc.nextInt()).toCharArray();

			Arrays.sort(buf);

			int a =Integer.valueOf(String.valueOf(buf));

			for(int j =0; j<buf.length/2;j++){

				char t = buf[j];

				buf[j] =buf[buf.length-j-1];

				buf[buf.length-j-1]=t;    

			}

			int b= Integer.valueOf(String.valueOf(buf));

			System.out.println(b-a);

		}

		

	}

	public static void main(String[] args){

		Main m = new Main();

		m.run();

		

	}

}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define mod 998244353 
int32_t main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int dp[n+1];dp[0]=0;
    for(int i=1;i<n;i++)
    {
        dp[i]=INT_MAX;
    }
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<=min(k,i);j++)
        {    
            dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
        }
        //cout<<dp[i]<<" ";
    }
    cout<<dp[n-1];

}

Measured memory_bytes: 1792
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        int c = s.nextInt();
        if(a < b){
            if(b < c){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26156
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
const int D_MAX_V=1010;
const int D_v_size=1010;
struct D_wolf{
	int t,c,r;
	D_wolf(){t=c=r=0;}
	D_wolf(int t1,int c1,int r1){
		t=t1;c=c1;r=r1;
	}
};
vector<D_wolf>D_G[D_MAX_V];
int D_level[D_MAX_V];
int D_iter[D_MAX_V];

void add_edge(int from,int to,int cap){
	D_G[from].push_back(D_wolf(to,cap,D_G[to].size()));
	D_G[to].push_back(D_wolf(from,0,D_G[from].size()-1));
}
void D_bfs(int s){
	for(int i=0;i<D_v_size;i++)D_level[i]=-1;
	queue<int> Q;
	D_level[s]=0;
	Q.push(s);
	while(Q.size()){
		int v=Q.front();
		Q.pop();
		for(int i=0;i<D_G[v].size();i++){
			if(D_G[v][i].c>0&&D_level[D_G[v][i].t]<0){
				D_level[D_G[v][i].t]=D_level[v]+1;
				Q.push(D_G[v][i].t);
			}
		}
	}
}
int D_dfs(int v,int t,int f){
	if(v==t)return f;
	for(;D_iter[v]<D_G[v].size();D_iter[v]++){
		int i=D_iter[v];
		if(D_G[v][i].c>0&&D_level[v]<D_level[D_G[v][i].t]){
			int d=D_dfs(D_G[v][i].t,t,min(f,D_G[v][i].c));
			if(d>0){
				D_G[v][i].c-=d;
				D_G[D_G[v][i].t][D_G[v][i].r].c+=d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s,int t){
	int flow=0;
	for(;;){
		D_bfs(s);
		if(D_level[t]<0)return flow;
		for(int i=0;i<D_v_size;i++)D_iter[i]=0;
		int f;
		while((f=D_dfs(s,t,99999999))>0){flow+=f;}
	}
	return 0;
}
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int m[30][30];
int main(){
	int T;scanf("%d",&T);
	for(int tc=1;tc<=T;tc++){
		int a,b;scanf("%d%d",&b,&a);
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)scanf("%d",&m[i][j]);
		int s=a*b;
		int t=a*b+1;
		for(int i=0;i<D_MAX_V;i++){
			D_G[i].clear();
			D_level[i]=D_iter[i]=0;
		}
		int INF=99999999;
		int sum=0;
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				sum+=m[i][j];
				if((i+j)%2==0){
					add_edge(s,i*b+j,m[i][j]);
					for(int k=0;k<4;k++){
						if(0<=i+dx[k]&&i+dx[k]<a&&0<=j+dy[k]&&j+dy[k]<b)
							add_edge(i*b+j,(i+dx[k])*b+j+dy[k],INF);
					}
				}else add_edge(i*b+j,t,m[i][j]);
			}
		}
		printf("Case %d: %d\n",tc,sum-max_flow(s,t));
	}
}

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

using namespace std;

int main()
{
    #ifdef HOME
    freopen("input.txt", "rt", stdin);
    #endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    if (n % 10 == n / 100)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//const double pi=acos(-1.0);
#define mod 1000000007
#define forn(i,k,n) for(ll i=k;i<n;i++)
#define fornr(i,k,k1) for(ll i=k;i>=k1;i--)
#define v(ll) vector<ll>
#define vl(a,n,ll,k) vector<ll> a(n,k)
#define vli(a,n) vector<ll> a(n)
#define init(a,n) vector<ll> a(n);forn(i,0,n)cin>>a[i]
#define vll(a,n,m,ll,k) vector<vector<ll>> a(n,vector<ll>(m,k))
#define mp(a,ll,ll1) map<ll,ll1> a
#define st(a,ll) set<ll> a
#define mpa make_pair
#define pr pair<ll,ll>
#define pb push_back
#define MAX 1000000
#define ed '\n'
#define fileTake ifstream cin("input.txt");ofstream cout("output.txt");
#define sortv(a) sort(a.begin(),a.end())
#define sorta(a,n) sort(a,a+n)
#define yeah "YES"
#define nil "NO"
#define All(x) x.begin(),x.end()
#define remDup(a) a.erase(unique(All(a)),a.end())
#define N 100
 
void swap(ll &x,ll &y) 
{ 
	x=x^y;
	y=x^y;
	x=x^y;
} 

template<typename T>
void print(T a){for(auto i=a.begin();i!=a.end();i++)cout<<*i<<" ";cout<<endl;}
bool isVowel(char c)
{
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')return true;
	return false;
}

void sync(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}

int main(){
	sync();
	
	ll n,k;
	cin>>n>>k;
	init(a,n);
	ll ans=-1;
	ll lo=1,hi=1000000000;
	while(lo<=hi)
	{
		ll mid=(lo+hi)/2;
		ll cnt=0;
		forn(i,0,n)
		{
			cnt+=a[i]/mid;
			if(a[i]%mid==0)cnt--;
		}
		if(cnt<=k)
		{
			ans=mid;
			hi=mid-1;
		}
		else lo=mid+1;
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 4712
#include <stdio.h>
#define N 200000

int main(void) {
	int max,min, i ,j, n;
	scanf("%d" ,&n);
	int R[N];
	
	for(i = 0;i < n;i++){
		scanf("%d" , &R[i]);
	}
	
	max = R[1] - R[0];
	min = R[0];
	
	for(i = 1; i < n ;i++){
		if(max < R[i] - min){
		max = R[i] - min;
		}
		if(min > R[i]){
		min = R[i];
		}
	}

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



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


//      DEEP


using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fwd(i,a,n) for(int i=a;i<=n;i++)
#define bak(i,a,n) for(int i=a;i>=n;i--)
#define all(v) v.begin(),v.end()
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef set<int> si;
const ll mod = 1e9 + 7;
ll power(ll x,ll y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}
ull gcd(ull x,ull y){
   if(y==0)return x;
   return gcd(y,x%y);
}
int main(){
    string s,t;
    cin>>s>>t;
    if((int)s.size()==(int)t.size()-1){
        string n(t.begin(),t.begin()+s.size());
        if(n==s)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    else cout<<"No"<<endl;
}








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

ll solve() {
    ll N;
    cin >> N;
    vector<string> S(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> S[i];
    }
    vector<string> t(N);
    for ( int i = 0; i < N; i++ ) {
        for ( int j = 0; j < N; j++ ) {
            t[i].push_back(S[j][i]);
        }
    }
    for ( int i = 0; i < N; i++ ) {
        S[i].append(S[i]);
    }
    ll cnt = 0;
    for ( int k = 0; k < N; k++ ) {
        bool ok = true;
        for ( int i = 0; i < N; i++ ) {
            if ( t[(i+k)%N] != S[i].substr(k, N) ) {
                ok = false;
                break;
            }
        }
        if ( ok ) cnt++;
    }
    ll ans = cnt * N;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
pii md = {1000000007, 1000000009};
pii operator + (pii a, pii b){
	a.first += b.first;
	a.second += b.second;
	if(a.first >= md.first) a.first -= md.first;
	if(a.second >= md.second) a.second -= md.second;
	return a;
}
pii operator - (pii a, pii b){
	if(b.first) b.first = md.first - b.first;
	if(b.second) b.second = md.second - b.second;
	return a + b;
}
const int maxn = 5050;
pii ways[maxn];
int a[maxn];
int main(){
	ways[0] = {1, 1};
	int n, k; cin >> n >> k;
	for(int i = 0; i < n; i++) cin >> a[i];
	int cnt = 0;
	for(int i = 0; i < n; i++) {
		if(a[i] < k){
			for(int j = maxn - a[i] - 1; j >= 0; j--)
				ways[j + a[i]] = ways[j + a[i]] + ways[j];
		}
	}
	for(int i = 0; i < n; i++){
		if(a[i] < k){
			for(int j = 0; j <= maxn - a[i] - 1; j++)
				ways[j + a[i]] = ways[j + a[i]] - ways[j];
			bool some = false;
			for(int j = k - a[i]; j <= k - 1; j++)
				if(ways[j].first || ways[j].second)
					some = true;
			if(!some) {
				cnt++;
			}
			for(int j = maxn - a[i] - 1; j >= 0; j--)
				ways[j + a[i]] = ways[j + a[i]] + ways[j];
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 384
//#include "SaveFuncs.cpp"

/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
//#define int long long
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divUp(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }

/*****/

int Main()
{
	int N;
	cin >> N;

	cout << pow(N ,3);
}

/*****/

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

	//std::cout << std::fixed << std::setprecision(10);

	Main();

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<deque>
#include<iomanip>
#include<tuple>
#include<stack>

#define _USE_MATH_DEFINES
#include<math.h>


using namespace std;
typedef long long ll;

typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef tuple<int, int, int> ti3;

const ll MOD_CONST = 1000000007;
//const ll MOD_CONST = 998244353;


const int BIG_NUM = 1000000005;
const ll INF = 1000000000000000000;

//const vector<vector<int>> DIR{ {1,0},{0,1},{-1,0},{0,-1} };

//const double EPS = 1e-10;


int main() {
	int n;
	cin >> n;
	vector<pii> edge;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (n % 2 == 0) {
				if (i + j != n - 1) {
					edge.emplace_back(make_pair(i + 1, j + 1));
				}
			}
			else {
				if (i + j != n - 2) {
					edge.emplace_back(make_pair(i + 1, j + 1));
				}
			}
		}
	}

	std::cout << edge.size() << endl;
	for (pii e : edge) {
		std::cout << e.first << " " << e.second << endl;
	}
} 




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

typedef long long ll;

const ll MOD = (1e+9) + 7;

ll memo[10];
ll dp[101][8];

void dfs(string s)
{
  if(s.size() > 8) return;

  bool f = false;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '1'){
      if(f) return;
      f = true;
    }else{
      f = false;
    }
  }

  memo[s.size()]++;

  dfs(s + '0');
  dfs(s + '1');
}

int main()
{
  dfs("");

  int h, w, k;
  cin >> h >> w >> k;

  dp[0][0] = 1;

  ll t;
  for(int i = 1; i <= h; i++){
    for(int j = 0; j < w; j++){
      if(j > 0){
        t = memo[max(0, w-1-(j+1))];
        t *= memo[max(0, j-2)];
        t %= MOD;
        dp[i][j] = dp[i-1][j-1] * t % MOD;
      }

      if(j < w-1){
        t = memo[max(0, j-1)];
        t *= memo[max(0, w-1-(j+2))];
        t %= MOD;
        dp[i][j] += dp[i-1][j+1] * t % MOD;
        dp[i][j] %= MOD;
      }

      t = memo[max(0, j-1)];
      t *= memo[max(0, w-1-(j+1))];
      t %= MOD;
      dp[i][j] += dp[i-1][j] * t % MOD;
      dp[i][j] %= MOD;
    }
  }

  cout << dp[h][k-1] << endl;

  return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 1123456;
ll num_of_divisors[MAX_N];

int main2() {
  ll N = nextLong();

  ll ans = 0;
  for (int n = 1; n < N; n++) {
    ans += num_of_divisors[n];
  }
  cout << ans << endl;
  return 0;
}

int main() {

  for (int d = 1; d < MAX_N; d++) {
    for (int i = d; i < MAX_N; i += d) {
      num_of_divisors[i]++;
    }
  }

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

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

int main() {
    string s,t; cin >> s >> t;
    vector<string> ans;
    int l = s.size();
    for(int i = 0; i < max(0, l); i++)
    {
        string tmp = s;
        for(int j = 0; j < t.length(); j++)
        {
            if(i+j>s.size()-1) break;
            if(tmp[i+j]=='?' || tmp[i+j]==t[j]) tmp[i+j] = t[j];
            else break;
            if(j==t.length()-1) {
                for(int k = 0; k < tmp.length(); k ++) {
                    if(tmp[k]=='?') tmp[k] = 'a';
                }
                ans.push_back(tmp);
            }
        }
    }
    sort(ans.begin(), ans.end());
    cout << (ans.size() > 0 ? ans[0] : "UNRESTORABLE") << endl;
    return 0;
}


Measured memory_bytes: 256
let () =
  let rec simple_calculator ()=
    let a, op, b = Scanf.sscanf (read_line()) "%d %c %d" (fun a op b -> a,op,b) in
    match op with
      |'+' -> print_int (a + b);print_string "\n"; simple_calculator ();
      |'-' -> print_int (a - b);print_string "\n"; simple_calculator ();
      |'*' -> print_int (a * b);print_string "\n"; simple_calculator ();
      |'/' -> print_int (a / b);print_string "\n"; simple_calculator ();
      |_ -> ();
  in
  simple_calculator ();
;;


Measured memory_bytes: 2344
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    long long N, A, B;
    cin >> N >> A >> B;
    long long n = N / (A + B);
    long long mod = N % (A + B);
    long long sum;
    if (mod > A)
    {
        sum = A * (n + 1);
    }else
    {
        sum = A * n + mod;
    }

    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
long n;
 
int main() {
    cin >> n;
    long a;
    vector<long> junban(n);
    for(long i = 0; i < n; i++){
        cin >> a;
        junban[a-1] += i+1;
    }
    for(long j = 0; j < n; j++){
        cout << junban[j] << " ";
    }
    cout << endl;
}

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

using namespace std;

#define dbg(x) cerr << #x"=" << x << endl;
typedef long long LL;

int main(){
	//freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    int a,b;
    cin >> a >> b;
    int ans = 0;
    if(a <= 5){
        ans = 0;
    } else if(a >= 13){
        ans = b;
    } else {
        ans = b/2;
    }
    cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner input = new Scanner(System.in);
        int index = 1;
        while(true){
            int W = input.nextInt();
        	if(W == 0)break;
        	int num = input.nextInt();
        	input.nextLine();
        	int[] v = new int[num];
        	int[] w = new int[num];
        	for(int i = 0 ; i < num ; i++){
        		String[] st = input.nextLine().split(",");
        		v[i] = Integer.parseInt(st[0]);
        		w[i] = Integer.parseInt(st[1]);
        	}
        	System.out.println("Case "+index+":");
        	treasure(v,w,num,W);
        	index++;
        }
    }

    public static void treasure(int[] v,int[] w,int N,int W){
    	int[][] dp = new int[N+1][W+1];//v,w
    	for(int i = N-1 ; i >= 0 ; i--){
    		for(int j = 0 ; j <= W ; j++){
    			if(j < w[i]){
    				dp[i][j] = dp[i+1][j];
    			}else{
    				dp[i][j] = Math.max(dp[i+1][j], dp[i+1][j-w[i]]+v[i]);
    			}
    		}
    	}
    	int var = 0;
    	int weight = 0;
    	for(int i = W ; i >= 0 ; i--){
    		if(var <= dp[0][i]){
    			var = dp[0][i];
    			weight = i;
    		}
    	}
    	System.out.println(var);
    	System.out.println(weight);
    }
}

Measured memory_bytes: 30844
#include<cstdio>
#include<cmath>
int a,b,h;
int main()
{
	scanf("%d%d",&a,&b);
	if(b>9&&b!=100)
		h=a*100+b;
	else if(b==100)
		h=a*1000+b;
		else
		h=a*10+b;
	if((int(sqrt(h)))*(int(sqrt(h)))==h)
		printf("Yes");
	else
		printf("No");
}

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


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

    int cntR = 0;
    int ans = 0;
    rep(i,N) if (S[i] == 'R') ++cntR;
    rep(i,cntR) if (S[i] == 'W') ++ans;
    cout << ans << endl;
}

Measured memory_bytes: 3744
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int64> sum(n + 1);
  for (int i = 1; i <= n; ++i) {
    int64 x;
    scanf("%lld", &x);
    sum[i] = sum[i - 1] + x;
  }
  vector<int64> A, B;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      A.push_back(sum[j] - sum[i]);
    }
  }
  int64 ret = 0;
  for (int k = 60; k >= 0; --k) {
    B.clear();
    for (auto& it : A) {
      if (it & (1LL << k)) B.push_back(it);
    }
    // trace(k, B.size());
    if (B.size() >= m) {
      swap(A, B);
      ret += 1LL << k;
    }
  }
  printf("%lld\n", ret);
  return 0;
}


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

#define ll long long
#define MOD 1000000007
using namespace std;

ll f(int mask, vector<vector<int>> &compat, vector<int> &dp) {
    int k = __builtin_popcount(mask);   // no. of men already assigned
    // base case: all men assigned
    if (k >= compat.size())
        return 1;
    
    if (dp[mask] != -1)
        return dp[mask];

    int res = 0;
    for (int j = 0; j < compat.size(); j++) {
        if (!(mask & (1 << j))) {
            if (compat[k][j]) {
                // if jth woman is compatible with kth man
                int newmask = (mask | (1 << j));
                res = ((res % MOD) + (f(newmask, compat, dp) % MOD)) % MOD;
            }
        }
    }
    dp[mask] = res % MOD;
    return dp[mask];
}

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

    vector<int> dp(1 << N, -1);

    cout << f(0, compat, dp) % MOD;
    return 0;
}

Measured memory_bytes: 8448
#include <stdio.h>

int main()
{
	int i, H, W;
	char s[102][102];
	scanf("%d %d", &H, &W);
	for (i = 1; i <= H; i++) scanf("%s", &(s[i][1]));
	
	int j, dist[102][102] = {}, tmp[2];
	if (s[1][1] == '#') dist[1][1] = 1;
	for (i = 2; i <= H; i++) dist[i][1] = (s[i][1] == s[i-1][1])? dist[i-1][1]: dist[i-1][1] + 1;
	for (j = 2; j <= W; j++) dist[1][j] = (s[1][j] == s[1][j-1])? dist[1][j-1]: dist[1][j-1] + 1;
	for (i = 2; i <= H; i++) {
		for (j = 2; j <= W; j++) {
			tmp[0] = (s[i][j] == s[i-1][j])? dist[i-1][j]: dist[i-1][j] + 1;
			tmp[1] = (s[i][j] == s[i][j-1])? dist[i][j-1]: dist[i][j-1] + 1;
			dist[i][j] = (tmp[0] < tmp[1])? tmp[0]: tmp[1];
		}
	}
	
	printf("%d\n", (dist[H][W] + 1) / 2);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 256
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };

    let x: i32 = sc.read();
    let y: i32 = sc.read();

    for i in 0..x+1 {
        if 2 * i + 4 * (x - i) == y {
            println!("{}", "Yes");
            return;
        }
    }

    println!("{}", "No");
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 2144
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });

            var N= Sarray()[0];
            var DX = Sarray();
            var D = DX[0];
            var X = DX[1];
            var sum = 0L;
            for(var i=0;i<N;++i)
            {
                var ai = Sarray()[0];
                sum += (D - 1) / ai + 1;
            }
            WriteLine(sum + X);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+5;
long long int f(long long int n)
{
	if(n == 1)
		return 1;
	return 1 + 2 * f(n/2) ;
}

int main() {
	long long int n;
	cin >> n;
	
	cout << f(n) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();


int main(){
  int n;
  cin >> n;
  bool flag = true;

  REP(i,n){
   int a;
   cin >> a;

   if (a%2==0)
   {
     if(a%3!=0&&a%5!=0){
     flag = false;
      break;
     }

    }
  }

  if (flag)
    cout << "APPROVED" << endl;
  else
   cout << "DENIED" << endl;

}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 200010
#define MO 924844033
#define G 5
#define LL long long
LL fac[MAXN],inv[MAXN],f[MAXN];
int n;
LL PowMod(LL a,int b)
{
	LL ret=1;
	while(b)
	{
		if(b&1) ret=ret*a%MO;
		a=a*a%MO;
		b>>=1;
	}
	return ret;
}
void Pre()
{
	fac[0]=1;
	for(int i=1;i<=n;i++)
		fac[i]=fac[i-1]*i%MO;
	inv[n]=PowMod(fac[n],MO-2);
	for(int i=n-1;i>=0;i--)
		inv[i]=inv[i+1]*(i+1)%MO;
}
int Adj[MAXN],V[MAXN*2],nxt[MAXN*2],c,siz[MAXN];
void AddEdge(int u,int v)
{
	c++;V[c]=v,nxt[c]=Adj[u];Adj[u]=c;
}
void dfs(int u,int p)
{
	siz[u]=1;
	for(int i=Adj[u];i;i=nxt[i])
		if(V[i]!=p)
		{
			dfs(V[i],u);
			siz[u]+=siz[V[i]];
		}
	f[siz[u]]--;
	f[n-siz[u]]--;
}
void NTT(LL A[],int N,int typ)
{
	for(int i=1,j=0;i<N-1;i++)
	{
		for(int s=N;j^=s>>=1,~j&s;);
		if(i<j) swap(A[i],A[j]);
	}
	for(int i=1;i<N;i<<=1)
	{
		LL w1=PowMod(G,(MO-1)/(i<<1)),w=1;
		if(typ==-1)
			w1=PowMod(w1,MO-2);
		for(int j=0;j<i;j++,w=w*w1%MO)
			for(int l=j,r=l+i;l<N;l+=(i<<1),r=l+i)
			{
				int tmp=A[r]*w%MO;
				A[r]=(A[l]-tmp+MO)%MO;
				A[l]=(A[l]+tmp)%MO;
			}
	}
	if(typ==-1)
	{
		int Inv=PowMod(N,MO-2);
		for(int i=0;i<N;i++)
			A[i]=A[i]*Inv%MO;
	}
}
LL a[MAXN*4],b[MAXN*4];
int main()
{
	scanf("%d",&n);
	Pre();
	int u,v;
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		AddEdge(u,v);
		AddEdge(v,u);
	}
	dfs(1,0);
	f[n]=n;
	int len=1;
	for(;len<=2*n;len<<=1);
	for(int i=0;i<=n;i++)
	{
		a[i]=f[i]*fac[i]%MO;
		b[i]=inv[n-i];
	}
	NTT(a,len,1);
	NTT(b,len,1);
	for(int i=0;i<=len;i++)
		a[i]=1LL*a[i]*b[i]%MO;
	NTT(a,len,-1);
	for(int i=1;i<=n;i++)
	{
		LL ans=a[i+n]*inv[i]%MO;
		printf("%lld\n",(ans%MO+MO)%MO);
	}
}

Measured memory_bytes: 31872
#include <bits/stdc++.h>
  using namespace std;
  typedef long long int ll;
  #define mod 1000000007
  #define all(v)  v.begin(),v.end()
  #define pb push_back
  #define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
  ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
  ll inv(ll a){return power_mod(a,mod-2);}
  ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}
  

  int main()
  {
     
           int n;
           cin>>n;
           int a[n+1];
           for(int i=1;i<=n;i++) cin>>a[i];

           
           int ans=1e9;

           for(int t=1;t<n;t++)
           {
               int s1=0,s2=0;
               for(int i=1;i<=n;i++)
               { 
                   if(i<=t) s1+=a[i];
                   else s2+=a[i];
               }

               ans=min(ans,abs(s1-s2));
           } 
           cout<<ans<<endl;
  }
  
  




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void)
{
    str S;cin>>S;
    int cn=0,cnt=0;
    for(int i=0; i<S.size();i++){
      if(i%2==0 && S[i]!='1') cn++;
      else if(i%2==1 && S[i]!='0') cn++;

      if(i%2==0 && S[i]!='0') cnt++;
      else if(i%2==1 && S[i]!='1') cnt++;
    }
    int ans = min(cn,cnt);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int dt, a, b, c, i;
    
    cin >> dt;
    a = dt / 100;
    b = dt % 100 / 10;
    c = dt % 100 % 10;
    
    i = 0;
    if (a == 1)
        i++;
    if (b == 1)
        i++;
    if (c == 1)
        i++;
    cout << i << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
	int A, B, K;
	cin >> A >> B >> K;
  	vector<int> v;
  	REP(i,100){
      if(A % (i + 1) == 0 && B % (i + 1) == 0) v.push_back(i + 1);
    }
    cout << v[v.size() - K] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
#define REP(i, d, n) for(int i=(d); i<(n); i++)
typedef long long ll;
const int mod = 1e9 + 7;
int main() {

    ll x, y;
    cin >> x >> y;

    ll ans = 0;
    ll res = x;
    while(res <= y){
        ans++;
        res *= 2;
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  
  int counter = 0;
  rep (i, s.size()) {
    if (s[i] != t[i]) counter++;
  }
  
  cout << counter << endl;
}

Measured memory_bytes: 3844
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;

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; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
constexpr int MAX = 5000000;


struct mint {
	long long x;
	mint(long long x = 0) :x((x% mod + mod) % mod) {}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	int n; cin >> n;
	vector dp(2, vector(2, vector<mint>(n + 1)));
	dp[0][0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k < 2; k++) {
				for (int l = 0; l < 10; l++) {
					int nj = j;
					int nk = k;
					if (l == 0) nj = 1;
					if (l == 9) nk = 1;
					dp[nj][nk][i + 1] += dp[j][k][i];
				}
			}
		}
	}
	cout << dp[1][1][n].x << endl;
	return 0;
}

Measured memory_bytes: 57744
N,K = gets.chomp.split.map(&:to_i)
P = gets.chomp.split.map(&:to_i)
C = gets.chomp.split.map(&:to_i)
 
abc = []
 
(0..N-1).each do |i|
  cnt = 0
  ans = [0]
  y = i+1
while (cnt < K) do
  y = P[y-1]
  ans << ans.last+C[y-1]
  cnt += 1
  break if y == i+1
end
a = ans[1..-1].max
if cnt == K
abc << a
else
abc << [((ans.last)*(K/cnt)+ ans[0..K%cnt].max),((ans.last)*(K/cnt-1)+ ans[0..-2].max),a].max 
end
end
 
puts abc.max

Measured memory_bytes: 103300
n=int(input())
a=list(map(int,input().split()))
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
from collections import defaultdict
d=defaultdict(int)
op=set(make_divisors(a[0])+make_divisors(a[1]))
next_op=set()
for i in range(n):
    for opi in op:
        if a[i]%opi==0:
            d[opi]+=1
        if d[opi]>=i:
            next_op.add(opi)
    op=next_op
    next_op=set()
print(max(op))


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

int main() {
  int a,b;
  cin >> a >> b;
  vector<int> vec(a);
	int ans =0;
	for(int i=0;i<a;i++)cin >> vec.at(i);
	for(int i=1;i<a;i++)vec.at(i)+=vec.at(i-1);
	for(int i=0;i<a;i++)if(vec.at(i)<=b)ans++;
	cout << ans + 1<< endl;
}

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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n, sa, sb, ea, eb;
  cin >> n >> sa >> sb >> ea >> eb;
  sa--, sb--, ea--, eb--;
  string s;
  cin >> s;
  int ok = 1;
  for (int i = sa+1; i < ea; i++)
    if (s[i] == '#' && s[i-1] == '#') ok = 0;
  for (int i = sb+1; i < eb; i++)
    if (s[i] == '#' && s[i-1] == '#') ok = 0;
  if (ea > eb) {
    int found = 0;
    for (int i = sb; i <= eb && i+1 < n; i++)
      if (s[i-1] == '.' && s[i] == '.' && s[i+1] == '.')
	found = 1;
    if (!found) ok = 0;
  }
  cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
const int N = 5020 , Mod = 1e9+7;
inline int add(int a,int b) { return a + b >= Mod ? a + b - Mod : a + b; }
inline int sub(int a,int b) { return a - b < 0 ? a - b + Mod : a - b; }
inline int mul(int a,int b) { return 1LL * a * b % Mod; }
inline void Add(int &a,int b) { a = add( a , b ); }
inline void Sub(int &a,int b) { a = sub( a , b ); }
inline void Mul(int &a,int b) { a = mul( a , b ); }
inline int quickpow(int a,int b) { int res = 1; for (;b;Mul(a,a),b>>=1) if ( 1 & b ) Mul(res,a); return res; }
inline int inv(int x) { return quickpow( x , Mod-2 ); }
struct edge { int ver,next; } e[N*2];
int n,t,Head[N],f[N][N][2],size[N],dfac[N],g[N][2],Ans;
inline void insert(int x,int y) { e[++t] = (edge){y,Head[x]} , Head[x] = t; }
inline void input(void)
{
    scanf("%d",&n);
    for (int i=1,x,y;i<n;i++)
        scanf("%d%d",&x,&y),
        insert(x,y) , insert(y,x);
}
inline void init(void)
{
    dfac[1] = 1;
    for (int i=3;i<=n;i+=2)
        dfac[i] = mul( dfac[i-2] , i );
}
inline void dp(int x,int fa)
{
    f[x][1][0] = size[x] = 1;
    for (int i=Head[x];i;i=e[i].next)
    {
        int y = e[i].ver;
        if ( y == fa ) continue;
        dp( y , x );
        for (int j=1;j<=size[x];j++)
            g[j][0] = f[x][j][0] , g[j][1] = f[x][j][1] , f[x][j][0] = f[x][j][1] = 0;
        for (int j=1;j<=size[x];j++)
            for (int k=1;k<=size[y];k++)
            {
                Add( f[x][j+k][0] , add( mul( g[j][0] , f[y][k][0] ) , mul( g[j][1] , f[y][k][1] ) ) );
                Add( f[x][j+k][1] , add( mul( g[j][1] , f[y][k][0] ) , mul( g[j][0] , f[y][k][1] ) ) );
                if ( k & 1 ) continue;
                Add( f[x][j][0] , mul( g[j][1] , mul( f[y][k][0] , dfac[k-1] ) ) );
                Add( f[x][j][0] , mul( g[j][0] , mul( f[y][k][1] , dfac[k-1] ) ) );
                Add( f[x][j][1] , mul( g[j][0] , mul( f[y][k][0] , dfac[k-1] ) ) );
                Add( f[x][j][1] , mul( g[j][1] , mul( f[y][k][1] , dfac[k-1] ) ) );
            }
        size[x] += size[y];
    }
}
inline void solve(void)
{
    for (int i=2;i<=n;i+=2)
        Add( Ans , mul( f[1][i][0] , dfac[i-1] ) ),
        Sub( Ans , mul( f[1][i][1] , dfac[i-1] ) );
}
int main(void)
{
    input();
    init();
    dp( 1 , 0 );
    solve();
    printf("%d\n",Ans);
    return 0;
}


Measured memory_bytes: 196224
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>
#include <sstream>
#include <map>

using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

const ll mod = 1e9+7;


int main() {
	int n, d;
	cin >> n >> d;

	vector<vi> x(n);
	int xt;

	REP(i, n) {
		REP(j, d) {
			cin >> xt;
			x[i].push_back(xt);
		}
	}

	double dist = 0;
	int ans = 0;
	REP(i, n) {
		FOR(j, i + 1, n) {
			dist = 0;
			REP(k, d) {
				dist += pow(x[i][k] - x[j][k], 2);
			}
			if (sqrt(dist) == floor(sqrt(dist))) {
				ans += 1;
			}
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<cstring>
#include<map>
#include<sstream>
#include<math.h>
 
using namespace std;

int N;

int main(){
  
  cin>>N;
  
  for(int i = 1; i <= 50000; ++i){
    if((int)(i * 1.08) == N){
      cout << i << endl;
      return 0;
    }
  }
      cout <<":("<< endl;
}


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

int main()
{
    int T;
    cin >> T;
    for (int t = 0; t < T; t++) {
        vector<int> dim{1};
        vector<int> d{0};
        stack<int> st;
        st.push(0);
        using P = pair<int, int>;
        vector<P> edge;
        int pos = 0;
        int node = 0;
        while (true) {
            while (not st.empty()) {
                if (dim[st.top()] == 0) {
                    st.pop();
                    pos = st.empty() ? 0 : st.top();
                } else {
                    break;
                }
            }
            int n;
            cin >> n;
            if (n == 0) {
                break;
            } else if (n > 0) {
                dim[pos]--;
                dim.push_back(pos == 0 ? n : n - 1);
                node++;
                d.push_back(d[pos] + 1);
                edge.push_back({pos, node});
                pos = node;
                st.push(pos);
            } else {
                const int D = d[pos] + n;
                for (int i = 1; i <= node; i++) {
                    if (dim[i] > 0 and d[i] == D) {
                        dim[i]--;
                        edge.push_back({i, pos});
                        dim[pos]--;
                        break;
                    }
                }
            }
        }
        vector<multiset<int>> g(node + 1);
        for (const P& e : edge) {
            g[e.first].insert(e.second);
            g[e.second].insert(e.first);
        }
        for (int i = 1; i <= node; i++) {
            cout << i;
            for (const int to : g[i]) {
                if (to > 0) {
                    cout << " " << to;
                }
            }
            cout << endl;
        }
    }

    return 0;
}



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

int main() {
	int a, b;
	int k;
	int i;
	scanf("%d%d", &a, &b);
	for (i = 0;; i++) {
		k = i;
		if (i > a && i > b)break;
		if (abs(a - k) == abs(b - k)) {
			printf("%d\n", k);
			return 0;
		}
	}

	printf("IMPOSSIBLE\n");
	return 0;
}

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

int main() {
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    int l = max(X,Y);
    ll ans = 10000000050;
    for(int i=0;i<=l;i++) {
        ll n = 2*C*i + max(0, X-i)*A + max(0, Y-i)*B;
        ans = min(ans, n);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000000000000LL
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
ll N,X;
ll b[MAXN],l[MAXN],u[MAXN];
vector<ll> v;
struct segtree
{
    ll sum[4*MAXN];
    ll cnt[4*MAXN];
    void pushup(ll k)
    {
        cnt[k]=cnt[k*2]+cnt[k*2+1];
        sum[k]=sum[k*2]+sum[k*2+1];
    }
    void build(ll k,ll l,ll r)
    {
        sum[k]=0; cnt[k]=0;
        if(l==r) return;
        ll mid=(l+r)/2;
        build(k*2,l,mid); build(k*2+1,mid+1,r);
    }
    void update(ll k,ll l,ll r,ll p,ll val)
    {
        if(l==r)
        {
            cnt[k]+=val;
            sum[k]=1LL*cnt[k]*v[l];
            return;
        }
        ll mid=(l+r)/2;
        if(p<=mid) update(k*2,l,mid,p,val); else update(k*2+1,mid+1,r,p,val);
        pushup(k);
    }
    pair<ll,ll> query(ll k,ll l,ll r,ll s)
    {
        if(s<=0) return make_pair(0LL,0LL);
        if(l==r) 
        {
            ll need=max(0LL,(s-1)/v[l]+1);
            return make_pair(need,1LL*need*v[l]);
        }
        ll mid=(l+r)/2;
        if(sum[k*2+1]>=s) return query(k*2+1,mid+1,r,s);
        else
        {
            pair<ll,ll> p=query(k*2,l,mid,s-sum[k*2+1]);
            p.F+=cnt[k*2+1]; p.S+=sum[k*2+1];
            return p;
        }
    }
}seg;
int main()
{
    ll need=0,ans=INF;
    scanf("%lld%lld",&N,&X);
    for(ll i=1;i<=N;i++) 
    {
        scanf("%lld%lld%lld",&b[i],&l[i],&u[i]);
        need+=1LL*b[i]*l[i];
        v.push_back(1LL*X*u[i]-1LL*b[i]*(u[i]-l[i]));
    }
    v.push_back(-1);
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    ll sz=(int)v.size()-1;
    seg.build(1,1,sz);
    for(ll i=1;i<=N;i++)
    {
        ll res=1LL*X*u[i]-1LL*b[i]*(u[i]-l[i]);
        ll id=lower_bound(v.begin(),v.end(),res)-v.begin();
        seg.update(1,1,sz,id,1);
    }
    for(ll i=1;i<=N;i++)
    {
        ll res=1LL*X*u[i]-1LL*b[i]*(u[i]-l[i]);
        ll id=lower_bound(v.begin(),v.end(),res)-v.begin();
        seg.update(1,1,sz,id,-1);
        if(l[i]!=0)
        {
            ll r=X*l[i];
            pair<ll,ll> ret=seg.query(1,1,sz,need-r);
            ll more=min(X,(ret.S+r-need)/l[i]);
            ans=min(ans,X-more+1LL*ret.F*X);
        }
        ll cost=b[i]*(u[i]-l[i]);
        ll r=X*u[i];
        pair<ll,ll> ret=seg.query(1,1,sz,need+cost-r);
        ll more=min(X,(ret.S+r-need-cost)/u[i]);
        ans=min(ans,X-more+1LL*ret.F*X);
        seg.update(1,1,sz,id,1);
    }
    printf("%lld\n",ans);
    return 0;
}



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

int main(){
    int N; cin >> N;
    int A[N];
    for (int i = 0; i < N ; ++i){
        cin >> A[i];
    }
    int minv = A[0];
    int maxv = A[1]-A[0];
    for(int i = 1; i < N ; ++i){
        maxv = (maxv <= A[i]-minv) ? A[i]-minv : maxv;
        minv = (minv > A[i]) ? A[i] : minv;
    }
    cout << maxv << endl;
    
    return 0;
}


Measured memory_bytes: 3880