akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int a,b;
  
 cin>>a>>b;
  if(a>1&&b>1){
    if(a>b){
      cout<<"Alice"<<endl;
    }
    if(a<b){
      cout<<"Bob"<<endl;
    }
    if(a==b){
      cout<<"Draw"<<endl;
    }
  }
  
  else if(a==1&&b>1){
    cout<<"Alice"<<endl;
  }
  else if(a!=1&&b==1){
    cout<<"Bob"<<endl;
  }
  else if(a==1&&b==1){
    cout<<"Draw"<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

#define max(a,b) (a < b ? b : a)

int main(){
  int A = 0,B = 0,in,i;
  for(i = 0 ; i < 4 ; i++){
    scanf("%d",&in);
    A += in;
  }
  for(i = 0 ; i < 4 ; i++){
    scanf("%d",&in);
    B += in;
  }
  printf("%d\n",max(A,B));
  return 0;
}

Measured memory_bytes: 592
#include<iostream>

using namespace std;

#define MAX 100000

int main(){

	int n,k,a[MAX];
	long long num,max;

	while(1){

		cin>>n>>k;
		if(n==0&&k==0) break;

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

		num=0;
		for(int j=0;j<k;j++){
			num+=a[j];
		}
		max=num;

		for(int i=0;i<n-k;i++){
			num-=a[i];
			num+=a[i+k];
			max=(max<num)?num:max;
		}
		
		cout<<max<<endl;
		
	}

	return 0;
}

Measured memory_bytes: 1544
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()
int main(){
  int h,w,k;cin>>h>>w>>k;vector<vector<int>> c(h,vector<int>(w));
  int i,j,l,n,p;
  rep(i,h)rep(j,w){
    char ch;cin>>ch;
    c[i][j]=(ch-'0');
  }
  int ans=0;
  rep(i,h)rep(j,w){
    bool update=1;vector<vector<int>> m=c;
    m[i][j]=0;int score=0,timev=1;
    while(update) {
      update=0;
      rep(n,w){
        int to=h-1;
        for(l=h-1;l>=0;l--){
          if(m[l][n]!=0){
            swap(m[to][n],m[l][n]);to--;
          }
        }
      }
      int get=0;
      rep(l,h){
        int from=0,now=m[l][w-1];
        rep(n,w){
          if(now!=m[l][n]){
            int dis=(n-1)-from+1;
            if(dis>=k){
              for(p=from;p<n;p++) {
                get+=m[l][p];m[l][p]=0;
              }
            }from=n;now=m[l][n];
          }
        }
        int dis=(w-1)-from+1;
        if(dis>=k){
          for(p=from;p<n;p++){
            get+=m[l][p];m[l][p]=0;
          }
        }
      }
      if(get>0)update=1;
      else break;
      score+=timev*get; timev*=2;
    }ans=max(ans,score);
  }cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+20 , SIZE = 1020 , Mod = 1e9+7;
int n,m,p[SIZE],a[SIZE],cnt,fac[2*N],inv[2*N],Max,ans;
inline int quickpow(int a,int b)
{
    int res = 1;
    for (;b;a=1LL*a*a%Mod,b>>=1)
        if ( 1 & b ) res = 1LL * res * a % Mod;
    return res;
}
inline int C(int a,int b) { return 1LL * fac[a] * inv[b] % Mod * inv[a-b] % Mod; }
int main(void)
{
    scanf("%d%d",&n,&m);
    int val = m;
    for (int i=2;i*i<=val;i++)
        if ( m % i == 0 )
        {
            p[++cnt] = i;
            while ( m % i == 0 )
                m /= i , Max = max( Max , ++a[cnt] );
        }
    if ( m > 1 ) p[++cnt] = m , Max = max( Max , a[cnt] = 1 );
    fac[0] = inv[0] = 1LL;
    for (int i=1;i<=n+Max;i++)
        fac[i] = 1LL * fac[i-1] * i % Mod;
    inv[n+Max] = quickpow( fac[n+Max] , Mod-2 );
    for (int i=n+Max-1;i>=1;i--)
        inv[i] = 1LL * inv[i+1] * ( i + 1 ) % Mod;
    ans = 1LL;
    for (int i=1;i<=cnt;i++)
        ans = 1LL * ans * C( a[i] + n - 1 , n - 1 ) % Mod;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
#define first fi
#define second se
using namespace std;
int sdkys(int a,int b){
    if(b==0) return a;
    return sdkys(b,a%b);
}
int sskbs(int a,int b){
    return a*b/sdkys(a,b);
}
int sosu(int a){
    if(a==2){
        return 1;
    }
    for(int i=2;i<sqrt(a)+1;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}
vector<int> v;
int n,m,cnt=0,ans=0,aa[220000];
pair<int,int> pp[220000];
string s,ss[220000],sa;
char ch[110][110];
queue<int> que;
signed main(){
    cin>>n>>m;
    cout<<((n-m)*100+m*1900)*pow(2,m)<<endl;
}

Measured memory_bytes: 11012
#include <stdio.h>
#include <string.h>

#define N 100000

int main() {
	static char s[N + 1];
	int n, i, p, g, ans;

	scanf("%s", s);
	n = strlen(s);
	ans = p = g = 0;
	for (i = 0; i < n; i++)
		if (s[i] == 'g')
			if (p < g)
				ans++, p++;
			else
				g++;
		else
			if (p < g)
				p++;
			else
				ans--, g++;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
	int  N,i,cnt=0;

//入力
    scanf("%d",&N);
    char S[N];

    scanf("%s",S);

 for(i=0;i<N-2;i++) {
        if(S[i]!='A')   continue;
	    if(S[i+1]!='B') continue;
	    if(S[i+2]!='C') continue;
	cnt++;
 }

printf("\n%d",cnt);
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int> dp(n+1,0);
	FOR(i,1,n+1){
		dp[i]=dp[i-1]+1;
		int now=6;
		while(now<=i){
			chmin(dp[i],dp[i-now]+1);
			now*=6;
		}
		now=9;
		while(now<=i){
			chmin(dp[i],dp[i-now]+1);
			now*=9;
		}
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cmath>
#include <string>

#define rep( i, n, m ) for (int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for (int i = ( n ); i < ( m ); i--)

int main( void ){
	int num = 0;
	if (!scanf( "%d", &num ))
		return -1;
	rep( i, 0, num ){
		static int a, b, c, a_pre = 0, b_pre = 0, c_pre = 0;
		if (!scanf( "%d %d %d", &a, &b, &c ))
			return -1;
		int r = a - a_pre;
		int dif_x = abs( b - b_pre );
		int dif_y = abs( c - c_pre );
		if ((( dif_x + dif_y ) > r ) || ( dif_x + dif_y ) % 2 != r % 2){
			printf("No\n");
			return 0;
		}
		a_pre = a;
		b_pre = b;
		c_pre = c;
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	string b = "";
	while (N) {
		int s = N % 2;
		if (s < 0) s += 2;
		//cout << s << endl;
		if (s == 1) b.push_back('1');
		else b.push_back('0');
		N = (N - s) / -2;
	}

	if (b == "") b = '0';
	reverse(b.begin(), b.end());

	cout << b << endl;
}

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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());

        if (A % 2 == 0 || B % 2 == 0) {
            out.printf("No\n");
        } else {
            out.printf("Yes\n");
        }
        out.flush();
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}
Int tmpi = 0;
double tmpd = 0.0;


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

    Int n, m, a, b;
    multimap<Int, Int> mp;

    cin >> n >> m;
    for(Int i=0; i<n; i++){
        cin >> a >> b;
        mp.insert(make_pair(a, b));
    }

    typename map<Int, Int>::iterator it = begin(mp);

    Int cnt = 0;
    Int ans = 0;
    while(cnt < m){
        pair<Int, Int> p = *it;
        Int money = p.first;
        Int limit = p.second;
        for(Int i=0; i<limit; i++){
            if(cnt >= m){
                break;
            }
            ans += money; 
            cnt++;
        }
        it++;
    }
    cout << ans << endl;

    return 0;
}

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


  int xj[100001]={},yj[100001]={};
signed main() {
    int n;
    cin>>n;
  int x,y;
 
 for(int i=0;i<100001;i++){
     xj[i]=-1*n;yj[i]=-2*n;
 }
  pair<int,int> l[n]; 
  int p[n]={},q[n]={};
  for(int i=0;i<n;i++){
      cin>>x>>y;
      l[i]=make_pair(x,y);
    while(xj[x]>0)x=xj[x];
    while(yj[y]>0)y=yj[y];
    if(xj[x]!=yj[y]){
    if(xj[x]>-1*n){
        if(yj[y]>-1*n){
            p[-1*xj[x]]+=p[-1*yj[y]];
            p[-1*yj[y]]=0;
            q[-1*xj[x]]+=q[-1*yj[y]];
            q[-1*yj[y]]=0;
            xj[l[-1*yj[y]].first]=l[-1*xj[x]].first;
            yj[l[-1*yj[y]].second]=l[-1*xj[x]].second;
        
        }else {p[-1*xj[x]]++;
         yj[y]=l[-1*xj[x]].second;}

  }else{
      if(yj[y]>-1*n){
          q[-1*yj[y]]++;
          xj[x]=l[-1*yj[y]].first;
      }else{
          p[i]++;
          q[i]++;
          xj[x]=-1*i;
          yj[y]=-1*i;
      }
  }
  }
  }
  int ans=0;
  for(int i=0;i<n;i++){
      ans+=p[i]*q[i];
     
  }
  cout<<ans-n;


    return 0;


}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define rgi register int
#define ll long long
class fastin{
	private: int _ch,_f;
	public: template<typename _Tp> inline fastin& operator>>(_Tp&_x){
		_x=0; while(!isdigit(_ch)) _f|=(_ch==45),_ch=getchar();
		while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
		_f&&(_x=-_x,_f=0); return *this;}
	fastin() {_ch=_f=0;}
}fin;
class fastout{
	private: int _num[32],_head;
	public: int SUF; template<typename _Tp> inline fastout& operator<<(_Tp _x){
		_Tp _k; if(_x==0) {putchar('0'),putchar(SUF);return *this;} if(_x<0) putchar('-'),_x=-_x;
		while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
		while(_head>0) putchar(_num[_head]),--_head; putchar(SUF); return *this;}
	fastout() {_head=0,SUF=' ';}
}fout;
// ----------------------------
// #define int ll
// using namespace std;
const int maxn=200004;
const int mod=998244353,inf=1000000007;

double t;

signed main()
{
	int l;
	fin>>l;
	t=l; t/=3;
	printf("%.12lf",t*t*t);
	return 0;
}
// ----------------------------
// by imzzy


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;


int main()
{
    string s, t;
    int count = 0;
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++) {
        if(s.at(i) != t.at(i))
            count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, l, r;
  cin >> N;
  int sum = 0;
  for( int i = 0; i < N; i++){
    cin >> l >> r;
    sum += r - l + 1;
    
    }
  cout << sum;
}  
    

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>

int n, m;

int W[100000];
bool A[100000];

int main(){
  scanf("%d%d", &n, &m);
  for(int i = 0; i < m; i++){
    int p;
    char s[10];
    scanf("%d", &p);
    scanf("%s", s);
    p--;
    if(!std::strcmp(s, "WA")){
      if(!A[p]) W[p]++;
    }
    else {
      A[p] = true;
    }
  }
  int ac = 0;
  int wa = 0;
  for(int i = 0; i < n; i++){
    ac += A[i];
    if(A[i]) wa += W[i];
  }
  printf("%d %d\n", ac, wa);

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll a,b,v,w,t;
	cin>>a>>v>>b>>w>>t;
	if(a==b){
		cout << "YES";
		return 0;
	}
	if(v<=w){
		cout << "NO";
		return 0;
	}
	ll len=abs(w-v)*t;
	if(len>=abs(a-b)){
		cout << "YES";
	}
	else{
		cout << "NO";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main()
{
	int a, b, c;
	int max, min, total;
	scanf("%d %d %d", &a, &b, &c);
	
	total = a + b + c;
	
    if (a > b && a > c)
    {
    	max = a;
    }
    else if (b > a && b > c)
    {
    	max = b;
    }
    else
    {
    	max = c;
    }
    if (a < b && a < c)
    {
    	min = a;
    }
    else if (b < a && b < c)
    {
    	min = b;
    }
    else
    {
    	min = c;
    }
    
    
    printf("%d %d %d\n", min, (total - min - max), max);
		
	return 0;
	
} 


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#include <stdio.h>
#include <vector>
#include <algorithm> // sort
#include <map>
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]-=i+1;
    }
    sort(a.begin(),a.end());
    int m=a[n/2];
    long long int s;
    for(int i=0;i<n;i++){
        s+=max(a[i]-m,m-a[i]);
    }
    cout<<s<<endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
	int n, m, target[100], i, j, num, friend[100] = {0}, x = 0;
	scanf("%d %d", &n, &m);
	for (i = 0; i < m; i++){
		scanf("%d", &target[i]);
	}
	for (i = 0; i < m; i++){
		for (j = 0; j < n; j++){
			scanf("%d", &num);
			if (num == target[i])
				friend[j] += 1;
			else friend[target[i]-1]++;
		}
	}
	for (i = 0; i < n; i++)
		printf("%d\n", friend[i]);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 200006;
vector<int> E[N];
vector<int> seen(N, false);
int cnt = 0;

void dfs(int node) {
	seen[node] = true;
	cnt += 1;
	for(auto it : E[node]) {
		if(!seen[it]) {
			dfs(it);
		}
	}
}

int main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= m; i++) {
		int x, y;
		cin >> x >> y;
		E[x].push_back(y);
		E[y].push_back(x);
	}
	
	vector<int> sz;
	
	for(int i = 1; i <= n; i++) {
		if(!seen[i]) {
			cnt = 0;
			dfs(i);
			sz.push_back(cnt);
			
		}
	}
	
	sort(sz.begin(), sz.end());
	int ans = 0;
	int rem = 0;
	
	for(auto &it : sz) {
		it -= rem;
		ans += it;
		rem += it;
	}
	
	cout << ans << '\n';
	
	return 0;
}


Measured memory_bytes: 20960
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc107_a
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int i = int.Parse(input[1]);


            Console.WriteLine(N-i+1);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 11092
//
//  main.swift
//
//  Created by sun-yryr
//  Copyright © 2019 sun-yryr. All rights reserved.
//

import Foundation

prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}


func readInt(separator s: Character = " ") -> [Int] {return readLine()!.split(separator: s).map({Int($0)!})}
func readDouble(separator s: Character = " ") -> [Double] {return readLine()!.split(separator: s).map({Double($0)!})}
func readElement(separator s: Character = " ") -> [String] {return readLine()!.split(separator: s).map({String($0)})}

extension String {
    func at(_ i: Int) -> Character {
        precondition(0 <= i && i < self.count)
        return self[self.index(self.startIndex, offsetBy: i)]
    }
}

func main() {
    let (N, M, K) = *readInt()
    var A = readInt()
    var B = readInt()
    var ruisekiA = [0]
    var ruisekiB = [0]
    for i in 0..<N {
        ruisekiA.append(ruisekiA[i] + A[i])
    }
    for i in 0..<M {
        ruisekiB.append(ruisekiB[i] + B[i])
    }
    var bestBi = 0
    // i = 0
    for j in (0...M).reversed() {
        if (ruisekiB[j] <= K) {
            bestBi = j
            break
        }
    }
    var ans = bestBi
    for i in 1...N {
        if (ruisekiA[i] > K) {
            break
        }
        for j in (0...bestBi).reversed() {
            if (ruisekiA[i] + ruisekiB[j] <= K) {
                ans = max(ans, i+j)
                bestBi = j
                break
            }
        }
    }
    print(ans)
}
main()


Measured memory_bytes: 31712
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define msg(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define pri(a) cout << a << endl;

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

  ll n,ans=0;
  cin >> n;

  rep(i,500000){
    if(i*108/100==n){
      cout << i << endl;
      return 0;
    }
  }

  cout << ":(" << endl;

  // ans = n*100/108;
  //
  // if(ans*108/100==n){
  //   cout << ans << endl;
  // }
  // else{
  //   cout << ":(" << endl;
  // }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
using namespace std;

int main(){
  int N, M;
  string s;
  set<string> key;
  
  cin >> N;
  for(int i = 0 ; i < N ; i++){
    cin >> s;
    key.insert(s);
  }
  
  cin >> M;
  bool flag = false;
  for(int i = 0 ; i < M ; i++){
    cin >> s;
    if(key.find(s) == key.end()){
      cout << "Unknown " << s << endl;
    }
    else{
      if(!flag){
	flag = true;
	cout << "Opened by " << s << endl;
      }
      else{
	flag = false;
	cout << "Closed by " << s << endl;
      }
    }
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>

int main(){
    int N; cin >> N;
    map<int,int> mp;
    vector<int> v;
    for(int n=2;n<=N;++n){
        int temp = n;
        int x = 2;
        while(temp>1){
            if(temp%x==0){
                ++mp[x];
                if(mp[x]==1){ v.push_back(x); }
                temp /= x;
            }
            else{ ++x; }
        }
    }
    ll ans = 1;
    for(int x:v){
        ans *= (mp[x]+1);
        ans %= MOD;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#ifndef ONLINE_JUDGE
#define tr(...) {__l(__LINE__);__f(#__VA_ARGS__, __VA_ARGS__);}
inline void __l(int line) { cerr << "#" << line << ": "; }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...);}
#else
#define tr(...)
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}
const int N = 5*(int)1e5 + 10;
// make sure N size is correctttt!!!!!!!!!


int n;
string s;

int32_t main(){_

   cin>>s;

   n = sz(s);
   s = '*' + s;

   if(s.back() == '1' or s[1] == '0'){
      cout<<-1;
      return 0;
   }

   for (int i = 1; i < n; ++i)
   {
      if(s[i] != s[n-i]){
         cout<<-1;
         return 0;
      }
   }

   int root = 1;
   for (int i = 2; i <= n; ++i)
   {
      if(s[i] == '1'){  
         for (int j = root+1; j <= i+1; ++j)
            cout<<root<<' '<<j<<endl;
         root = i+1;
      }
   }

   for (int i = root+1; i <= n; ++i)
   {
      cout<<root<<' '<<i<<endl;
   }

   //make sure N size is correct!!!!!!!!!
   return 0;
} 

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

int main() {
    int N, K;
    std::cin >> N >> K;

    int l[N];
    for (int i = 0; i < N; ++i) {
        std::cin >> l[i];
    }
    
    std::sort(l, l + N, std::greater<int>());

    int ans = 0;
    for (int i = 0; i < K; ++i) {
        ans += l[i];
    }

    std::cout << ans << std::endl; 

    return 0;
}


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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;
using li=list<int>;
using lil=list<ll>;
using lis=list<string>;
using fli=forward_list<int>;
using fll=forward_list<ll>;
using fls=forward_list<string>;
using si=stack<int>;
using sl=stack<ll>;
using ss=stack<string>;
using qi=queue<int>;
using ql=queue<ll>;
using qs=queue<string>;
using pqi=priority_queue<int>;
using pql=priority_queue<ll>;
using pqs=priority_queue<string>;
using dqi=deque<int>;
using dql=deque<ll>;
using dqs=deque<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define repr(i, n) for(int i = (n); i >= 0; i--)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

template<typename T,typename U>
void Printarray2(T f,U n){
  for(int i=0;i<n;i++) cout<<f[i]<<endl;
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int a,p;cin>>a>>p;
  cout<<(a*3+p)/2<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n,x;
  cin>>n>>x;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  Int s=0;
  for(Int i=0;i<n;i++) s+=a[i];
  if(x>=s){
    cout<<n-(x!=s)<<endl;
    return 0;
  }
  sort(a.begin(),a.end());
  Int ans=0;
  for(Int i=0;i<n;i++){
    if(x>=a[i]) x-=a[i],ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 768
N = int(input())
L = list(map(int,input().split()))
count = 0
m = 0
for i in range(1,N):
    if L[i-1] >= L[i]:
        count += 1
    else:
        m = max([count,m])
        count = 0
m = max([count,m])
print(m)


Measured memory_bytes: 15020
first = True

while 1:
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        break

    if first:
        first = False
    else:
        print()

    anslist = []
    for i in range(a, b+1):
        if i % 400 == 0:
            anslist.append(i)
        elif i % 100 == 0:
            pass
        elif i % 4 == 0:
            anslist.append(i)

    if anslist == []:
        print("NA")
    else:
        for ans in anslist:
            print(ans)


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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n - 1; i++) {
        int x; cin >> x; p[x - 1]++;
    }
    for (int x : p) cout << x << "\n";
    
    return 0;
}

Measured memory_bytes: 4012
D, G = gets.split.map(&:to_i)

p = []
c = []

D.times do |i|
  p[i], c[i] = gets.split.map(&:to_i)
end

ans = Float::INFINITY

0.upto((1<<D)-1) do |s|
  count = 0
  sum = 0
  0.upto(D-1) do |i|
    if s & 1<<i > 0
      sum += 100*(i+1)*p[i] + c[i]
      count += p[i]
    end
  end

  if sum < G
    (D-1).downto(0) do |i|
      if s & 1<<i == 0
        tmp = ((G-sum).to_f/(100*(i+1))).ceil
        count +=
          if tmp >= p[i]
            Float::INFINITY
          else
            tmp
          end
        break
      end
    end
  end
  ans = count if ans > count
end

puts ans


Measured memory_bytes: 3836
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,x,t,i,j,res=0;
  cin >> a >> b >> c >> x;
  x/=50;
  for(i=0;i<=a;i++){
    t=x-i*10;
    if(t<0) break;
    if(t>2*b+c) continue;
    for(j=0;j<=b;j++){
      if(t-2*j<0) break;
      if(t-2*j<=c) res++;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cassert>

using namespace std;
#define int long long
#define repeat(i,n) for(int i=0;i<(n);i++)
const int u=1e16+1000;

signed main(){
  int k; cin>> k;
  int n=50;
  vector<int> a;
  repeat(i, k%n) a.push_back(n-i);
  while(a.size()<n) a.push_back(n-k%n-1);
  cout<< n<< endl;
  repeat(i, n){
    assert(0<=a[i] and a[i]<=u);
    if(i){
      cout<< " "<< a[i]+k/n;
    }else{
      cout<< a[i]+k/n;
    }
  }cout<< endl;
  return 0;
}
/*
6 5 3 3
2 6 4 4
3 2 5 5
4 3 1 6
5 4 2 2
1 5 3 3
2 1 4 4

4 3 3 3
0 4 4 4
1 0 5 5
2 1 1 6
3 2 2 2


5 4 2 2 2
0 5 3 3 3
1 0 4 4 4

5 4 3 1 1

5 4 3 2 0

4 3 1 1
0 4 2 2
1 0 3 3

5 4 2 2
1 5 3 3
2 1 4 4
3 2 0 5
4 3 1 1
*/

/*

N, N-1, ..., remainder: 0<=R<N-K%N
num of rem = N-K%N
plus K/N for [1, N]

*/


Measured memory_bytes: 256
import collections
n=int(input())
a = list(map(int, input().split()))
q=int(input())
sum=sum(a)
c=collections.Counter(a)
for i in range(q):
    b=list(map(int, input().split()))
    sum=sum+(b[1]-b[0])*c[b[0]]
    print(sum)
    c[b[1]]+=c[b[0]]
    c[b[0]]=0

Measured memory_bytes: 24112
#pragma GCC optimize("Ofast")
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy 2333333
#define bql 2147483647
using namespace std;
int n,lim,ans;
int main()
{
	fast;
	cin>>n>>lim;
	for (int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		if (x>=lim)
		   ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  long long ans = 0;
  vector<pair<long long,int>>data(n);
  for(int i = 0;i < n;i++){
    cin >> data[i].first;
    data[i].second = 1;
  }
  for(int i = 0;i < m;i++){
    int b,c;
    cin >> b >> c;
    data.push_back(make_pair(c,b));
  }
  sort(data.begin(),data.end(), greater<pair<long long,int> >());
  int cnt = 0,c = 0;
  while(cnt < n){
    if(cnt+data[c].second >= n) data[c].second = n-cnt;
    ans += data[c].first*data[c].second;
    cnt += data[c].second;
    c++;
  }
  cout << ans << endl;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

void solve(long long N, vector<long long> a){
	map<int,int> s;
	REP(i,N)s[a[i]]++;
	if(s.size()==1){
		int u = s.begin()->first;
		if(u==N-1 or u*2<=N){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}else if(s.size()==2){
		int p = s.begin()->first;
		if(s.find(p+1)==s.end()){
			cout<<"No"<<endl;
		}else{
			int x = s[p], y = s[p+1];
			int t = p+1-x;
			if(y==1 or t<=0 or t*2>y){
				cout<<"No"<<endl;
			}else{
				cout<<"Yes"<<endl;
			}
		}
	}else{
		cout<<"No"<<endl;
	}
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> a(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(N, a);
	return 0;
}



Measured memory_bytes: 6528
import java.util.Scanner;
 
public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	public static void main(String[] args) {
		int N=sc.nextInt();
		int M=sc.nextInt();
		int s[]=new int[M];
		int c[]=new int[M];
		for(int i=0;i<M;i++) {
			s[i]=sc.nextInt();
			c[i]=sc.nextInt();
		}
		boolean xx=true;
		boolean xxx=true;
		if(N==1) {
			for(int i=0;i<=9&&xxx;i++) {
				xx=true;
				for(int a=0;a<M&&xx;a++) {
					if(String.valueOf(i).charAt(s[a]-1)!=c[a]+48) {
					xx=false;
					}
					
				}
				if(xx) {
					System.out.println(i);
					xxx=false;
				}
			}
		}else if(N==2) {
			for(int i=10;i<=99&&xxx;i++) {
				xx=true;
				for(int a=0;a<M&&xx;a++) {
					if(String.valueOf(i).charAt(s[a]-1)!=c[a]+48) {
					xx=false;
					}
					
				}
				if(xx) {
					System.out.println(i);
					xxx=false;
				}
			}
		}else if(N==3) {
			for(int i=100;i<=999&&xxx;i++) {
				xx=true;
				for(int a=0;a<M&&xx;a++) {
					if(String.valueOf(i).charAt(s[a]-1)!=c[a]+48) {
					xx=false;
					}
					
				}
				if(xx) {
					System.out.println(i);
					xxx=false;
				}
			}
		}
		if(xxx) {
			System.out.println(-1);
		}
		
	}
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
#define MAX 51
#define inf (1e8)
using namespace std;

int n,m,a,b,c;
vector<int> re[MAX];
bool can[MAX][MAX][MAX*2]={};

int main()
{
  int x,y;

  cin>>n>>m>>a>>b>>c;

  for(int i=0;i<m;i++){
    cin>>x>>y;
    x--;y--;
    re[y].push_back(x);
  }

  for(int i=0;i<n;i++){
    queue<int> q;
    q.push(i);
    for(int j=1;j<MAX*2;j++){
      vector<int> v;
      while(!q.empty()){
	int now=q.front();
	q.pop();
	for(int k=0;k<re[now].size();k++){
	  int next=re[now][k];
	  if(!can[i][next][j]){
	    can[i][next][j]=true;
	    v.push_back(next);
	  }
	}
      }
      for(int k=0;k<v.size();k++)q.push(v[k]);
    }
  }
 
  queue<int> q;
  q.push(n-1);
  int dis[n];
  bool A[n],B[n],C[n];
  for(int i=0;i<n;i++){
    dis[i]=inf;
    A[i]=B[i]=C[i]=false;
  }
  dis[n-1]=0;
  while(!q.empty()){
    int now=q.front();
    q.pop();
    if(now==0)break;
    for(int i=0;i<n;i++){
      if(can[now][i][a])A[i]=true;
      if(can[now][i][b])B[i]=true;
      if(can[now][i][c])C[i]=true;

      if(A[i] && B[i] && C[i] && dis[i]==inf){
	dis[i]=dis[now]+1;
	q.push(i);
      }
    }
  }
  if(dis[0]==inf)cout<<"IMPOSSIBLE"<<endl;
  else cout<<dis[0]<<endl;
  return 0;
}

Measured memory_bytes: 1492
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
#define y1 qwert
using namespace std;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
int n,m,k,x1,y1,x2,y2,dir,tot,cur,nx,ny,res;
string g[1000100];
vector<vector<pair<int,int> > >dis[4];
priority_queue<pair<pair<int,int>,pair<pair<int,int>,int> > > q;
pair<int,int> INF=make_pair(1e9,1e9),NOX;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m>>k>>x1>>y1>>x2>>y2;
	for(int i=1;i<=n;i++){cin>>g[i];g[i]="?"+g[i];}
	for(int i=0;i<4;i++){
		dis[i].resize(n+1,vector<pair<int,int> >(m+1,INF));
		dis[i][x1][y1]={0,0};
		q.push(make_pair(make_pair(0,0),make_pair(make_pair(x1,y1),i)));
	}
	while(q.size()){
		x1=q.top().second.first.first;y1=q.top().second.first.second;
		dir=q.top().second.second;
		NOX=q.top().first;
		q.pop();
		NOX.first*=-1,NOX.second*=-1;
		if(NOX>dis[dir][x1][y1]) continue;
		tot=dis[dir][x1][y1].first;
		cur=dis[dir][x1][y1].second;
		if(cur==k) goto nxt;
		nx=x1+dx[dir],ny=y1+dy[dir];
		NOX=dis[dir][x1][y1];
		NOX.second++;
		if(nx>=1&&nx<=n&&ny>=1&&ny<=m&&g[nx][ny]=='.'){
			if(dis[dir][nx][ny]>NOX){
				dis[dir][nx][ny]=NOX;
				NOX.first*=-1,NOX.second*=-1;
				q.push(make_pair(NOX,make_pair(make_pair(nx,ny),dir)));
			}
		}
		nxt:;
		for(int i=0;i<4;i++){
			nx=x1+dx[i],ny=y1+dy[i];
			NOX=dis[dir][x1][y1];
			NOX.first++;NOX.second=1;
			if(nx>=1&&nx<=n&&ny>=1&&ny<=m&&g[nx][ny]=='.'){
				if(dis[i][nx][ny]>NOX){
					dis[i][nx][ny]=NOX;
					NOX.first*=-1,NOX.second*=-1;
					q.push(make_pair(NOX,make_pair(make_pair(nx,ny),i)));
				}
			}
		}
	}
	res=min(dis[0][x2][y2].first,dis[1][x2][y2].first);
	res=min(res,dis[2][x2][y2].first);
	res=min(res,dis[3][x2][y2].first);
	res++;
	if(res>=1e9) res=-1;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 113648
#include <iostream>
#include <vector>
typedef long long ll;

using namespace std;

int main() {
    vector<ll> t(2);
    cin >> t[0] >> t[1];
    
    vector<ll> a(2);
    cin >> a[0] >> a[1];
    
    vector<ll> b(2);
    cin >> b[0] >> b[1];
    
    ll diff1 = a[0] < b[0] ? t[0] * (b[0] - a[0]) : t[0] * (a[0] - b[0]);
    ll diff2 = a[0] < b[0] ? t[1] * (b[1] - a[1]) : t[1] * (a[1] - b[1]);
    
    // cout << "diff1 = " << diff1 << ", diff2 = " << diff2 << endl;
    
    if(diff1 + diff2 == 0) {
        cout << "infinity" << endl;
    }
    else if(diff1 + diff2 > 0){
        cout << 0 << endl;
    }
    else {
        ll ans = 1 + 2 * (diff1 / -(diff1 + diff2));
        if(diff1 % -(diff1 + diff2) == 0) {
            ans--;
        }
        
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    private int N, K;
    private int[] A;
    private void Scan()
    {
        var line = Console.ReadLine().Split(' ');
        N = int.Parse(line[0]);
        K = int.Parse(line[1]);
        A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }


    public void Solve()
    {
        Scan();
        long max = A.Max();
        long g = A[0];
        foreach(int i in A)
        {
            g = GCD(g, i);
        }
        if (K <= max && K % g == 0)
        {
            Console.WriteLine("POSSIBLE");
        }
        else
        {
            Console.WriteLine("IMPOSSIBLE");
        }
    }

    private long GCD(long a, long b)
    {
        if (a < b)
        {
            Swap(ref a, ref b);
        }
        long r = a % b;
        while (r > 0)
        {
            a = b;
            b = r;
            r = a % b;
        }
        return b;
    }

    private void Swap<T>(ref T a, ref T b)
    {
        T t = a;
        a = b;
        b = t;
    }
}


Measured memory_bytes: 18912
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <iterator>
#include <cmath>
#include <deque>
#include <stack>
using namespace std;

int main()
{
    {
        if (fopen("input.txt", "r")) {
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        }
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
    }

    string s;
    cin >> s;
    int k = 0;
    for (int i = 0; i != s.size() / 2; ++i)
        if (s[i] != s[s.size() - 1 - i])
            ++k;
    cout << k;
    return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//  
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
// const double PI=3.1415926535897932;

//#define __DBG__


void solve(void){
  
  int N;
  
  cin >> N;
  vector<int> A(N+1);
  vector<int> B(N+1);
  vector<int> C(N);
  
  REP2(i,1,N+1){
  	cin >> A[i];
  }
  REP2(i,1,N+1){
  	cin >> B[i];
  } 
  REP2(i,1,N){
  	cin >> C[i];
  }  
  
  int ans=0;
  
  REP2(i,1,N+1){    
//    cout << i << " " << A[i] << " " << B[A[i]] << endl;
    ans += B[A[i]];
    if(i>1){
      if(A[i]==A[i-1]+1){ans += C[A[i-1]];}
//      cout << "EXTRA " << C[A[i-1]] << endl;
    }
  }
  
  cout << ans << endl;

  return;
   
}


int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();
 
    return 0;
}





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

using namespace std;
int main() {
	int n; cin>>n;
	int max_=0;
	int ans=0;
	for(int i=0; i<n; ++i) {
		int hi; cin>>hi;
		if(max_<=hi) {
			++ans; max_=hi;
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
import sys
import math
input = sys.stdin.readline


N, M = (int(i) for i in input().split())  
#a = [int(i) for i in input().split()] 
#e = [[int(i) for i in input().split()] for i in range(n)] 

if N==M:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int> pii;
typedef long long ll;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

ll N, L;
ll A[100010];

vector<int> solve(){
    vector<int> ans;
    for(int i = 0; i < N; i++){
        if(A[i] >= L){
            for(int j = i - 1; j >= 0; j--){
                ans.push_back(j);
            }
            for(int j = i; j < N - 1; j++){
                ans.push_back(j);
            }
            reverse(ans.begin(), ans.end());
            return ans;
        }
    }
    
    for(int i = 0; i < N - 1; i++){
        if(A[i] + A[i + 1] >= L){
            ans.push_back(i);
            for(int j = i - 1; j >= 0; j--){
                ans.push_back(j);
            }
            for(int j = i + 1; j < N - 1; j++){
                ans.push_back(j);
            }
            reverse(ans.begin(), ans.end());
            return ans;
        }
    }
    return ans;
}

int main(){

    fastStream();
    cin >> N >> L;
    for(int i = 0; i < N; i++) cin >> A[i];
    auto v = solve();
    if(v.size() == 0){
        cout << "Impossible" << endl;
    }
    else{
        cout << "Possible" << endl;
        for(int a: v){
            cout << a + 1 << endl;
        }
    }


    return 0;
}


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

'''

'''

def solve(n, k, a):
    res = []

    for i in range(k, n):
        if a[i-k] < a[i]:
            res.append("Yes")
        else:
            res.append("No")
    
    return res

n, k = map(int, input().split())
a = list(map(int, input().split()))

res = solve(n, k, a)
for r in res:
    print(r)

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

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

    vec A;
    for(ll i=1; i*i<=N; ++i) {
        if(N % i == 0) A.pb(i);
    }
    ll m = INF;
    FORR(a,A) m = MIN(m,a+N/a-2);
    PR(m);

}

/*



*/

Measured memory_bytes: 3616
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a[ohara],b[ohara],c[ohara],d[ohara],tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

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

    rep(i,n){
        pos=LINF;
        rep(j,m){
            if(pos>abs(a[i]-c[j])+abs(b[i]-d[j])){
                pos=abs(a[i]-c[j])+abs(b[i]-d[j]);
                ans=j;
            }
        }
        Cout(ans+1);
    }
    return 0;
}


Measured memory_bytes: 6400
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)

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

  cin >> S;
  if (S == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
  return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#pragma region atcoder
/*#include <atcoder/all>
using namespace atcoder;
//These are for segment tree
/*int op(int a, int b){return max(a, b);}
int e(){return -1;}
bool f(int v){ return v < target;}
*/
#pragma endregion
#pragma region macros
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vl = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n - 1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
template<class T>bool chmax(T &a, const T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b){return a / gcd(a, b) * b;}
#pragma endregion
#pragma region debug for var, v, vv
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){cout << endl;int cnt = 0;for(const auto& v : vv){cout << cnt << "th : "; view(v); cnt++;} cout << endl;}
#pragma endregion
const ll mod = 1000000007;
const int inf = INT_MAX;
const ll INF = 1001001001001001001;
const int MAX = 2000005;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    ll a, b, c, d; cin >> a >> b >> c >> d;
    cout << max(a * c, max(a * d, max(b * c, b * d)));
} 


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    cout << n*800 - n/15 * 200 << endl;

}

Measured memory_bytes: 256