akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace ABC165
{
    public class Solve
    {
        public static void Main(string[] args)
        {
            new ABC_B();
        }
    }
    public class ABC_A
    {
        public ABC_A()
        {
            //飛距離をKの倍数にすること
            var k = Ex.ReadInt;
            var l = Ex.ReadIntArray();
            //飛距離の範囲はA以上B以下
            var a = l[0];
            var b = l[1];
            bool ans = false;

            for (int i = a; i <= b; i++)
            {
                if (i % k == 0)
                {
                    ans = true;
                    break;
                }
            }

            var str = ans ? "OK" : "NG";
            str.Cw();
        }
    }
    public class ABC_B
    {
        public ABC_B()
        {
            var x = Ex.ReadLong;
            long ans = 0;
            long i = 100;


            while (i < x)
            {
                i += (long)Math.Floor(i * .01);
                ans++;
            }



            ans.Cw();
        }
    }
    public class ABC_C
    {
        public ABC_C()
        {
        }
    }
    public class ABC_D
    {
        public ABC_D()
        {
        }
    }
    public class ABC_E
    {
        public ABC_E()
        {
        }
    }
    public class ABC_F
    {
        public ABC_F()
        {
        }
    }
    public static class Ex
    {
        public static void Cw(this object s) { Console.WriteLine(s); }

        public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); }
        public static string yesno(this bool b) { return b ? "yes" : "no"; }
        public static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        public static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        public static string Read { get { return Console.ReadLine().Trim(); } }
        public static int ReadInt { get { return int.Parse(Read); } }
        public static long ReadLong { get { return long.Parse(Read); } }
        public static double ReadDouble { get { return double.Parse(Read); } }
        public static string[] ReadArray() { return Read.Split(' '); }
        public static int[] ReadIntArray() { return Read.Split(' ').Select(int.Parse).ToArray(); }
        public static long[] ReadLongArray() { return Read.Split(' ').Select(long.Parse).ToArray(); }
        public static string[] ReadArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public static int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public static long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 17644
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <time.h>
#include <chrono>
#include <random>
//#include <math.h>
#include <cmath>
#include <fstream>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <stdlib.h>
#include <cstring>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <bitset>

#pragma comment(linker, "/STACK:36777216")
using namespace std;

#define flu fflush(stdout)
#define gg return 0
#define mp make_pair

typedef long double ptype;

long long mod = /*27449*//*998244353*/ /*1e9 + 7*/998244353 /*1e9 + 9*/;
int inf = 1e9;
double eps = 1e-7;
long double pi = acosl(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ifstream in("input.txt");
ofstream out("output.txt");

void solve()
{
	int n, k;
	cin >> n >> k;
	vector<pair<int, int>> a(k);
	for (int i = 0; i < k; i++)
	{
		cin >> a[i].first >> a[i].second;
	}
	sort(a.begin(), a.end());
	vector<long long> dp(n, 0);
	vector<long long> ps(n + 1, 1);
	dp[0] = 1;
	ps[0] = 0;
	ps[1] = 1;
	for (int i = 1; i < n; i++)
	{
		for (int j = 0; j < k; j++)
		{
			if (i < a[j].first) break;

			long long dv = ps[i - a[j].first + 1] - ps[max(0, i - a[j].second)] + mod;
			dv %= mod;

			dp[i] = (dp[i] + dv) % mod;
		}
		ps[i + 1] = (ps[i] + dp[i]) % mod;
	}
	cout << dp[n - 1];
}

int main()
{
	cout << setprecision(20) << fixed;
	cin.tie();
	cout.tie();
	clock_t t1 = clock();
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int t;
	//cin >> t;
	t = 1;
	while (t--) {
		solve();
		//test();
	}
	//cout << (clock() - t1) * 1.0 / CLOCKS_PER_SEC;
	gg;
}

Measured memory_bytes: 6416
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
int a[110],n,m;
int main(){
	cin>>n>>m;
	int sum=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	int ans=0;
	for(int i=n;i>=1;i--){
		if(4*m*a[i]>=sum){
			ans++;
		}
	}
	if(ans>=m)	puts("Yes");
	else	puts("No");
	return 0;
}


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

int main() {
  int n, a;
  cin >> n >> a;
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x.at(i);
    x.at(i) -= a;
  }
  vector<vector<int64_t>> dp(n + 1, vector<int64_t>(100 * n));
  dp.at(0).at(50 * n) = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 100 * n; j++) {
      dp.at(i + 1).at(j) += dp.at(i).at(j);
      int k = j + x.at(i);
      if (k < 0 or 100 * n <= k) continue;
      dp.at(i + 1).at(k) += dp.at(i).at(j);
    }
  }
  cout << dp.at(n).at(50 * n) - 1 << endl;
}


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

#define int long long
#define IOS ios::sync_with_stdio(false); cin.tie(nullptr);                                                        

int32_t main()
{
	IOS;
	#ifdef LOCAL
	freopen("input.txt","rt",stdin);
	#endif

	int a,b;
	cin >> a >> b;
	int tot = a*b;
	if(a > 9 or b > 9)
		tot = -1;
	cout << tot <<endl;
 
	#ifdef LOCAL
	cerr << "Time elapsed : " << 1.0*clock()/CLOCKS_PER_SEC << " s.\n";
	#endif
    return 0;
}   

Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var x = o.a();
  var b = o.m(n);
  var s = 0;
  for(var i = 0; i < n; i++){
    var t = b[i][0]*b[i][1];
    var a = (x-b[i][0])*b[i][2];
    s += t;
    b[i].push(a,t,a+t);
  }
  b.sort((a,b)=>b[5]-a[5]);
  var ok = n*x, ng = -1;
  while(ok-ng>1){
    var m = Math.floor((ok+ng)/2);
    var u = s, k = m, z = m % x;
    for(var i = 0; i < n && k > 0 && u > 0; i++){
      if(x <= k)u -= b[i][5], k -= x;
      else{
          for(var j = 0; j < i; j++){
            var v = u + b[j][5] - b[i][5];
            if(k < b[j][0]){
              v -= k*b[j][1];
            }else{
              v -= b[j][4] + (k-b[j][0])*b[j][2];
            }
            if(v <= 0){u = v; break;}
          }
          for(; i < n; i++){
            var v = u;
            if(k < b[i][0]){
              v -= k*b[i][1];
            }else{
              v -= b[i][4] + (k-b[i][0])*b[i][2];
            }
            if(v <= 0)break;
          }
          u = v;
      }
    }
    if(u > 0)ng = m;
    else ok = m;
  }
  return ok;
}

Measured memory_bytes: 99552
#include<stdio.h>
int up(const void *a,const void *b){
  return *(int *)a - *(int *)b;
}
int main(void){
  int n;
  scanf("%d",&n);
  int a[n] , b[n];
  for(int i = 0;i < n;i ++){
    scanf("%d",&a[i]);
    b[i] = a[i];
  }
  qsort(a,n,sizeof(int),up);
  for(int  i = 0;i < n;i ++){
    if(b[i] == a[n-1]){
      printf("%d\n",a[n-2]);
    }
    else{
      printf("%d\n",a[n-1]);
    }
  } 
  return 0;
}

Measured memory_bytes: 3872
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];
int main()
{
	int n;
	cin >> n;
	int cnt = 1;
	for(int i = 1; i <= n; i++){
		int x;
		scanf("%d", &x);
		a[x] = cnt++;
	}
	for(int i = 1; i <= n; i++){
		printf("%d ", a[i]);
	}
	return 0;
}

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

int main() {
  
  int a,b,x;
  cin >> a >> b >> x;

  bool ans = false;
  if (a == x) ans = true;
  else if (a < x && a+b > x) ans = true;
  
  cout << ((ans) ? "YES" : "NO") << endl;
   
}

Measured memory_bytes: 256
import sys

#+++++
		
def main():
	n = int(input())
	al = list(map(int, input().split()))
	
	aal=[(i,v) for i,v in enumerate(al)]
	aal.sort(key=lambda x: x[1])
	#pa(aal)
	ans_s=[str(i+1) for i,v in aal]
	print(' '.join(ans_s))
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 25312
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as C
import Data.Vector.Algorithms.Search
import Data.Vector.Algorithms.Intro as VAI

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

main :: IO ()
main = do
    n <- readLn
    as <- r n
    let ls = U.imap (+) as
    let rs = U.imap (-) as
    mutRs <- U.thaw rs
    VAI.sort mutRs
    res <- U.forM ls (\l -> do
            il <- binarySearchL mutRs l
            ir <- binarySearchR mutRs l
            return $ ir - il)
    print $ U.sum res

Measured memory_bytes: 13764
#include <stdio.h>
#define MAX_N 250

int N;
int heap[MAX_N];

int main() {
  int i, parent, left, right;
  scanf("%d", &N);
  for(i = 0; i < N; ++i) {
    scanf("%d", heap+i);
  }
  for(i = 0; i < N; ++i) {
    printf("node %d: key = %d, ", i+1, heap[i]);
    parent = (i-1)/2;
    left = i*2 + 1;
    right = i*2 + 2;
    if(i != 0) printf("parent key = %d, ", heap[parent]);
    if(left < N) printf("left key = %d, ", heap[left]);
    if(right < N) printf("right key = %d, ", heap[right]);
    printf("\n");
  }
  return 0;
}

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


int main(){

  int i=0,j,m,k,a;
  int *n;
  int count = 0;

  scanf("%d",&k);

  n = malloc(sizeof(int) * k);
  
  while(i < k){
    scanf("%d",&n[i]);
    i++;
    }

  m = 0;
  while(m != k-1){

  for(i=k-1; i > 0 ; i--){

    
    if(n[i] < n[i-1]){

      a = n[i-1];

      n[i-1] = n[i];

      n[i] = a;

      count++;
    }
    else if(n[i] > n[i-1]){
      continue;
    }
    
  }
  m++;
  }

  i = 0;

  while(i < k){
    printf("%d",n[i]);
    if(i != k-1){
      printf(" ");
      
    }

    i++;

  }
    printf("\n");

  printf("%d\n",count);

  free(n);


  return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	vector<int>R(5);
	rep(i, 5) {
		cin >> R[i];
	}
	int sum = 0;
	rep(i, 5) {
		sum += (R[i] / 10 + bool(R[i] % 10)) * 10;
	}
	vector<int>E(5);
	rep(i, 5) {
		E[i] = R[i] % 10;
	}
	sort(E);
	sum += lupper(E,0);
	sum -= 10;
	if (E[4] == 0) {
		sum += 10;
	}
	cout << sum << endl;
}

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

using i64 = int64_t;

constexpr i64 MOD = 1e9 + 7;

int main(){
    i64 n;
    cin >> n;
    i64 ans = 1;
    for(i64 i=1;i<=n;++i){
        ans *= i;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;

int check(vector<vector<int> > &x,int i,int j){
  int k,buf,sum=0;
  for(k=0;k<x[i].size();k++){
    buf=x[i][k]-x[j][k];
    buf=buf*buf;
    sum+=buf;
  }
  double d;
  d=sqrt((double)sum);
  buf=(int)d;
  buf=buf*buf;
  if(buf==sum) return 1;
  else return 0;
}
int main(){
  int n,d,i,j,r=0;
  cin>>n>>d;
  vector<vector<int> > x(n);
  vector<int> buf(d);
  for(i=0;i<n;i++){
    for(j=0;j<d;j++) cin>>buf[j];
    x[i]=buf;
    for(j=0;j<i;j++) r+=check(x,i,j);
  }
  cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
inline int read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	int k=1,kk=0;if (c=='-')c=getchar(),k=-1;
	while (c>='0'&&c<='9')kk=kk*10+c-'0',c=getchar();return kk*k;
}using namespace std;
void write(int x){if (x<0)putchar('-'),x=-x;if (x/10)write(x/10);putchar(x%10+'0');}
void writeln(int x){write(x);puts("");}
int n,ll,rr,a[1000010],ans;
int clc(int x,int y,int z){return abs((a[y]-a[x-1])-(a[z]-a[y]));}
signed main(){
	n=read();for (int i=1;i<=n;i++)a[i]=read()+a[i-1];
	ll=1;rr=4;ans=1e15;
	for (int i=3;i+1<=n;i++){
		rr=max(rr,i+1);
		while (ll+2<i&&clc(1,ll,i-1)>clc(1,ll+1,i-1))ll++;
		while (ll>1&&clc(1,ll,i-1)>clc(1,ll-1,i-1))ll--;
		while (rr<n&&clc(i,rr-1,n)>clc(i,rr,n))rr++;
		while (rr>i+1&&clc(i,rr-1,n)>clc(i,rr-2,n))rr--;
		ans=min(ans,max(max(a[ll],a[i-1]-a[ll]),max(a[rr-1]-a[i-1],a[n]-a[rr-1]))
			-min(min(a[ll],a[i-1]-a[ll]),min(a[rr-1]-a[i-1],a[n]-a[rr-1])));
	}writeln(ans);
}




Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 1000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    int A[200010];
    rep(i, N) cin >> A[i];
    int ok = INF;
    int ng = 0;
    while(abs(ok - ng) > 1) {
        int cnt = 0;
        int mid = (ok + ng) / 2;
        rep(i, N) {
            cnt += (A[i] - 1) / mid;
        }
        if(cnt <= K) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;

    return 0;
}


Measured memory_bytes: 5160
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,c,x,y[100];
  while(cin>>n>>a>>b>>c>>x, n){
    for(int i=0;i<n;++i) cin>>y[i];
    int ans=-1, cnt=0;
    for(int i=0, j=0;i<10001;++i, x=(a*x+b)%c)
      if(x==y[j]){
        cnt++, j++;
        if(cnt==n){
          ans=i;
          break;
        }
      }
    cout<<ans<<endl;
  }
  return 0;
}

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


int L, R, d;
int count1 = 0;

int main(){
    cin >> L >> R >> d;

    for (int i = L; i < R + 1; i++){
        if(i % d == 0) count1++;
    }
    cout << count1 << endl;
}

Measured memory_bytes: 3640
/*
貪欲
後ろから見る
DP
順位表をチェック
二分探索


*/
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<tuple>
using namespace std;
#define INF 3e18+7
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<double,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());

int A[20][20];


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

    int N;
    cin>>N;
    for(int i=0;i<20;i++){
        for(int j=0;j<20;j++) A[i][j]=-1;
    }

    for(int i=0;i<N;i++){
        int B;
        cin>>B;
        for(int j=0;j<B;j++){
            int x,y;
            cin>>x>>y;
            x--;
            A[i][x]=y;
        }
    }
    int ans=0;
    for(int S=0;S<(1LL<<N);S++){
        bool flag=true;
        for(int i=0;i<N;i++){
            if(bit(S,i)==0) continue;
            for(int j=0;j<N;j++){
                if(A[i][j]==-1) continue;
                if(A[i][j]==1 && bit(S,j)==0) flag=false;
                if(A[i][j]==0 && bit(S,j)==1) flag=false;
            }
        }
        if(flag) chmax(ans,__builtin_popcount(S));
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int inf = 2e18;
const int mod = 1e9 + 7;

const int base = 80 * (2 * 80) + 10;
const int baseTwo = base * 2;

signed main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> mass(H, vector<int>(W, 0));
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> mass[i][j];
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) {
        int a; cin >> a;
        mass[i][j] = abs(a - mass[i][j]);
    }
    vector<vector<bitset<baseTwo>>> dp(H, vector<bitset<baseTwo>>(W, 0));
    dp[0][0][base - mass[0][0]] = true;
    dp[0][0][base + mass[0][0]] = true;
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) {
        if (i == 0 && j == 0) continue;
        if (i > 0) {
            dp[i][j] |= dp[i - 1][j] << mass[i][j];
            dp[i][j] |= dp[i - 1][j] >> mass[i][j];
        }
        if (j > 0) {
            dp[i][j] |= dp[i][j - 1] << mass[i][j];
            dp[i][j] |= dp[i][j - 1] >> mass[i][j];
        }
    }
    int ans = inf;
    for (int i = 0; i < baseTwo; i++) if (dp[H - 1][W - 1][i]) ans = min(ans, abs(base - i));
    cout << ans << endl;
}


Measured memory_bytes: 20736
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define loop(i,a,b) for(int i = a ; i < b; i ++)
#define rep(i,a) for(int i = 0 ; i < a; i ++)
int main(void){
  int a,b,n;
  while(cin>>a>>b>>n){

    unsigned long long int res = 0;
    /*
    double dis = 1.0*a/b*10;
    rep(i,n){
      res += (int)dis%10;
      //cout<<dis<<endl;
      dis *= 10;
    }
    */
    /* make first
    unsigned long long int sum = (int)(a*1.0/b * pow(10,n));
    cout<<pow(10,n)<<endl;;
    cout<<sum<<endl;
    rep(i,n){
      res += sum % 10;
      sum /= 10;
    }
    */

    ///* sum each line
       
    loop(i,1,n+1){
      res += (unsigned long long )(a*1.0/b *pow(10,i) )%10;
    }
    
    cout<<res<<endl;;
  }
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes\n";
    else
        cout<<"No\n";
   	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;

int a[100005];
int g[100005];

const int mod = 1000000007;
int add(int a, int b) { return (a += b) < mod? a : a - mod; }
int sub(int a, int b) { return (a -= b) >=  0? a : a + mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
void adds(int& a, int b) { a = add(a, b); }
void subs(int& a, int b) { a = sub(a, b); }
void muls(int& a, int b) { a = mul(a, b); }
void maxs(int& a, int b) { a = max(a, b); }
void mins(int& a, int b) { a = min(a, b); }
int pwr(int a, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(a, pwr(a, p - 1));
    return pwr(mul(a, a), p / 2);
}
int inv(int a) { return pwr(a, mod - 2); }
const int maxn = 1000000;
int f[maxn + 1], fi[maxn + 1];
int ncr(int n, int r) { if (r > n) return 0; return mul(f[n], mul(fi[r], fi[n - r])); }

void precompute()
{
    f[0] = 1;
    for (int i = 1; i <= maxn; ++i)
        f[i] = mul(f[i - 1], i);

    fi[maxn] = inv(f[maxn]);
    for (int i = maxn - 1; i >= 0; --i)
        fi[i] = mul(fi[i + 1], i + 1);
}

int main()
{
    int n;
    cin >> n;
    int x;
    for (int i = 0; i < n + 1; ++i)
    {
        cin >> a[i];
        g[a[i]]++;
        if (g[a[i]] == 2)
            x = a[i];
    }
    precompute();
    vector<int> v;
    for (int i = 0; i < n + 1; ++i)
        if (a[i] == x)
            v.push_back(i);

    v[1] = n - v[1];
    for (int k = 1; k <= n + 1; ++k)
        cout << sub(ncr(n + 1, k), ncr(v[0] + v[1], k - 1)) << '\n';
}


Measured memory_bytes: 9856
line = readlines
len = line.length
i = 0

while i < len
    line[i] = line[i].chomp.split(' ')
    i += 1
end


num = line[0]
words = line[1]
newWord = ""

w1 = words[0]
strW1 = w1.split(//)
w2 = words[1]
strW2 = w2.split(//)

i = 0
strW1.each do |word| 
  newWord += strW1[i]
  newWord += strW2[i]
  i += 1
end

print newWord

Measured memory_bytes: 1788
n = int(input())
res = 0
for i in range(6):
    if n // (10 ** i) >= 10 and (i + 1) % 2 == 1:
        res += 9 * (10 ** i)
    elif 1 <= n // (10 ** i) < 10 and (i + 1) % 2 == 1:
        res += ((n // (10 ** i)) - 1) * (10 ** i)
        res += (n % (10 ** i)) + 1 # i になってなかった
print(res)

# res_2 = 0
# for i in range(1, n + 1):
#     if len(str(i)) % 2 == 1:
#         res_2 += 1

# print(res_2)


Measured memory_bytes: 9196
N = int(input())
Dn = list(map(int,input().split(' ')))
#Dn.sort()
previous_num = 0
previous_cnt = 1
current_num = 0
sum_num = 1
flag = False
output_list = [0]* N
max_num = 0
if Dn[0] == 0:
    output_list[0] = 1
    for i in range(1,N):
        max_num = max(max_num,Dn[i]) 
        output_list[Dn[i]] +=1


    '''
    for i in range(1,N):
        if Dn[i] == previous_num + 1:
            current_num += 1
        elif Dn[i] == previous_num + 2:
            if previous_num > 0:
                sum_num = sum_num * (previous_cnt**current_num)
            previous_cnt = current_num
            previous_num += 1
            current_num = 1
        else:
            flag = True
            break
        if i == N-1:
            if previous_num > 0:
                sum_num = sum_num * (previous_cnt**current_num)
    if flag:
        print(0)
    else:
        print(sum_num%998244353)
    '''
    if output_list[0] !=1:
        print(0)
    else:
        for i in range(2,max_num+1):
            sum_num = sum_num * (output_list[i-1]**output_list[i])
        print(sum_num%998244353)
else:
    print(0) 

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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int D, c[27];
int s[366][27];

chrono::steady_clock::time_point program_begin;

double runtime() {
	chrono::steady_clock::time_point program_end = chrono::steady_clock::now();

	return chrono::duration_cast<chrono::microseconds>(program_end - program_begin).count() / 1000000.0;
}

int calc(vector<int> sc) {
	vector<int> last(27, 0);
	int val = 0;
	rep(d, 1, D + 1) {
		val += s[d][sc[d]];
		last[sc[d]] = d;
		rep(i, 1, 27)
			val -= c[i] * (d - last[i]);
	}
	return val;
}

int myrand(int a, int b) {
	return a + rand() % (b - a + 1);
}

void solve() {
	vector<int> ans(366), best_ans(366);
	int best_ans_val;

	for (int i = 1; i <= 365; i++)
		ans[i] = myrand(1, 26);
	best_ans = ans;
	best_ans_val = calc(ans);

	while (runtime() <= 1.8) {
		int d = myrand(1, 365), n = myrand(1, 26);
		if (ans[d] == n)
			continue;
		vector<int> new_ans = ans;
		new_ans[d] = n;
		int new_val = calc(new_ans);
		if (chmax(best_ans_val, new_val)) {
			best_ans = new_ans;
		}
	}

	//cerr << best_ans_val << endl;
	
	rep(i, 1, D + 1)
		write(best_ans[i]);
}

void test() {}

int main(int argc, char *argv[]) {
	//cin.tie(0)->sync_with_stdio(0);
	//cin.exceptions(cin.failbit);

	srand(time(NULL));

	program_begin = chrono::steady_clock::now();

	if (argc >= 2 && string(argv[1]) == "test") {
		test();
		return 0;
	}

	read(D);
	rep(i, 1, 27) read(c[i]);
	rep(i, 1, D + 1) rep(j, 1, 27) read(s[i][j]);
	
	solve();
}


Measured memory_bytes: 3652
use proconio::input;
use std::iter::Iterator;
use std::collections::HashMap;

fn main() {
    input! {
    n: i32,
    mut a: [i32; n-1],
    }

    let mut map: HashMap<&i32, i32> = HashMap::new();
    
    for i in &a {
        map.entry(i).and_modify(|e| *e += 1).or_insert(1); 
    }

    dbg!(&map);

    for i in 1..=n {
        let count = map.get(&(i));
        let ans = match count{
            None => &0,
            Some(i) => i,
        };

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

}


Measured memory_bytes: 10676
n=int(input())
alist = list(map(int, input().split()))
blist = list(map(int, input().split()))

taos=0
for x in range(n):
    if blist[x]>=alist[x]:
        taos+=alist[x]
        blist[x]=blist[x]-alist[x]
        alist[x]=0
        if blist[x]>=alist[x+1]:
            taos+=alist[x+1]
            alist[x+1]=0
        else:
            taos+=blist[x]
            alist[x+1]-=blist[x]
    else:
        taos+=blist[x]
        alist[x]=alist[x]-blist[x]

print(taos)

Measured memory_bytes: 18752
#include<bits/stdc++.h> 
//compiling code: g++ test.cpp(file) -o script(output) -std=c++11(version) -O2(make it 2x faster)
using namespace std;

string S;
string W[3] = {"Sunny", "Cloudy", "Rainy"};

int main(){

    cin >> S;
    if (S == W[0]){
        cout << W[1];
    } else if (S == W[1]){
        cout << W[2];
    } else if (S == W[2]){
        cout << W[0];
    }


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int m, f, r, i = 1, a=0;

	while (i != 50)
	{
		scanf("%d %d %d", &m, &f, &r);

		if (m == -1 && f == -1 && r == -1)
		{
			break;
		}

		if (m == -1 || f == -1)
		{
			printf("F\n");
			a++;
		}

		if (m + f >= 80)
		{
			printf("A\n");
		}

		if (m + f < 80 && m + f >= 65)
		{
			printf("B\n");
		}

		if (m + f < 65 && m + f >= 50)
		{
			printf("C\n");
		}

		if (m + f < 50 && m + f >= 30)
		{
			if (r >= 50)
			{
				printf("C\n");
			}
			else if(a==0)
			{
				printf("D\n");
			}
			a = 0;
		}

		if (m + f<30)
		{
			printf("F\n");
		}
		i++;
	}
	return 0;
}


Measured memory_bytes: 2032
count = gets.chomp.to_i
line = gets.chomp.split(" ").map(&:to_i)
line2 = line.sort
line3 = line2.each_slice(2).to_a

reslut = []
(0..count-1).each do |i|
    minnum = line3[i].min
    reslut.push(minnum)
end

puts reslut.inject(:+)

Measured memory_bytes: 1916
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

long long gcd(long long n, long long m) {
	if (n < m) {
		swap(n,m);
	}
	if (m == 0) {
		return n;
	}
	return gcd(m,n%m);
}

int main(void) {
	long long A,B;
	cin >> A >> B;
	long long C = gcd(A,B);
	long long lim = sqrt(C)+1;
	long long res = 1;
	for (int i = 2; i < lim; ++i) {
		if (C%i == 0) {
			++res;
			while (C%i == 0) {
				C /= i;
			}
		}
	}
	if (C != 1) {
		++res;
	}
	cout << res << endl;
	
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define  vi vector<long long int>
#define  set1 set<long long int>
#define  pb push_back
#define  map1 map<long long int,long long int>
#define  ll  long long int
#define  inf INT_MAX
#define  minf INT_MIN
#define setbits(x) __builtin_popcountll(x)
#define pres(x,y) fixed<<setprecision(y)<<x
#define pair1 pair<long long int,long long int>
#define mp make_pair
#define mk(arr,n,type) type *arr=new type[n];
#define mod  1000000009
#define ins insert
#define w(t) long long int t;t=1; while(t--)



void solve() {

  ll n, k;
  cin >> n >> k;
  ll h[n + 1], dp[n + 1];
  for (ll i = 1; i <= n; i++) {
    cin >> h[i];
  }
  dp[1] = 0;
  for (ll i = 2; i <= n; i++) {

    dp[i] = inf;
    for (ll j = i - 1; j >= 1 && j >= i - k; j--) {
      ll cur = abs(h[i] - h[j]) + dp[j];
      dp[i] = min(dp[i], cur);
    }
  }

  cout << dp[n];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  w(t) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 5176
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;



int main() {
	int n; cin >> n;
	string s; cin >> s;
	int cnt = 0, d = 0;
	for (int i = 0; i < n; i++) {
		cnt += s[i] == '(' ? 1 : -1;
		d = min(d, cnt);
	}
	for (int i = 0; i < -d; i++) cout << "(";
	cout << s;
	for (int i = 0; i < cnt - d; i++) cout << ")";
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>

using namespace std;

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if((a<c&&c<b)||(b<c&&c<a))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<cstring>
using namespace std;
char s[1000000];
main(){
	long long n = 0,r = 0,ans = 0;
	gets(s);
	n = strlen(s);
	for(int x = 0;x < n;x++){
		if(s[x] == 'W')  r++;
	}
	for(int x = 0;x < n;x++){
		if(s[x] == 'W') r = r - 1;
else ans = ans + r;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9+7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
  int N; cin>>N;
  string S; cin>>S;
  int ans=0;
  rep(i,N-2)if(S.at(i)=='A'&&S.at(i+1)=='B'&&S.at(i+2)=='C')ans++;
 cout<<ans<<endl;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int N=scanner.nextInt();
        int K=scanner.nextInt();
        if(N%K==0){
            System.out.println(0);
        }else{
            System.out.println(1);
        }

    }
}

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

int main() {
  int MOD = 1e9 + 7;
  int N;
  cin >> N;

  vector<int> sum(N+1, 0);
  for (int i = 2; i <= N; i++) {
    int b = i;
    for (int j = 2; j <= b; j++) {
      while (b % j == 0) {
        b /= j;
        sum[j]++;
      }
    }
  }

  long long ans = 1;
  for (int i = 0; i <= N; i++) {
    if (sum[i] > 0) ans = ans * (sum[i] + 1) % MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
A,B,C,X,Y = map(int,input().split())

z = max(X,Y)*2

act_list = []
for i in range(0,z+1,2):
    x = int(X - i*0.5)
    y = int(Y - i*0.5)
    
    if x <= 0:
        x = 0
    if y <= 0:
        y = 0
    act = x * A + y * B + i * C
    act_list.append(act)

print(min(act_list))

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll INF=1LL<<60;
const ll MOD=(ll)1e9+7;

long long modpow(long long a, long long n, long long mod){
    long long res=1;
    while(n>0){
        if(n & 1) res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}

long long modinv(long long a, long long mod){
    return modpow(a, mod-2, mod);
}

vi cnt((int)1e6+5, 0);

void calc(int n){
    for(int i=2; i*i<=n; i++){
        int tmp=0;
        while(n%i == 0){
            tmp++;
            n/=i;
        }
        cnt[i]=max(cnt[i], tmp);
    }
    cnt[n]=max(cnt[n], 1);
}

int main(){
    int N; cin >> N;
    vi A(N);
    for(auto &x: A){
        cin >> x;
        calc(x);
    }
    ll L=1;
    for(int i=2; i<(int)cnt.size(); i++){
        L=L*modpow(i, cnt[i], MOD)%MOD;
    }
    ll res=0;
    for(int i=0; i<N; i++){
        res=(res+L*modinv(A[i], MOD)%MOD)%MOD;
    }
    if(res < 0) res+=MOD;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 6976
#include <bits/stdc++.h>
using namespace std;
int func(int n){
  int count = 0;
  while (n % 2 == 0) {
    count++;
    n /= 2;
  }
  return count;
}
int main() {
  int N;
  cin >> N;
  int max = 0;
  int answer = 1;
  for (int i = 1; i <= N; i++){
    if (func(i) > max){
      max = func(i);
      answer = i;
    }
  }
  
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define hackcyborg shresth_walia
#define ll long long
#define ld double
#define pb push_back
#define mod 998244353
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
ll bp(ll a,ll b,ll m=mod)
{
    ll res=1;
    if(b<0)
        return bp(bp(a,m-2),-b);
    while(b>0)
    {
        if(b&1)
        res=(a*res)%m;
        a=(a*a)%m;
        b/=2;
    }
    return res;
}
main()
{
    IO
    ll n,g,m;
    cin>>n>>g>>m;
    ll po[m+1];
    memset(po,-1,sizeof(po));
    vector<ll> as;
    as.pb(0);
    ll a=g;
    as.pb(g);
    ll l=g;
    po[l%m]=1;
    ll v=1;
    for(int x=2;x<=n;x++)
    {
        ll e=((l%m)*(l%m))%m;
        if(po[e]==-1 || v==0)
          {a+=e;
          l=e;
          po[e]=x;
          as.pb(e);
          }
          else
          {  // cout<<e<<" "<<po[e]<<" "<<x<<"\n";
              ll k=0;
              v=0;
              for(int y=po[e];y<x;y++)
              {
                  k+=as[y];
              }
              ll h=((n-x+1)/(x-po[e]));
              a+=(((n-x+1)/(x-po[e]))*k);
              x+=(h*(x-po[e]))-1;
              //cout<<h<<" "<<x<<"\n";
          }
    }
    cout<<a;
}


Measured memory_bytes: 4932
#include <stdio.h>

int main() {
	int n, i, a[100000];
	int min, max;
	long int sum = 0;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		sum += a[i];
		if (i == 0) {
			min = a[i]; max = a[i];
		}
		if (min > a[i]) min = a[i];
		if (max < a[i]) max = a[i];
	}

	printf("%d %d %ld\n", min, max, sum);
	return 0;

}

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

int main() {
  long N, T, c, t, tmp = 1001, ans = 1001;
  cin >> N >> T;

  for (int i = 1; i <= N; i++) {
    cin >> c >> t;
    if (T >= t) tmp = c;
    if (ans > tmp ) ans = tmp;
  }
  
  if (ans == 1001) cout << "TLE" << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, s, n) for (int i = (s); i <= (int)(n); i++)
int a[200010];
int b[200010];

int main() {
	int n;
	int onaji;
	int na1,na2;
	int nb1,nb2;
	int nc1,nc2;
	int nd1,nd2;

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

	onaji=-1;
	rep(i,n) {
		if (a[i]==b[n-1-i])onaji=a[i];
	}
	if(onaji<0){
		cout << "Yes" << endl;
		rep(i,n) {
			cout << b[n-1-i] << " ";
		}
		cout << endl;
		return 0;
	}
	na1=n+5;
	na2=-1;
	nb1=n+5;
	nb2=-1;
	rep(i,n) {
		if(a[i]==onaji){
			na1=min(na1,i);
			na2=max(na2,i);
		}
		if(b[n-1-i]==onaji){
			nb1=min(nb1,i);
			nb2=max(nb2,i);
		}
	}
	if (na2-na1+1+nb2-nb1+1>n){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	nc1=min(na1,nb1);
	nd1=max(na1,nb1);
	nd2=min(na2,nb2);
	nc2=max(na2,nb2);

	if(nc1<1){
      for (int i = nd1; i <=nd2; i++){
			b[n-1-i]=b[nd2-i];
			b[nd2-i]=onaji;
		} 
	}else if(nc1>nd2-nd1){
      for (int i = 0; i <= nd2-nd1; i++){
			b[n-1-nd1-i]=b[n-1-i];
			b[n-1-i]=onaji;
		} 
	}else{
      for (int i = 0; i < nc1; i++){
			b[n-1-nd1-i]=b[n-1-i];
			b[n-1-i]=onaji;
		} 
		for (int i = 0; i <= nd2-nd1-nc1; i++){
			b[n-1-nd1-nc1-i]=b[i];
			b[i]=onaji;
		} 
	}
	rep(i,n) cout << b[n-1-i] << " ";
	return 0;
}

Measured memory_bytes: 5204
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

int x[100001], y[100001];

signed main() {

	int N, A, B;
	cin >> N >> A >> B;
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < N-1; i++) {
		y[i] = min(B, (x[i + 1] - x[i])*A);
	}
	int ans = 0;
	for (int i = 0; i <= N - 1; i++) {
		ans += y[i];
	}
	cout << ans << "\n";



	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
using namespace std;
int K,a1,a2;string S[1000],T[1000];
int main(){
	cin>>K;
	for(int i=0;i<K;i++)cin>>S[i];
	for(int i=0;i<K;i++)cin>>T[i];
	for(int i=0;i<K;i++){
		int hansoku=0;int p1=a1,p2=a2;
		if(S[i]=="kougekida" && a1==0)hansoku+=1;
		if(T[i]=="kougekida" && a2==0)hansoku+=2;
		if(hansoku==1){cout<<"Nakajima-kun"<<endl;return 0;}
		if(hansoku==2){cout<<"Isono-kun"<<endl;return 0;}
		if(S[i]=="kougekida"){
			if(T[i]=="mamoru" && a1==5){cout<<"Isono-kun"<<endl;return 0;}
			if(T[i]=="tameru" && a1>=0){cout<<"Isono-kun"<<endl;return 0;}
			if(T[i]=="kougekida" && a1>a2){cout<<"Isono-kun"<<endl;return 0;}
			p1=0;
		}
		if(T[i]=="kougekida"){
			if(S[i]=="mamoru" && a2==5){cout<<"Nakajima-kun"<<endl;return 0;}
			if(S[i]=="tameru" && a2>=0){cout<<"Nakajima-kun"<<endl;return 0;}
			if(S[i]=="kougekida" && a2>a1){cout<<"Nakajima-kun"<<endl;return 0;}
			p2=0;
		}
		a1=p1;a2=p2;
		if(S[i]=="tameru"){if(a1<=4)a1++;}
		if(T[i]=="tameru"){if(a2<=4)a2++;}
	}
	cout<<"Hikiwake-kun"<<endl;
	return 0;
}

Measured memory_bytes: 3176
import collections

n=int(input())
a=list(map(int,input().split(" ")))
#n=5
#a=[1,-2,3,-4,5]
s=[0 for i in range(n+1)]
for i in range(1,n+1):
  s[i]=s[i-1]+a[i-1]
c=collections.Counter(s).most_common()
d=0
for i in c:
  if i[1]<2:
    break
  d+=i[1]*(i[1]-1)//2
print(d)

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

int main() {
    string s;  cin >> s;
    sort(s.begin(), s.end());

    string t;  cin >> t;
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if (s < t)  cout << "Yes" << endl;
    else  cout << "No" << endl;
}

Measured memory_bytes: 256
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, ll M, ll Q, std::vector<ll> L, std::vector<ll> R,
           std::vector<ll> p, std::vector<ll> q) {
  vector<vector<ll>> sum(N + 1, vector<ll>(N + 1, 0));
  rep(i, M) sum.at(L.at(i)).at(R.at(i))++;

  FOR(i, 1, N + 1) {
    FOR(j, 1, N + 1) {
      sum.at(i).at(j) += sum.at(i - 1).at(j);
      sum.at(i).at(j) += sum.at(i).at(j - 1);
      sum.at(i).at(j) -= sum.at(i - 1).at(j - 1);
    }
  }

  rep(i, Q) {
    ll l = p.at(i);
    ll r = q.at(i);
    ll ans = sum.at(r).at(r) - sum.at(r).at(l - 1) - sum.at(l - 1).at(r) +
             sum.at(l - 1).at(l - 1);
    cout << ans << endl;
  }
}

int main() {
  ll N;
  scanf("%lld", &N);
  ll M;
  scanf("%lld", &M);
  ll Q;
  scanf("%lld", &Q);
  std::vector<ll> L(M);
  std::vector<ll> R(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &L[i]);
    scanf("%lld", &R[i]);
    L.at(i);
    R.at(i);
  }
  std::vector<ll> p(Q);
  std::vector<ll> q(Q);
  for (int i = 0; i < Q; i++) {
    scanf("%lld", &p[i]);
    scanf("%lld", &q[i]);
    p.at(i);
    q.at(i);
  }
  solve(N, M, Q, std::move(L), std::move(R), std::move(p), std::move(q));
  return 0;
}


Measured memory_bytes: 9892
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3 4");
            //Even
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("1 21");
            //Odd
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int a = wkArr[0];
        int b = wkArr[1];
        if ((a * b) % 2 == 0) {
            Console.WriteLine("Even");
        }
        else {
            Console.WriteLine("Odd");
        }
    }
}


Measured memory_bytes: 13268
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class A
{
	public static void Main()
	{
		int A = GetInt();
		int B = GetInt();

		Console.WriteLine((A + B) % 24);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define FOR(j,k,n) for (int j = k; j < (int)(n); j++)
#define MAXN 10000000000000000
#define realMAXN 1000000000000000000
#define fi first
#define se second
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define pb push_back
#define test(t)  int t; cin>>t; for(int tes = 0; tes < t; tes++)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int lli;
typedef pair<lli,lli> plli;
const int MM = 1200000;

lli m,n,k,p1,p2,p3,p,f,a[MM];
string s,s1,s2;

int main(){fio; // remove during scanf
        // IF YOU ARE STUCK AT C, READ D. I repeat read D. It's OK.  
    // Have you solved the problem completely?    
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> a[i];
    int ind1=0, ind2=0;
    p1 = *min_element(a,a+n);
    p2 = *max_element(a,a+n);
    for(int i=0; i<n; i++)
    {
        if(a[i] == p1)
            ind1 = i;
        if(a[i] == p2)
            ind2 = i;
    }
    cout << 2*n - 1 << endl;
    
    if(p1 <= 0 && abs(p1) >= abs(p2))
    {
        bool h = 0;
        for(int i=0; i<n; i++)
            cout << ind1+1 << " " << i+1<<endl;
        
        for(int i=n-2; i>=0; i--)
            cout << i+2 << ' ' << i+1 << endl;
        return 0;
    }
    else
    {
        bool h = 0;
        for(int i=0; i<n; i++)
        {
            cout << ind2+1 << " " << i+1<<endl;
        }

        for(int i=1; i < n; i++)
        {
            cout << i << ' ' << i+1 << endl;
            a[i] += a[i-1];
        }
        return 0;

    }
    

    return 0;
}


Measured memory_bytes: 256