akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
signed main() {
  string s;
  cin >> s;
  if (s == "Sunny"){
    cout << "Cloudy" << endl;
  }  
  else if (s == "Cloudy"){
    cout << "Rainy" << endl;
  }
  else {
    cout << "Sunny" << endl;
  }
}


  

  
    
  
  
 
 





















Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int a,b,c=0,d=0;
  cin>>a>>b;
  
  if(b==1)
  cout<<"0";
  else if(a>=b)
  cout<<"1";
  else
   {
       while(1)
       {
            
           c+=a;
          if(c>=b)
          { d+=1;break;}
           c-=1;
           d++;
          
       }
       cout<<d;
   }
  
  
 return 0; 
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var N = IO.RInt;

            var calc = new int[100100100];

            for (int i = 1; i <= Sqrt(N); i++)
            {
                for (int j = 1; j <= Sqrt(N); j++)
                {
                    for (int k = 1; k <= Sqrt(N); k++)
                    {
                        var res = i * i + j * j + k * k + i * j + j * k + k * i;
                        calc[res]++;
                    }
                }
            }
            for (int i = 1; i <= N; i++)
            {
                WriteLine(calc[i]);
            }
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

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

n, m = map(int, input().split())

dp = [float("inf")] * ((1<<n) + 1)
dp[0] = 0

for i in range(m):
    a, b = map(int, input().split())
    c = sum(1<<(ci-1) for ci in map(int, input().split()))

    for j in range(1<<n):
        if dp[j] + a < dp[j | c]:
            dp[j | c] = dp[j] + a
        # dp[j | c] = min(dp[j] + a, dp[j | c])


if dp[(1<<n) - 1] == float("inf"):
    ans = -1
else:
    ans = dp[(1<<n) - 1]

print(ans)


Measured memory_bytes: 3316
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        
        //if K is an odd number
        //a,b,c must be multiple of K
        if(K%2!=0){
        	long multiple = N/K;
        	long ans = multiple*multiple*multiple;
        	System.out.println(ans);
        }
        //if K is an even number
        //first solution: a,b,c are multiple of K
        //second solution: a,b,c are K/2*[odd number]
        else{
        	long multiple = N/K;
        	long half = N/(K/2)-multiple;
        	long ans = multiple*multiple*multiple + half*half*half;
        	System.out.println(ans);
        }
    }
}

Measured memory_bytes: 21844
import sys
table = [0]*26

a = "abcdefghijklmnopqrstuvwxyz"
b = sys.stdin.read()

for i in b:
    index = 0
    for j in a:
        if i == j or j == i.lower():
            table[index] += 1
            break
        index += 1

for i in range(len(a)):
    print("%s : %d"%(a[i],table[i]))


Measured memory_bytes: 5564
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ld long double
#define mem(a,b) memset(a,b,sizeof(a) )
#define M 4000010
#define md 1000000007

ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}
//inline ll add(ll a,ll b){return (a+b)%md;}
//inline ll mul(ll a,ll b){return (a*b)%md;}
//ll f[M],iv[M];
//ll C(ll n,ll r){return mul(f[n],mul(iv[r],iv[n-r]));}
//void prep_fac(){
//    f[0]=1;
//    rep(i,1,M)f[i]=mul(i,f[i-1]);
//    iv[M-1]=power(f[M-1],md-2,md);
//    for(ll i=M-2;i>=0;--i)iv[i]=mul(i+1,iv[i+1]);
//}
//


int main()
{
	IOS;
	int n,m,k;
	cin>>n>>m>>k;
	string s[n];
	rep(i,0,n)cin>>s[i];
	int ans=0;
	for(int i=0;i<(1LL<<n);i++)
	{
		for(int j=0;j<(1LL<<m);j++)
		{
			int count=0;
			for(int r=0;r<n;r++)
			{
				for(int c=0;c<m;c++)
				{
					if(((1LL<<c)&j)||((1LL<<r)&i))continue;
					if(s[r][c]=='#')count++;
				}
			}
			if(count==k)
			ans++;
		}
	}
	cout<<ans;
	
}



Measured memory_bytes: 3636
#include <stdio.h>
#include<string.h>
int main(void)
{
int t[6];
int i;
int q;
int temp;
int temp2;
int a;
int b;
scanf("%d%d",&a,&b);
if(a+b>=24){
	
	printf("%d\n",(a+b)-24);
}else{
printf("%d\n",a+b);
}
return 0;
}

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

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;
int H, W;
int nonzero = 0;
vector<int> di = {0, 1};
vector<int> dj = {1, 0};

// namespace utils
namespace utils{
  template <typename T> void print(vector<vector<T>> mat) {
    rep (i, mat.size()) {
      rep (j, mat[0].size()) cout << mat[i][j] << ' ';
      cout << endl;
    }
  }

  template <typename T> void print(vector<T> v) {
    rep (i, v.size()) cout << v[i] << ' ';
    cout << endl;
  }
// end namespace utils
}

bool restricted_dfs(vector<vector<char>> &A, int i, int j, int cnt) {
  // cout << cnt << "(" << nonzero << ")" << endl;
  if (H == i && W == j && cnt == nonzero) {
    return true;
  }


  rep (k, 2) {
    int next_i = i + di[k];
    int next_j = j + dj[k];


    if (next_i <= A.size()-1 && next_j <= A[0].size()-1 && \
        next_i >= 0 && next_j >= 0 && A[next_i][next_j] == '#') {
      return restricted_dfs(A, next_i, next_j, ++cnt); // return じゃないとダメな理由
    }
  }

  return false;
}

int main() {
  cin >> H >> W;

  vector<vector<char>> A(H);

  rep (i, H) {
    vector<char> row(W);
    rep (i, W) {
      cin >> row[i];
      if (row[i] == '#') nonzero++;
    }
    A[i] = row;
  }

  // utils::print(A);
  H--;
  W--;
  if (restricted_dfs(A, 0, 0, 1)) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
def find(S):
    S = S[::-1]
    number = [0] * 2019
    ans = 0
    cur = 0
    power = 1
    for i in range(len(S)):
        
        cur += power * int(S[i])
        power *= 10
        power %= 2019
        cur %= 2019
        ans += number[cur]
        if cur == 0:
            ans += 1
        number[cur] += 1
        
    return ans

print(find(input()))

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

int main(){
  int a, b, c = 0;
  cin >> a >> b;
  c = (a + b) / 2;
  if((a + b) % 2 == 0) cout << c << endl;
  else cout << c+1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int mod=998244353;
#define N 432
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,a[N],b[N],dp[N][N][N],sumA,sumB,fac[N],inv[N],ans;
int qpow(int a,int b){
	int ans=1;
	while(b){
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}
	return ans;
}
void init(int n){
	fac[0]=1;
	for(int i=1;i<=n;++i){
		fac[i]=1LL*fac[i-1]*i%mod;
	}
	inv[n]=qpow(fac[n],mod-2);
	for(int i=n-1;i>=0;--i){
		inv[i]=1LL*inv[i+1]*(i+1)%mod;
	}
}
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		a[i]=read(),b[i]=read();
	}
	init(400);
	dp[0][0][0]=-1;
	for(int i=1;i<=n;++i){
		sumA+=a[i];
		sumB+=b[i];
		memcpy(dp[i],dp[i-1],sizeof(dp[i]));
		for(int j=sumA;j>=a[i];--j){
			for(int k=0;k<=sumB;++k){
				for(int p=0,tmp=1;p<=min(b[i]-1,k);++p,tmp=1LL*tmp*a[i]%mod){
					dp[i][j][k]=(dp[i][j][k]-1LL*dp[i-1][j-a[i]][k-p]*tmp%mod*inv[p])%mod;
				}
			}
		}
	}
	for(int j=0;j<=sumA;++j){
		for(int k=0;k<=sumB;++k){
			ans=(ans+1LL*sumA*dp[n][j][k]%mod*fac[k]%mod*qpow(qpow(j,k+1),mod-2))%mod;
		}
	}
	printf("%d\n",(ans+mod)%mod);
	return 0;
}



Measured memory_bytes: 295148
#include <stdio.h>
#include <time.h>

int get_day_week(int year, int month, int day) {
    struct tm time_in, *local;
    time_t t;

    time_in.tm_year = year - 1900;
    time_in.tm_mon  = month - 1;
    time_in.tm_mday = day;
    time_in.tm_hour = 1;
    time_in.tm_min  = 0;
    time_in.tm_sec  = 0;
    time_in.tm_wday = 0;
    time_in.tm_yday = 0;

    if ( (t = mktime(&time_in) ) == (time_t)(-1) ) {
        return -1;
    }

    local = localtime(&t);
    return local->tm_wday;
}

char week[7][16] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

int main(void) {
	int m,d;
	while(1) {
		scanf("%d %d\n", &m, &d);
		if(m == 0 && d == 0)
			break;
		
		printf("%s\n", week[get_day_week(2004, m, d)]);
	}
	
	return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
#include <stdio.h>
int main() {
  vector<int>a(3);
  for(int i; i<3; i++) cin >> a.at(i);
  sort ( a.begin(), a.end() );
  int pls = 0;
  for (int i; i<2; i++) pls += a.at(i+1)-a.at(i);
  cout << pls << endl;
}



Measured memory_bytes: 256
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [A, B] = string_to_int(inputs[0])
    if (A + B) % 2 != 0:
        return "IMPOSSIBLE"
    else:
        return (A+B) // 2


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 3060
//abc179_a.cpp
//Sat Sep 19 20:59:50 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	if (s[s.length()-1]=='s'){
		cout << s << "es" << endl;
	}else {
		cout << s << "s" << endl;
	}

}

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

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

	//並びをチェック
	for(int i=1;i<n;i++){
		if(s[i-1]=='W' && s[i]=='R'){
			break;
		}
		if(i==n-1){
			cout << 0 << endl;
			return 0;
		}
	}
	int ans=0;
	int red_right=n-1,white_left=0;
	while(1){
		//右端の赤を探す
		for(int r=red_right;r>0;r--){
			if(r==white_left){
				cout << ans << endl;
				return 0;
			}else if(s[r]=='R'){
				red_right=r;
				break;
			}
		}

		//左端を探す
		for(int l=white_left;l<n;l++){
			if(l==red_right){
				cout << ans << endl;
				return 0;
			}else if(s[l]=='W'){
				white_left=l;
				break;
			}
		}

		s[red_right]='W';
		s[white_left]='R';
		ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3724
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int n, c[500], f[500], s[500];

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

    for (int i = 0; i < n - 1; i++) {
        int t = 0;
        for (int j = i; j < n - 1; j++) {
            if (t < s[j]) t = s[j];
            else if (t % f[j] == 0);
            else t += f[j] - t % f[j];
            t += c[j];
        }
        cout << t << endl;
    }
    cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, A, B;
  scanf("%d%d%d", &n, &A, &B);
  int64 ret = 0;
  vector<int64> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
  }
  for (int i = 1; i < n; ++i) {
    ret += min((int64)B, A * (a[i] - a[i - 1]));
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 1024
(defun traveling (n tm x y)
  (let ((can  t)
        (dt   0)
        (dist 0))
    (dotimes (i n)
      (setf dt   (- (aref tm (+ i 1)) (aref tm i)))
      (setf dist (+ (abs (- (aref x (+ i 1)) (aref x i)))
                    (abs (- (aref y (+ i 1)) (aref y i)))))
      (if (< dt dist)
          (setf can nil))
      (if (not (= (rem dist 2) (rem dt 2)))
          (setf can nil)))
    (if (eq can t)
        "Yes"
        "No")))

(defun create-data ()
  (let ((n  (read))
        (tm (make-array '(110000) :initial-element 0))
        (x  (make-array '(110000) :initial-element 0))
        (y  (make-array '(110000) :initial-element 0)))
    (dotimes (i n)
      (setf (aref tm (1+ i)) (read))
      (setf (aref x (1+ i))  (read))
      (setf (aref y (1+ i))  (read)))
    (values n tm x y)))

(multiple-value-bind (n tm x y) (create-data)
  (format t "~A~%" (traveling n tm x y)))

Measured memory_bytes: 59748
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 200001;
const int MOD = 1000000007;

        signed main() {
  int n;
  cin>>n;
  int a[n],mxa=0;
  for(int i=0;i<n;i++){
          cin>>a[i];
          mxa=max(mxa,a[i]);
  }
  int z=1;while(z<=mxa)z*=2;
  int t[n],c[n]={};
  for(int i=0;i<n;i++){
          t[i]=a[i];
          while(t[i]<z){
                  t[i]*=2;c[i]++;
          }
  }
        int p[n]={},q[n]={};
        p[0]=0;
        for(int i=1;i<n;i++){
                if(2*p[i-1]+c[i]-c[i-1]<0){
                        p[i]=0;
                }else{
                        p[i]=p[i-1]+(c[i]-c[i-1])/2;
                        if(c[i]<c[i-1]&&(c[i]-c[i-1])%2!=0){continue;}
                        if(t[i-1]>t[i]||(c[i]-c[i-1])%2!=0)p[i]++;
                }
        }
        q[n-1]=0;
        for(int i=n-2;i>=0;i--){
                if(2*q[i+1]+c[i]-c[i+1]<0){
                        q[i]=0;
                }else{
                        q[i]=q[i+1]+(c[i]-c[i+1])/2;
                        if(c[i]<c[i+1]&&(c[i]-c[i+1])%2!=0){continue;}
                        if(t[i+1]>t[i]||(c[i]-c[i+1])%2!=0)q[i]++;
                }
        }
        int smp[n],smq[n];
        smp[n-1]=p[n-1];
        for(int i=n-2;i>=0;i--)smp[i]=smp[i+1]+p[i];
        smq[0]=q[0];
        for(int i=1;i<n;i++)smq[i]=smq[i-1]+q[i];
        pair<int,int>px[n],qx[n];
        for(int i=0;i<n;i++){
                px[i]=make_pair(p[i],i);
                qx[i]=make_pair(q[i],i);
        }sort(px,px+n);sort(qx,qx+n);
        int pi[n],qi[n];
       map<int,int> py,qy;
       
        decltype(py)::iterator it;
        for(int i=0;i<n;i++){
                it=py.lower_bound(px[i].second);
                if(it==py.end())pi[px[i].second]=n;
                else pi[px[i].second]=it->first;
                py.insert(make_pair(px[i].second,px[i].first));
        }
          for(int i=0;i<n;i++){
                it=qy.lower_bound(-1*qx[i].second);
                if(it==qy.end())qi[qx[i].second]=-1;
                else qi[qx[i].second]=-1*it->first;
                qy.insert(make_pair(-1*qx[i].second,qx[i].first));
        }
        int ansp[n],ansq[n];
        for(int i=n-1;i>=0;i--){
                ansp[i]=smp[i]-(pi[i]-i)*p[i];
                if(pi[i]!=n)ansp[i]+=ansp[pi[i]]-smp[pi[i]];
        }
        for(int i=0;i<n;i++){
                ansq[i]=smq[i]-(i-qi[i])*q[i];
                if(qi[i]!=-1)ansq[i]+=ansq[qi[i]]-smq[qi[i]];
        }
        int ans=min(2*ansp[0],n+2*ansq[n-1]);
       //cerr<<ansp[0]<<endl;
        for(int i=1;i<n;i++){
                ans=min(ans,2*ansp[i]+i+2*ansq[i-1]);
                //cerr<<ansp[i]+i+ansq[i-1]<<' '<<ansp[i]<<' '<<ansq[i-1]<<endl;
        }
       // cerr<<n+ansq[n-1]<<endl;
        cout<<ans<<endl;
       // for(int i=0;i<n;i++)cerr<<ansp[i]<<' '<<ansq[i]<<' '<<smq[i]<<endl;
         
       
      }


        


Measured memory_bytes: 48640
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 N, K;
  string S;
  cin >> N >> K >> S;
  i64 h = 0, l = 0, r = 0;
  while (l < N)
  {
    while (S[l] == S[r] && r < N)
      r++;
    h += r - l - 1;
    l = r;
  }
  cout << min(N - 1, h + 2 * K) << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<sstream>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define loop(i,a,b) for(i=(int)a;i<(int)b;i++)
#define revloop(i,a,b) for(i=(int)a;i>=(int)b;i--)
#define stloop(it,v) for(it=v.begin();it!=v.end();++it)
#define ii pair<int,int>
#define MP make_pair
#define pb push_back
#define f first
#define s second
#define ll long long int
#define PI acos(-1.0)
#define rs resize
int main()
{  std::ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int a,b,ans,i,idx,j,o;
   cin>>a>>b;
   vector<ii> v1(a),v2(b);
   loop(i,0,a)
    cin>>v1[i].f>>v1[i].s;
   loop(i,0,b)
    cin>>v2[i].f>>v2[i].s;
   loop(i,0,a)
   {
    ans=mod;
    loop(j,0,b)
    {
      o=abs(v1[i].f-v2[j].f)+abs(v1[i].s-v2[j].s);
      if(ans>o)
      {
       ans=o;
       idx=j;
      }
    }
    cout<<idx+1<<endl;
   }
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    int N;cin>>N;
    vector<int>a(N);
    vector<int>b(N);
    vector<int>c(N-1);
    int ans=0;
    rep(i,N){
        cin>>a.at(i);
    }
    rep(i,N){
        cin>>b.at(i);
    }
    rep(i,N-1){
        cin>>c.at(i);
    }
    rep(i,N){
        if(i!=0){
            if(a.at(i)-a.at(i-1)==1){
                ans+=c.at(a.at(i-1)-1);
            }
        }
        ans+=b.at(a.at(i)-1);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3608
p[5];i,j,f,t;*s;main(){for(;({for(f=t=i=0;i<5;f|=1<<p[i++])scanf("%d",&p[i]),t+=p[i];}),*p;)for(i=0;i<5;i++){for(j=0;j<5;j++)p[i]-p[j]?s=p[j]-p[i]-1&&p[j]-p[i]+2?"2":"1":0;puts(14^f&&t%5?s:"3");}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'a' = 97

int main()
{
    while (1) {
        string x;
        cin >> x;
        if (x == "0") break;
        int len = x.size();
        int sum = 0;
        rep(i, 0, len) sum += x[i] - '0';
        cout << sum << endl;
    }
    return 0;
}



Measured memory_bytes: 3184
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    vector<int> x(n);
    for(int i=0; i<k; i++){
        int d; cin >> d;
        for(int j=0; j<d; j++){
            int a; cin >> a;
            x[a-1] = 1;
        }
    }
    cout << n - accumulate(all(x), 0);
    cout << endl;
    return 0;
}

Measured memory_bytes: 3544
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int h, w, n, i, j;
	int d[10000];
	scanf("%d%d%d", &h, &w, &n);
	j=0;
	for(i=1; i<=n; i++){
		int a;
		scanf("%d", &a);
		for(a+=j; j<a; j++){
			d[j]=i;
		}
	}
	for(i=0; i<h; i++){
		if(i&1){
			for(j=0; j<w; j++){
				printf("%d ", d[i*w+j]);
			}
		}else{
			for(j=0; j<w; j++){
				printf("%d ", d[i*w+(w-j-1)]);
			}
		}
		putchar(10);
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll A, B , C , N ;
    cin >> A >> B >> C >> N;
    
    ll ans = 0;
    for(ll i = 0; i <= N/A+ 1; i++){
        ll rA = N - i * A;
        for(ll j = 0; j <= rA/B + 1; j++){
            ll rAB = rA - j * B;
            if(rAB < 0) continue;
            if(rAB % C  == 0) ans ++;
            
        }
    }
    cout << ans << endl;
    
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(auto& ai:a)cin>>ai;
  
  map<int,int64_t> mp;
  for(auto const& ai:a)mp[ai]++;
  
  constexpr int64_t mod = 1e9+7;
  
  if(n&1){
    bool ok = true;
    if(mp[0]!=1)ok=false;
    for(auto& [k,v]:mp){
      if(k%2!=0)ok=false;
      if(k!=0&&v!=2)ok=false;
    }
    if(!ok){cout<<0<<endl;return 0;}
    int64_t ans = 1;
    for(int i=0;i<n/2;++i)(ans*=2)%=mod;
    cout<<ans<<endl;
  }
  else{
    bool ok = true;
    for(auto& [k,v]:mp){
      if(k%2==0)ok=false;
      if(v!=2)ok=false;
    }
    if(!ok){cout<<0<<endl;return 0;}
    int64_t ans = 1;
    for(int i=0;i<n/2;++i)(ans*=2)%=mod;
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 7436
#include<iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  int i;
  int a[N];
  for(i=0 ; i<N ; i++){
    cin >> a[i];
  }

  int max = a[0];
  for(i=1 ; i<N ; i++){
    if(max < a[i])
      max = a[i];
  }

  int min = a[0];
  for(i=1 ; i<N ; i++){
    if(min > a[i])
      min = a[i];
  }

  cout <<max - min<<"\n";
}
  

Measured memory_bytes: 256
#import numpy as np

n = int(input())
a = list(map(int, input().split()))
#a = np.fromstring(input(), dtype=np.int32, sep=' ')

def calc(mode):
    d = 0
    s = 0
    for i in range(n):
        s += a[i]
        if (i+mode) & 1:
            if s >= 0:
                d += s + 1
                s = -1
        else:
            if s <= 0:
                d += abs(s) + 1
                s = 1
    return d


print(min(calc(0), calc(1)))


Measured memory_bytes: 14468
#include "bits/stdc++.h"
using namespace std;
#define ll long long;

int main(){
	int N;
	string S;
	cin >> N;
	cin >> S;
	char fc = S[0];
	string T(1,fc);
	for(int x=1;x<N/2+1;x++){
		if(S[x]==fc){
			T = S.substr(x, N);		
		}
	}
	if(S==T+T){
		cout << "Yes";

	}else{
		cout << "No";

	}

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

ll N, L;

int main(){
	cin >> N >> L;
	ll sum = 0;
	for(ll i = 1; i <= N; i++) {
		sum += L + i - 1;
	}


	ll mini = 100000;
	for(ll i = 1; i <= N; i++){
		ll tmp = 0;
		for(ll j = 1; j <= N; j++) {
			if(i == j)continue;
			tmp += L + j - 1;
		}
		if(abs(sum - mini)> abs(sum - tmp)) {
			mini = tmp;
		}
	}

	cout << mini << endl;

}


Measured memory_bytes: 3568
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        double t = 0.0;
        for (int i = 0; i < n; i++) {
            double p = sc.nextDouble();
            boolean b = sc.next().equals("BTC");

            if (b) {
                t += p * 380000.0;
            } else {
                t += p;
            }
        }

        System.out.println(t);
    }
}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pil;
typedef complex<double> xy_t;

const lint mod = 1e9 + 7;

int main(){
    int n;
    scanf("%d", &n);
    int c[n];
    rep(i, n) scanf("%d", &c[i]);

    lint dpsum[200010], dp[n];
    rep(i, 200010) dpsum[i] = 0;
    rep(i, n) dp[i] = 0;
    dpsum[c[0]] = 1;
    rep(i, n){
        dp[i] = dpsum[c[i]];
        if(i < n-1 && c[i] != c[i+1]){
            (dpsum[c[i+1]] += dp[i]) %= mod;
        }
    }

    printf("%lld\n", dp[n-1]);
}

Measured memory_bytes: 4096
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long X, Y;
  cin >> X >> Y;
  if (X % Y == 0) cout << -1 << endl;
  else cout << X << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def main():
    S = input()
    Q = int(input())
    flag = False
    head = []
    tail = []
    for n in range(Q):
        query = input()
        if query[0] == '1':
            flag = not flag
        elif query[0] == '2':
            command = query.split()
            F = int(command[1])
            C = command[2]
            if (not flag and F == 1) or (flag and F == 2):
                head.append(C)
            else:
                tail.append(C)
    result = ''.join(reversed(head)) + S + ''.join(tail)
    if flag:
        result = result[::-1]
    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 6252
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//素因数分解O(√n)
map<ll,ll>prime_factor(ll n){
  map<ll,ll>res;
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      res[i]++;
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}
int main(){
  ll n;cin>>n;
  map<ll,ll>M;
  for(ll i=1;i<=n;i++){
    map<ll,ll>M2=prime_factor(i);
    for(auto p:M2){
      M[p.first]+=p.second;
    }
  }
  map<ll,ll>ans;
  for(auto p:M){
    if(2<=p.second)ans[2]++;
    if(p.second>=4)ans[4]++;
    if(p.second>=14)ans[14]++;
    if(p.second>=24)ans[24]++;
    if(p.second>=74)ans[74]++;
  }
  ll last=0;
  last+=ans[4]*(ans[4]-1)/2*(ans[2]-ans[4]);
  last+=ans[4]*(ans[4]-1)*(ans[4]-2)/2;//2個と4個と4個のとき２つ区別できるから２！で割る
  last+=ans[14]*(ans[4]-1);
  last+=ans[24]*(ans[2]-1);
  last+=ans[74];
  cout<<last<<endl;
}

Measured memory_bytes: 256
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
1 2 2 2 1
2 4
5 1
3
'''

def solve(p,q,r,x,y):
	a,b,c = len(p),len(q),len(r)
	p = sorted(p)[::-1][:x]
	q = sorted(q)[::-1][:y]
	r = sorted(r)[::-1]
	t = p + q + r
	t = sorted(t)[::-1][:x+y]
	return sum(t)


X,Y,A,B,C = list(map(int, stdin.readline().rstrip().split()))
P = list(map(int, stdin.readline().rstrip().split()))
Q = list(map(int, stdin.readline().rstrip().split()))
R = list(map(int, stdin.readline().rstrip().split()))
ans = solve(P,Q,R,X,Y)
print(ans)


Measured memory_bytes: 108840
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
 
int gcd(int a, int b) {
  return b != 0 ? gcd(b, a % b) : a;
}
 
bool ck(int a, int b, int c)
{
    int t=b*b-4*a*c;
    for(int i=0; i*i<=t; i++)
        if(i*i==t) return true;
         
    return false;
}
 
int main()
{
    int a,b,c;
    while(scanf("%d%d%d", &a,&b,&c),(a||b||c))
    {
        if(b*b-4*a*c < 0 || !ck(a,b,c)) puts("Impossible");
        else
        {
            int p=2*a, r=2*a;
            int q=-(-b+sqrt(b*b-4*a*c));
            int s=-(-b-sqrt(b*b-4*a*c));
             
            int s1=gcd(p,q);
            int s2=gcd(r,s);
             
            p/=s1; q/=s1; r/=s2; s/=s2;
             
            if(p<0)
            {
                p*=-1; q*=-1;
            }
            if(r<0)
            {
                r*=-1; s*=-1;
            }
             
             
            if(p<r || (p==r&&q<s))
            {
                swap(p,r);
                swap(q,s);
                swap(s1,s2);
            }
            printf("%d %d %d %d\n", p,q,r,s);
        }
    }
}

Measured memory_bytes: 1044
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define get0(x)     (get<0>(x))
#define get1(x)     (get<1>(x))
#define get2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807LL
#define LLMIN       -9223372036854775808LL
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;
using namespace std;

LL N,M;
vector<int> G[100000];
int dist[100000];
int isOddCycle=0;

int dfs(int v,int p,int d){
    if(dist[v]==-1){
        dist[v]=d;
        REP(i,SZ(G[v])){
            if(G[v][i]!=p){
                dfs(G[v][i],v,d+1);
            }
        }
    }
}

int main(void){
    cin>>N>>M;
    REP(i,M){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    fill(dist,dist+100000,-1);
    dfs(0,-1,0);
    REP(i,N)
        REP(j,SZ(G[i])){
            if((dist[i]-dist[G[i][j]])%2==0)
                isOddCycle=1;
        }
    // printf("isOddCycle=%d\n",isOddCycle);

    if(isOddCycle){
        cout<<N*(N-1)/2-M<<endl;
    }else{
        LL nOddNode=0,nEvenNode=0;
        REP(i,N){
            if(dist[i]%2==0)
                nOddNode++;
            else
                nEvenNode++;
        }
       cout<<nOddNode*nEvenNode-M<<endl;
    }
     return 0;
}

Measured memory_bytes: 7680
object Main extends App {

  val k = 10000

  def countingSort(A: Array[Int]): Array[Int] = {
    val C = new Array[Int](k + 1)

    for (e <- A)
      C(e) = C(e) + 1

    for (i <- 1 to k)
      C(i) = C(i) + C(i - 1)

    val B = new Array[Int](A.size)
    for (e <- A) {
      B(C(e) - 1) = e
      C(e) = C(e) - 1
    }

    B
  }

  val sc = new java.util.Scanner(Console.in)

  def readInt() = sc.next().toInt

  val ary = Array.fill(readInt())(readInt())
  println(countingSort(ary) mkString " ")
}



Measured memory_bytes: 491588
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){

			long N = scan.nextLong();
			long K = scan.nextLong();
			long S = scan.nextLong();


			long count = 0;

			for(int i = 0;i<K;i++) {
				if(i==K-1&&K== N) {
					System.out.print(S);
				}else {

					System.out.print(S+" ");
				}
			}
			for(long i= K;i<N;i++) {

				if(i==N-1) {
					if(S!=1000000000)
						System.out.print((S+1));
					else
						System.out.print(1);

				}else {
					if(S!=1000000000)
					System.out.print((S+1)+" ");
					else
						System.out.println(1);
				}




				}


		}


	}


}


Measured memory_bytes: 53596
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<algorithm>

void echo_index(std::multimap<std::string,int> &index);
void echo_page(std::vector<int> &chunk_page);

//------------------------------main----------------------------------
int main()
{
	using namespace std;
	
	string ward;
	int page;
	
	multimap<string,int> index;
	
	for(;1;)
	{
		cin>>ward>>page;
		if(cin.eof())
		{
			echo_index(index);
			break;
		}
		index.insert(pair<string,int>(ward,page));
	}
	
	return 0;
}
//------------------------------------------------------------

void echo_index(std::multimap<std::string,int> &index)
{
	using namespace std;
	
	multimap<string,int>::iterator itr;
	vector<int> chunk_page;
	
	itr=index.begin();
	string pre_ward=itr->first;
	cout<<itr->first<<endl;
	chunk_page.push_back(itr->second);
	++itr;
	
	for(;itr!=index.end();++itr)
	{
		if(pre_ward==itr->first)
		{
			chunk_page.push_back(itr->second);
		}
		else
		{
			echo_page(chunk_page);
			cout<<itr->first<<endl;
			chunk_page.push_back(itr->second);
		}
		pre_ward=itr->first;
	}
	
	echo_page(chunk_page);
}

void echo_page(std::vector<int> &chunk_page)
{
	using namespace std;
	
	sort(chunk_page.begin(),chunk_page.end());
	
	vector<int>::iterator itr;
	itr=chunk_page.begin();
	cout<<*itr;
	++itr;
	
	for(;itr!=chunk_page.end();++itr)
	{
		cout<<" "<<*itr;
	}
	cout<<endl;
	
	chunk_page.clear();
}

Measured memory_bytes: 1244
/* Simplicity and Goodness */

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) { cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=a; i<(int)b; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int maxN = 2e5+2;


void solve()
{   
    int n, x, t;
    cin >> n >> x >> t;

    int c = (n + x - 1) / x;

    c *= t;

    prin(c);   
}

int main()
{
    int t = 1;
    // scn(t);
    
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3760
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n;
  int array[200005];
  int maxim=0;
  bool divisible[1000005]={false};
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>array[i];
    maxim=max(array[i],maxim);
  }
  sort(array,array+n);
  
  int cnt=0;
  for(int i=0;i<n;i++){
    int pos=array[i];
    if(divisible[pos]==false){
      if(array[i]!=array[i+1]){
	cnt++;
      }
      for(int j=pos;j<=maxim;j+=pos){
	divisible[j]=true;
      }
    }
  }
  cout<<cnt<<endl;
  return(0);
}

Measured memory_bytes: 5384
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        long n = long.Parse(Console.ReadLine());
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();

        var dic = new Dictionary<long, long>() { };
        for (int i = 0; i < n; i++)
        {
            if (!dic.ContainsKey(a[i]))
            {
                dic.Add(a[i], 1);
            }
            else
            {
                dic[a[i]]++;
            }
        }

        long ans = 0;
        foreach (var item in dic)
        {
            if (item.Value != item.Key)
            {
                if (item.Value > item.Key)
                {
                    ans += Math.Abs(item.Value - item.Key);
                }
                else
                {
                    ans += item.Value;
                }
            }
        }

        Console.WriteLine(ans);
    }
}


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

void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) R a[i];
  sort(a,a+n);
  pr(a[n-1]-a[0]);
}

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


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

int main() {
	int n;
	cin>>n;
	int a[n];
	int ans=100;
	for(int i=0;i<n;i++){
		cin>>a[i];
		int pow=0;
		while(a[i]%2==0){
			pow++;
			a[i]=a[i]/2;
		}
		if(ans>pow)ans=pow;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split(" ")))
b = list(map(int,input().split(" ")))
c = list(map(int,input().split(" ")))
#アルゴリズムわからないけどN log N?
a.sort()
b.sort()
c.sort()

#O(N)?
i,j,k = 0,0,0
ans = 0
while j < N:
  while i < N and a[i]<b[j] :
    i += 1
  while k < N and c[k]<=b[j]:
    k += 1
  ans += i * (N - k)
  j += 1

print(ans)

Measured memory_bytes: 23328
#include <stdio.h>
int main(){
int a[101]={0},temp,top=0;
while(scanf("%d",&temp)!=EOF){
a[temp]++;
}
for(int i=1;i<101;i++){
if(a[i]>top)top=a[i];
}
for(int i=1;i<101;i++)if(a[i]==top)printf("%d\n",i);
}

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

int main() {
	int a,b,n,s,i;
	
	while(cin>>a>>b>>n){
		
		a=(a%b)*10;
		
		for(s=0,i=n;i;--i){
			s += a/b;
			a = a%b;
			a*=10;
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0 && a[i] % 2 == 1) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  if (s == "RRR") cout << 3 << endl;
  else if (s == "RRS" || s == "SRR") cout << 2 << endl;
  else if (s == "SSS") cout << 0 << endl;
  else cout << 1 << endl;
}

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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

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

	int n, k;
	cin >> n >> k;

	LD ans = 0.0;
	for (int i = 1; i <= n; i++) {
		int steps = 0;
		while ((i<<steps) < k) steps++;
		//cout << i << " " << steps << "\n";
		LD tmp = (LD) 1.0 / n;
		while (steps--) tmp /= (LD) 2.0;
		ans += tmp;
	}

	cout << fixed << setprecision(15);
	cout << ans << "\n";
    return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int h[n+1];
    for(int i = 1; i <= n; i++)
        cin >> h[i];
    int dp[n+1];
    dp[1] = 0;
    dp[2] = abs(h[1]-h[2]);
    for(int i = 3; i <= n; i++){
        dp[i] = abs(h[i]-h[i-1]) + dp[i-1];
        dp[i] = min(dp[i], abs(h[i]-h[i-2]) + dp[i-2]);
    }
    cout << dp[n] << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
typedef long long ll;
 
int main(){
    ll H,W;
    cin>>H>>W;
    vector<VL> a(H,vector<ll>(W,0));
    rep(i,0,H)rep(j,0,W)cin>>a[i][j];
    ll ans=0;
	vector<ll> ys, xs, yg, xg;
	rep(i,0,H){
		rep(j,0,W){
			if(i==H-1 && j==W-1) break;
			if(a[i][j]%2==1){
				ans++;
				if(j!=W-1){
					a[i][j]--;
					a[i][j+1]++;
					ys.emplace_back(i+1);
					xs.emplace_back(j+1);
					yg.emplace_back(i+1);
					xg.emplace_back(j+2);
				}
				else{
					a[i][j]--;
					a[i+1][j]++;
					ys.emplace_back(i+1);
					xs.emplace_back(j+1);
					yg.emplace_back(i+2);
					xg.emplace_back(j+1);
				}
			}
		}
	}
	cout << ans << endl;
	rep(i,0,ans) cout<<ys[i]<<" "<<xs[i]<<" "<<yg[i]<<" "<<xg[i]<<endl;
 
	return 0;
}

Measured memory_bytes: 8152
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define maxn 300005
#define LL long long
using namespace std;

int n,m;
LL cst[maxn],f[maxn],g[maxn],y[maxn],Q[maxn],sum[maxn],h[maxn],tmp[maxn],L,R;
inline bool check1(int a,int b,int k){
	return y[b] - y[a] < 1ll * (b - a) * k; }
inline bool check2(int a,int b,int k){ return 1ll * (k - b) * (y[k] - y[a]) - 1ll * (k - a) * (y[k] - y[b]) < 0; }
inline void shift(int b,int a,LL f[])
{

	f[b] = max(f[b] , f[a] + 1ll * (b - a) * (b - a + 1) / 2ll - sum[b] + sum[a]);

}

void DP(LL f[])
{
	L=R=0,Q[R++] = 0;
	for(int i=1;i<=n;i++)
	{
		sum[i] = sum[i-1] + cst[i];
		for(;L<R-1 && check1(Q[R-2],Q[R-1],i);R--);
		f[i] = f[i-1];
		shift(i,Q[R-1],f);
		y[i] = f[i] + 1ll * i * (i-1) / 2 + sum[i];
		for(;L<R-1 && check2(Q[R-2],Q[R-1],i);R--);
		Q[R++] = i;
	}
}

inline void Rev(LL f[]){ for(int i=1;i<=n/2;i++) swap(f[i] , f[n-i+1]); }

void Solve(LL *f,LL *g,int l,int r)
{
	if(l==r){ h[l] = max(h[l] , f[l-1] + g[l+1] - cst[l] + 1); return; }
    if(l>r) return;
    int mid = (l+r)>>1;
    L=R=0;
	for(int i=l-1;i<=r;i++)
	{
		for(;L<R-1 && check2(Q[R-2],Q[R-1],i);R--);
        if(i<mid) Q[R++] = i , tmp[i] = f[i];
		else tmp[i] = -0x3f3f3f3f3f3f3f3f , tmp[i] = max(tmp[i] , f[Q[R-1]] + 1ll * (i - Q[R-1]) * (i - Q[R-1] + 1) / 2ll - sum[i] + sum[Q[R-1]] + g[i+1]);
	}

	for(int i=r-1;i>=mid;i--) tmp[i] = max(tmp[i] , tmp[i+1]);
	for(int i=r;i>=mid;i--) h[i] = max(h[i] , tmp[i]);

	Solve(f,g,l,mid) , Solve(f,g,mid+1,r);
}

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

	Rev(cst) , DP(g) , Rev(g) , Rev(cst) , DP(f);
	memset(h,-0x3f,sizeof h);
	Solve(f,g,1,n);
	Rev(cst) , Rev(g) , Rev(f) , Rev(h);
	for(int i=1;i<=n;i++) sum[i] = sum[i-1] + cst[i] , y[i] = g[i] + 1ll * i * (i-1) / 2 + sum[i];
	Solve(g,f,1,n);
	Rev(h) , Rev(f) , Rev(g) , Rev(cst);


	for(int u,v;m--;)
	{
		scanf("%d%d",&u,&v);
		printf("%lld\n",max(f[u-1] + g[u+1] , h[u] - (v - cst[u])));
	}
}


Measured memory_bytes: 21248