akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


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

    string inp; cin >> inp;
    
    rep(i, 3){
        if(inp[i] == '7'){
            cout << "Yes" << endl;
            
            return 0;
        }

    }
    
    cout << "No" << endl;


    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

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

  double ans, y = m - 1;
  if (d == 0) {
    ans = y / n;
  } else {
    double x = n - d;
    ans = 2.0 * x / n / n * y;
  }
  printf("%.9f\n", ans);
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()



int main() {
    int N;
    cin >> N;
    //B-Aで始めなければいけない時間がわかる

    vector<ll> A(N);
    vector<ll> st(N);
    for(int i=0;i<N;i++){
        ll a,b;
        cin >> a >> b;
        A[i]=a;//かかる時間
        st[i]=b;//simekiri時間
        // cout << i << " : " << st[i] << endl;
    }

    vector<int> ord(N);
    iota(ord.begin(),ord.end(),0);
    //始めるべき時間順にソート、始めるべき時間が同じ場合はかかる時間が多いものから行う
    sort(ord.begin(),ord.end(),[&](int x,int y){
        if(st[x]==st[y]) return A[x]>A[y];
        else return st[x]<st[y];
    });

    ll sum=0;//累積じかん
    for(int i=0;i<N;i++){
        int ci = ord[i];
        // cout << sum << " " << st[ci] << " " << A[ci] << endl;
        if(sum+A[ci]>st[ci]){
            cout << "No" << endl;
            return 0;
        }
        sum += A[ci]; //累積時間をたす
    }

    cout << "Yes" << endl;

    return 0;

}



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

int main() {
    int n;
    cin>>n;
    lli b[n+1],a[n+1];
    for(int i=1;i<n;i++)cin>>b[i];
    a[1] = b[1];
    a[n] = b[n-1];
    for(int i=2;i<n;i++){
        a[i] = min(b[i], b[i-1]);
    }
    lli sum = 0;
    for(int i=1;i<=n;i++){
        sum += a[i];
    }
    cout<<sum<<"\n";
    return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/02  Problem: 013_agc_b / Link: https://agc013.contest.atcoder.jp/tasks/agc013_b?lang=en  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N, M;

LL ans = 0LL;
void dfs(int v, VI& path, VI& visit, VVI& G) {
	visit[v] = 1;
	path.push_back(v);
	FOR(i, 0, SZ(G[v])) {
		int nx = G[v][i];
		if (!visit[nx]) {
			dfs(nx, path, visit, G);
			break;
		}
	}
}

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

	cin >> N >> M;
	VVI G(N);
	FOR(i, 0, M) {
		int a, b; cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	VI path;

	VI visit(N,0);
	dfs(0, path, visit, G);
	VI path2;
	dfs(0, path2, visit, G);
	cout << SZ(path) + SZ(path2) -1<< endl;
	reverse(ALL(path2));
	FOR(i, 0, SZ(path2)-1) {
		cout << path2[i] + 1 << " ";
	}
	FOR(i, 0, SZ(path)) {
		cout << path[i] + 1<< " ";
	}
	cout << "\n";

	return 0;
}


Measured memory_bytes: 11512
#include<bits/stdc++.h>
using namespace std;
#define fine cout<<"fine"<<endl;
#define ll long long int
#define pb push_back
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
const ll inf=(ll)2e18;
const int mod=1e9+7;
bool overflow(ll a,ll b){
    if (a <= (inf+b-1)/b) return false;
    return true;
}
int n,m,k;
int pref[15][1005];
int main(){
FASTIO;
cin>>n>>m>>k;
string s[n];
int i,j,it;
for(i=0;i<n;i++)
    cin>>s[i];
for(i=0;i<n;i++){
    for(j=0;j<m;j++){
        pref[i+1][j+1]=pref[i+1][j]+pref[i][j+1]-pref[i][j]+(s[i][j]-48);
    }
}
int mini=1e9;
for(i=0;i<(1<<(n-1));i++){
    vector<int> v;
    v.pb(1);
    for(j=0;j<(n-1);j++){
        if(i&(1<<j)){
            v.pb(j+1);
            v.pb(j+2);
        }
    }
    v.pb(n);
    assert((int)(v.size())%2==0);
    int last=0,j=1,count=0;
    while(j<=m){
        for(it=0;it<v.size();it+=2){
            int sum=pref[v[it+1]][j]+pref[v[it]-1][last]-pref[v[it]-1][j]-pref[v[it+1]][last];
            if(sum>k)
                break;
        }
        if(it<v.size()){
            count++;
            last=j-1;
        }
        else j++;
        if(count>j)
            break;
    }
    if(j>m){
        mini=min(mini,__builtin_popcount(i)+count);
    }
}
cout<<mini<<endl;
}


Measured memory_bytes: 384
A, B, M = [int(v) for v in input().strip().split(" ")]
a_list = [int(v) for v in input().strip().split(" ")]
b_list = [int(v) for v in input().strip().split(" ")]
m_list = [
    [int(v) for v in input().strip().split(" ")]
    for _ in range(M)
]

c = [min(a_list) + min(b_list)]
for m in m_list:
    c.append(a_list[m[0]-1]+b_list[m[1]-1]-m[2])

print(min(c))


Measured memory_bytes: 36468
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
using namespace std;

int main()
{
    
    string w;
    cin >> w;
    unordered_map<char, int> u;
    for(int i = 0; i < w.length(); i++){
        if(u.find(w[i]) == u.end())
            u[w[i]] = 1;
        else
            u[w[i]]++;
    }
    for(const auto& n : u){
        if(n.second % 2 == 1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}






































/*#include<iostream>
#include<fstream>
#include<string>
#include<vector>
using namespace std;

int main()
{
    int N, x;
    vector<long long> A;
    vector<bool> colors;
    cin >> N;
    cin >> x;
    A.resize(N);
    colors.resize(N);
    
    for(int i = 0; i < N; i++){
        cin >> A[i];
        colors[i] = false;
    }
    long long sum = 0;
    int num_true = 0;
    int start_idx = 0;
    while(num_true < N){
        for(int i = 0; i < N; i++){
            if(colors[(i+start_idx)%N] == false && A[i] <= x){
                sum += A[i];
                colors[(i+start_idx)%N] = true;
                num_true++;
            }
        }
        //cout << num_true << endl;
        if(num_true < N){
            sum += x;
            start_idx = (start_idx+1)%N;
            
        }
    }
    cout << sum << endl;
    return 0;
}*/

Measured memory_bytes: 256
def main():
    S = input()
    size = [[[[0, 0]], []], [[], []]]
    length = 0

    for s in S:
        size2 = [[[], []], [[], []], [[], []]]
        if s != "0":
            for i in range(2):
                for j in range(2):
                    if size[i][j]:
                        for x, y in size[i][j]:
                            if y == length+i:
                                size2[i+1][j ^ 1].append([y+1, y+1])
                                if x != y:
                                    size2[i][j ^ 1].append([x+1, y-1])
                            else:
                                size2[i][j ^ 1].append([x+1, y+1])
        if s != "1":
            for i in range(2):
                for j in range(2):
                    if size[i][j]:
                        for x, y in size[i][j]:
                            if x == 0:
                                size2[i+1][j].append([0, 0])
                                if x != y:
                                    size2[i][j ^ 1].append([x+1, y-1])
                            else:
                                size2[i][j ^ 1].append([x-1, y-1])
        if len(size2[0][0]+size2[0][1]) == 0:
            size2 = size2[1:]
            length += 1
        else:
            size2.pop()
        for i in range(2):
            for j in range(2):
                size2[i][j] = sorted(size2[i][j])
        size = [[[], []], [[], []]]
        for i in range(2):
            for j in range(2):
                if len(size2[i][j]) == 0:
                    continue
                size[i][j] = [size2[i][j][0]]
                for x, y in size2[i][j][1:]:
                    size[i][j][-1][1] = max(y, size[i][j][-1][1])

    print(length)


main()


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

int main(){
	/*input*/
	vector<vector<int>>xy(4, vector<int>(2));
	for(int i = 0; i < 2; i++){
		for(int j = 0; j < 2; j++){
			cin >> xy.at(i).at(j);
		}
	}
	/*calculation*/
	vector<int>sidex(2);
	vector<int>sidey(2);
	sidex.at(0) = xy[1][0] - xy[0][0];
	sidex.at(1) = xy[1][1] - xy[0][1];
	sidey.at(0) = -sidex.at(1);
	sidey.at(1) = sidex.at(0);
	xy.at(2).at(0) = xy.at(0).at(0) + sidex.at(0) + sidey.at(0);
	xy.at(2).at(1) = xy.at(0).at(1) + sidex.at(1) + sidey.at(1);
	xy.at(3).at(0) = xy.at(0).at(0) + sidey.at(0);
	xy.at(3).at(1) = xy.at(0).at(1) + sidey.at(1);
	/*output*/
	for(int i = 2; i < 4; i++){
		for(int j = 0; j < 2; j++){
			cout << xy.at(i).at(j) << " ";
		}
	}
	cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1<<18;
struct po{int l,r;};
int n;
po dat[2*MAX_N-1];
 
void init(int n_){
  n=1;
  while(n<n_)n*=2;
  for(int i=0;i<2*n-1;i++)dat[i]=(po){0,0};
}
 
void compute(int k,po t){
  if(t.r==0)return;
  if(dat[k].r==0) dat[k]=t;
  else if(dat[k].r==t.l-1)dat[k].r=t.r;
  else dat[k]=(po){-1,-1};
}
 
void query(int a,int b,int x,int k=0,int l=0,int r=n){
  if(r<=a||b<=l)return ;
  if(a<=l&&r<=b){
    compute(k,(po){x,x});
    return ;
  }
   
  int left=k*2+1,right=k*2+2;
  compute(left,dat[k]);
  compute(right,dat[k]);
  dat[k]=(po){0,0};
 
  query(a,b,x,left,l,(l+r)/2);
  query(a,b,x,right,(l+r)/2,r);
}
 
int main(){
  int N,k;
  cin>>n>>k;
  N=n;
  init(n);
 
  int q;
  cin>>q;
  while(q--){
    int l,r,x;
    cin>>l>>r>>x;
    query(l-1,r,x);
  }
   
  int ans=0;
  for(int i=0;i<N;i++){
    query(i,i+1,k+1);
    ans+=(dat[i+n-1].l==1&&dat[i+n-1].r==k+1);
  }
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 7180
#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>;
 
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
 
int main() {
	int n, a, b;
	int ans;
	cin >> n;
	int nm = n;
    ans = modpow(2, n, 1000000007);
	cin >> a;
	int am = a;
	cin >> b;
	int bm = b;
	ll c0 = 1;
	ll c1 = 1;
	for(int i=0; i<a; i++){
    	c0 *= nm;
   		c0 %= 1000000007;
    	c0 *= modpow(am, 1000000005, 1000000007);
   		c0 %= 1000000007;
    	nm--;
    	am--;
    }
	nm = n;
	for(int i=0; i<b; i++){
    	c1 *= nm;
   		c1 %= 1000000007;
    	c1 *= modpow(bm, 1000000005, 1000000007);
   		c1 %= 1000000007;
    	nm--;
    	bm--;
    }
	ans--;
	if(ans < 0) ans += 1000000007;
	ans -= c0;
	if(ans < 0) ans += 1000000007;
	ans -= c1;
	if(ans < 0) ans += 1000000007;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin>>a>>b;
    if(a<b){
    cout<<"a < b"<<endl;
    }else if(a>b){
        cout<<"a > b"<<endl;
    }else{
        cout<<"a == b"<<endl;
    }
}



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

#define int long long 

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 40+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

char c[maxn][maxn];
int n,f[maxn][maxn][maxn];

ll dfs(int l,int r,int mid) {
    if(f[l][r][mid]!=-1) return f[l][r][mid];
    if(l==r) return 1;
    if(l==mid||r==mid) return 0;
    ll ans=0;
    for(int j=l;j<mid;j++)
        for(int k=mid+1;k<=r;k++) {
            if(c[j][k]=='0') continue;
            for(int s=j;s<mid;s++)
                for(int t=mid+1;t<=k;t++)
                    ans+=dfs(l,s,j)*dfs(t,r,k)*dfs(s+1,t-1,mid);
        }
    // printf("dfs :: %d %d %d %d\n",l,r,mid,ans);
    return f[l][r][mid]=ans;
}

signed main() {
    read(n);n<<=1;for(int i=1;i<=n;i++) scanf("%s",c[i]+1);
    ll ans=0;memset(f,-1,sizeof f);
    for(int i=2;i<=n;i++) if(c[1][i]=='1') ans+=dfs(2,n,i);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define FOR(i, b, n) for (long i = b; i < n; ++i)

using namespace std;

void solve(string S) {
  long ans(0);
  FOR(i, 1, S.length())
    if (S[i] != S[i - 1])
      ans++;
  cout << ans << endl;
}

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

  string S;
  cin >> S;

  solve(S);

  return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define _for(i,a,b) for(int i = (a);i <= (b);++i)
#define LOCAL
typedef long long ll;
const int maxn = 1e5+5;
map<string,int>mp;
int main()
{
#ifdef LOCALa
    freopen("simple.in","r",stdin);
    freopen("simple.out","w",stdout);
#endif
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    string a;
    for(int i = 1;i <= n;++i){
        cin>>a;
        mp[a]++;
    }
    map<string,int>::iterator ite;
    vector<string>ans;
    int mx = 0;
    for(ite=mp.begin();ite!=mp.end();++ite){
        mx=max(mx,ite->second);
    }
    for(ite=mp.begin();ite!=mp.end();++ite)
    {
        if(ite->second==mx)ans.push_back(ite->first);
    }
    sort(ans.begin(),ans.end());
    for(int i = 0;i < ans.size();++i)cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 25584
#include <bits/stdc++.h>
#include <sys/time.h>
#define CIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define fa(d,i,n) for(d i = 0; i < n; i++)
#define far(d,i,n) for(d i = n - 1; i >= 0; i--)
#define fi(d,i,ind,n) for(d i = ind; i < n; i++)
#define fir(d,i,ind,n) for(d i = n - 1; i >= i; i--)
#define F first
#define S second
#define flush cin>>ws
#define getstring(s) getline(cin,s)
#define mp make_pair
#define MOD 1000000007
#define vi vector<int>
#define vll vector<lli>
#define dyni(a,n) int *a = new int[n];
#define dynill(a,n) lli *a = new lli[n];
#define pii pair<int,int>
#define pll pair<lli,lli>
#define setprec(n) cout << setprecesion(n)
#define setfixedprec cout << fixed
#define MID (l + (r - l) / 2)
#define all(x) x.begin(),x.end()
#define MAX =INT_MAX
#define MIN =INT_MIN
#define BS l<=r
int getTime() {
	struct timeval start;
	gettimeofday(&start, NULL);
	return start.tv_sec * 1000000 + start.tv_usec;
}

using namespace std;
using lli = long long int;

int main()
{
	//lli st = getTime();
	CIN

	lli n;
	cin >> n;
	vll a(n);
	fa(lli, i, n) cin >> a[i];

	unordered_map<lli, lli> mp;
	fa(lli, i, n) mp[a[i]]++;

	lli ans = 0;
	for (auto i = mp.begin(); i != mp.end(); i++) {
		if (i -> first != i -> second) {
			if (i -> second > i -> first) ans += (i -> second - i -> first);
			else ans += i -> second;
		}
	}
	cout << ans;


	//lli et = getTime();
	//cout<<"Total time taken = "<<(et - st);
	return 0;
}


Measured memory_bytes: 7972
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<62,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  int n,m;
  cin >> n >> m;
  P a[n];
  rep(i,n) cin >> a[i].F >> a[i].S;
  sort(a,a+n);
  ll ans=MAXL;
  rep(i,n) {
    rep(j,n) {
      rep(k,n) {
        rep(l,n) {
          ll x1=a[i].F,y1=a[j].S,x2=a[k].F,y2=a[l].S,cnt=0;
          if(x1>x2) swap(x1,x2);
          if(y1>y2) swap(y1,y2);
          rep(x,n) {
            if(a[x].F>=x1&&a[x].S>=y1&&a[x].F<=x2&&a[x].S<=y2) cnt++;
          }
          if(cnt>=m) ans=min(ans,(x2-x1)*(y2-y1));
        }
      }
    }
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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


ll a,b,c;
string k;
int main(){
  cin>>a>>b>>c>>k;
  if((k[k.size()-1]-'0')%2==0)cout<<a-b<<endl;
  else cout<<b-a<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;



int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << ketasitei;

	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i, n)
	{
		cin >> a[i];
		a[i]--;
	}
	ll now = a[0];
	vector<ll> was(n, -1);
	was[0] = 0;
	ll num = 1;
	ll lp = 1;
	k--;

	while (k)
	{
		if (was[now]==-1)
		{
			was[now] = num;
		}
		else
		{
			lp = num - was[now];
			break;
		}
		k--;
		now = a[now];
		num++;
	}
	k %= lp;
	rep(i, k)
	{
		now = a[now];
	}
	cout << now + 1 << endl;
	return 0;
}

Measured memory_bytes: 6372
#include<stdio.h>
#include<stdlib.h>
#define INF 1000000

int matrixChainOrder(int*);
int min(int,int);
int n;

int main(){
  int *p,i;
  
  scanf("%d",&n);
  p = (int *)malloc(sizeof(int)*(n+2));

  for(i=0;i<n;i++){
    scanf("%d %d",&p[i],&p[i+1]);
  }
  printf("%d\n",matrixChainOrder(p));

  return 0;
}

int matrixChainOrder(int* p){
  int i,j,l,k,q;
  int hairetu[100][100];

  for(i=1;i<=n;i++){
    hairetu[i][i] = 0;
  }

  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j = i+l-1;
      hairetu[i][j] = INF;
      for(k=i;k<j;k++){
	q = hairetu[i][k] + hairetu[k+1][j] + p[i-1]*p[k]*p[j];
	hairetu[i][j] = min(hairetu[i][j],q);
      }
    }
  }

  return hairetu[1][n];
}

int min(int a,int b){
  
  if(a<b)return a;
  
  else return b;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

  string s;
  cin >> s;
  ll n = s.size();
  string t(s);
  reverse(t.begin(), t.end());

  vector<vector<ll>> spos(n+1, vector<ll>(26, n)), tpos(n+1, vector<ll>(26, n));
  for(int i=n-1; i>=0; --i) {
    REP(j, 26) {
      if(s[i]=='a'+j) {
        spos[i][j] = i;
      } else {
        spos[i][j] = spos[i+1][j];
      }
    }
  }
  for(int i=n-1; i>=0; --i) {
    REP(j, 26) {
      if(t[i]=='a'+j) {
        tpos[i][j] = i;
      } else {
        tpos[i][j] = tpos[i+1][j];
      }
    }
  }

  auto dp = make_v<ll>(n+1, n+1);
  dp[0][0] = 1;
  REP(i, n) REP(j, n) {
    REP(k, 26) {
      if(spos[i][k]+tpos[j][k]+2 > n) continue;
      (dp[spos[i][k]+1][tpos[j][k]+1] += dp[i][j]) %= MOD;
    }
  }

  ll ret = 0;
  REP(i, n+1) for(int j=0; i+j<=n; ++j) {
    ll num = 1;
    REP(k, 26) {
      if(spos[i][k] < n-j) {
        num++;
      }
    }
    (ret += dp[i][j] * num % MOD) %= MOD;
  }
  cout << ret-1 << endl;

  return 0;
}



Measured memory_bytes: 35356
#include <stdio.h>
 
int main() {
char a;
char ch[120];
char c[120];
char b[120];
int i,j,k,l,m,n,o;
m = 0;
n = 0;
i=0;
l=0;
 
while(1) {
scanf("%c",&a);
 
if(a == '\n') {
 break;
}
 
ch[i] = a;
i=i+1;
 
}
 
j=0;
while(1) {
scanf("%c",&a);
if(a == '\n') {
break;
}
c[j] = a;
j +=1;
}
/*??????????????§??\??????*/
 
for(k=0;k<i;k++) {
 
if(c[0] == ch[k] ) {       /*???????????????????????¨?????????????????? */
 l = k;
n = 0;                         /* ??????????????´???????????????*/
for(m=0;m<i-k;m++) {         /* c[k]????????????????§????????????? */
n = n +1;
l  +=1;
b[m] = ch[l-1];
}
l=0;
for(m=n;m<n+1+k;m++) {
l +=1;
b[m] = ch[l-1];            
}
o=0;
for(n=0;n<j;n++) {
/*printf("b[%d] = %c\n c[%d] = %c\n",n,b[n],n,c[n]); */
if(b[n] == c[n]){
o +=1;
}
}
}
 
/* printf("i = %d\nj = %d\n",i,j); */
 
 
if(o == j) {
printf("Yes\n");
break;
} else if(k==i-1) {
printf("No\n");
}
}
  
return 0;
 
}


Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  string N;
  cin >> N;
  if(N.at(0)=='9' || N.at(1)=='9')  cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int A = s.nextInt(), B = s.nextInt(), X = s.nextInt(), Y = s.nextInt(), C = s.nextInt();
        Long a[] = new Long[X];
        Long b[] = new Long[Y];
        Long c[] = new Long[C];
        long sum = 0;
        for(int i = 0; i < X; i++) {
            a[i] = s.nextLong();
        }
        for(int i = 0; i < Y; i++) {
            b[i] = s.nextLong();
        }
        for(int i = 0; i < C; i++) {
            c[i] = s.nextLong();
        }
        Arrays.sort(a, Comparator.reverseOrder());
        Arrays.sort(b, Comparator.reverseOrder());
        Arrays.sort(c, Comparator.reverseOrder());
        PriorityQueue<Long> q = new PriorityQueue<>(Comparator.reverseOrder());
        for(int i = 0; i < A; i++) {
            q.offer(a[i]);
        }
        for(int j = 0; j < B; j++) {
            q.offer(b[j]);
        }
        for(int k = 0; k < C; k++) {
            q.offer(c[k]);
        }
        int total = A+B;
        while(total-- > 0) {
            sum += q.poll();
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 104372
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
B.append(0)
B.append(0)
ans = 0
for i in range(len(A)-1):
    a = A[i]
    b = B[i]
    if a > b:
        ans += b
    else:
        ans += a
        if A[i + 1] >= b - a:
            ans += b - a
            A[i + 1] -= b - a
        else:
            ans += A[i + 1]
            A[i + 1] = 0
print(ans)

Measured memory_bytes: 18476
#A,B,C=(int(x) for x in input().split())
N=int(input())
A=list(map(int, input().split()))


if 0 in A:
  t=0
else:
  t=A[0]
  i=1
  for k in range(N-1):
    t=t*A[i]
    if t>10**18:
      break
    i+=1

if t<=10**18:
  print(t)
else:
  print(-1)


Measured memory_bytes: 21688
#include <stdio.h>
#pragma warning(disable:4996)

int main() {
	int K, A, B;
	(void)scanf("%d%d%d", &K, &A, &B);
	bool ans = true;
	int i = 1;
	while (ans) {
		if (A > i * K) {
			i++;
			continue;
		}
		else if (B < i * K) {
			ans = false;
			break;
		}
		else break;
	}
	if (ans)printf("OK"); else printf("NG");
}

Measured memory_bytes: 1732
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	string s;
	cin >> s;
	int cnt[26] = {};
	for (auto x : s) {
		if (cnt[x - 'a'] > 0) {
			no();
			return 0;
		}
		cnt[x - 'a'] = 1;
	}

	yes();

	return 0;
}

Measured memory_bytes: 256
def main():
    n=int(input())
    A=[list(map(int,input().split())) for i in range(n)]
    A.sort(key=lambda x:x[2],reverse=True)
    for cx in range(101):
        for cy in range(101):
            flag=True
            h=abs(A[0][0]-cx)+abs(A[0][1]-cy)+A[0][2]
            for i in range(1,n):
                if A[i][2]>0:
                    if h!=abs(A[i][0]-cx)+abs(A[i][1]-cy)+A[i][2]:
                        flag=False
                        break
                else:
                    if h-abs(A[i][0]-cx)-abs(A[i][1]-cy)>0:
                        flag=False
                        break
            if flag:
                print(cx,cy,h)
                exit()
if __name__=='__main__':
    main()

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

#define int long long

#define F first
#define S second
#define all(x) (x).begin(), (x).end()

using namespace std;

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

//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);

    int x, k, d;
    cin >> x >> k >> d;
    if(x == 0) {
        cout << (k%2) * d;
    }
    else {
        x = abs(x);
        if(x/d <= k) {
            int s = x/d;
            if(abs(x-d*s) > abs(x-d*(s+1)))
                s++;
            int cur = abs(x-d*s);
            k -= s;
            if(k%2)
                cur = min(abs(cur+d), abs(cur-d));
            cout << cur;
        }
        else {
            cout << x - d*k;
        }
    }

    return 0;
}


Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
int main(void){
  string s;
  cin >> s;
  int up;
  int down;
  int mmu;
  int mmd;
  if(s[0]==0){
    up = s[1]-'0';
  }else{
    up = (s[0]-'0')*10+(s[1]-'0');
  }
  if(s[2]==0){
    down = s[3]-'0';
  }else{
    down = (s[2]-'0')*10+(s[3]-'0');
  }
  if(0<up&&13>up){
    mmu = 1;
  }else{
    mmu = 0;
  }
  if(0<down&&13>down){
    mmd = 1;
  }else{
    mmd = 0;
  }
  if(mmd==1&&mmu==1){
    cout << "AMBIGUOUS";
    return 0;
  }
  if(mmd==0&&mmu==0){
    cout << "NA";
    return 0;
  }
  if(mmu==1){
    cout << "MMYY";
    return 0;
  }
  if(mmd==1){
    cout << "YYMM";
    return 0;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>

using ll = long long;
using ull = unsigned long long;

using namespace std;
int main()
{
  ll a, b;
  cin >> a >> b;
  ll res = (a-1) * (b-1);
  cout << res << endl;
  return 0;
}


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

void roll(char);
char ch;
int dice[6],temp;

int main(void)
{
	int i;
	char str[101] = {0};
	int n;

	for(i = 0; i < 6; i++)
	{
		scanf("%d", &dice[i]);
	}

	scanf("%s", str);
	n = strlen(str);


	for(i = 0; i < n; i++)
	{
		ch = str[i];
		if (ch == '\n')
		{
			break;
		}

		roll(ch);

	}

	printf("%d\n", dice[0]);

	return 0;
}



void roll(char ch)
{

	
	if (ch == 'N')
	{	
		temp = dice[4];
		dice[4] = dice[0];
		dice[0] = dice[1];
		dice[1] = dice[5];
		dice[5] = temp;
	}
	if (ch == 'S')
	{
		temp = dice[1];
		dice[1] = dice[0];
		dice[0] = dice[4];
		dice[4] = dice[5];
		dice[5] = temp;
	}
	if (ch == 'W')
	{
		temp = dice[3];
		dice[3] = dice[0];
		dice[0] = dice[2];
		dice[2] = dice[5];
		dice[5] = temp;
	}
	if (ch == 'E')
	{
		temp = dice[2];
		dice[2] = dice[0];
		dice[0] = dice[3];
		dice[3] = dice[5];
		dice[5] = temp;
	}


	

}

Measured memory_bytes: 596
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        char[] ch = sc.next().toCharArray();
        StringBuilder result = new StringBuilder();
        
        for (int i = 0; i < ch.length; i++) {
            if (i == 0 || i % 2 == 0) {
                result.append(ch[i]);
            }
        }
        System.out.println(result);
    }
}


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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define MODA 1000000007 

int main() {
    bool ans = true;
    string S;
    cin >> S;
    REP(i, S.length()){
        if(S[i] == 'U' || S[i] == 'D') continue;
        else if(i%2==0 && S[i] == 'R') continue;
        else if(i%2==1 && S[i] == 'L') continue;
        else{
            ans = false;
            break;
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
const int maxint=200005;
ll a[maxint+100];
map < ll,ll > mp;
ll po[1050];
void init_po(){
	cin >> n;
	for (ll i=1;i<=n;i++){
		cin >> a[i];
		mp[a[i]]++;
	}
//	map < ll,ll > :: iterator ite;
//	for (ite=mp.begin();ite!=mp.end();ite++){
//		cout << ite->first << ' ' << ite->second << endl;
//	}
	sort(a+1,a+1+n);
	po[0]=1;
	for (ll i=1;i<=62;i++) po[i]=po[i-1]*2;
//	for (ll i=1;i<=10;i++) cout << po[i] << ' ';
//	cout << endl;
}
ll have(ll x){
	ll ge;
//	cout << "x=" << x << endl;
	for (ge=1;ge<=62;ge++){
		if (po[ge]>x){
			break;
		}
	}
//	cout << "ge=" << ge << endl;
//	cout << "po=" << po[ge]-x << endl;
	if (mp[po[ge]-x]==0) return -1;
	return po[ge]-x;
}
void go(){
	init_po();
	ll s=0;
	for (ll i=n;i>=1;i--){
//		cout << "a=" << a[i] << endl;
		if (mp[a[i]]>0){
			mp[a[i]]--;
			ll tmp=have(a[i]);
//			cout << "tmp=" << tmp << endl;
			if (tmp!=-1){
				mp[tmp]--;
				s++;
			}
		}
//		cout << "s=" << s << endl;
//		map < ll,ll > :: iterator ite;
//		for (ite=mp.begin();ite!=mp.end();ite++){
//			cout << ite->first << ' ' << ite->second << endl;
//		}
	}
	cout << s;
}
int main(){
	go();
	return 0;
}
/*
3
1 2 3
6
1 7 3 1 8 4
*/

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

using namespace std;


#define PI 3.14159265
#define int long long




main(){

	int n, l; cin >> n >> l;

	vector <int> a(n);

	for(int i = 0; i < n; i++){
		a[i] = l + i;
	}


	int sum = accumulate(a.begin(), a.end(), 0);

	int dif = 1e9;
	for(int i = 0; i < n; i++){
		if(abs(dif) > abs(a[i])){
			dif = a[i];
		}
	}

	cout << sum - dif << endl;
	


	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#define M 500010
#define ls node<<1
#define rs node<<1|1
#define inf 1e9
using namespace std;
int n,num,k,cnt;
int p[M],a[M],dig[M],ans[M],head[M],val[M<<2];
struct edge{int next,to;}e[M<<1];
void add(int from,int to) {
	e[++num]=(edge){head[from],to};
	head[from]=num;
}
priority_queue<int,vector<int>,greater<int> >Q;
void build(int node,int l,int r) {
	val[node]=inf;
	if(l==r) return;
	int mid=(l+r)>>1;
	build(ls,l,mid);
	build(rs,mid+1,r);
}
void change(int node,int l,int r,int p,int v) {
	val[node]=min(val[node],v);
	if(l==r) return;
	int mid=(l+r)>>1;
	if(p<=mid) change(ls,l,mid,p,v);
	else change(rs,mid+1,r,p,v);
}
int query(int node,int l,int r,int l1,int r1) {
	if(l1>r1) return inf;
	if(l1<=l&&r1>=r) return val[node];
	int mid=(l+r)>>1,ans=inf;
	if(l1<=mid) ans=min(ans,query(ls,l,mid,l1,r1));
	if(r1>mid) ans=min(ans,query(rs,mid+1,r,l1,r1));
	return ans;
}
int main() {
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&p[i]);
	for(int i=1;i<=n;i++) a[p[i]]=i;
	build(1,1,n);
	for(int i=n;i>=1;i--) {
		int res;
		res=query(1,1,n,max(1,a[i]-k+1),a[i]-1);
		if(res!=inf) add(a[i],a[res]),dig[a[res]]++;
		res=query(1,1,n,a[i]+1,min(a[i]+k-1,n));
		if(res!=inf) add(a[i],a[res]),dig[a[res]]++;
		change(1,1,n,a[i],i);
	}
	for(int i=1;i<=n;i++) 
		if(!dig[i]) Q.push(i);
	while(!Q.empty()) {
		int x=Q.top();Q.pop();ans[x]=++cnt;
		for(int i=head[x];i;i=e[i].next) {
			int to=e[i].to;
			if((--dig[to])==0)
				Q.push(to); 
		}
	}
	for(int i=1;i<=cnt;i++) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 27384
using System;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.IO.Pipes;
using System.Runtime.InteropServices;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int a,b;
            string[] s=Console.ReadLine().Split(' ');
            a=int.Parse(s[0]);
            b = int.Parse(s[1]);
            Console.WriteLine((b-1)*(a-1));
        }

    }
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:



int main(void){
	int n;
	cin >> n;
	
	deque<int> q;

	rep(i,n){
		int cur;
		cin >> cur;
		if((i + n)&1)
			q.push_front(cur);
		else
			q.push_back(cur);
	}

	rep(i,n){
		cout << (i?" ":"") <<  q.front();
		q.pop_front();
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int a[200000];
int main(){
	int k,n;
	cin>>k>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	int maxx=0;
	for(int i=1;i<n;i++)maxx=max(maxx,a[i]-a[i-1]);
	maxx=max(a[0],maxx);
	maxx=max(k-a[n-1],maxx);
	cout<<min(k-maxx,a[n-1]-a[0])<<'\n';
}

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

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto S = RD!string;
	auto T = RD!string;

	writeln(S == T[0..$-1] && S.length+1 == T.length ? "Yes" : "No");
	stdout.flush;
	debug readln;
}

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

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

using namespace std;

int main(){
  int n,k,s;
  while(cin >> n >> k >> s, n|k|s ){
    int dp[k+1][s+1];
    memset(dp,0,sizeof(dp));
    dp[0][0] = 1;
    REP(value,1,n+1){
      for(int use=k-1;use>=0;use--){
	rep(cur,s+1){
	  int next = cur + value;
	  if( next <= s ) {
	    dp[use+1][next] += dp[use][cur];
	  }
	}
      }
    }
    cout << dp[k][s] << endl;
  }
  return 0;
}

Measured memory_bytes: 1176
H, W, K = map(int, input().split())
C = [list(input()) for i in range(H)]

ans = 0
for h in range(1<<H):
  for w in range(1<<W):
    curr = 0
    for i in range(H):
      for j in range(W):
        if not (h & 1<<i) and not (w & 1<<j) and C[i][j] == '#':
          curr += 1
    if K == curr:
      ans += 1
print(ans)

Measured memory_bytes: 9148
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	long long int a,b,c,d;
	cin>>a>>b>>c;
	d=b/c-a/c;
	if(a%c==0){
		d++;
	}
	cout<<d<<endl;
		
	
	
}	

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

int a[111][3];

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i ++ )
        scanf("%d%d%d", &a[i][0], &a[i][1], &a[i][2]);
    if (!a[0][2])
        for (int i = 0; i < n; i ++ )
            if (a[i][2])
                for (int j = 0; j < 3; j ++ )
                    a[0][j] ^= a[i][j] ^= a[0][j] ^= a[i][j];
    for (int x = 0; x <= 100; x ++ )
        for (int y = 0; y <= 100; y ++ ){
            int h = a[0][2] + std::abs(x - a[0][0]) + std::abs(y - a[0][1]);
            bool amd = 1;
            for (int i = 0; amd && i < n; i ++ )
                if (std::max(h - std::abs(x - a[i][0]) - std::abs(y - a[i][1]), 0) != a[i][2])
                    amd = 0;
            if (amd)
                printf("%d %d %d", x, y, h);
        }
}


Measured memory_bytes: 256
# =============================================================================
#　Depth First Search
# =============================================================================
import sys
sys.setrecursionlimit(10**8)

N=int(input())
Graph=[list(map(int,input().split()))[2:] for _ in range(N)]
Graph.insert(0,[])
seen=[False for _ in range(N+1)]
first_order=[0]*(N+1)
last_order=[0]*(N+1)
time=1

def dfs(Graph,v):
    global seen
    global time
    seen[v]=True
    first_order[v]=time
    time+=1
    for nv in Graph[v]:
        if seen[nv]:
            continue
        dfs(Graph,nv)

    last_order[v]=time
    time+=1

for v in range(1,N+1):
    if not seen[v]:
        dfs(Graph,v)
for i in range(1,N+1):
    print(i,first_order[i],last_order[i])



Measured memory_bytes: 5660
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;
ll mod9 = 1000000009;

signed main(){
    double r;
    cin>>r;
    r *= 2*M_PI;
    cout<<r<<endl;  
}


Measured memory_bytes: 3800
#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; ++i)
using namespace std;

int main() {
  int N, K;
	cin >> N >> K;
  vector<int> c(N);
	REP(i,N) {
		int a; cin >> a; c[--a]++;
	}
	sort(c.begin(), c.end(), greater<int>());
	int s = N;
	REP(i,K) s -= c[i];
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main{
	public static char[] s;
	public static boolean debug = true;
	static final int n = 8;
	public static void main(String[] args) throws IOException{
		Scanner in = debug ? new Scanner(System.in) : new Scanner(new File("L"));
		char[][] s = new char[n][];
		for(int i=0; i<n; i++){
			s[i] = in.next().toCharArray();
		}
		dfs(s, 'o', false);
		output(s);
	}
	
	static void output(char[][] s){
		for(int i=0; i<n; i++){
			System.out.println(String.valueOf(s[i]));
		}
	}
	
//	static int[][] dbg = new int[n][n];
//	static String dump(char[][] s){
//		StringBuilder sb = new StringBuilder();
//		for(int i=0; i<n; i++){
//			for(int j=0; j<n; j++){
//				if(dbg[i][j] != 0) sb.append(dbg[i][j]);
//				else sb.append(s[i][j]);
//			}
//			sb.append('\n');
//		}
//		return sb.toString();
//	}
//	static void clear(){
//		for(int i=0; i<n; i++){
//			for(int j=0; j<n; j++){
//				dbg[i][j] = 0;
//			}
//		}
//	}
	
	static final int[] dx = {-1, 0, 1, -1, 1, -1, 0, 1};
	static final int[] dy = {-1, -1, -1, 0, 0, 1, 1, 1};
	static void dfs(char[][] s, char c, boolean pass){
//		clear();
		
		Pos p = null;
		if(c=='o'){
			for(int i=0; i<n; i++){
				for(int j=0; j<n; j++){
					if(s[i][j] != '.') continue;
					Pos tmp = check(s, c, i, j);
//					dbg[i][j] = tmp.del;
					if(tmp.del > 0 && (p == null || p.del < tmp.del)){
						p = tmp;
					}
				}
			}
		}else{
			for(int i=n-1; i>=0; i--){
				for(int j=n-1; j>=0; j--){
					if(s[i][j] != '.') continue;
					Pos tmp = check(s, c, i, j);
//					dbg[i][j] = tmp.del;
					if(tmp.del > 0 && (p == null || p.del < tmp.del)){
						p = tmp;
					}
				}
			}
		}
//		System.out.println(dump(s));
		if(p == null){
			if(!pass) dfs(s, c=='o'?'x':'o', true);
			return;
		}
//		System.out.println(p);
		s[p.y][p.x] = c;
		for(int i=0; i<8; i++){
			if((p.dir&1<<i)==0) continue;
			int x = p.x + dx[i];
			int y = p.y + dy[i];
			while(s[y][x] != c){
				s[y][x] = c;
				y += dy[i];
				x += dx[i];
			}
		}
		dfs(s, c=='o'?'x':'o', false);
	}
	
	static Pos check(char[][] s, char c, int i, int j){
		char enm = c=='o'?'x':'o';
		int del = 0;
		int dir = 0;
		for(int k=0; k<8; k++){
			int nx = j+dx[k];
			int ny = i+dy[k];
			if(out(nx, ny) || s[ny][nx] != enm) continue;
			while(!out(nx, ny) && s[ny][nx] == enm){
				nx += dx[k];
				ny += dy[k];
			}
			if(out(nx, ny) || s[ny][nx] != c) continue;
			del += Math.max(Math.abs(i-ny), Math.abs(j-nx))-1;
			dir |= 1<<k;
		}
		return new Pos(j, i, dir, del);
	}
	
	static boolean out(int x, int y){
		return x<0 || x>=n || y<0 || y>=n;
	}
}

class Pos{
	int x, y, dir;
	int del;
	Pos(int x, int y, int dir, int del){
		this.x = x;
		this.y = y;
		this.dir = dir;
		this.del = del;
	}
	
	public String toString(){
		return "("+x+","+y+")";
	}
}

Measured memory_bytes: 19336