akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
  private static long gcd(long a, long b) {
    return a % b == 0 ? b : gcd(b, a % b);
  }
  
  private static long solve(long a, long b) {
    return a * b / gcd(a, b);
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    long a = reader.nextLong();
    long b = reader.nextLong();
    out.println(solve(a, b));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 21332
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e9+1;

struct BIT {
   vector<ll> bit;
   ll n;
   BIT(ll n=0):n(n),bit(n+1){}
 
   // 一点更新です
   void add(ll x, ll w) {
     for (x++; x <= n; x += x & -x) bit[x] += w;
   }
 
   // 1~Nまでの和を求める。
   ll sum(ll x) {
     ll ret = 0;
     for (x++; x > 0; x -= x & -x) ret += bit[x];
     return ret;
   }
 };

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    /*if(n==1){
        cout << a[0] << endl;
        return 0;
    }*/
    ll le=0,ri=INF;
    while(ri-le>1){
        ll mid=(ri+le)/2;
        vector<ll> v(n),s(n);
        rep(i,n){
            if(a[i]>=mid){
                v[i]=1;
            }
            else{
                v[i]=-1;
            }
        }
        rep(i,n){
            if(i){
                s[i]=s[i-1]+v[i];
            }
            else{
                s[i]=v[i];
            }
        }
        ll total=0;
        BIT b(n+n+10);  // これまでの数字がどんな風になってるのかをメモる為のBIT
        b.add(n+1,1LL);
        for (ll i = 0; i < n; i++) {
            total += i+1- b.sum(s[i]+n+1); // BITの総和 - 自分より左側 ＝ 自分より右側
            b.add(s[i]+n+1, 1LL); // 自分の位置に1を足す
            //cout << total << " ";
        }
        if((n+1)*n/2-total>((n+1)*n-1)/4) le=mid;
        else ri=mid;
        //cout << mid << " " << total << endl;
    }
    cout << le << endl;
    return 0;
} 

Measured memory_bytes: 4212
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int H = 0;
		for(int t =1;t<=c;t++){
			if(c % t ==0){
				if(a<=t){
					if(b>=t){
					H++;
					}
				}
			}
		}
		System.out.println(H);
	}
}

Measured memory_bytes: 17324
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define dprint(Exp,...) if(Exp){fprintf(stderr, __VA_ARGS__);}
#define printe(...) fprintf(stderr, __VA_ARGS__);
#define PrtExp(_Exp)  cerr<< #_Exp <<" = "<< (_Exp)
#define PrtExpN(_Exp)  cerr<< #_Exp <<" = "<< (_Exp) <<"\n"

#define SINT(n) scanf("%d",&n)
#define SINT2(n,m) scanf("%d %d",&n,&m)
#define SINT3(n,m,o) scanf("%d %d %d",&n,&m,&o)
#define SINT4(n,m,o,p) scanf("%d %d %d %d",&n,&m,&o,&p)
#define SINT5(n,m,o,p,q) scanf("%d %d %d %d %d",&n,&m,&o,&p,&q)
#define SLL(n) scanf("%lld",&n)
#define SLL2(n,m) scanf("%lld %lld",&n,&m)
#define SLL3(n,m,o) scanf("%lld %lld %lld",&n,&m,&o)
#define SST(s) scanf("%s",s)
#define SCH(c) scanf("%c",&c)

#define GC() getchar()

#define PINT(n) printf("%d",(int)(n))
#define PINT2(n,m) printf("%d %d",(int)(n),(int)(m))
#define PINT3(n,m,l) printf("%d %d %d",(int)(n),(int)(m),(int)(l))
#define PLL(n) printf("%lld",(long long)(n))
#define PST(s) printf("%s",(s))
#define PCH(s) printf("%c",(s))

#define PINTN(n) printf("%d\n",(int)(n))
#define PINT2N(n,m) printf("%d %d\n",(int)(n),(int)(m))
#define PINT3N(n,m,l) printf("%d %d %d\n",(int)(n),(int)(m),(int)(l))
#define PLLN(n) printf("%lld\n",(long long)(n))
#define PSTN(s) printf("%s\n",(s))
#define PCHN(s) printf("%c\n",(s))

#define PSP() printf(" ")
#define PN() printf("\n")

#define PC(c) putchar(c)
#define CSP (' ')
#define SN ("\n")

#define rep(i,a) for(int i=0;i<a;i++)
#define reP(i,a) for(int i=0;i<=a;i++)
#define Rep(i,a) for(int i=a-1;i>=0;i--)
#define ReP(i,a) for(int i=a;i>=0;i--)

#define rEp(i,a) for(i=0;i<a;i++)
#define rEP(i,a) for(i=0;i<=a;i++)
#define REp(i,a) for(i=a-1;i>=0;i--)
#define REP(i,a) for(i=a;i>=0;i--)

#define repft(i,a,b) for(int i=a;i<b;i++)
#define repfT(i,a,b) for(int i=a;i<=b;i++)
#define Repft(i,a,b) for(int i=a-1;i>=b;i--)
#define RepfT(i,a,b) for(int i=a;i>=b;i--)

#define foreach(a,it) for(auto it = a.begin(); it != a.end(); ++it)

#define FILL(a,v) fill(begin(a),end(a), v)
#define FILL0(a) memset(a,0,sizeof(a))
#define FILL1(a) memset(a,-1,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll>   Pll;


const int INF = 0x2aaaaaaa; // 715,827,882
const ll INFLL = 0x1f1f1f1f1f1f1f1fLL;//2,242,545,357,980,376,863

template <class A, class B> inline ostream& operator<<(ostream& st, const pair<A, B>& P) { return st << "(" << P.first << "," << P.second << ")"; };
template <class A, class B> inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first + Q.first, P.second + Q.second); };
template <class A, class B> inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first - Q.first, P.second - Q.second); };


#define fs first
#define sc second






int main() {
	string s;

	cin >> s;

	rep(i, s.size() - 1) {
		if (s[i] == 'A' && s[i + 1] == 'C') {
			puts("Yes");
			return 0;
		}
	}
	puts("No");

	return 0;
}




Measured memory_bytes: 256
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    u32 n;
    std::cin >> n;
    std::cout << (1ll << (numr<u32>::digits - __builtin_clz(n) - 1)) << '\n';
}


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

const ll INF = 1LL << 60;

ll H, W;
vector<string> maze;
ll w_dist[2010][2010];
ll h_dist[2010][2010];

int main() {
    cin >> H >> W;
    maze.resize(H);
    rep(i, H) cin >> maze[i];

    // w_dist の構築
    rep(i, H) {
        ll tmp = 0;
        // vector<ll> v;
        vector<pair<char, int>> v;
        for (int j = 0; j < W; j++) {
            if (maze[i][j] == '#') {
                v.push_back(make_pair('#', 1));
                continue;
            }

            // .
            if (v.size() == 0) {
                v.push_back(make_pair('.', 1));
                continue;
            } 

            int last = v.size() - 1;
            pair<char, int> p = v[last];
            if (p.first == '#') {
                v.push_back(make_pair('.', 1));
            } else {
                p.second++;
                v[last] = p;
            }
        }

        // 更新
        int start = 0;
        for (int j = 0; j < v.size(); j++) {
            // cout << v[j].first << " " << v[j].second << endl;
            for (int k = 0; k < v[j].second; k++) {
                if (v[j].first == '#') {
                    w_dist[i][k + start] = 0;
                } else {
                    w_dist[i][k + start] = v[j].second;
                }
            }
            start += v[j].second;
        }
    }

    // rep(i, H) {
    //     rep(j, W) {
    //         cout << w_dist[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // h_dist の構築
    rep(j, W) {
        ll tmp = 0;
        // vector<ll> v;
        vector<pair<char, int>> v;
        for (int i = 0; i < H; i++) {
            if (maze[i][j] == '#') {
                v.push_back(make_pair('#', 1));
                continue;
            }

            // .
            if (v.size() == 0) {
                v.push_back(make_pair('.', 1));
                continue;
            } 

            int last = v.size() - 1;
            pair<char, int> p = v[last];
            if (p.first == '#') {
                v.push_back(make_pair('.', 1));
            } else {
                p.second++;
                v[last] = p;
            }
        }

        // rep(j, v.size()) {
        //     cout << v[j].first << " " << v[j].second << endl;
        // }

        // 更新
        int start = 0;
        for (int i = 0; i < v.size(); i++) {
            for (int k = 0; k < v[i].second; k++) {
                if (v[i].first == '#') {
                    h_dist[k + start][j] = 0;
                } else {
                    h_dist[k + start][j] = v[i].second;
                }
            }
            start += v[i].second;
        }
    }
    // rep(i, H) {
    //     rep(j, W) {
    //         cout << h_dist[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    ll ans = 0;
    rep(i, H)rep(j, W) {
        if (maze[i][j] == '#') continue;

        ll c = h_dist[i][j] + w_dist[i][j] - 1;
        ans = max(ans, c);
    }
    cout << ans << endl;
}

Measured memory_bytes: 74064
(println (let 
  [a
   (map 
     (fn [a] (Integer/parseInt a))
     (.split (.nextLine (java.util.Scanner. System/in)) " "))] 
  (.intValue (* (Math/pow 100 (first a)) (let [c (first (rest a))] (if (= c 100) 101 c))))))

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

vector< vector<int> > to(100010);
int dist[100010];
int pre[100010];
const int INF = 20000000;


int main(){
  int N,M;
  cin >> N >> M;
  REP(i,M) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    to[a].emplace_back(b);
    to[b].emplace_back(a);
  }

  REP(i,N) dist[i] = INF;
  queue< int > q;
  q.push( 0 );
  dist[0] = 0;
  while( !q.empty()){
    auto v = q.front();  q.pop();
    for ( auto nv: to[v] ) {
      if (dist[nv] <= dist[v]+1 ) continue;
      dist[nv] = dist[v]+1;
      pre[nv] = v;
      q.push( nv );
    }
  }

  int ok = 1;
  REP(i,N) if (dist[i] == INF) ok = 0;
//  REP(i,N) cout << dist[i] << endl;
  if (ok==0) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
    for(int i=1; i<N; i++ ) cout << (pre[i]+1) << endl;
  }
}


Measured memory_bytes: 10680
#include<stdio.h>
#include<string.h> 
int main()
{
	int n,l,g,i;
	char m[150];
	scanf("%d",&n);
	scanf("%s",&m);
	if(n%2!=0) printf("No\n");
	else
	{
		l=strlen(m);
//		printf("%d\n",l);
		g=0;
		for(i=0;i<l/2;i++)
		{
			if(m[i]!=m[i+l/2])
			{
				g=1;break;
			}
		}
		if(g==0)printf("Yes\n");
		else printf("No\n");
		
	}
	return 0;
 } 

Measured memory_bytes: 128
import java.util.Scanner;

public class Main
{

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

        int t[] = new int[12];
        int a = 0;
        int f = 0;

        for (int i = 0; i < 12; i++) {
            t[i] = scan.nextInt();
        }
        for (int c = 0; c < 12; c++) {
            for (int d = 0; d < 12; d++) {
                if (t[c] == t[d]) {
                    a++;
                }
            }
            if (a % 4 == 0) {
                f++;
            }
            a = 0;
        }

        if (f == 12) {
            System.out.println("yes");
        } else {
            System.out.println("no");
        }

    }
}



Measured memory_bytes: 26252
import std.stdio;
import std.string;
import std.conv;
import std.range;
import std.array;
import std.algorithm;

void main() {
    string input;

    while ((input = readln.chomp).length != 0) {
        auto line = input.map!(a => a.to!int - '0').array;

        while (line.length > 1) {
            for (int i = 0; i < (line.length - 1); i++) {
                line[i] = line[i] + line[i+1];
            }
            line.popBack;
        }

        writeln(line.front % 10);
    }
}

Measured memory_bytes: 1036
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
const ll mo=1000000007;
string ans;
ll dp[0][0];

int main()
{
ll a,b,c,d,e,k;

cin >> a>>b>>c>>d>>e>>k;

if(e-a>k){
    ans=":(";
}
else{
    ans="Yay!";
}

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





Measured memory_bytes: 256
N,A,B= map(int,input().split())
S=input()
f=[]
d=0
e=1
for i in range(N):
  if S[i]=='a':
    if d < A+B:
      f.append('Yes')
      d+=1
    else:
      f.append('No')
  if S[i]=='b':
    if d <A+B and e<=B:
      f.append('Yes')
      d+=1
      e+=1
    else:
      f.append('No')
  if S[i]=='c':
    f.append('No')

for F in f:
  print(F)
    
    

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

using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n); i > 0; i--)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n,min=1<<19,max=0;
    cin >> n;
    vector<int> x(n);
    rep(i,n){
        cin >> x[i];
        if(x[i]<min) min = x[i];
        if(x[i]>max) max = x[i];
    }
    ll sum,ans=1<<19;
    rep(p,max-min+1){
        sum=0;
        rep(i,n) sum += (x[i]-p-min)*(x[i]-p-min);
        if(sum<ans) ans = sum;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

int N,ans=0,a;

int main(){
    cin>>N;
    int A[N],C[N-1];
    rep(i,N){
        cin>>A[i];
    }
    rep(i,N){
        cin>>a;
        ans+=a;
    }
    rep(i,N-1){
        cin>>C[i];
    }
    rep(i,N-1){
        if(A[i+1]-A[i]==1){
            ans+=C[A[i]-1];
        }
    }
    out(ans);
    
    
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define files(name) name!=""?freopen(name".in","r",stdin),freopen(name".out","w",stdout):0
#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define elif else if
#define mp make_pair
#define pb push_back
#define fir first
#define sec second

using namespace std;
#define int long long

typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;

const int arr=2e5+10;
const int ar=2e3+10;
const ld pi=acos(-1);
const ld eps=1e-10;
const ll md=1e9+7;

///---program start---///

#define arr (int)(1e5+10)

map<vi,bool> win;

bool get_win(vi a)
{
    if (a.empty()){
        return 1;
    }
    if (win.count(a)){
        return win[a];
    }
    bool res=0;
    vi b;

    b=a;
    b.pop_back();
    res|=(!get_win(b));

    b=a;
    reverse(all(b));
    while (!b.empty()&&b.back()==1){
        b.pop_back();
    }
    reverse(all(b));
    for (auto& i:b){
        i--;
    }
    res|=(!get_win(b));
    win[a]=res;

    return res;
}

string solve(int a)
{
    if (a==1){
        return "First";
    }
    else{
        return "Second";
    }
}

bitset<arr> reversed(bitset<arr> a)
{
    bitset<arr> res;
    for (int i=0;i<arr;i++){
        res[i]=a[arr-i-1];
    }
    return res;
}

main()
{
    #ifdef Barik
        files("barik");
        freopen("debug.txt","w",stderr);
    #endif

    bool debug=0;
    int n;
    vi a;

    if (debug){
        srand(time(0));
        n=5;
        a.resize(n);
        for (auto& i:a){
            i=rand()%5+1;
        }
    }
    else{
        cin>>n;
        a.resize(n);
        for (auto& i:a){
            cin>>i;
        }
    }
//    cout<<n<<"\n";
//    for (auto i:a){
//        cout<<i<<" ";
//    }
//    cout<<"\n";

    sort(all(a));
//    cout<<"naive :: "<<solve(get_win(a))<<"\n";

    bitset<arr> wins;
    bitset<arr> buf;
    bitset<arr> all_gamebale;
    for (auto& i:a){
        if (i>=arr){
            i=(arr-2)+((arr-2)%2!=i%2);
        }
    }
    sort(all(a));
    for (int i=a[0];i>=0;i-=2){
        wins[i]=1;
    }
    for (int i=0;i<=a[0];i++){
        all_gamebale[i]=1;
    }
    for (int i=1;i<n;i++){
//        cout<<"before i :: "<<reversed(wins)<<"\n";
        buf=wins;
        wins=wins^all_gamebale;
        for (int j=a[i-1]+(a[i-1]%2!=a[i]%2);j<=a[i];j+=2){
            wins[j]=1;
        }
        for (int j=a[i-1];j<arr&&j<=a[i];j++){
            all_gamebale[j]=1;
        }
        wins=wins|((buf&(wins>>1))>>1);
//        cout<<" after i :: "<<reversed(wins)<<"\n";
    }


    cout<<solve(wins[0])<<"\n";
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define rep(i,a,b,c)            for(int i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(int i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define vpii                    vector<pair<int,int>>
#define si                      set<int>
#define usi                     unordered_set<int>
#define vi                      vector<int>
#define vld                     vector<ld>
#define vvi                     vector<vector<int>>
#define vvld                    vector<vector<ld>>
#define pii                     pair<int,int>
#define vvpii                   vector<vector<pair<int,int>>>
#define pqi                     priority_queue<int>
#define mii                     map<int,int>
#define mic                     map<int,char>
#define um                      unordered_map
#define umii                    um<int,int>
#define umic                    um<int,char>
#define umci                    um<char,int>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define test                    int Testcases;cin>>Testcases;while(Testcases--)
#define input(a,n)              for(int i=0;i<n;++i) cin>>a[i];
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
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...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int32_t main()
{
	fastIO
	inp_out();
	string s;
	cin>>s;
	cout<<(s=="ABC"?"ARC":"ABC");
	return 0;
}

Measured memory_bytes: 3604
def main():
    S = input()
    N = int(S)

    d = sum(map(int, S))
    print('Yes' if N % d == 0 else 'No')


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 3060
#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>

int main(){
    int n;
    int d, min, max;
    long long sum;
    
    scanf("%d%d", &n, &d);
    sum = min = max = d;
    while (--n > 0){
        scanf("%d", &d);
        if (d < min) min = d;
        if (d > max) max = d;
        sum += d;
    }
    printf("%d %d %lld\n", min, max, sum);
    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
int main(){

    string S;

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

    if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]){
        cout << "Bad" << endl;
    }else{
        cout << "Good" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
  int n;

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

  ll ans = 1;
  for(int i = 0 ; i < n ; i++){
    if(a[i] > ans) break;
    else ans += a[i];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323846264338327950L
 
long double a,b,h,m,c,d1,d2;
int main()
{
	cin>>a>>b>>h>>m;
	d1=(long double)m/360.0+(long double)h/6;
	d2=(long double)m/30;
	d2=(d1-d2);
	c=sqrt(2*a*b)*sqrt((a*a+b*b)/(2*a*b)-cos(d2*PI));
	cout<<fixed<<setprecision(20)<<c; 
}


Measured memory_bytes: 4156
/* Date: 01/04/2020
 * Author: @codingoo
 * Problem Name: Ferris Wheel
 * Platform: AtCoder
 */
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    int a, b;
    cin >> a >> b;
    if (a >= 13)
        cout << b;
    else {
        if (a <= 6 || a <= 12) {
            if (a <= 5)
                cout << "0";
            else
                cout << b / 2;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cctype>
#include<cmath>
using namespace std;
#define pi 3.1415926535
int main()
{

	double a, b, angle, rad;
	cin >> a >> b >> angle;
	rad = (M_PI/ 180)*angle;
	cout.setf(ios::fixed);
	cout.setf(ios::showpoint);
	cout.precision(8);
	cout << 0.5*a*b*sin(rad) <<endl;
	cout<< a + b + sqrt(a*a + b * b - 2 * a*b*cos(rad)) <<endl;
	cout<<b*sin(rad);
	return 0;
	
	}


Measured memory_bytes: 3464
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

H, W = map(int, readline().split())
masu = []
for _ in range(H):
    masu.append(readline().rstrip().decode('utf-8'))
# print(masu)

dp = [[INF]*W for _ in range(H)]
dp[0][0] = int(masu[0][0] == "#")

dd = [(1, 0), (0, 1)]

# 配るDP
for i in range(H):
    for j in range(W):
        for dx, dy in dd:
            ni = i + dy
            nj = j + dx
            # はみ出す場合
            if (ni >= H or nj >= W):
                continue
            add = 0
            if masu[ni][nj] == "#" and masu[i][j] == ".":
                add = 1
            dp[ni][nj] = min(dp[ni][nj], dp[i][j] + add)
# print(dp)
ans = dp[H-1][W-1]
print(ans)

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

int mod = 1e9 + 7;
vector<int> adj[100001];

pair<int, int> dfs(int node, int parent) {
	long long w{1}, b{1};
	for (int nb : adj[node]) {
		if (nb != parent) {
			pair<int, int> z = dfs(nb, node);
			b *= z.first;
			b %= mod;
			w *= (z.first + z.second);
			w %= mod;
		}
	}
	return {w, b};
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	
	pair<long long, long long> ans = dfs(1, 0);
	cout << (ans.first + ans.second)%mod;
}

Measured memory_bytes: 14524
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

struct edge {
	int to; // ?????????
	int cap; // ??????
	int rev; // ??????
	edge() {}
	edge(int to, int cap, int rev) :to(to), cap(cap), rev(rev) {}
};

vector<vector<edge>> G; // ??°???????????£??\???????????¨???
vector<int> used; // DFS??§?????§???????????????????????°

				  // from??????to??????????????????cap???????????°?????????????????????
void add_edge(int from, int to, int cap) {
	G[from].push_back(edge(to, cap, G[to].size()));
	G[to].push_back(edge(from, 0, G[from].size() - 1));
}

// ?¢?????????????DFS??§??¢???
int dfs(int v, int t, int f) {
	if (v == t) return f;
	used[v] = true;
	for (int i = 0; i < G[v].size(); i++) {
		edge &e = G[v][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

// s??????t???????????§???????±???????
int max_flow(int s, int t) {
	int flow = 0;
	for (;;) {
		fill(used.begin(), used.end(), 0);
		int f = dfs(s, t, INF);
		if (f == 0) return flow;
		flow += f;
	}
}


/* use example */
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll X, Y, E; cin >> X >> Y >> E;
	G.resize(X + Y + 2); used.resize(X + Y + 2);
	for (int i = 0; i < E;i++) {
		ll x, y; cin >> x >> y;
		x++; y++;
		add_edge(x, X + y, 1); // ?????¨??´???????????¨??´???????????????
	}
	for (int i = 1; i <= X;i++) add_edge(0, i, 1);
	for (int j = X + 1;j <= X + Y;j++) add_edge(j, X + Y + 1, 1);
	cout << max_flow(0, X+Y+1) << endl;
	return 0;
}

Measured memory_bytes: 3296
using System;
using System.IO;
using System.Linq;

namespace Tree
{
    class Rooted_Trees
    {
        struct Node
        {
            public int id;
            public int parent;
            public int depth;
            public int[] childlen;
            public string type;
        }
        static void Main(string[] args)
        {
            int size = int.Parse(Console.ReadLine());
            var nodes = new Node[size];

            for (int i = 0; i < size; i++)
                nodes[i].parent = -1;

            for (int i = 0; i < size; i++)
            {
                var token = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                var id = token[0];
                nodes[id].id = id;

                var k = token[1];
                if (k == 0) nodes[id].type = "leaf";
                else nodes[id].type = "internal node";
                nodes[id].childlen = new int[k];
                for (int j = 0; j < k; j++)
                {
                    nodes[id].childlen[j] = token[2 + j];
                    nodes[token[2 + j]].parent = id;
                }
            }

            for (int i = 0; i < size; i++)
                if (nodes[i].parent == -1)
                {
                    nodes[i].type = "root";
                    SetDepth(nodes, i, 0);
                    break;
                }

            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            for (int i = 0; i < size; i++)
            {
                Console.Write("node {0}: parent = {1}, depth = {2}, {3}, [", nodes[i].id, nodes[i].parent, nodes[i].depth, nodes[i].type);
                Console.Write(string.Join(", ", Array.ConvertAll(nodes[i].childlen, n => n.ToString())));
                Console.WriteLine("]");
            }

            Console.Out.Flush();
        }

        static void SetDepth(Node[] nodes, int id, int depth)
        {
            nodes[id].depth = depth;
            for (int i = 0; i < nodes[id].childlen.Length; i++)
                SetDepth(nodes, nodes[id].childlen[i], depth + 1);
        }
    }
}

Measured memory_bytes: 22892
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int A,B;
  cin>>A>>B;
  cout<<(B%A==0?A+B:B-A)<<endl;
  return 0;
}


Measured memory_bytes: 256
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.09.08 03:29:59
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;



struct StronglyConnectedComponents {
private:
    vector<vector<int>> g, rg;
    vector<int> order; 
    vector<bool> visited;
    int V;
    void dfs(int v) {
        if (visited[v]) return;
        visited[v] = true;
        for (int u : g[v]) dfs(u);
        order.push_back(v);
    }
    void rdfs(int v, int c) {
        if (comp[v] != -1) return;
        comp[v] = c;
        for (int u : rg[v]) rdfs(u, c);
    }
public:
    vector<vector<int>> Graph; 
    vector<int> comp; 
    StronglyConnectedComponents(int v) : V(v) {
        g.resize(v);
        rg.resize(v);
        visited.resize(v);
        comp.resize(v);
    }
    void add_edge(int from, int to) {
        g[from].push_back(to);
        rg[to].push_back(from);
    }
    void build() {
        Graph = vector<vector<int>>();
        order = vector<int>();
        visited.assign(V, false);
        comp.assign(V, -1);
        for (int i = 0; i < V; i++) dfs(i);
        reverse(order.begin(), order.end());
        int number = 0;
        for (int i = 0; i < V; i++) {
            if (comp[order[i]] == -1) {
                rdfs(order[i], number++);
            }
        }
        Graph.resize(number);
        for (int i = 0; i < V; i++) {
            for (int v : g[i]) {
                if (comp[i] == comp[v]) continue;
                Graph[comp[i]].push_back(comp[v]);
            }
        }
    }
};
int main() {
    int n,m;cin >> n >> m;
    StronglyConnectedComponents scc(n);
    for (int i = 0; i < m; i++) {
        int a,b;scanf("%d %d",&a,&b);
        scc.add_edge(a,b);
    }
    scc.build();
    vector<vector<int>> b(n);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        b[scc.comp[i]].push_back(i);
        ans = max(ans,scc.comp[i] + 1);
    }
    printf("%d\n",ans);
    for (int i = 0; i < n; i++) {
        if (b[i].size() == 0) break;
        printf("%d ",(int)b[i].size());
        for (int j = 0; j < b[i].size(); j++) {
            printf("%d ",b[i][j]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 101712
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n>>k;

	if(k>(((n-2)*(n-1))/2)){
		cout<<"-1\n";
		return 0;
	}

	cout<<(n*(n-1))/2-k<<endl;
	l=((n-2)*(n-1))/2;
	for(i=2;i<=n;i++){
		cout<<"1 "<<i<<endl;
	}
	for(i=2;i<n;i++){
		for(j=i+1;j<=n;j++){
			if(l==k) return 0;
			cout<<i<<" "<<j<<endl;
			l--;
		}
	}
	return 0;
}


Measured memory_bytes: 256
// コメント, ロジックを修正して再提出.
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
const int INF = 2020202020;
int dp[404][404]; // タイプA が a[g], タイプB が b[g] の 場合における 最小価格[円] を 保存.

int main() {
    
    // 1. 入力情報取得.
    int N, Ma, Mb;
    scanf("%d %d %d", &N, &Ma, &Mb);
    
    // 2. dp更新.
    rep(i, N){
        int ca, cb, cc;
        scanf("%d %d %d", &ca, &cb, &cc);
        repr(a, 403, 0){
            repr(b, 403, 0){
                int na = a + ca;
                int nb = b + cb;
                if(na > 403 || nb > 403) continue;
                if(na == ca && nb == cb){
                    // 同じ組み合わせが含まれる場合があるので注意(※以下のロジックを追加).
                    // -> subtask_1_09.txt における 5 4 73 と 5 4 7
                    if(dp[na][nb]) dp[na][nb] = min(dp[na][nb], cc);
                    else           dp[na][nb] = cc;
                }
                if(dp[a][b]){
                    if(dp[na][nb]) dp[na][nb] = min(dp[na][nb], dp[a][b] + cc);
                    else           dp[na][nb] = dp[a][b] + cc;
                }
            }
        }
    }
    
    // 3. 物質C を 生成するための最小予算は？
    int ans = INF;
    rep(i, N + 1){
        int a = Ma * i;
        int b = Mb * i;
        if(a > 400 || b > 400) break;
        if(dp[a][b]) ans = min(ans, dp[a][b]);
    }
    
    // 4. 出力.
    if(ans == INF) ans = -1;
    printf("%d\n", ans);
    return 0;
    
}

Measured memory_bytes: 4124
n = int(input())

C = [[1 for i in range(n)] for j in range(n)]
for i in range(n):
    C[i][i] = 0
if n%2 == 0:
    for i in range(n):
        C[i][n-1-i] = 0
else:
    for i in range(n):
        C[i][n-2-i] = 0

print(n*(n-1)//2-n//2)
for i in range(n):
    for j in range(n):
        if i<j and C[i][j] == 1:
            print(i+1,j+1)

Measured memory_bytes: 43760
N = int(input())
As = list(map(int, input().split()))
n4 = 0
n2 = 0
n1 = 0
for A in As:
  if A%4 == 0:
    n4 += 1
  elif A%2 == 0:
    n2 += 1
  else:
    n1 += 1
#print(n1, n2, n4)
if n4 >= n1:
  print("Yes")
elif n4 >= n1-1 and n2 == 0:
  print("Yes")
else:
  print("No")


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

int main() {
  int a, b;
  cin >> a >> b;
  int vec[b];
  for (int i=0; i < b; i++){
    cin >> vec[i];
  }
  int c = 0;
  for (int i=0; i<b; i++){
    c += vec[i];
  }
  if (a <= c){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

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

        try{
            //入力
            int N = scan.nextInt();
            int X = scan.nextInt();
            int[] x_ = new int[N];
            int[] d_ = new int[N];
            for(int i = 0; i < N; i++){
                x_[i] = scan.nextInt();
                d_[i] = Math.abs(X-x_[i]);
            }

            int D = gcd(d_, N);

            System.out.println(D);

        }finally{
            scan.close();
        }
    }

    static int gcd(int[] d, int n){
        int D = d[0];
        for(int i = 1; i < n; i++){
            while(d[i] % D != 0){
                int tmp = d[i] % D;
                d[i] = D;
                D = tmp;
            }
        }
        return D;
    }
}


Measured memory_bytes: 57692
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N + 1];
    for (int i = 1; i <= N; i++) {
      a[i] = sc.nextInt();
    }
    TreeMap<String, Integer> map = new TreeMap<>();
    for (int k = 1; k <= N; k++) {
      int i = Math.min(k, a[k]);
      int j = Math.max(k, a[k]);
      String key = i + ":" + j;
      if (map.containsKey(key)) {
        map.put(key, map.get(key) + 1);
      } else {
        map.put(key, 1);
      }
    }
    int ans = 0;
    for (Integer value : map.values()) {
      ans += (value / 2);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 66104
n, q = map(int, input().split())
s = input()

acs = [0]
pre_a = False
for c in s:
  acs.append(acs[-1])
  if pre_a:
    if c == 'C':
      acs[-1] += 1
    pre_a = False
    if c == 'A':
      pre_a = True
  else:
    if c == 'A':
      pre_a = True

for _ in range(q):
  l, r = map(int, input().split())
  print(acs[r] - acs[l])


Measured memory_bytes: 6148
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int a,b; cin >> a >> b;
    cout << abs(a-b) << endl;
}





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

int main(void){
  char c;
  scanf("%c", &c);
  if(c=='S'){
    printf("Cloudy");
  }else if(c=='C'){
    printf("Rainy");
  }else if(c=='R'){
    printf("Sunny");
  }
  return 0;
}
  


Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  int x; cin >>x;
  cout <<360/__gcd(x,360);
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  solve();
return 0;}

Measured memory_bytes: 3600
/*input
2
1 2
50 50
50
*/
    /**
        Author: Kristopher Paul
        Date Created: 07-09-2019
        Contest Name:
                    _/    _/   _/_/_/_/   _/   _/_/_/_/
                   _/  _/     _/    _/   _/   _/
                  _/_/       _/_/_/_/   _/   _/_/_/_/
                 _/  _/     _/  _/     _/         _/
                _/    _/   _/    _/   _/   _/_/_/_/
    **/
    #include<bits/stdc++.h>
    //#include <ext/pb_ds/assoc_container.hpp>
    //#include <ext/pb_ds/tree_policy.hpp>
    #define ll long long
    #define int ll
    #define pb push_back
    #define INF 1e18
    #define MOD 1000000007
    #define mp make_pair
    const double PI=3.141592653589793238462643383279502884197169399375105820974944;
    #define REP(i,n) for (int i = 0; i < n; i++)
    #define FOR(i,a,b) for (int i = a; i < b; i++)
    #define REPD(i,n) for (int i = n-1; i >= 0; i--)
    #define FORD(i,a,b) for (int i = a; i >= b; i--)
    #define remax(a,b) a = max(a,b)
    #define remin(a,b) a = min(a,b)
    #define umap unordered_map
    #define pii pair<int,int>
    #define F first
    #define S second
    #define mii map<int,int>
    #define vi vector<int>
    #define vvi vector<vi>
    #define itr :: iterator it
    #define all(v) v.begin(),v.end()
    #define WL(t) while(t--)
    #define gcd(a,b) __gcd((a),(b))
    #define lcm(a,b) ((a)*(b))/gcd((a),(b))
    #define out(x) cout << #x << " is " << x << endl
    #define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    using namespace std;
    //using namespace __gnu_pbds;
     
    //typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
    //typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset
     
    int ModExp(int x,int y,int m){
        int res = 1;
        x = x % m;
        while (y > 0)
        {
            if (y & 1)
                res = (res*x) % m;
     
            y = y>>1;
            x = (x*x) % m;
        }
        return res;
    }
     
    void solve(){
        int n;
        cin >> n;
        int a[n];
        int b[n];
        int c[n];
        FOR(i,0,n){
            cin >> a[i];
        }
        FOR(i,0,n){
            cin >> b[i];
        }
        FOR(i,0,n-1){
            cin >> c[i];
        }
        int ans = b[a[0]-1];
        FOR(i,1,n){
            if(a[i] >= 2){
                if((a[i-1]+1) == a[i]){
                    ans += c[a[i]-1-1];
                }
            }
            ans += b[a[i]-1];
        }
        cout << ans << endl;
    }
     
    signed main(){
        FastIO;
        int t = 1;
    //    cin >> t;
        WL(t){
            solve();
        }
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define repr(i,n) for(int i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;

int main() {
  ll n;
  cin >> n;
  vector<ll> vec(100000);
  
  ll ans = 0;
  ll count = 0;

  for(ll i = 0; i < n; i++){
    cin >> vec.at(i);
    if(i == 0) continue;
    
    if(vec.at(i-1) >= vec.at(i)){
      count++;
    }else{
      if(ans < count){
        ans = count;
        count = 0;
      }else{
        count = 0;
      }
    }
  }
  
  if(ans < count){
    ans = count;
  }
  cout << ans << endl;

}



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

namespace Tenka1_PBC_2019
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);
            if (a <= c && b >= c)


                Console.WriteLine("Yes");
            else if (a >= c && b <= c)
                Console.WriteLine("Yes");
            else
            {
                Console.WriteLine("No");
            }
            Console.ReadKey();
        }
    }
}

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

int main() {
  int n;
  while (cin >> n, n) {
    auto c = vector<int>(2, 0);
    int ans = 0;
    for (int i = 0; i < n; ++i) {
      string f; cin >> f;
      c[f[0] == 'l'] ^= 1;
      if (all_of(begin(c), end(c), [](int x) { return x == 1; })) {
        ++ans;
        c = vector<int>(2, 0);
      }
    }
    cout << ans << endl;
  }
  return 0;
}



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


int main(void) {
  int a,b,c;
  cin >> a >> b >> c;
  
  int d = a%b;
  rep2(i,1,101){
    int e = d*i;
    if(e%b == c) {
      cout << "YES" << endl;
      break;
    }
    if(i==100) cout << "NO" << endl;
  }
    
  
               
   
}

Measured memory_bytes: 256
N,M = map(int,input().split())
 
from heapq import heappush, heappop
INF = float("inf")
miti = [-1]*N
def dijkstra(N, G, s):
    dist = [INF] * N
    que = [(0, s)]
    dist[s] = 0
    while que:
        c, v = heappop(que)
        if dist[v] < c:
            continue
        for t, cost in G[v]:
            if dist[v] + cost < dist[t]:
                dist[t] = dist[v] + cost
                miti[t] = v+1
                heappush(que, (dist[t], t))
    return dist
 
edge = [[] for _ in range(N)]
 
for _ in range(M):
    a,b = map(int,input().split())
    edge[a-1].append((b-1,1))
    edge[b-1].append((a-1,1))
 
dist = dijkstra(N,edge,0)
 
if -1 in miti[1:]:
    print("No")
else:
    print("Yes")
    for t in miti[1:]:
        print(t)

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


const long MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

long long ruijou_2(int x){
    if(x==0) return 1;
    long long ans = ruijou_2(x/2);
    ans = (ans*ans);
    if(x%2==1) ans = (2*ans);
    return ans%MOD;
}

int main() {


    int n,a,b;

    cin >> n >> a >>b;

    if (n<=2){
        cout << 0 << endl;
        return 0;
    }

    int i=1;
    long long ans = ruijou_2(n)-1;
    //cout << ans << endl;
    long long num=n;
    for (i=1;i<=b;i++){
        if(i>1){
            num = (num * (n-i+1)) % MOD;
            num = (num*power(i, MOD - 2, MOD))%MOD;
        }
        if(i==a || i==b){
            ans = (MOD + ans - num)%MOD;
            //cout << ans << endl;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256