akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) {
    return '"' + s + '"';
}
string to_string(const char* s) {
    return to_string((string) s);
}
string to_string(bool b) {
    return (b ? "true" : "false");
}
string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}
template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for (size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
//Auther: Arin Roday
#define vec vector
#define i64 long long
#define endl '\n'
#define sz(x) (x).size()
#define times(n) for(int i = 0; i < (n); ++i)
#define bits(x) __builtin_popcount(x)
 
int test_case_number = 1;

void print_case(){
    #ifdef LOCAL
    cout << "Case #" << test_case_number++ << ": ";
    #endif
}

#define int long long 
void solve(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int> ());
    int ans = 0;
    int k = 0;
    for(int i = 1; i < n; ++i){
        ans += a[k];
        if(i % 2 == 1 || i == 1){
            k ++;
        }
    }
    cout << ans << endl;
}
 
int32_t main(){
    solve();
}

Measured memory_bytes: 4816
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define all_acc(x) (x).begin(), (x).end(), 0LL
#define int long long
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool { return abs(i) < abs(j); });
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
using ll = long long;
double pi=3.14159265359;

//出力するよ
void output(vector<int> s)
{
    int n = s.size();
    for (int i = 0; i < n; i++)
    {
        if (i != 0)
            cout << " ";
        cout << s[i]; //<<endl;
    }
    cout << endl;
}

int MOD = pow(10, 9) + 7;

//各要素で最低操作回数を数える
pair<int,int> count(vector<int> a,vector<int> b){
    int n=a.size();
    int a_cnt=0,b_cnt=0;
    for(int i=0;i<n;i++){
        if(a[i]>b[i]){
            b_cnt+=(a[i]-b[i]);
        }
        if(a[i]<b[i]){
            if((b[i]-a[i])%2==0){
                a_cnt+=(b[i]-a[i])/2;
            }else{
                a_cnt+=(b[i]-a[i])/2 +1;
            }
        }
    }

    return make_pair(a_cnt,b_cnt);
}

signed main(){
    //スタックで処理することでいい感じに出来る。
    //STが作れたら上の要素をポップしていく。最終的にスタックの長さが答えになる。
    stack<char> st;
    string s; cin>>s;
    int n=s.length();

    for(int i=0;i<n;i++){
        //cout<<s[i]<<endl;
        if(st.size()==0) st.push(s[i]);
        else{
            char c=st.top();
            if(c=='S'&&s[i]=='T'){
                st.pop();
            }else st.push(s[i]);
        }
    }

    cout<<st.size()<<endl;
}

Measured memory_bytes: 3772
def main():
    A,B,C = map(int, input().split())

    if C == 0:
        print("YES")
        return

    D = set()
    for b in range(1, B):
        D.add((A*b)%B)

    if C in D:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()


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

using namespace std;

int main(){
    int N,M;
    vector<int> HH,WW;
    while(cin >>N>>M,N|M){
        int H[N+1]; H[0]=0;
        for(int i=1;i<=N;i++){
            cin >> H[i];
            H[i]+=H[i-1];
        }
        HH.clear();
        for(int i=0;i<=N;i++){
            for(int j=i+1;j<=N;j++){
                HH.push_back(H[j]-H[i]);
            }
        }
        int W[M+1]; W[0]=0;
        for(int i=1;i<=M;i++){
            cin >> W[i];
            W[i]+=W[i-1];
        }
        WW.clear();
        for(int i=0;i<=M;i++){
            for(int j=i+1;j<=M;j++){
                WW.push_back(W[j]-W[i]);
            }
        }
        sort(HH.begin(),HH.end());
        sort(WW.begin(),WW.end());
        int c=0;
        for(auto&h:HH){
            auto lo=lower_bound(WW.begin(),WW.end(),h);
            auto up=upper_bound(WW.begin(),WW.end(),h);
            for(auto i=lo;i!=up;++i){
                if(h==*i)c++;
            }
        }
        cout << c << endl;
    }
}

Measured memory_bytes: 15700
#include <bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define ll long long int
#define INF 5000000
#define eps 1e-13
#define mod 998244353
#define N 100005

using namespace std;

long double n,x[N],y[N],dx[N],dy[N];

long double calc(long double time)
{
    long double xMax=-1e18,xmin=1e18,yMax=-1e18,ymin=1e18,tmpx,tmpy;
    for(register int i=0;i<n;++i){
        tmpx=x[i]+time*dx[i];
        tmpy=y[i]+time*dy[i];

        xMax=max(xMax,tmpx);
        yMax=max(yMax,tmpy);

        xmin=min(xmin,tmpx);
        ymin=min(ymin,tmpy);
    }

    return (xMax-xmin)*(yMax-ymin);
}

inline void init()
{
    cin >> n;

    register char tmp;
    for(register int i=0;i<n;++i){
        cin >> x[i] >> y[i] >> tmp;

        switch(tmp){
            case'R':
                dx[i]=1;
                break;
            case'L':
                dx[i]=-1;
                break;
            case'U':
                dy[i]=1;
                break;
            case'D':
                dy[i]=-1;
                break;
        }
    }
}

inline void solve()
{
    long double TimeU=1e9,TimeD=0,ansMR,ansML,Ans=1e18;
    while(true){
        ansMR=calc( (TimeU*2+TimeD)/3 );
        ansML=calc( (TimeU+TimeD*2)/3 );

        Ans=min(ansML,Ans);
        Ans=min(ansMR,Ans);

        if(ansMR>ansML)
            TimeU=(TimeU*2+TimeD)/3;
        else
            TimeD=(TimeU+TimeD*2)/3;

        if(abs(ansMR-ansML)<eps)
            break;
    }

    cout << Ans << endl;
}

int main()
{
    fastIO;
    
    cout << fixed << setprecision(15);

    init();
    solve();

    cout << flush;

    return 0;
}



Measured memory_bytes: 6528
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	string s;
	cin >> s;
	cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No");





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    map<int, int> a;
    rep(i, 0, n) {
        int p; cin >> p;
        a[p]++;
    }
    int ans = 1;
    rep(i, 1, n-1) {
        ans = max(ans, a[i-1] + a[i] + a[i+1]);
    }
    cout << ans << endl;
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define VEC(TYPE, A, NAME, INIT) vector<TYPE> NAME(A, INIT)
#define VEC2(TYPE, A, B, NAME, INIT) vector<vector<TYPE>> NAME(A, vector<TYPE>(B, (INIT)))

template <typename T>
T gcd(T a, T b)
{
    if (a < b)
        swap(a, b);
    return b ? gcd(b, a % b) : a;
}

int main()
{
    int n, x;
    cin >> n >> x;
    VEC(ull, n + 1, vec, 0);
    REP(i, n) cin >> vec[i];
    vec[n] = x;
    sort( vec.begin(), vec.end(), less<ull>() );
    VEC( ull, n, sub, 0 );
    REP( i, n ) sub[i] = vec[i+1]-vec[0];
    ull ans = 0;

    ans = sub[0];
    for( int i = 1; i < n; ++i )
    {
        if( sub[i] % ans == 0 ) continue;
        ans = gcd( sub[i], ans );
    }

    cout << ans << endl;
    return 0;
}

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


struct node
{
	int x,y,z;
	node():x(0),y(0),z(0){}
	node(int x1,int y1,int z1):x(x1),y(y1),z(z1){}

};

vector<node> g;
int maxH=0;
int main()
{   ios::sync_with_stdio(false);
	cin>>n;
	int x,y,z;
	for(int i=1;i<=n;i++)
	{
		cin>>x>>y>>z;
		g.push_back(node(x,y,z));
		maxH=max(maxH,z);
	}

	int curH=0;
	int H;
	n=g.size();
	for(int x1=0;x1<=100;x1++)
	for(int y1=0;y1<=100;y1++)
	{	

		    for(int i=0;i<n;i++)
			{		if(g[i].z==0) continue;
	                curH=abs(x1-g[i].x)+abs(y1-g[i].y)+g[i].z;
                    break;
			}

			if(curH<maxH||curH<1) continue;
			for(int i=1;i<n;i++)
			{
				if((abs(x1-g[i].x)+abs(y1-g[i].y)+g[i].z)!=curH) 
				{
				if(g[i].z!=0)					
				{
	   					curH=-1;
						break;
				}
				else
				{
					if(curH-abs(x1-g[i].x)-abs(y1-g[i].y)<0)	continue;
					   curH=-1;
				break;
				}
					
				}
			}
			if(curH>=1) 
			{
				x=x1;y=y1;
				H=curH;
				
			}

	}
	cout<<x<<' '<<y<<' '<<H;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int K, X; std::cin >> K >> X;
  if ( 500 * K >= X) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  return 0;
}


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

int64_t pow(int64_t n, int64_t r) {
    int ret = 1;
    for(int i=0;i<r;i++) {
        ret *= n;
    }
    return n;
}
int main(void) {
    int64_t X;
    
    cin >> X;

    for(int i=1000;i>-1000;i--){
        for(int j=1000;j>-1000;j--){
            if((pow(i,5) - pow(j,5)) == X) {
                cout << i << " " << j << "\n";
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 7;
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans /= (i + 1);
        ans %= mod;
    }
    return ans;
}

int main(){
    double a,b,x;
    cin >> a >> b >> x;
    x /= a;
    if(x * 2 <= a * b){
        printf("%.12f\n",90.0 - atan(x * 2.0 / b / b) * (180.0 / pi));
    }else{
        printf("%.12f\n",atan((a * b - x) * 2.0 / a / a) * (180.0 / pi));
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#define INF 1e8
using namespace std;
#define ll long long

#define MAX 100020
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#define INF 1e8
using namespace std;
#define ll long long

#define MAX 100020

int main(){
int a,b,n;
  cin>>n;
  for(int i=1;i<=9;i++){
      for(int j=1;j<=9;j++){
          if(n==i*j){
              cout<<"Yes";
              return 0;
          }
      }
  }
  cout<<"No";
}



Measured memory_bytes: 3072
#include<iostream>
using namespace std;
int main(void)
{
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	if(a<40) a=40;if(b<40) b=40;if(c<40) c=40;if(d<40) d=40;if(e<40) e=40;
	cout<<(a+b+c+d+e)/5<<endl;
	return 0;
}


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

#define dv(i) for (int c=0; c<(int)(i).size(); c++) cout<<(i)[c]<<(c==(int)(i).size()-1?"\n":" ")
#define da(i) for (int c=0; c<(int)(sizeof((i))/sizeof((i)[0])); c++) cout<<(i)[c]<<(c==(int)(sizeof((i))/sizeof((i)[0]))-1?"\n":" ")
#define ds(i) for (auto f: i) cout<<f<<"\n";
#define dm(i) for (auto f: i) cout<<f.first<<" "<<f.second<<"\n"
#define F0R(i,a,b) for (int i=a; i<(b); i++)
#define FOR(i,a) for (int i=0; i<(a); i++)
#define F0Rd(i,a,b) for (int i=(b)-1; i>=a; i--)
#define FORd(i,a) for (int i=(a)-1; i>=0; i--)

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define sz(x) (int) x.size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define alp(i) i,i + sizeof(i) / sizeof(i[0])
#define memp(i,x) std::memset(i, x, sizeof i)
#define fils(i,x) std::fill(all(i), x)
#define filp(i,x) std::fill(alp(i), x)
#define dr4 {0, 1, 0, -1}
#define dc4 {1, 0, -1, 0}
#define dr8 {-1, -1, -1, 0, 1, 1, 1, 0}
#define dc8 {-1, 0, 1, 1, 1, 0, -1, -1}
#define inBounds(a,b,c,d) (a >= 0 && a < c && b >= 0 && b < d)

string rem(string s) {if(s[s.size()-1]=='\r')s.erase(s.size()-1);return s;}
vector<string> split(string s, char delim) {replace(s.begin(),s.end(),delim,' ');stringstream ss(s); string buf;vector<string> v;while (ss>>buf) v.push_back(buf);return v;}

const int MOD = 1000000007;
const double EPS = 1e-6;

#ifndef KMPC
    const int MAXN = -1;
#else
    const int MAXN = -1;
#endif

inline vi ints(int x) { vi A(x); FOR(i,x) cin >> A[i]; return A; }
inline vl lls(int x) { vl A(x); FOR(i,x) cin >> A[i]; return A; }
inline vs strs(int x) { vs A(x); FOR(i,x) cin >> A[i]; return A; }

int tc() {
    int A, B; cin >> A >> B; cout << A * B << '\n';

    return 0;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    
    int N; cin >> N; vl A = lls(N);

    for (ll f: A) if (!f) return !(cout << "0\n");

    ll ans = 1;
    for (ll el: A) {
        if ((ld) el <= (ld) 1e18 / ans) {
            ans *= el;
        } else {
            return !(cout << "-1\n");
        }
    }

    cout << ans << '\n';
 
    return 0;
}

Measured memory_bytes: 3928
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI(n);
  GVI(v, n);
  map<int, int> list1, list2;
  FOR(i, n) {
    if (i % 2 == 0) {
      list1[v[i]]++;
    } else {
      list2[v[i]]++;
    }
  }
  vector<P> order1, order2;
  for (P p : list1) {
    order1.push_back(p);
  }
  for (P p : list2) {
    order2.push_back(p);
  }
  sort(ALL(order1), [](const P& l, const P& r) { return l.second > r.second; });
  sort(ALL(order2), [](const P& l, const P& r) { return l.second > r.second; });
  if (order1.size() == 1)
    order1.push_back(P(0, 0));
  if (order2.size() == 1)
    order2.push_back(P(-1, 0));
  int ans = 1e9;
  int change1_1 = n / 2 - order1[0].second,
      change1_2 = n / 2 - order1[1].second,
      change2_1 = n / 2 - order2[0].second,
      change2_2 = n / 2 - order2[1].second;
  if (order1[0].first != order2[0].first) {
    ans = min(ans, change1_1 + change2_1);
  }
  if (order1[0].first != order2[1].first) {
    ans = min(ans, change1_1 + change2_2);
  }
  if (order1[1].first != order2[0].first) {
    ans = min(ans, change1_2 + change2_1);
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 6520
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [[input().split()] for _ in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()
a=n1()
b=n1()
c=n1()

a.sort()
b.sort()
c.sort()

from bisect import bisect_left,bisect_right
b2=[]
for i in b:
    b2.append(bisect_left(a,i))

import itertools
b3=list(itertools.accumulate(b2))
    
ans=0
for i in c:
    t=bisect_left(b,i)
    if t>0:
        ans+=b3[t-1]
    
print(ans)

Measured memory_bytes: 24684
#include "bits/stdc++.h"
using namespace std;

int main(){
  double n,m,d;
  cin>>n>>m>>d;
  if(d!=0){
    double one=d*2;
    //cout<<one<<endl;
    double two=n-one;
    //cout<<two<<endl;
    one*=1/(n*n);
    two*=2/(n*n);
    //cout<<one<<" "<<two<<endl;
    double ans=(one+two)*(m-1);
    cout<<fixed << setprecision(10) <<ans<<endl;
  }else{
    double ans=1/n;
    ans*=(m-1);
    cout<<fixed << setprecision(10) <<ans<<endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
const double pi=acos(-1);

int main(){
  int n,m,l;
  cin >> n >> m >> l;
  vector<vector<int> > A(n,vector<int>(m));
  vector<vector<int> > B(m,vector<int>(l));
  rep(i,n){
    rep(j,m){
      cin >> A[i][j];
    }
  }
  rep(i,m){
    rep(j,l){
      cin >> B[i][j];
    }
  }
  rep(i,n){
    rep(j,l){
      ll sum=0;
      rep(k,m){
        sum+=A[i][k]*B[k][j];
      }
      if(j<l-1)cout << sum << " ";
      else cout << sum;
    }
    cout << endl;
  }  
  return 0;
}



Measured memory_bytes: 3248
// A.

#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <stdio.h>

typedef long long LL;

int main(int argc, char* argv[]) {
	char buffer[3072000];
	LL cnt[20][20] = {};
	LL sum[20][20] = {};
	LL n = 0, ans = 0;
	char c, *bufptr = buffer;
	fread(buffer, 1, 3072000, stdin);
	while ((c = *bufptr++) >= '0') {
		n = (n * 10) + (c - '0');
	}
	for (LL i = 0; i < n; ++i) {
		LL x = 0, two = 0, five = 9, df = 0;
		while ((c = *bufptr++) >= ' ') {
			if (c == '.') {
				df = -1;
			} else {
				x = (x * 10) + c - '0';
				five += df;
			}
		}
		if ((x & 1) == 0) {
			two = __builtin_ctzll(x);
			x >>= two;
		}
		two += five;
		while (x % 5 == 0) {
			++five;
			x /= 5;
		}
		cnt[two > 18 ? 18 : two][five] += 1;
	}
	for (int i = 0; i <= 18; ++i) {
		sum[i][0] = cnt[18 - i][18];
		for (int j = 1; j <= 18; ++j) {
			sum[i][j] += sum[i][j - 1] + cnt[18 - i][18 - j];
		}
	}
	for (int i = 1; i <= 18; ++i) {
		for (int j = 0; j <= 18; ++j) {
			sum[i][j] += sum[i - 1][j];
		}
	}
	for (int i = 0; i <= 18; ++i) {
		for (int j = 0; j <= 18; ++j) {
			ans += sum[i][j] * cnt[i][j];
			if (i >= 9 && j >= 9) {
				ans -= cnt[i][j];
			}
		}
	}
	printf("%lld\n", ans >> 1);
	return 0;
}


Measured memory_bytes: 4264
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000



int main(){
  unsigned short *A, *B,k=0;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);



  for(i=0;i<=VMAX;i++)C[i]=0;

  for(j=0;j<n;j++){
   scanf("%u",&A[j+1]);
    C[A[j+1]]++;

  }
  for(i=1;i<=VMAX;i++)C[i]=C[i]+C[i-1];

  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++){
    printf("%u",B[i]);
    if(i<n)printf(" ");
  }
  printf("\n");



  return 0;
}



Measured memory_bytes: 9564
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 9e18;

vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) {
                res.push_back(n / i);
            }
        }
    }
    return res;
}

ll calc(ll a, ll b) {
    return a * a * a * a * a - b * b * b * b * b;
}

int main() {
    ll X;
    cin >> X;

    vector<ll> dsrs = divisor(X);
    for (auto dr : dsrs) {
        // 65^5 = 1160290625
        for (ll b = -65; true; b++) {
            ll a = b + dr;
            // 120^5 - 119^5 = 1019663401
            if (a > 120) {
                break;
            }
            if (calc(a, b) == X) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll a,b,n;
	cin>>a>>b>>n;
	if(b<=n)
		cout<<(a*(b-1))/b<<endl;
	else
		cout<<(a*n)/b<<endl;
			
}

Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
typedef long long ll;
const ll MAX=510000;
const ll mod = 1e9 + 7;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,D,Q,K,R,W,H,P,L,G;
ll ans;
string S,T;
ll h[101010];
ll y[101010];
ll a[201010];
ll k[101010];
ll b[201010];
ll d[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll r[101010];
ll v[101010];
ll s[101010];
ll x[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
	ll GetSize(ll x){
		return size[root(x)];
	}

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		size[ry]+=size[rx];

    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main(){
    cin>>M>>D;
    ans =0;
    rep(i,1,M+1){
        rep(j,1,D+1){
            if(!((j%10)<=1 ||(j/10)%10<=1)){ 
                if(i == j%10 * (j/10)){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

s = str(input())
c = s[0]
ran = [1]
for i in range(1, len(s)):
    if c == s[i]:
        ran[-1] += 1
    else:
        ran.append(1)
        c = s[i]

result = ran[0]
if s[0] == '<':
    result = ((ran[0]-1)*ran[0])//2
    h = True
else:
    result = ((1+ran[0])*ran[0])//2
    h = False
if len(ran) == 1:
    result = ((1+ran[0])*ran[0])//2

for i in range(1, len(ran)):
    if h:
        if ran[i-1] < ran[i]:
            result += ((1+ran[i])*ran[i])//2
        else:
            result += ((ran[i]-1)*ran[i])//2 + ran[i-1]
        h = False
    else:
        result += ((ran[i]-1)*ran[i])//2
        h = True
        if i == len(ran)-1:
            result += ran[i]
print(int(result))

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

int main() {
    int N;
    cin >> N;
    ll A[300][300];
    vector<vector<ll>> v;
    rep(i, N) rep(j, N) {
        cin >> A[i][j];
        if (i != j) v.push_back({A[i][j], i, j});
    }
    sort(v.begin(), v.end());
    vector<vector<ll>> d(N, vector<ll>(N, 1e18));
    rep(i, N) d[i][i] = 0;
    int count = 0;
    ll ans = 0;
    rep(i, N * N - N) {
        //rep(j, 3) cout << v[i][j] << " ";
        //cout << endl;
        int x = v[i][0], y = v[i][1], z = v[i][2];
        if (d[y][z] < x) {
            cout << "-1\n";
            return 0;
        }
        if (d[y][z] == x) {
            continue;
        }
        d[y][z] = x;
        d[z][y] = x;
        count++;
        ans += x;
        rep(j, N) {
            rep(k, N) {
                if (d[j][y] + d[y][z] + d[z][k] < d[j][k]) {
                    d[j][k] = d[j][y] + d[y][z] + d[z][k];
                }
                if (d[j][z] + d[z][y] + d[y][k] < d[j][k]) {
                    d[j][k] = d[j][z] + d[z][y] + d[y][k];
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 8880
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
#include <iomanip>
using namespace std;
typedef long long ll;

int Tmax, V, E, u, v, d, dis[444][444], Nnew, new_id, dst,order[11111],check[444],par[444];
vector<vector<pair<int, int>>> li(444);
queue<pair<int,int>> route;

void dfs(int now,int distance) {
	route.push(make_pair(now,distance));
	for (auto &e : li[now]) {
		if (par[e.first] == now) {
			dfs(e.first, e.second);
			route.push(make_pair(now, e.second));
		}
	}
}

int main() {
	cin >> V >> E;
	for (int i = 0; i < E; i++) {
		cin >> u >> v >> d;
		li[u].push_back(make_pair(v, d));
		li[v].push_back(make_pair(u, d));
		dis[u][v] = d;
		dis[v][u] = d;
	}
	cin >> Tmax;
	for (int i = 0; i < Tmax; i++) {
		cin >> Nnew;
		if (Nnew)
			cin >> new_id >> order[i];
		else
			order[i] = -1;
	}
	for (int i = 1; i <= V; i++)
		check[i] = 0;
	priority_queue<pair<pair<int, int>,int>,vector<pair<pair<int, int>,int>>,greater<pair<pair<int, int>, int >>> que;
	que.push(make_pair(make_pair(0, 1),-1));
	while (!que.empty()) {
		int now = que.top().first.second, npar=que.top().second;
		que.pop();
		if (!check[now]) {
			check[now]++;
			par[now] = npar;
			for (auto &e : li[now]) {
				int next = e.first, dnext = e.second;
				if (!check[next])
					que.push(make_pair(make_pair(dnext, next), now));
			}
		}
	}
	dfs(1,0);
	route.pop();
	int count = 0,ndst;
	for (int i = 0; i < Tmax; i++) {
		if (!count) {
			ndst = route.front().first;
			count = route.front().second;
			route.pop();
			route.push(make_pair(ndst, count));
		}
		cout << ndst << endl;
		count--;
	}
}


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

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  string s;
  cin >> s;
  unordered_map< char, int > m;
  for (int i=0; i<s.size(); ++i) {
    if (m.count(s[i]) > 0) m[s[i]]++;
    else m[s[i]] = 1;
  }
  for (auto itr : m) {
    if (itr.second != 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int N;
int A[100000];
int cnt[100001];
int main()
{
	cin>>N;
	long long S=0;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		cnt[A[i]]++;
		S+=A[i];
	}
	int Q;cin>>Q;
	for(int i=0;i<Q;i++)
	{
		int B,C;
		cin>>B>>C;
		int t=cnt[B];
		cnt[C]+=t;
		cnt[B]=0;
		S-=(long long)B*t;
		S+=(long long)C*t;
		cout<<S<<endl;
	}
}


Measured memory_bytes: 4364
piece_num = int(input())                                # 駒の数
piece_pos_list = [int(s) for s in input().split()]      # 駒の位置リスト
ope_num = int(input())                                  # 操作回数
ope_list = [int(s) for s in input().split()]            # 操作の対象とする駒の番号リスト

MAX_SQUARE = 2019

for i in range(ope_num):
    if (piece_pos_list[ope_list[i] - 1] != MAX_SQUARE)\
       and ((piece_pos_list[ope_list[i] - 1] + 1) not in piece_pos_list):
        # 駒を1つ進める
        piece_pos_list[ope_list[i] - 1] += 1

# 結果を出力
for i in range(piece_num):
    print(piece_pos_list[i])


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

int main(){
    int wait[6] = {};
    int Time = 0;
    for (int i = 0; i < 5; i++){
        cin >> wait[i];
    }

    wait[5] = wait[0];
    for (int i = 1; i < 5; i++){
        if ((wait[i] % 10) < (wait[5] % 10)
            && (wait[i] % 10) != 0
            && wait[i] != wait[5] ){
            wait[5] = wait[i];
        }
    }

    for (int i = 0; i < 5; i++){
        if ( wait[i] == wait[5] ) {
            wait[i] = 0;
            break;
        }
    }

    for ( int i = 0; i < 6; i++){
        Time += wait[i];
        if ( i == 5 ) {
            break;
        }
        while ( Time % 10 != 0 ) {
            Time++;
        }
    }

    cout << Time << endl;
}

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

int n,m;
int a[5005];
vector<int> G[5005];
int col[5005];
vector<P> vec;
int cnt[2];
ll dp[2][5005];

bool dfs(int v,int c){
	cnt[c]++;
	col[v]=c;
	for(int i=0;i<G[v].size();i++){
		if(col[G[v][i]]==-1){
			if(!dfs(G[v][i],1-c)){
				return false;
			}
		}else if(col[v]==col[G[v][i]]){
			return false;
		}
	}
	return true;
}

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(a[i]>a[j]){
				G[i].push_back(j);
				G[j].push_back(i);
			}
		}
	}
	memset(col,-1,sizeof(col));
	for(int i=0;i<n;i++){
		if(col[i]==-1){
			cnt[0]=cnt[1]=0;
			if(!dfs(i,0)){
				printf("0\n");
				return 0;
			}
			vec.push_back(P(cnt[0],cnt[1]));
		}
	}
	int cur=0,nxt=1;
	dp[0][0]=1;
	int sum=0;
	for(int i=0;i<vec.size();i++){
		//printf("%d %d\n",vec[i].first,vec[i].second);
		for(int j=0;j<=sum;j++){
			dp[nxt][j+vec[i].first]+=dp[cur][j];
			dp[nxt][j+vec[i].first]%=MOD;
			dp[nxt][j+vec[i].second]+=dp[cur][j];
			dp[nxt][j+vec[i].second]%=MOD;
		}
		sum+=vec[i].first;
		sum+=vec[i].second;
		swap(cur,nxt);
		memset(dp[nxt],0,sizeof(dp[nxt]));
	}
	ll ans=0;
	for(int i=0;i<=n;i++){
		if(i<=m && (n-i)<=m){
			ans+=dp[cur][i];
		}
	}
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 6460
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
long long val;
constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
if (val < 0) val += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator - () const noexcept {
return val ? MOD - val : 0;
}
constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
constexpr Fp& operator += (const Fp& r) noexcept {
val += r.val;
if (val >= MOD) val -= MOD;
return *this;
}
constexpr Fp& operator -= (const Fp& r) noexcept {
val -= r.val;
if (val < 0) val += MOD;
return *this;
}
constexpr Fp& operator *= (const Fp& r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp& operator /= (const Fp& r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b; swap(a, b);
u -= t * v; swap(u, v);
}
val = val * u % MOD;
if (val < 0) val += MOD;
return *this;
}
constexpr bool operator == (const Fp& r) const noexcept {
return this->val == r.val;
}
constexpr bool operator != (const Fp& r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
return os << x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0) return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1) t = t * a;
return t;
}
};

const int MOD = 1000000007;
using mint = Fp<MOD>;

// 愚直計算による二項係数計算
mint com(long long n, long long r) {
mint res = 1;
for (long long i = 0; i < r; ++i) {
res *= (n-i);
res /= (i+1);
}
return res;
}

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

ll r1,c1,r2,c2;
cin >> r1 >> c1 >> r2 >> c2;
r1--; c1--;

mint ans = com(r2 + c2 + 2, r2 + 1) + com(r1 + c1 + 2, r1 + 1);
ans -= com(r2 + c1 + 2, c1 + 1) + com(r1 + c2 + 2, r1 + 1);

cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
def examA():
    a, b = LI()
    if b<a:
        a,b = b,a
    if a<=0 and 0<=b:
        print("Zero")
    elif 0<a:
        print("Positive")
    else:
        judge = b-a+1
        if judge%2==0:
            print("Positive")
        else:
            print("Negative")
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examA()

"""

"""

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

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

	vector<int> S(N);
	int Q = 0;
	for (int i = 0; i < N; i++) {
		cin >> S.at(i);
		Q += S.at(i);
	}

	sort(S.begin(), S.end());

	if (Q % 10 != 0) {
		cout << Q << endl;
		return 0;
	}
	else {
		int i = 0;
		for (i = 0; i < N; i++) {
			if (S.at(i) % 10 != 0) break;
		}
		if (i == N) cout << 0 << endl;
		else cout << Q - S.at(i) << endl;
	}
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;




int n;
ll c[maxn], s[maxn], f[maxn];

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

    for (int i=0; i<n-1; i++) {
	cin>>c[i]>>s[i]>>f[i];
    }

    for (int i=0; i<n; i++) {
	if (i==n-1) {
	    out(0);
	}
	ll t=0;
	for (int j=i; j<n-1; j++) {
	    if (t<s[j]) {
		t=s[j];
	    } else {
		t=(t+f[j]-1)/f[j]*f[j];
	    }
	    t+=c[j];
	}
	cout<<t<<"\n";
    }
  

    return 0;
}


Measured memory_bytes: 4352
s = input()
t = input()
S, T = len(s), len(t)

dp = [[0 for _ in range(S + 1)] for _ in range(T + 1)]

for i in range(T):
    for j in range(S):
        if s[j] == t[i]:
            dp[i + 1][j + 1] = dp[i][j] + 1
        else:
            dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1])

# reconstruction
i, j = T, S
ans = ''
while i > 0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans = s[j-1] + ans
        i -= 1
        j -= 1

print(ans)

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

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

	vector<stack<pair<long long, int>>> mono(m); // val, index
	for (int i = 0; i < m; i++) {
		mono[i].emplace(1e18, n);
	}

	vector<long long> a(n);
	long long curr = 0;
	for (int i = 1; i < n; i++) {
		long long tmp;
		scanf("%lld", &tmp);
		curr += tmp;
		a[i] = curr;
	}

	vector<vector<long long>> b(n, vector<long long>(m));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			scanf("%lld", &b[i][j]);
		}
	}

	vector<long long> val(n);

	long long ans = LLONG_MIN;
	for (int i = n - 1; i >= 0; i--) {
		vector<long long> imos(n + 1);
		for (int j = 0; j < m; j++) {
			while (mono[j].top().first <= b[i][j]) {
				long long v, id;
				tie(v, id) = mono[j].top(); mono[j].pop();
				int id2 = mono[j].top().second;
				imos[id] -= v;
				imos[id2] += v;
			}
			int id = mono[j].top().second;
			mono[j].emplace(b[i][j], i);
			imos[i] += b[i][j];
			imos[id] -= b[i][j];
		}
		for (int j = 0; j < n; j++) {
			imos[j + 1] += imos[j];
			val[j] += imos[j];
		}
		for (int j = i; j < n; j++) {
			ans = max(ans, val[j] - (a[j] - a[i]));
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 8448
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int m, n;
	int[][] a;
	int[] c;

	void run(){
		for(;;){
			m=sc.nextInt();
			n=sc.nextInt();
			if((m|n)==0){
				break;
			}
			a=new int[n][m];
			for(int j=0; j<n; j++){
				for(int i=0; i<m; i++){
					a[j][i]=sc.nextInt();
				}
			}
			c=new int[4];
			for(int i=0; i<4; i++){
				c[i]=sc.nextInt();
			}
			solve();
		}
	}

	void solve(){
		int[][][] d=new int[n][m][4];
		for(int j=0; j<n; j++){
			for(int i=0; i<m; i++){
				fill(d[j][i], INF);
			}
		}
		int[] dx={1, 0, -1, 0};
		int[] dy={0, 1, 0, -1};
		PriorityQueue<P> que=new PriorityQueue<P>();
		que.offer(new P(0, 0, 0));
		d[0][0][0]=0;
		for(; !que.isEmpty();){
			P p=que.poll();
			if(p.d>d[p.y][p.x][p.v]){
				continue;
			}
			int[] cost=c.clone();
			if(a[p.y][p.x]!=4){
				cost[a[p.y][p.x]]=0;
			}
			for(int i=0; i<4; i++){
				P q=new P(p.x, p.y, (p.v+i)%4);
				q.x+=dx[q.v];
				q.y+=dy[q.v];
				if(q.x<0||q.x>=m||q.y<0||q.y>=n){
					continue;
				}
				if(d[q.y][q.x][q.v]>d[p.y][p.x][p.v]+cost[i]){
					q.d=d[q.y][q.x][q.v]=d[p.y][p.x][p.v]+cost[i];
					que.offer(q);
				}
			}
		}
		for(int j=0; j<n; j++){
			for(int i=0; i<m; i++){
				// debug(j, i, d[j][i]);
			}
		}
		// debug(d[n-1][m-1]);
		int ans=INF;
		for(int i=0; i<4; i++){
			ans=min(ans, d[n-1][m-1][i]);
		}
		println(ans+"");
	}

	class P implements Comparable<P>{
		int x, y, v;
		int d;

		P(int x, int y, int v){
			this.x=x;
			this.y=y;
			this.v=v;
		}

		@Override
		public int compareTo(P p){
			return d-p.d;
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 13000
/*
				   _ooOoo_
				  o8888888o
				  88" . "88
				  (| -_- |)
				  O\  =  /O
			   ____/`---'\____
			 .'  \\|     |//  `.
			/  \\|||  :  |||//  \
		   /  _||||| -:- |||||-  \
		   |   | \\\  -  /// |   |
		   | \_|  ''\---/''  |   |
		   \  .-\__  `-`  ___/-. /
		 ___`. .'  /--.--\  `. . __
	  ."" '<  `.___\_<|>_/___.'  >'"".
	 | | :  `- \`.;`\ _ /`;.`/ - ` : | |
	 \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
				   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
		fozubaoyou    pass System Test!
		quoted from "https://codeforces.com/contest/472/submission/7996840"
*/
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


int main(void){

	list<string> li;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		string t="";
		t+=s[i];
		li.push_back(t);
		
	}
	string bef,tmp;
	int minus=0;
	for(auto it=li.begin();it!=li.end();it++){
		// cout<<*it<<endl;
		if(it==li.begin()){
			bef=*it;
			continue;
		} else{
			if(bef==*it){
				it++;
				// cout<<distance(it,li.end())<<endl;
				if(distance(it,li.end())==0){
					minus++;
					break;
				} else{
					tmp=*it;
					it--;
					*it=*it+tmp;
					it++;
					li.erase(it);
					it--;
				}
			}
			bef=*it;
		}
		// for(auto it2=li.begin();it2!=li.end();it2++){
		// 	cout<<*it2<<" ";
		// }
		// cout<<endl;
	}
	fin(li.size()-minus);
}


Measured memory_bytes: 16004
#include<stdio.h>
int n,a[33]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
    scanf("%d",&n);
    printf("%d",a[n]);
    return 0;
}


Measured memory_bytes: 128