akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
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<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#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())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr double EPS = 1e-9;



int main() {
    
    int n;
    cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    int ans=INF;
    for(int j=-100;j<=100;j++){
        int t=0;
        rep(i,n){
            t+=pow(abs(v[i]-j),2);
        }
        chmin(ans,t);
    }
    fin(ans);

}








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

const int INF = 2e9;

int main(){
    int n;
    cin >> n;
    n %= 10;
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9 ) cout << "hon"  << endl;
    else if (n == 0 || n == 1 || n == 6 || n == 8 ) cout << "pon" << endl;
    else cout << "bon" << endl;
}

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

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

int main(){
    int r; cin >> r;
    cout << 2*M_PI*r << endl;
}

Measured memory_bytes: 3788
#include<stdio.h>
#include<string.h>
int main(void)
{
	int i,len;
	char s[20];
	scanf("%s",s);
    len=strlen(s);
	for(i=len-1;i>=0;i--){
	    printf("%c",s[i]);
	}
	    printf("\n");
	return 0;
}




Measured memory_bytes: 2048
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,T=MI()
    A=LI()
    M=[0]*N#自分以降の最大値
    M[-1]=A[-1]
    for i in range(1,N):
        M[-1-i]=max(M[-i],A[-i])
        
    diff=[0]*N
    for i in range(N):
        diff[i]=M[i]-A[i]
     
    diff.sort(reverse = True)
    ans=diff.count(diff[0])
    print(ans)

main()


Measured memory_bytes: 58864
#include <iostream>
using namespace std;
int n,k,i,x,y;
int main(){
      cin>>n>>k;
      for(i=0;i<k;i++){
            cin>>x>>y;
            cout<< (x+y<=n?(x<y?(x+2)%3+1:(y+2)%3+1):(x<y?(n-y)%3+1:(n-x)%3+1))<<endl;
      }
}

Measured memory_bytes: 1160
import java.util.Scanner
import scala.collection.mutable.Stack 

object Main extends App { 
  val sc = new Scanner(System.in)
  val H, W = sc.nextInt()
  val map = Array.ofDim[Int](H,W)
  for (i <- 0 until H; j <- 0 until W) map(i)(j) = sc.nextInt()

  val bar = Array.fill[Int](W)(0)
  val hist = new Histgram()

  class Histgram() {
    var stack = Stack[Int]()

    @scala.annotation.tailrec
    final def solver(i:Int, m:Int):Int = {
      def compute(i:Int, m:Int):Int = {
        if (stack.isEmpty || i < W && bar(stack.top) <= bar(i)) m
        else {
          val t = stack.pop
          val n = bar(t) * (if (stack.isEmpty) i else (i -stack.top -1))

          compute(i, n max m)
        }
      }

      if (i == W) compute(i, m)
      else if (stack.isEmpty || bar(stack.top) <= bar(i)) {
        stack.push(i)
        solver(i+1, m)
      }
      else solver(i, compute(i, m))

    }
  }

  def solver(h:Int, m:Int):Int = {
    if (h < H) {
      map(h).indices.foreach(i => bar(i) = if (map(h)(i) == 0) bar(i)+1 else 0)
      val n = hist.solver(0, 0)
      solver(h+1, m max n)
    } else m
  }

  println(solver(0, 0))

}


Measured memory_bytes: 464644
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[] x = new double[n];
		String[] u = new String[n];
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextDouble();
			u[i] = sc.next();
		}
		double ans = 0;
		for(int i = 0; i < n; i++) {
			if(u[i].equals("JPY")) {
				ans += x[i];
			}else {
				ans += x[i]*380000.0;
			}
		}
		System.out.println(ans);
		sc.close();
	}
	
}



Measured memory_bytes: 24916
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  string s;
  cin>>s;
  if(s=="ABC"){
    cout<<"ARC"<<endl;
  }else{
    cout<<"ABC"<<endl;
  }
}

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

bool comp(const pair<int, int> &l, const pair<int, int> &r) { return l.second < r.second; }

int main() {
  int n;
  cin >> n;
  pair<int, int> xs[n];
  for ( int i = 0; i < n; i++ ) {
    int x;
    cin >> x;
    xs[i] = {i, x};
  }
  sort(xs, xs+n, comp);
  
  int ans[n];
  int i = 0;
  for ( ; i < n/2; i++ ) { ans[xs[i].first] = xs[n/2].second; }
  for ( ; i < n; i++ ) { ans[xs[i].first] = xs[n/2-1].second; }

  for ( int i = 0; i < n; i++ ) {
    cout << ans[i] << endl;;
  }
  return 0;
}


Measured memory_bytes: 5840
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 998244353;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N),LS(N),RS(N);
    rep(i,N){
        cin >> A[i];
    }
    ll tmp = A[0];
    rep(i,N){
        tmp = __gcd(A[i], tmp);
        LS[i] = tmp;
    }
    tmp = A[N-1];
    rep(i,N){
        tmp = __gcd(A[N-1-i], tmp);
        RS[N-1-i] = tmp;
    }
    ll M = 0;
    rep(i,N){
        if(i == 0){
            cmax(M, RS[1]);
            continue;
        }else if(i == N-1){
            cmax(M,LS[N-2]);
            continue;
        }
        cmax(M, __gcd(LS[i-1], RS[i+1]));
    }
    cout << M << endl;
}

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

int main()
{
  int a,b,c,d,e,f,i;
  for(int i=1; i>0;){
    cin >> a >> b;
    if(a == 0 && b == 0){
      break;
    }
    for(int ii=0; ii<a; ii++){
      for(int iii=0; iii<b; iii++){
	cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1156
N = int(input())
ratio = [tuple(map(int, input().split())) for _ in range(N)]
t,a = 1,1

for nt,na in ratio:
    if nt<t or na<a:
        r = max((t-1)//nt+1, (a-1)//na+1)
        nt *= r
        na *= r
    t,a = nt,na
    #print(t, a)
print(t+a)


Measured memory_bytes: 39152
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

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

int main()
{
        //input->compute->output//

        int N, K;
        cin >> N >> K;

        cout << (N + K - 1) / K - (N / K) << endl;

        return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        int[] h = new int[n];
        for (int i = 0; i < n; i++) h[i] = sc.nextInt();
        int tmp = 0;
        for (int i = 1; i < n; i++) {
            if(h[i-1] < h[i]){
                if(ans < tmp) ans = tmp;
                tmp = 0;
            }else{
                tmp++;
            }
        }
        if(ans < tmp) ans = tmp;
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 50312
#include<bits/stdc++.h>
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int main(){
    FIO
    
    int n;
    cin>>n;
    int a[n],sum=0;
    forn(i,n)
    {
        cin>>a[i];
        sum+=a[i];
    }
    int avg;
    double avg1=(double)sum/n;
    int avg2=sum/n;
    if(avg1>=avg2+0.5)avg=avg2+1;
        else avg=avg1;
  //  cout<<avg1<<avg2;

    int ans=0;
    forn(i,n)
    {
        ans+=(avg-a[i])*(avg-a[i]);
    }
    cout<<ans;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();

		int cnt=0;
		while(n>0) {
			n=n/k;
			cnt++;
		}
		System.out.println(cnt);
		sc.close();
	}
}


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

using namespace std;

/**
 *  Name: Chris M. Perez
 *  University: Interamerican University Metro Campus
 *
**/

#define endl '\n'
#define MOD 10e9
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define gcd(x , y) __gcd(x , y)
#define all(x) (x).begin() , (x).end()
#define forn(i , a , b) for(int i=(a);i<(b);i++)
#define forrange(j , a , b) for(int j=(a);j<=(b);j++)
#define nestedforn(i , a , b , j , c , d) for(int i=(a);i<=(b);i++) for(int j=(c);j<=(d);j++)
#define sort_all(x) sort(all(x))
#define zeros_at_beginning(x) __builtin_clz(x)
#define zeros_at_end(x) __builtin_ctz(x)
#define ones(x) __builtin_popcount(x)
#define parity_even_or_odd_ones __builtin_parity(x)

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef tuple<int , int , int> tiii;
typedef vector<pii> vpii;
typedef vector<tiii> vtiii;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long long ll;
typedef long long int lli;

             
inline int input(){
  int n;
  scanf("%d" , &n);
  return n;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;  

#ifdef LOCAL_DEFINE
  freopen("input.txt" , "rt" , stdin);
#endif
  
  int H; cin >> H;
  int W; cin >> W; 
  int h; cin >> h; 
  int w; cin >> w;
  cout << ((H - h) * (W - w)) << endl; 
       
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <cmath>
#include <map>
#include <tuple>
#include <queue>

#define MOD (1000000007)
using namespace std;

typedef long long ll;

typedef tuple<ll, ll> tup; // mp, tairyoku

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

    int ret2 = 0;
    for(int i = 1; i <= N; i+=2) {
        int ret = 0;
        for(int j = 1; j <=i; j++) {
            if(i % j == 0) ret++;
        }
        if (ret == 8) ret2++;
    }
    cout << ret2 << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
    int r, d, x;
    cin >> r >> d >> x;
    for (int i = 1; i <= 10; i++){
        x = r * x - d;
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  while(cin >> s){
    for(string::size_type i=0; i<s.size(); i++){
      char c=s[i]-3;
      if(!(c >= 'A' && c <= 'Z'))
	c+=26;
	cout << c;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>

#define rep(i,n) for(int i = 0;i < n;i++)
#define Rep(i,m,M) for(int i = m;i < M;i++)
#define print(var) cout<<#var" = "<<var<<endl;

typedef long long ll;

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;

int main()
{
	int N, A;
	cin >> N >> A;
	vint x(N+1);
	int goal = A * N,S;
	rep(i, N)
	{
		cin >> x[i+1];
	}
//	cout << x[4] << endl;
	vector<vector<vector<long long>>> dp(N + 1, vector<vector<long long>>(goal + 1, vector<long long>(N + 1)));
	dp[0][0][0] = 1;
	rep(i, N)
	{
		dp[i][0][0] = 1;
	}
	for (int i = 1; i <= N;i++)
	{
	//	print(i)
		for (int j = 0; j <= goal; j++)
		{
	//		print(j)
				for (int k = 1; k <= N; k++)
				{
	//				print(k)
						//			cout << dp[i - 1][j][k];
						
						if (j - x[i] >= 0)
						{
			//				cout << '!' << endl;
							dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - x[i]][k - 1];
				//			print("end")
						}
						else
						{
				//			cout << '?' << endl;
							dp[i][j][k] = dp[i - 1][j][k];
				//			print("end")
						}
					
				}
		}
	}
/*	rep(i, N+1)
	{
		rep(j, goal+1)
		{
			rep(k, N+1)
			{
				if (dp[i][j][k] != 0)
				{
					cout << "dp[" << i << "][" << j << "][" << k << "] = " << dp[i][j][k] << endl;
				}
			}
		}
	}
	*/
	ll ans = 0;

	for(int i = 1;i<=N;i++)
	{
	//	print(i)
//		cout << "dp[" << N << "][" << (i + 1) * A << "][" << i + 1 << "] = " << dp[N][(i + 1) * A][i + 1] << endl;
			ans += dp[N][i*A][i];
	//	print(ans)
	}
	cout << ans << endl;
//	print(dp[0][16][2])
}


Measured memory_bytes: 56064
using System;

class Program
{
    static void Main(string[] args)
    {
        String[] aryInput = Console.ReadLine().Split(' ');
        int n = int.Parse(aryInput[0]);
        int m = int.Parse(aryInput[1]);
        int l = int.Parse(aryInput[2]);

        long[,] A = new long[n, m];
        long[,] B = new long[m, l];
        long[,] C = new long[n, l];

        //配列A代入
        for (int i = 0; i < n; i++)
        {
            String[] tmp1 = Console.ReadLine().Split(' ');

            for (int j = 0; j < m; j++)
            {
                A[i, j] = int.Parse(tmp1[j]);
            }

        }

        //配列B代入
        for (int i = 0; i < m; i++)
        {
            String[] tmp2 = Console.ReadLine().Split(' ');

            for (int j = 0; j < l; j++)
            {
                B[i, j] = int.Parse(tmp2[j]);
            }

        }

        //Cの配列に整数入力
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < l; j++)
            {
                for (int k = 0; k < m; k++)
                {
                    C[i,j] += A[i,k] * B[k,j];
                }
            }
        }

        //Cの中身出力
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < l - 1; j++)
            {
                Console.Write(C[i, j] + " ");
            }
            Console.WriteLine(C[i, l - 1]);
        }

    }
}

Measured memory_bytes: 9800
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

def ispalindrome(str): return True if str == str[::-1] else False


S = i_s()
N = len(S)

if not ispalindrome(S):
    print('No')
    exit()


if not ispalindrome(S[:int((N-1)/2)]):
    print('No')
    exit()

if not ispalindrome(S[int(((N+3)/2-1)):]):
    print('No')
    exit()

print('Yes')

Measured memory_bytes: 3064
#include <cstdio>

const int MaxN = 100005;

int n, map[MaxN][3];

inline int Abs(int x) {
	return x < 0 ? -x : x;
}

struct BIT {
	int a[MaxN];
	
	inline int add(int p) {
		int res = 0;
		for (int q = p; q <= n; q += q & -q) res ^= a[q];
		for (; p; p -= p & -p) a[p] ^= 1;
		return res;
	}
} T[2];

bool check() {
	int row[2] = {0}, col[2] = {0};
	for (int i = 1; i <= n; ++i) {
		int I = i & 1;
		int *a = map[i];
		if (2 * a[1] != a[0] + a[2]) return false;
		if (Abs(a[1] - a[0]) != 1) return false;
		int quot = (a[1] + 1) / 3;
		int rem  = (a[1] + 1) % 3;
		if ((quot ^ i) & 1) return false;
		if (rem != 0) return false;
		col[I] ^= a[1] < a[0];
		row[I] ^= T[I].add(quot);
	}
	return row[0] == col[1] && row[1] == col[0];
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < 3; ++i) {
		for (int j = 1; j <= n; ++j) {
			scanf("%d", &map[j][i]);
		}
	}
	puts(check() ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 5136
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0502
#include<iostream>
#include<algorithm>
#include <string>
using namespace std;
struct Cube {
	int f[6];
	int sum;
	Cube() {
		f[0] = 1; f[1] = 2; f[2] = 3; f[3] = 4; f[4] = 5; f[5] = 6;
		sum = 1;
	}
	void roll(int i, int j, int k, int l) {
		int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
	}
	void n() { roll(0, 1, 5, 4); sum += f[0]; }
	void e() { roll(0, 3, 5, 2); sum += f[0]; }
	void w() { roll(0, 2, 5, 3); sum += f[0]; }
	void s() { roll(0, 4, 5, 1); sum += f[0]; }
	void r() { roll(1, 2, 4, 3); sum += f[0]; }
	void l() { roll(2, 1, 3, 4); sum += f[0]; }
};
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	while (true) {
		int n; cin >> n;
		if (!n) break;
		Cube c;
		for (int i = 0; i < n; i++) {
			string s;
			cin >> s;
			if (s == "North")c.n();
			else if (s == "East")c.e();
			else if (s == "South")c.s();
			else if (s == "West")c.w();
			else if (s == "Right")c.r();
			else if (s == "Left")c.l();
		}
		cout << c.sum << endl;
	}
	return 0;
}

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

const int INF = 0x3f3f3f3f;

int x[100123];

int main()
{
	int n;
	cin >> n;
	LL a, b;
	cin >> a >> b;
	Rep(i, n) scanf("%d", x+i);
	LL ans = 0;
	for(int i = 2; i <= n; ++i) {
		ans += min(a*(x[i]-x[i-1]), b);
	}
	cout<<ans <<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    int robot[101];
    for(int i=0;i<=101;++i){
        robot[i]=0;
    }
    for(int alice=A;alice<=B;++alice){
        ++robot[alice];
    }
    for(int Bob=C;Bob<=D;++Bob){
        ++robot[Bob];
    }
    int sum=0;
    for(int i=0;i<=101;++i){
        if(robot[i]==2)++sum;
    }
    sum=(sum==0)?(sum):(sum-1);
    cout<<sum<<endl;
    return 0;
}


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

int main(){
	int N, i;
	scanf("%d", &N);
	vector<pair<pair<string, int>, int>> SP(N);
	for(i = 0; i < N; i++){
		SP[i].second = i;
		cin >> SP[i].first.first;
		scanf("%d", &SP[i].first.second);
		SP[i].first.second *= -1;
	}
	sort(SP.begin(), SP.end());
	for(i = 0; i < N; i++){
		printf("%d\n", SP[i].second + 1);
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(a) for a in input().split(" ")]

minus_count = 0
max_minus = -1145141919
min_plus = 1145141919
ans = 0
for a in A:
    ans += abs(a)
    if a < 0:
        minus_count += 1
        if max_minus < a:
            max_minus = a
    else:
        if min_plus > a:
            min_plus = a

if minus_count % 2 == 1:
    if -min_plus < max_minus:
        ans += 2*max_minus
    else:
        ans += -2*min_plus

print(ans)


Measured memory_bytes: 64220
import java.util.Scanner;

//Room Numbers of a Hospital
public class Main{

	static int[] t = {0,1,2,3,5,7,8,9};
	
	static void f(int n){
		if(n>=8)f(n/8);
		System.out.print(t[n%8]);
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			f(n);
			System.out.println();
		}
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll , ll> P;
typedef pair<ll, ll> PL;
const ll INT_INF = 2147483646;
const ll ll_INF = 9223372036854775807;
ll mod = 1e9+7;

bool SecondCompare(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
       return a.second>b.second;
}

ll n,m;
pair<ll,pair<ll,ll>> p[100010];
pair<ll,pair<ll,ll>> a[100010];
string aa[100010];
int cou[100010];

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

    for(int i = 0; i < m; i++){
        cin >> a[i].first >> a[i].second.first;
        a[i].second.second = i;
    }

    sort(a,a+m);

    for(int i = 0; i < m; i++){
        ++cou[a[i].first];
        p[i].first = a[i].second.second;
        p[i].second.first = a[i].first;
        p[i].second.second = cou[a[i].first];
    }

    sort(p,p+m);

    for(int i = 0; i < m; i++){
        cout << setfill('0') << setw(6) << p[i].second.first;
        cout << setfill('0') << setw(6) << p[i].second.second << endl;
    }

    
}

Measured memory_bytes: 7424
#include <iostream>

int cal(unsigned long N) {
    if(N < 6) { return N; }

    unsigned long s = 6, n = 9;
    while(s < N) {
        s *= 6;
    }
    if(s > N) {
        s /= 6;
    }

    while(n < N) {
        n *= 9;
    }
    if(n > N) {
        n /= 9;
    }

    unsigned long ds = N - s, dn = N - n;
    int cs = cal(ds), cn = cal(dn);
    if(cs > cn) {
        return cn + 1;
    } else {
        return cs + 1;
    }
}

int main() {
    using namespace std;
    unsigned long N;
    cin >> N;

    cout << cal(N) << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#define llint long long

using namespace std;

double a, b, x;

int main(void)
{
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	
	cin >> a >> b >> x;
	
	double s = x / a;
	
	if(s < a*b/2){
		double x = 2*s/b;
		double ans = atan(b/x);
		ans *= 180 / M_PI;
		printf("%.11f\n", ans);
	}
	else{
		s = a*b-s;
		double x = 2*s/a;
		//cout << x << endl;
		double ans = atan(x/a);
		ans *= 180 / M_PI;
		printf("%.11f\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;
int main() {
    int N, L;
    cin >> N >> L;
    int f = (L-1)*N + (N*(N+1))/2;
    if ((1-L) <= N && (1-L) > 0)
        cout << f << "\n";
    else if (L > 0)
        cout << f - (L) << "\n";
    else
        cout << f - (L + N - 1) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define Rep(i, n) for (int i = 1; i <= n; i++)
typedef pair<int, int> P;

const ll INF = 1ll<<60;
typedef struct{int to, cost;} edge;
int N, Q, K;
vector<edge> G[100100];
vll d(100100, INF);

void nya(int s){
    priority_queue<P, vector<P>, greater<P> >que;
    d[s] = 0ll;
    que.push(P(0, s));
    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        rep(i, G[v].size()){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
    return;
}

int main(){
    cin >> N;
    rep(i, N)if(i){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        edge tmp;
        tmp.to = b;
        tmp.cost = c;
        G[a].push_back(tmp);
        tmp.to = a;
        G[b].push_back(tmp);
    }
    cin >> Q >> K;
    nya(K - 1);
    while(Q--){
        int x, y;
        cin >> x >> y;
        x--; y--;
        cout << d[x] + d[y] << endl;
    }
    return 0;
}

Measured memory_bytes: 11680
#include <cstdio>
#include <algorithm>
using namespace std;

int n;


int main(){
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	printf("%d",a[0]);
	for(int i=1;i<n;i++)	printf(" %d",a[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 8844
import java.io.InputStream;
import java.util.Scanner;

public class Main {


	public static void main(String args[]) {
        InputStream inputStream = System.in;
        Scanner sc = new Scanner(inputStream);
        String out;
        //String N=sc.next();
        int A = sc.nextInt();
        //int B = sc.nextInt();
        int count=0;
        int last=0;
        for(int k=1;k<=A;k=k+2) {
        	//System.out.println(k);
        for(int i=1;i<=k;i++) {
        	if(k%i==0) {count++;}
        }
        if(count==8) {last++;
        //System.out.println(k+"=8count");
        }
        count=0;
        }
        System.out.println(last);

	}

}

Measured memory_bytes: 21588
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] resultArray = str.split(" ");
		int[] box = new int[3];
		
		for (int i = 0; i < resultArray.length; i++) {
			
			box[i] = Integer.parseInt(resultArray[i]);
		
		}
		for (int i = 0; i < box.length-1; i++) {
			for (int j = i+1; j < box.length; j++) {
				if (box[i] > box[j]) {
					int tmp = box[j];
					box[j] = box[i];
					box[i] = tmp;
				}
			}
		}
		System.out.println(box[0] + " " + box[1] + " " + box[2]);
	}
}

Measured memory_bytes: 24288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int H, W, N;
vector<vector<int>> ans;

struct elem {
  int n, v;
  elem(int n, int v) : n(n), v(v){};
};
vector<elem> b;

int main() {
  cin >> H >> W >> N;
  ans.resize(H, vector<int>(W, 0));
  rep(i, N) {
    int a;
    cin >> a;
    b.emplace_back(a, i + 1);
  }

  sort(all(b), [&](const elem& e1, const elem& e2) { return e1.n > e2.n; });

  int k = 0;
  rep(i, H) rep(j, W) {
    int y = i;
    int x = (i % 2 == 0 ? j : W - 1 - j);
    if (b[k].n == 0) k++;
    ans[y][x] = b[k].v;
    b[k].n--;
  }

  rep(i, H) {
    rep(j, W) {
      if (j != 0) cout << " ";
      cout << ans[i][j];
    }
    cout << endl;
  }

  return 0;
}


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

int main(int argc, char const *argv[]) {
  int n;
  cin>>n;
  for(int i=1;i<10;i++){
    if(111*(i-1)<n&&n<=111*i){
      cout<<111*i<<endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int n, m;
    cin >> n >> m;
    int s = 0;
    int a[n];
    for (int i = 0; i < n; i++) {
    	cin >> a[i];
    	s += a[i];
    }
    int c = 0;
    for (int i = 0; i < n; i++) {
    	if (a[i] >= 1.0/4/m * s) c++;
    }
    if (c >= m) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<algorithm>
#include<vector>
using namespace std;
int a[200005];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n-1;i++)
	{
		if(a[i]==a[i+1])
		{
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <queue>
#include <cstring>
#define INF 1000000007
using namespace std;
using ll = long long;
ll dpl[1000002];
ll dpr[1000002];
bool num[1000002];
bool v[1000002];
ll n;
ll res;

char c;
void solve()
{
   if(v[0]){
       dpl[0]=3;
       dpr[0]=0;
   }
   else{
       dpl[0]=1;
       dpr[0]=2;
   }
   for(int i = 1;i<n;i++){
       if(v[i]){
           dpl[i] += dpl[i-1]+dpr[i-1];
           dpl[i] += 2*dpl[i-1];
           dpr[i] += 2*dpr[i-1];
       }
       else{
            dpl[i] += dpl[i-1];
            dpr[i] += dpr[i-1];
            dpr[i] += 2*(dpr[i-1]+dpl[i-1]);
       }
       dpl[i] = dpl[i]%INF;
       dpr[i] = dpr[i]%INF;
   }
   cout<<dpl[n-1]<<endl;
}

int main()
{
    while((c=getchar())!='\n'){
        if(c=='1')num[n] =true;
        n++;
    }
    for(int j = 0;j<n;j++){
        v[j] = num[n-1-j];
    }
    solve();
    return 0;
}


Measured memory_bytes: 6656
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var s = cin.next();
            var t = cin.next();

            var tt = t.Substring(0, t.Length - 1);
            Console.WriteLine((s ==tt && t.Length == s.Length+1)?"Yes":"No");
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 25812
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define x1 xdddddddddddddddddd
#define y1 ydddddddddddddddddd

int n,k,x,ans=INF;

vector <int> a,b;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n >> k;
    for(int i=1;i<=n;i++){
        cin >> x;
        if(x<0) a.pb(x);
        else if(x>0) b.pb(x);
        else k--;
    }
    if(!k){
        cout << 0;
        return 0;
    }
    reverse(a.begin(),a.end());
    for(int i=0;i<a.sz;i++) a[i]*=-1;
    for(int i=0;i<min((int)a.sz,k-1);i++){
        if(k-i-2<b.sz) ans=min(ans,min(2*a[i]+b[k-i-2],a[i]+2*b[k-i-2]));
    }
    if(a.sz>=k) ans=min(ans,a[k-1]);
    if(b.sz>=k) ans=min(ans,b[k-1]);
    cout << ans;
}


Measured memory_bytes: 1020
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int h, w, d;
  cin >> h >> w >> d;
  vector<std::pair<int, int>> vv(h*w+1);
  for (size_t i = 0; i < vv.size() - 1; ++i) {
      int a;
      cin >> a;
      vv[a].first = i / w + 1;
      vv[a].second = i % w + 1;
  }
  
  vector<int> dd(vv.size());
  for (size_t i = vv.size()-1; i > 0; --i) {
    if (i+d > vv.size()) {
        dd[i] = 0;
        continue;
    }
    int xx = abs(vv[i+d].first - vv[i].first);
    int yy = abs(vv[i+d].second - vv[i].second);
    dd[i] = dd[i+d] + xx + yy;
  }
  size_t q;
  cin >> q;
  for (size_t i = 0; i < q; ++i) {
      int l, r;
      cin >> l >> r;
      cout << dd[l] - dd[r] << endl;
  }
  return 0;
}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 10e-10;

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int a[3], ans = 0;
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    ans = abs(a[1]-a[0]) + abs(a[2]-a[1]);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define SIZE 100005
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;

stack<ll> S;

ll calc(ll x,string op,ll y){
	if(op=="+") return x+y;
	if(op=="-") return x-y;
	if(op=="*") return x*y;
}

int main(){
	string str;
	ll numA,numB;
	
	while(cin >> str){
		if(str=="+"||str=="-"||str=="*"){
			numA = S.top();S.pop();
			numB = S.top();S.pop();
			S.push(calc(numB,str,numA));
		}else{
				numA=0;
				for(int i=0;i<(int)str.size();i++){
					numA*=10;
					numA+=str[i]-'0';
				}
			S.push(numA);
		}
	}
	cout << S.top()<<endl;
	return 0;
}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K;
    cin >> K;
    vector<int> vec = {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};
    cout << vec.at(K-1);
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
constexpr int INF = 1e9;
constexpr int MOD = 1e9+7;

ll sum[500010];

int main() {
    int n;
    cin >> n;
    string str[4] = {"AC","WA","TLE","RE"};
    int ans[4] = {};
    string s;
    rep(i,n){
        string s;
        cin >> s;
        if(s[0] == 'A') ans[0]++;
        else if(s[0] == 'W') ans[1]++;
        else if(s[0] == 'T') ans[2]++;
        else ans[3]++;
    }
    rep(i,4){
        cout << str[i] << " x " << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
N = int(input())

counts = [0 for i in range(N+1)]

for i in range(1,150):
    for j in range(1,150):
        for k in range(1,150):
            now = i**2 + j**2 + k**2 + i*j + j*k + k*i
            try:
                counts[now] += 1
            except:
                pass
for i in range(1,N+1):
    print(counts[i])

Measured memory_bytes: 74136
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;

signed main(){
	cin>>N;
	if(N%2==1){
		cout<<0<<endl;
	}
	else{
		int ans=0;
		int t=5;
		while(N/t>0){
			ans+=(N/t)/2;
			t*=5;
		}
		cout<<ans<<endl;
	}
	return 0;
}


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

#define debug_input freopen("stdin.in", "r", stdin)
#define debug_output freopen("stdout.out", "w", stdout)
#define FOR(i, a, b) for(ll i = a; i <= b; i++)
#define FORALL(i, n) for(ll i = 0; i < n; i++)
#define FORD(i, a, b) for(ll i = a; i >= b; i--)
#define SORT(a) sort(a.begin(), a.end())
#define REV(a) reverse(a.begin(), a.end())
#define NP(a) next_permutation(a.begin(), a.end())
#define ALL(a) a.begin, a.end()
#define mp make_pair
#define pb push_back
#define endl "\n"
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

ll a[1000004], b[1000004], n;

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

	ll x1, y1;
	ll x2, y2;	 

	ll mini = 2 * 1e9;
	ll maxi = -1;

	cin >> n;
	FORALL(i, n) {
		cin >> a[i] >> b[i];

		if(a[i] + b[i] > maxi) {
			maxi = a[i] + b[i];
			x1 = a[i], y1 = b[i];
		}
		if(a[i] + b[i] < mini) {
			mini = a[i] + b[i];
			x2 = a[i], y2 = b[i];
		}
	}
	ll ans = abs(x1 - x2) + abs(y1 - y2);

	mini = 2 * 1e9;
	maxi = -1;
	FORALL(i, n) {
		if(a[i] - b[i] > maxi) {
			maxi = a[i] - b[i];
			x1 = a[i], y1 = b[i];
		}
		if(a[i] - b[i] < mini) {
			mini = a[i] - b[i];
			x2 = a[i], y2 = b[i];
		}
	}
	ans = max(ans, abs(x1 - x2) + abs(y1 - y2));

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

Measured memory_bytes: 6736
#include<bits/stdc++.h>
#define int long long
#define MAXN 200010
using namespace std;
int n,X[MAXN],Y[MAXN],x[MAXN],y[MAXN],lenx,leny,ans;
const int MOD=998244353;
int point[MAXN];
int Quick_Pow(int x,int p) {
	int res=1;
	while(p) {
		if(p&1)res=res*x%MOD;
		x=x*x%MOD;
		p=p>>1;
	}
	return (res+MOD-1)%MOD;
}
struct ___ {
	int num_up[MAXN],num_down[MAXN];
	void AddUp(int i,int x) {
		while(i>=1)num_up[i]+=x,i-=i&-i;
	}
	void AddDown(int i,int x) {
		while(i<=n)num_down[i]+=x,i+=i&-i;
	}
	int QueryUp(int i) {
		int res=0;
		while(i<=n)res+=num_up[i],i+=i&-i;
		return res;
	}
	int QueryDown(int i) {
		int res=0;
		while(i>=1)res+=num_down[i],i-=i&-i;
		return res;
	}
} BIT1,BIT2;
signed main() {
	scanf("%lld",&n);
	for(int i=1; i<=n; i++) {
		scanf("%lld %lld",&X[i],&Y[i]);
		x[i]=X[i],y[i]=Y[i];
	}
	ans+=n*(Quick_Pow(2,n))%MOD,ans%=MOD;
	for(int i=1;i<=n;i++){
		int res=2*(Quick_Pow(2,i-1)+Quick_Pow(2,n-i));
		res%=MOD;
		ans-=res,ans=(ans+MOD)%MOD;
	}
	sort(x+1,x+1+n),sort(y+1,y+1+n);
	lenx=unique(x+1,x+1+n)-x-1,leny=unique(y+1,y+1+n)-y-1;
	for(int i=1; i<=n; i++)X[i]=lower_bound(x+1,x+1+lenx,X[i])-x,Y[i]=lower_bound(y+1,y+1+leny,Y[i])-y;
	for(int i=1; i<=n; i++)BIT2.AddDown(Y[i],1),BIT2.AddUp(Y[i],1),point[X[i]]=Y[i];
	for(int i=1;i<=n;i++){
		BIT2.AddDown(point[i],-1),BIT2.AddUp(point[i],-1);
		int sum,res;
		sum=BIT2.QueryUp(point[i]+1);
		res=Quick_Pow(2,sum);
		ans+=res,ans=(ans+MOD)%MOD;
		sum=BIT2.QueryDown(point[i]-1);
		res=Quick_Pow(2,sum);
		ans+=res,ans=(ans+MOD)%MOD;
		sum=BIT1.QueryUp(point[i]+1);
		res=Quick_Pow(2,sum);
		ans+=res,ans=(ans+MOD)%MOD;
		sum=BIT1.QueryDown(point[i]-1);
		res=Quick_Pow(2,sum);
		ans+=res,ans=(ans+MOD)%MOD;
		BIT1.AddDown(point[i],1),BIT1.AddUp(point[i],1);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 14336
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

for Z in range(X+1, Y+1):
  if all([i < Z for i in x]) and all([i >= Z for i in y]):
    print('No War')
    exit()

print('War')

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

using namespace std;

int main(){
	string s,ss; cin >> s;
	ss = "CODEFESTIVAL2016";
	int ans = 0;
	for (int i = 0; i < s.length(); ++ i){
		if (s[i] != ss[i]) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int n, num[200005];
int mat[2][4 * 200005];

int f(int a0, int a1) {
	if (a0 == -1) return a1;
	if (a1 == -1) return a0;
	if (num[a0] < num[a1]) return a0;
	return a1;
}

void build(int at, int l, int r) {
	mat[0][at] = mat[1][at] = -1;
	if (l == r) {
		mat[l & 1][at] = l;
		return;
	}
	int mid = (l + r) / 2;
	build(at * 2, l, mid);
	build(at * 2 + 1, mid + 1, r);

	for (int i = 0; i < 2; i++) {
		mat[i][at] = f(mat[i][at * 2], mat[i][at * 2 + 1]);
	}
}

int query(int at, int l, int r, int L, int R, int parity) {
	if (R < l || r < L) return -1;
	if (L <= l && r <= R) {
		return mat[parity][at];
	}
	if (l == r) {
		if ((l & 1) == parity) {
			return mat[parity][at];
		}
		return -1;
	}
	int mid = (l + r) / 2;
	int x = query(at * 2, l, mid, L, R, parity);
	int y = query(at * 2 + 1, mid + 1, r, L, R, parity);
	return f(x, y);
}

struct Tree {
	int left, mid, right;
	PII val;
	Tree() {
		left = mid = right = -1;
		val = { -1, -1 };
	}
};
Tree tree[200005];
bool operator<(Tree A, Tree B) {
	return A.val < B.val;
}

int cur = 0;

int solve(int l, int r) {
	int x = query(1, 1, n, l, r, l & 1);
	int y = query(1, 1, n, x, r, 1 ^ (l & 1));
	// l .. x ... y .. r
	int now = cur++;
	if (x != l) {
		tree[now].left = solve(l, x - 1);
	}
	if (y != x + 1) {
		tree[now].mid = solve(x + 1, y - 1);
	}
	if (y != r) {
		tree[now].right = solve(y + 1, r);
	}
	tree[now].val = PII(num[x], num[y]);
	return now;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &num[i]);
	}

	build(1, 1, n);

	int root = solve(1, n);
	set<Tree> S;
	S.insert(tree[root]);
	VI ans;
	while (!S.empty()) {
		Tree u = *S.begin();
		S.erase(u);

		ans.push_back(u.val.first);
		ans.push_back(u.val.second);
		if (u.left != -1) S.insert(tree[u.left]);
		if (u.mid != -1) S.insert(tree[u.mid]);
		if (u.right != -1) S.insert(tree[u.right]);
	}

	for (int i = 0; i < SZ(ans); i++) {
		if (i) printf(" ");
		printf("%d", ans[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 18036
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <array>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
const int  INF=10e7;

typedef  pair<int,int> P;


int main(){
     string s;
     cin>>s;
     int now=s[0];
     int ans=0;
     for(int i=0;i<s.size();++i){
          if(now!=s[i]){
               now=s[i];
               ans++;
          }
     }
     cout<<ans<<endl;
}

Measured memory_bytes: 512