akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<algorithm>
#include<iomanip>

using namespace std;

int N, M;
double FertilizerData[100][100];
double DpResult[100][100];


void solve() {
	double maxData;

	for (int j = 0; j < N; ++j) {
		DpResult[0][j] = 1.0;
	}

	for (int i = 1; i < M; ++i) {
		for (int j = 0; j < N; ++j) {
			for (int k = 0; k < N; ++k) {
				DpResult[i][j] = max(DpResult[i][j], DpResult[i - 1][k] * FertilizerData[k][j]);
			}
		}
	}

	maxData = -0.1;
	for (int k = 0; k < N; ++k) {
		maxData = max(maxData, DpResult[M - 1][k]);
	}
	cout << fixed << setprecision(2) << maxData << endl;
}

int main() {

	while (cin >> N >> M, N) {
		memset(FertilizerData, 0, sizeof(FertilizerData));
		memset(DpResult, 0, sizeof(DpResult));
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				cin >> FertilizerData[i][j];
			}
		}
		////show:
		//for (int i = 0; i < N; ++i) {
		//	for (int j = 0; j < N; ++j) {
		//		cout << FertilizerData[i][j] << " ";
		//	}
		//	cout << endl;
		//}
		solve();
	}

	return 0;
}




Measured memory_bytes: 3428
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <climits>

using namespace std;

template<typename T> class LazyRMQ {
    public:
    int n;
    T inf = INT_MAX;
    vector<T> data, lazy;

    LazyRMQ(int m, T init_value=INT_MAX){
        // 2のべき乗にする
        n = 1;
        while(n < m) n <<= 1;
        data.assign(2*n-1, init_value);
        lazy.assign(2*n-1, 0);
    }

    void eval(int k, int kl, int kr){
        if(data[k] == inf) data[k] = 0;
        if(lazy[k] == 0) return;
        data[k] += lazy[k];
        if(kr - kl > 1){
            lazy[2*k+1] += lazy[k];
            lazy[2*k+2] += lazy[k];
        }
        lazy[k] = 0;
    }

    // [s,t)
    void add(int s, int t, int k, int kl, int kr, T x){
        eval(k, kl, kr);
        if(kr <= s || t <= kl) return;
        if(s <= kl && kr <= t){
            lazy[k] += x;
            eval(k, kl, kr);
            return;
        }
        int kc = (kl+kr)/2;
        add(s, t, 2*k+1, kl, kc, x);
        add(s, t, 2*k+2, kc, kr, x);
        data[k] = min(data[2*k+1], data[2*k+2]);
    }

    // [s,t)
    T find(int s, int t, int k, int kl, int kr){
        eval(k, kl, kr);
        if(kr <= s || t <= kl) return inf;
        if(s <= kl && kr <= t) return data[k];
        int kc = (kl+kr)/2;
        T vl = find(s, t, 2*k+1, kl, kc);
        T vr = find(s, t, 2*k+2, kc, kr);
        return min(vl, vr);
    }
};

int main(){
    int n,Q,q;
    scanf("%d %d", &n, &Q);
    LazyRMQ<int> rmq(n+1);

    char s[n+1];
    scanf("%s", s);
    set<int> close;
    int data[n+1];
    data[0] = 0;
    for(int i=0;i<n;i++){
        if(s[i]=='('){
            data[i+1] = data[i]+1;
        }else{
            data[i+1] = data[i]-1;
            close.insert(i+1);
        }
        rmq.add(i+1, i+2, 0, 0, rmq.n, data[i+1]);
    }

    for(int i=0;i<Q;i++){
        scanf("%d", &q);
        // 今回の変更により，閉じかっこが開いたか？
        bool open_parentheses = (s[q-1] == ')');
        int j;
        if(open_parentheses){
            rmq.add(q, rmq.n, 0, 0, rmq.n, 2);
            s[q-1] = '(';
            close.erase(q);
            // どこかの開きかっこを閉じる
            // 「以降全て2以上」のところはひっくり返せる
            j = (n+1)/2;
            int ng = 0, ok = n;
            while(ok-ng > 1){
                j = (ng+ok)/2;
                if(rmq.find(j, rmq.n, 0, 0, rmq.n) >= 2){
                    ok = j;
                }else{
                    ng = j;
                }
            }
            j = ok;
            rmq.add(j, rmq.n, 0, 0, rmq.n, -2);
            s[j-1] = ')';
            close.insert(j);
        }else{
            rmq.add(q, rmq.n, 0, 0, rmq.n, -2);
            s[q-1] = ')';
            close.insert(q);
            // どこかの閉じかっこを開く
            // 先頭の閉じかっこをひっくり返せば良い
            j = *close.begin();
            rmq.add(j, rmq.n, 0, 0, rmq.n, 2);
            s[j-1] = '(';
            close.erase(j);
        }
        printf("%d\n", j);
    }
}



Measured memory_bytes: 19476
#include <cstdio>
#include <string>

using namespace std;

int main(void)
{
    int h, w;
    while(1)
    {
        scanf("%d %d", &h, &w);
        if((h==0) && (w==0)) break;
        for(int i=0; i<h; i++)
        {
            string str;
            for(int j=0; j<w; j++)
            {
                if((i+j)%2==1) str.push_back('.');
                else str.push_back('#');
            }
            printf("%s\n", str.c_str());
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2708
#define DINGER_GISBAR
#include <bits/stdc++.h>
using namespace std;
const long long MOD = static_cast<int>(1e9) + 7;
//{{{TEMPLATE_BEGIN
#include <unistd.h>
using namespace std::rel_ops;
#ifdef ZEROKUGI
#include <dumper.hpp>
#define dump(x) dumper::dumper(cerr, __LINE__, (#x), (x), 50, 1, 1)
#define tick(...) dumper::tick(__VA_ARGS__)
#pragma message "Compiling " __FILE__
#else
#define dump(x)
#define tick(...)
#endif
typedef long long lint;
typedef unsigned long long ulint;
typedef long double ldouble;
typedef vector<int> vint;
#define rep(i, n) \
    for (int i = 0, i##_len = static_cast<int>(n); i < i##_len; i++)
#define all(c) begin(c), end(c)
#define perm(c)   \
    sort(all(c)); \
    for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))
#define uniquenize(v) (v).erase(unique(all(v)), end(v))
#define size(c) (int)((c).size())
#define cauto const auto &
#define memset(x, y) memset(x, y, sizeof(x))
#define popcount __builtin_popcount
#define gcd __gcd
inline lint bit(int x) { return 1LL << x; }
template <class T>
inline bool chmin(T& a, const T& b) {
    return a > b ? a = b, 1 : 0;
}
template <class T>
inline int clamp(T v, T lo, T hi) {
    return (v > hi) - (v < lo);
}
template <class T>
inline bool chmax(T& a, const T& b) {
    return a < b ? a = b, 1 : 0;
}
template <class T>
inline pair<vector<T>, char> operator*(const vector<T>& v, const char& c) {
    return make_pair(v, c);
}
template <class T>
inline istream& operator>>(istream& is, vector<T>& v) {
#ifdef ZEROKUGI
    if (v.empty()) {
        cerr << "Error L" << __LINE__ << ": vector size is zero." << endl;
        exit(EXIT_FAILURE);
    }
#endif
    for (auto& x : v) is >> x;
    return is;
}
template <class T>
inline ostream& operator<<(ostream& os, const pair<vector<T>, char>& v) {
    bool t = 0;
    for (const T& x : v.first) {
        if (t) os << v.second;
        os << x;
        t = 1;
    }
    return os;
}
template <class T>
inline ostream& operator<<(ostream& os, vector<T>& v) {
    return os << v * ' ';
}
struct before_main {
    before_main() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
        tick(0, 0);
    };
} __before_main;
//}}}TEMPLATE_END

int main() {
    lint N, X, D;
    cin >> N >> X;
    D = N - X;

    lint ans = X;
    while (X != 0) {
        lint b = X / D;
        ans += b * 2 * D;
        X %= D;
        if (X != 0) {
            ans += D-X;
            swap(X, D);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
using namespace std;

int main(){
	int n=0,x=0,d=0,l=0,ans=0;
	cin>>n>>x;
	for(int i=0;i<=n && d<=x;i++){
		ans++;
		cin>>l;
		d+=l;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n;
  cin>>n;
  vecint cnt(n, 0);
  int mn = n;
  int mx = 0;
  for(int i:irange(0,n)) {
    int a;
    cin>>a;
    ++cnt[a];
    mn = min(mn, a);
    mx = max(mx, a);
  }
  bool ok = true;
  if (mn < mx / 2) {
    ok = false;
  }
  if (cnt[mx/2] > 1) {
    ok = false;
  }
  if ((mx%2) == 1 && cnt[mx/2+1] != 2) {
    ok = false;
  }
  for(int i:irange(min(mx+1,mx/2+2), mx+1)) {
    if (cnt[i] < 2) {
      ok = false;
    }
  }
  if (!ok) {
    cout<<"Impossible"<<endl;
  } else {
    cout<<"Possible"<<endl;
  }
  return 0;
}


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

int main() {
	int ma=-1,mi=200001;
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(s.substr(i,1)=="A"){
			mi=min(i,mi);
		}else if(s.substr(i,1)=="Z"){
			ma=max(i,ma);
		}
	}
	cout<<ma+1-mi<<endl;
	return 0;

}



Measured memory_bytes: 640
#include<iostream>
using namespace std;
const long mod=998244353;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
long fac[2<<17],inv[2<<17],ans,N,M,K;
int main()
{
	fac[0]=1;
	for(int i=1;i<2<<17;i++)fac[i]=fac[i-1]*i%mod;
	inv[(2<<17)-1]=power(fac[(2<<17)-1],mod-2);
	for(int i=(2<<17)-1;i--;)inv[i]=inv[i+1]*(i+1)%mod;
	cin>>N>>M>>K;
	for(int L=0;L<=K;L++)ans+=fac[N-1]*inv[N-1-L]%mod*inv[L]%mod*M%mod*power(M-1,N-L-1)%mod;
	cout<<(ans%mod+mod)%mod<<endl;
}


Measured memory_bytes: 7732
n,m=map(int,input().split())
ans=[0]*2
l=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append((a,b))
l.sort()
for i,j in l:
    if ans[1]+j<=m:
        ans[0]+=i*j
        ans[1]+=j
    else:
        ans[0]+=i*(m-ans[1])
        break
print(ans[0])


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

#define ll long long
#define pb push_back


int main() {
    int n, x, t;
    cin >> n >> x >> t;
    int ans = 0;
    while (n > 0){
        n -= x;
        ans += t;
    }
    cout << ans;

}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int mINF = 1e9;
const int MOD = 1e9+7;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    int n,k;
    cin >> n >> k;
    vector<bool> num(10,true);
    rep(i,k){
        int t;cin >> t;
        num[t] = false;
    }
    while(1){
        string s = to_string(n);
        bool flag = true;
        for(int i=0;i<s.size();i++){
            if(num[s[i]-'0']==false){
                n++;
                flag = false;
                break;
            }
        }
        if(flag==true)break;
    }
    cout << n << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007

#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return (a*( b/ gcd(a,b)));}

void f()
{
  int n;
  cin>>n;
  cout<<"Christmas";
  for(int i=1;i<=25-n;i++)
  {
    cout<<" Eve";
  }
  cout<<nl;
}

int main()
{
    su;

    f();
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,a,b,c,d;
  cin >> n >> a >> b >> c >> d;
  ll k=b-a;
  bool ok=false;
  for(int i=-n+1;i<=n-1;i++){    
    ll j=n-1-abs(i);
    rep(l,2){
      j=j*pow(-1,l);
      ll low=i*d+j*c;
      ll high=(i+j)*d;
      if(low>high) swap(low,high);
      if(low<=k && k<=high) ok=true;     
    }
  }
  if(ok) cout << "YES" << endl;
  else cout << "NO" << endl;

  
  return 0;
    

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
#define REP(i, a, b) for(int i = int(a); i <= int(b); i++)
#define LOOP(i, v) for(int i = 0; i < v.size(); i++)
#define EPS 1e-9
#define INF 1e12
#define debug(x) cerr << "DEBUG : " << (#x) << " => " << (x) << endl

int main()
{
  int N;
  vi a;
  vi b;
  
  scanf("%d", &N);
  a.resize(N);
  b.resize(N);
  REP(i, 0, N-1)
  {
    scanf("%d", &a[i]);
    b[i] = a[i];
  }
  
  sort(b.begin(), b.end());
  
  int d = b[(N/2)-1];
  int e = b[N/2];
  
  REP(i, 0, N-1)
  {
    if(a[i] >= e) printf("%d\n", d);
    else printf("%d\n", e);
  }
    
  return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
	int a[100000]={0};
int main()
{
	int n;
	cin>>n;
int count=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
		for(int i=1;i<=n;i++)
		{  int t;
			if(a[i]==i)
			 {
			 	t=a[i];
			 	a[i]=a[i+1];
			 	a[i+1]=t;
			 	count++;
			 }
		}
		cout<<count<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;

int N;
struct P{
	int i;  //自己 
	int num;  //班里几个人 
	bool operator <(const P &p) const{
		if(num!=p.num) return num<p.num;
	}
}; 
P A[100050];

int main(){
	ios::sync_with_stdio(0);
	cin>>N;
	for(int j=1; j<=N;j++){
		A[j].i=j;
		cin>>A[j].num;
	}
	sort(A+1,A+1+N);
	for(int j=1;j<=N;j++){
		cout<<A[j].i<<" ";
	}
	
	return 0;
} 

Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;

class Program
{
    private static int Solve(int C, int K, int[] T)
    {
        int n = 0;
        var bus = new List<int>();
        foreach (int t in T.OrderBy(t => t))
        {
            if (bus.Count > 0)
            {
                if (bus.Count == C || bus[0] + K < t)
                {
                    bus.Clear();
                    ++n;
                }
            }
            bus.Add(t);
        }
        return bus.Count > 0 ? n + 1 : n;
    }
    static void Main(string[] args)
    {
        int[] x = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int[] T = new int[x[0]];
        for (int i = 0; i < T.Length; ++i) { T[i] = int.Parse(Console.ReadLine()); }
        Console.WriteLine(Solve(x[1], x[2], T));
    }
}


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

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int sum = 0;
	for (int i = 0; i < n; i++) sum += a[i];
	int sum2 = 0;
	int ans = 1e9;
	for (int i = 0; i < n; i++) {
		sum2 += a[i];
		ans = min(ans, abs((sum - sum2) - sum2));
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3660
/*
TASK: ditch
LANG: C++11
 */
//#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;
const int N = 1e5 + 3, M = 2 * 3e4 + 3;

int arr[N];
int pre[N];
int suf[N];

int main() {
    //freopen("test.in", "r", stdin);
    int n;
    while (cin >> n) {
        int res = INT_MIN;
        for (int i = 1; i <= n; i++)cin >> arr[i];
        int p=0,s=0;
        for (int i = 1,j=n; i <= n; i++,j--){
            p=__gcd(p,arr[i]);
            pre[i]=p;
            s=__gcd(s,arr[j]);
            suf[j]=s;
        }
        suf[n+1]=0;
        for (int i = 1; i <= n; i++){
            int x=__gcd(pre[i-1],suf[i+1]);
            res=max(res,x);
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 1408
/*************************************************************************
	> File Name: 1.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Blog: https://blog.csdn.net/Pig_cfbsl 
	> Created Time: 2020/5/2 20:44:09
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
int h[100010],l[100010];
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	int n=read(),m=read(),u,v;
	For(i,1,n){
		h[i]=read();
		l[i]=-1;
	}
	For(i,1,m){
		u=read(); v=read();
		l[u]=max(l[u],h[v]);
		l[v]=max(l[v],h[u]);
	}
	int ans=0;
	For(i,1,n)
		if(h[i]>l[i])
			ans++;
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 4468
integer N
integer t_pre,x_pre,y_pre!previousのつもりだけどpresentにもとれる、、、
integer t,x,y
integer check
read*,N

t_pre=0;x_pre=0;y_pre=0
check=1
do i=1,N
  read*,t,x,y
  if(abs(x-x_pre)+abs(y-y_pre)>t-t_pre)check=0
  if(mod(abs(x+y-(x_pre+y_pre)),2)/=mod(t-t_pre,2))check=0
end do
print"(A)",merge("Yes"," No",check==1)
end

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

int n,k,a[15];

bool used[15];

int main(){
     cin >> n >> k;
     for(int i = 1; i <= k; i++){
     	cin >> a[i];
     	used[a[i]] = 1;
     }
     while(1){
     	bool ok = true;
     	int x = n;
     	while(x){
     		if(used[x % 10]){
     			ok = false;
     			break;	
     		}
     		x /= 10;
     	}
     	if(ok) break;
     	n++;
     }
     cout << n;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
//#include <chrono>
//#include <random>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <ctime>
#include <tuple>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <list>
#include <map>
#include <set>

using namespace std;

const int N = 200005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int n, a, b;

vector <int> g;

int mas[N];

int main() {
	//mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++) {
		if (i == 0) {
			if ((a >> i) & 1) {
				g.push_back(1);
				g.push_back(0);
			}
			else {
				g.push_back(0);
				g.push_back(1);
			}
		}
		else {
			vector <int> ng;
			int bit = ((a >> i) & 1);
			for (int j = 0; j < 2; j++) {
				for (int h = 0; h < (int)g.size(); h++) {
					ng.push_back(g[h] + bit * (1 << i));
				}
				reverse(g.begin(), g.end());
				bit ^= 1;
			}
			g = ng;
		}
	}
	int id;
	for (int i = 0; i < (int)g.size(); i++) {
		if (g[i] == b) id = i;
		if (g[i] == b && i % 2 == 0) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	if (id == (int)g.size() - 1) {
		for (int i = 0; i < (int)g.size(); i++) {
			cout << g[i] << " ";
		}
		cout << endl;
		return 0;
	}
	//////////////////////////////////////////
	int p = 4;
	while (id < (int)g.size() - p) {
		p *= 2;
	}
	int l = (int)g.size() - p;
	int r = (int)g.size() - 1;
	vector <int> answ;
	for (int i = id; i <= r - (id - l); i++) {
		answ.push_back(g[i]);
	}
	int L = id - 1;
	int R = r - (id - l) + 1;
	int z = 0;
	while (L != l - 1) {
		if (z == 0) {
			answ.push_back(g[R]);
			answ.push_back(g[L]);
		}
		else {
			answ.push_back(g[L]);
			answ.push_back(g[R]);
		}
		--L;
		++R;
		z ^= 1;
	}
	reverse(answ.begin(), answ.end());
	for (int i = l; i <= r; i++) {
		g[i] = answ[i - l];
	}
	for (int i = 0; i < (int)g.size(); i++) {
		cout << g[i] << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 2544
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=45;
int n;
int A[N][N];
LL f[N][N][N][N],g[N][N][N][N];
LL G(int a,int b,int c,int d);
LL F(int a,int b,int c,int d){
	LL &res=f[a][b][c][d];
	if (res!=-1)
		return res;
	if (a>b&&c>d)
		return res=1;
	if ((a>b)^(c>d))
		return res=0;
	res=0;
	For(i,a,b)
		Fod(j,d,c)
			res+=G(a,i,j,d)*F(i+1,b,c,j-1);
	return res;
}
LL G(int a,int b,int c,int d){
	LL &res=g[a][b][c][d];
	if (res!=-1)
		return res;
	if (a>b||c>d)
		return res=0;
	res=0;
	For(i,a,b)
		Fod(j,d,c)
			if (A[i][j])
				res+=F(a,i-1,i+1,b)*F(c,j-1,j+1,d);
	return res;
}
int main(){
	n=read()*2;
	For(i,1,n)
		For(j,1,n)
			scanf("%1d",&A[i][j]);
	memset(f,-1,sizeof f);
	memset(g,-1,sizeof g);
	LL ans=0;
	For(i,2,n)
		if (A[1][i])
			ans+=F(2,i-1,i+1,n);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 64384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int q;
	cin >> q;
	vector<int> b(q);
	vector<int> c(q);
	rep(i, q) cin >> b[i] >> c[i];

	ll sum = 0;
	rep(i, n) sum += a[i];
	map<int, int> mp;
	rep(i, n) {
		mp[a[i]]++;
	}

	rep(i, q) {
		int g = mp[b[i]];
		ll h = (c[i] - b[i])*g;
		sum += h;
		cout << sum << endl;

		mp[b[i]] = 0;
		mp[c[i]] += g;
	}

	return 0;
}

Measured memory_bytes: 8800
#include <bits/stdc++.h>
using namespace std;
int x[1005],y[1005];
vector<int>d;
int main(){
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d%d",&x[i],&y[i]);
    for(int i=1;i<=n;i++)
        if((x[i]+y[i]-x[1]-y[1])%2)
            puts("-1"),exit(0);
    if((x[1]+y[1])%2==0)d.push_back(1);
    for(int i=30;~i;i--)d.push_back(1<<i);
    cout<<d.size()<<"\n";
    for(int i:d)cout<<i<<" ";cout<<"\n";
    for(int i=1;i<=n;i++){
        for(int w:d)
            if(abs(x[i])>abs(y[i]))
                if(x[i]<0)x[i]+=w,cout<<"L";
                else x[i]-=w,cout<<"R";
            else
                if(y[i]<0)y[i]+=w,cout<<"D";
                else y[i]-=w,cout<<"U";
        cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0106&lang=jp
"""
import sys


def solve(amount):
    """
    :param amount: ?????\???????????°?????????
    :return: ?????????
    """
    best_price = (amount + 199) // 200 * 380
    for a in range(amount // 200 + 1):
        for b in range(amount // 300 + 1):
            for c in range(amount // 500 + 1):
                for a1 in range(amount // 1000 + 1):
                    for b1 in range(amount // 1200 + 1):
                        for c1 in range(amount // 1500 + 1):
                            if a*200 + b*300 + c*500 + a1*1000 + b1*1200 + c1*1500 == amount:
                                price = a*380 + b*550 + c*850 + a1*1520 + b1*1870 + c1*2244
                                if price < best_price:
                                    best_price = price
    return best_price




def main(args):
    while True:
        amount = int(input())
        if amount == 0:
            break
        result = solve(amount)
        print(result)



if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7564
def main():
    n=int(input())
    a=list(map(int,input().split()))
    import itertools as it
    import collections as co
    ac=it.accumulate(a)
    ac=list(ac)
    
    d=co.defaultdict(int)
    ans=0
    for i in ac:
        d[i]+=1
        if i==0:
            ans+=1
    
    for i in d.values():
        if i>=2:
            ans+=i*(i-1)//2
    print(ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 41492
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())

// code
// ------------------------------------------------
int main() {
	string a,b,c;
  cin >> a >> b >> c;
  
  cout << a[0] << b[1] << c[2];
  
  
  
  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a[10000],b[10000],c[10000],n;
  cin>>n;
  for(int i=0;i<n;i++){
  cin>>a[i]>>b[i]>>c[i];
  a[i]*=a[i];
  b[i]*=b[i];
  c[i]*=c[i];
  }
  for(int i=0;i<n;i++){
  if(a[i]+b[i]==c[i]||a[i]+c[i]==b[i]||b[i]+c[i]==a[i]){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  }
  return(0);
}
    

Measured memory_bytes: 3020
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define max_n 1000000

using namespace std;

void solve()
{
   ll n,d;
   cin>>n>>d;
   ll ans=0;
   while(n--)
   {
       ll x,y;
       cin>>x>>y;
       x*=x;
       y*=y;
       if(d*d>=x+y)
       {
           ans++;
       }
   }
   cout<<ans<<endl;
}

int32_t main()
{
	IOS
	ll T = 1;
// 	cin >> T;
	for (ll i = 1; i <= T; ++i)
	{
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3648
#include<iostream>

using namespace std;

int main(){

  int l,a,b,c,d,x,y;

  cin>>l>>a>>b>>c>>d;

  x=a/c;

  if((a%c)!=0){
    x=x+1;
  }


  y=b/d;

  if((b%d)!=0){
    y=y+1;
  }

  if(x>y){
    cout<<l-x<<endl;
  }else if(x<y){
    cout<<l-y<<endl;
  }else{
    cout<<l-x<<endl;
  }


  return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin>>N;
    string data[N];
    for(int i=0;i<N;i++){
        cin>>data[i];
    }
    set<string> s;
    for(int i=0;i<N;i++){
        s.insert(data[i]);
    }
    cout<<s.size()<<endl;
}

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

void solve()
{
  ll n;
    cin>>n;
    string s="";
    while(n)
    {
     int res=n%26;
        if(res==0)
        {
            s+='z';
            n=(n-1)/26;
        }
        else
        {
            s+=char('a'+(res-1));
            n/=26;
        }
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
}


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

Measured memory_bytes: 3632
N, M = list(map(int, input().split()))
SC = []
for i in range(M):
    s, c = list(map(int, input().split()))
    SC.append([s-1, c])

poss = []
if N == 3:
    s = 100
    e = 1000
elif N == 2:
    s = 10
    e = 100
else:
    s = 0
    e = 10

for i in range(s, e):
    poss.append(str(i))

for s, c in SC:
    poss2 = []
    for n in poss:
        if n[s] == str(c):
            poss2.append(n)
    poss = poss2

# print(poss2)

if poss:
    print(poss[0])
else:
    print(-1)

Measured memory_bytes: 3064
import sys


ans = 'No'
h, w = [int(_) for _ in input().split()]
s = ''
for i in range(h):
    s += input()

dict = {}
for i in range(len(s)):
    if s[i] in dict.keys():
        dict[s[i]] += 1
    else:
        dict[s[i]] = 1

list = list(dict.values())

if h % 2 != 0 and w % 2 != 0:
    for i in range(len(list)):
        if list[i] % 2 != 0:
            list[i] -= 1
            break

for i in list:
    if i % 2 != 0:
        print('No')
        sys.exit()

c = 0
if h % 2 == 1:
    if w % 2 == 0:
        c += w / 2
    else:
        c += (w - 1) / 2
if w % 2 == 1:
    if h % 2 == 0:
        c += h / 2
    else:
        c += (h - 1) / 2

p = (h // 2) * (w // 2)
for j in range(p):
    for i in range(len(list)):
        if list[i] >= 4:
            list[i] = list[i] % 4
            break

k = 0
for i in list:
    k += i / 2

if k == c:
    ans = 'Yes'

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second
#define vi vector<int>
#define vl vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define abu ios_base::sync_with_stdio(0)
#define said cin.tie(0)
using namespace std;
ll const MOD = 1000000007;

void yes(){
    cout<<"YES"<<'\n';
}

void no(){
    cout<<"NO"<<'\n';
}

ll fact(int n){
    ll ans = 1;
    for(int i=2;i<=n;i++){
        ans = (ans*i)%MOD;
    }

    return ans;
}

ll powM(int n, int x){
    if(x==0){
        return 1;
    }
    if(x==1){
        return n%MOD;
    }

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

ll C(int n, int k){
    return (fact(n) * powM((fact(k)*fact(n-k))%MOD,MOD-2))%MOD;
}

ll A(int n, int k){
    return (fact(n) * powM(fact(n-k)%MOD,MOD-2))%MOD;
}

ll dp[3010][3010];



void solve(){
    int n;
    cin>>n;
    vi a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }    

    for(int l = n-1;l>=0;l--){
        for(int r = l;r<n;r++){
            if(l==r){
                dp[l][r] = a[l];
            }else{
                dp[l][r] = max(a[l] - dp[l+1][r],a[r] - dp[l][r-1]);
            }
        }
    }

    cout<<dp[0][n-1]<<'\n';
}

int main(){
    abu;
    said;
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


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

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

int main(){
	string s;cin>>s;
	int Max=0,cnt=0;
	rep(i,s.size()){
		if(s[i]=='R')cnt++;
		else cnt=0;
		Max=max(Max,cnt);
	}
	cout<<Max<<endl;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repfrom(i, from, n) for (ll i = (from); i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)

using namespace std;

using ll = long long;
using p  = pair<ll, ll>;
constexpr ll INF = 1LL << 62;
constexpr ll MAX_N = 2000;

ll N, Z, W;
vector<ll> A;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N >> Z >> W;
    A = vector<ll>(N + 1, 0);
    reps(i, N) {
        cin >> A[i];
    }
    
    if (N == 1) {
        cout << abs(A[1] - W) << endl;
    } else {
        cout << max(abs(A[N] - W), abs(A[N - 1] - A[N])) << endl;
    }
    
    return 0;
}


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

int main()
{
	string s;
	cin >> s;

	int N = s.size();
	string ans;
	for( int i = 0; i < N; i++ ) {
		if( s[i] == 'B' ) {
			if( ans.size() > 0 ) ans.pop_back();
		}
		else ans += s[i];
	}

	cout << ans << endl;
}


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

using namespace std;

using ll = int_fast64_t;
constexpr ll llmax = INT_FAST64_MAX; // std::numeric_limits<int_fast64_t>::max()
constexpr ll llmin = INT_FAST64_MIN; // std::numeric_limits<int_fast64_t>::min()
using ull = uint_fast64_t;
constexpr ull ullmax = UINT_FAST64_MAX; // std::numeric_limits<uint_fast64_t>::max()

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

inline
ll gcd(ll a, ll b)
{
    if (a < b) swap(a, b);
    if (b == 0){
        return a;
    }else{
        return gcd(b, a % b);
    }
}

int main()
{
    scanLLInt(A);
    scanLLInt(B);
    scanLLInt(C);
    scanLLInt(D);
    const ll E = A - 1;
    // cout << A << " ";
    // cout << B << " ";
    // cout << C << " ";
    // cout << D << " ";
    // cout << endl;
    const ll cd = C * D / gcd(C, D);
    // cout << (B / C) << " ";
    // cout << (B / D) << " ";
    // cout << (B / cd) << " ";
    // cout << endl;
    // cout << (E / C) << " ";
    // cout << (E / D) << " ";
    // cout << (E / cd) << " ";
    // cout << endl;
    const ll Bl = (B / C + B / D - B / cd);
    const ll El = (E / C + E / D - E / cd);
    // cout << Bl << " ";
    // cout << El << " ";
    // cout << endl;
    cout << ((B - E) - (Bl - El)) << endl;
}


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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  int H,W;
  cin>>H>>W;
  int sw,sh,gw,gh;
  cin>>sh>>sw>>gh>>gw;
  sh--; sw--; gh--; gw--;
  vector<string> s(H);
  for(int i(0);i<H;i++){
    cin>>s[i];
  }
  vector<vector<int>> dp(H,vector<int>(W,INFint));
  dp[sh][sw] = 0;
  int pathed[1000][1000] = {0};
  int nh[4] = {1,-1,0,0};
  int nw[4] = {0,0,1,-1};

  queue<pair<int,int>> p;
  p.push({sh,sw});
  while(!p.empty()){
    int i = p.front().first,j = p.front().second; p.pop();
    if(pathed[i][j] == 1 || s[i][j] == '#') continue;
    //cout << i << " "<< j << endl;
    int now_cnt = dp[i][j];
    queue<pair<int,int>> q;
    q.push({i,j});
    pathed[i][j] = 1;
    while(!q.empty()){
      pair<int,int> now = q.front();q.pop();
      for(int x(-2);x<=2;x++){
        for(int y(-2);y<=2;y++){
          if(now.first+y >= 0 && now.first + y < H && now.second + x < W && now.second + x>= 0 && s[now.first + y][now.second + x] == '.'){
            dp[now.first+y][now.second+x] = min(dp[now.first+y][now.second+x],now_cnt+1);
            p.push({now.first+y,now.second+x});
          }
        }
      }
      for(int k(0);k<4;k++){
        int next_h = now.first + nh[k],next_w = now.second + nw[k];
        if(next_h >= 0 && next_h < H && next_w >= 0 && next_w < W && s[next_h][next_w] == '.' && pathed[next_h][next_w] == 0){
          pathed[next_h][next_w] = 1;
          dp[next_h][next_w] = min(dp[next_h][next_w],now_cnt);
          q.push({next_h,next_w});
        }
      }
    }
  }
  for(int i(0);i<H;i++){
    for(int j(0);j<W;j++){
      //cout << dp[i][j] << " ";
    } 
    //cout << endl;
  }
  if(dp[gh][gw] == INFint) cout << -1 << endl;
  else cout << dp[gh][gw] << endl;
  return 0;
}


Measured memory_bytes: 14364
import java.util.*;

public class Main{

	public static void main(String[] args){
    	Scanner sc=new Scanner(System.in);
      
      	int n=sc.nextInt();
      	int m=sc.nextInt();
      
      	System.out.println((n+m+1)/2);
    
    }
  
}

//1 2

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
  mint ans=0;
  mint sum=0;
  int n;
  cin >> n;
  rep(i, n){
    int tmp;
    cin >> tmp;
    ans+=sum*tmp;
    sum+=tmp;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
//#include <fstream>

using namespace std;

int main(int argc, const char * argv[]) {
//    ifstream in("input.txt");
//    cin.rdbuf(in.rdbuf());
    
    int L, R, M;
    L = 0;
    cin >> R >> M;
    
    int l, r;
    for (int i=0; i<M; i++)
    {
        cin >> l >> r;
        if (L < l)L = l;
        if (r < R)R = r;
    }
    
    cout << (R >= L ? R - L +1 : 0) << endl;
    return 0;
}


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

#define int  long long
#define pb emplace_back
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(0);

int32_t main(){
	fast;
	int r,d,x;
	cin >> r >> d >> x;
	
	f(i,0,10)
	{
		x = r*x - d;
		cout << x << "\n";
	}

}







Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef double db;
#define mk make_pair
#define pa pair<int,int>
using namespace std;

inline int rd() {
	int x=0,f=1;char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-1;
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
int N,M,X,Y;
int a[1001000],b[1001000];
int L,R;
//main=============================
int main() {
	N=rd(),M=rd(),L=X=rd(),R=Y=rd();
	for(int i=1;i<=N;++i) a[i]=rd(),L=max(L,a[i]);
	for(int i=1;i<=M;++i) b[i]=rd(),R=min(R,b[i]);
	if(L<R) puts("No War");
	else puts("War");
	return 0;
}


Measured memory_bytes: 2304
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
const int M=100010;
int INF=1000000007;
using ll=long long;

int main(){
	int n;
	string a[200010],t="";

	cin>>n;
	rep(i,0,n)cin>>a[i];
	if(n==1){
		cout<<a[0]<<endl;
		return 0;
	}
	if(n%2==0){
		for(int i=n-1;i>0;i-=2)t+=a[i]+" ";
		for(int i=0;i<n;i+=2){
			t+=a[i]+" ";
		}
		cout<<t<<endl;
		return 0;
	}else{
		for(int i=n-1;i>=0;i-=2)t+=a[i]+" ";
		for(int i=1;i<n;i+=2){
			t+=a[i]+" ";
		}
		cout<<t<<endl;
		return 0;
	}
}


Measured memory_bytes: 18052
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
    int n;
    int matr[11][11];
    while(cin >> n,n){
        matr[n][n]=0;
        for(int i=0;i<n;i++){
            matr[i][n]=0;
            for(int j=0;j<n;j++){
                if(i==0)matr[n][j]=0;
                cin >> matr[i][j];
                matr[i][n]+=matr[i][j];
                matr[n][j]+=matr[i][j];
                matr[n][n]+=matr[i][j];
            }
        }
        for(int i=0;i<=n;i++){
            for(int j=0;j<=n;j++){
                printf("%5d",matr[i][j]);
            }
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1164
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

const MOD: usize = 1_000_000_007;

fn main() {
    let n = read1::<usize>();
    let a = readn::<usize>(" ");
    let mut c = vec![1, 0, 0];
    let mut dp = vec![0; n];
    dp[0] = 3;

    if a[0] != 0 {
        println!("0");
        return;
    }

    for i in 1..n {
        let mut k = 0;
        for j in 0..3 {
            if c[j] == a[i] {
                if k == 0 {
                    c[j] += 1;
                }
                k += 1;
            }
        }
        dp[i] = dp[i-1] * k % MOD;
    }

    println!("{}", dp[n-1]);
}

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

#define rep(i,x,y) for(int (i)=(x);(i)<(y);(i)++)

int main()
{
  while(true){
    vector<int> temp;

    rep(i,0,300001){
      temp.push_back(i);
    }

    int n;
    cin>>n;
    if(n==1){
      break;
    }

    cout<<n<<":";

    rep(i,6,300001){
      if(temp[i]%7==1||temp[i]%7==6){
        if(temp[i]!=0){
          if(n%temp[i]==0){
            cout<<" "<<temp[i];
          }
          for(int j=i+i;j<=n;j+=i){
            temp[j]=0;
          }
        }
      }
    }
    cout<<endl;
  }

  return 0;
}

Measured memory_bytes: 6036
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll dist[100000];
int main()
{
	int num;
	ll a, b;
	scanf("%d%lld%lld", &num, &a, &b);
	for (int i = 0; i < num; i++)scanf("%lld", &dist[i]);
	ll ans = 0;
	for (int i = 0; i < num - 1; i++)ans += min((dist[i + 1] - dist[i])*a, b);
	printf("%lld\n", ans);
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <cstdlib>
#include <math.h>

using namespace std;

typedef long long ll;
#define rep(i, n) for(long (i) = 0; (i) < (long) (n); (i)++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,a,b) for(long i=(a);i<(b);i++)
#define rrep1(i,a,b) for(long i=(a);i<=(b);i++)
#define rrrep(i,a,b) for(long i=(a);i>=(b);i--)
#define define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define X first
#define Y second
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int> >

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const ll LINF = 1e18;

int printYes() {
    cout << "Yes" << endl;
    return 0;
}

int printNo() {
    cout << "No" << endl;
    return 0;
}

int ans;

int printAns() {
    cout << ans << endl;
    return 0;
}


int pow(int x) {
	if (x == 0) {
		return 1;
	}
	else {
		return pow(x - 1) * 2;
	}
}

int main(int argc, char const *argv[])
{
    long N,K;
    cin >> N >> K;
    long ans = 0;
    long w = (N - N % K) / K;
    ans += w + w * (w - 1) *3 + w * (w-1) * (w-2);
    if (K % 2 == 0) {
        long hK = K/2;
        long x = (N - N % hK) / hK;
        x = (x + x % 2) / 2;
        ans += x + x * (x - 1) * 3 + x * (x-1) * (x-2);
    }
    
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FORD(i,a,b) for(int i=(a);i>=b;i--)
#define FOR(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define ll long long
using namespace std;
double a[200005];
int main() {
	int n,k;
	double ans=0;
	cin>>n>>k;
	FOR(i,1,n) {
		cin>>a[i];
		a[i]=a[i-1]+(a[i]+1)/2;
	}
	FOR(i,k,n) ans=max(ans,a[i]-a[i-k]);
	cout<<fixed<<setprecision(12)<<ans;
	return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var ABC = ReadSplitLong();
            var A = ABC[0];
            var B = ABC[1];
            var C = ABC[2];

            if (ABC.Any(x => x % 2 == 0))
                Println(0);
            else
                Println(Min(Min(A * B, A * C), B * C));
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());
        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    int a;
    int count=0;
    for(int i=0;i<N;i++){
        cin>>a;
        while(true){
            if(a%2==1){break;}
            count++;
            a/=2;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
int n,q;
int s[100001];

int search(int key){
	int l=0,r=n;
	while(r-l>1){
		int m=(l+r)/2;
		if(s[m]>key)r=m;
		else l=m;
	}
	return s[l]==key?1:0;
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&s[i]);
	}
	scanf("%d",&q);
	int c=0;
	for(int i=0;i<q;i++){
		int t;
		scanf("%d",&t);
		c+=search(t);
	}
	printf("%d\n",c);
	return 0;
}


Measured memory_bytes: 3548