akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
V<int> dx={1,0,-1,0},dy={0,-1,0,1};
int main(){
    int h,w;
    cin>>h>>w;
    V<V<bool>> a(h,V<bool>(w,true));
    V<string> s(h);
    for(int i=0;i<h;i++)cin>>s[i];
       queue<P> q;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
        if(s[i][j]=='#'){
            q.push(P(i,j));
        }
        }
    }
    bool ok=true;
    while(!q.empty()){
        P now=q.front();
        q.pop();
        int cnt=0;
        for(int i=0;i<4;i++){
            int nx=now.fi+dx[i],ny=now.se+dy[i];
            if(nx<0||nx>=h||ny<0||ny>=w){
                continue;
            }
            if(s[nx][ny]!='#')continue;
            cnt++;
        }
        if(cnt==0)ok=false;
    }
    if(!ok)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    char c;
    cin >> c;

    if (c < 'a') {
        cout << 'A' << endl;
    } else {
        cout << 'a' << endl;
    }
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxn=1e6+5;
vector<ll> V;
int pre[maxn];
int main() {
	ll n;cin>>n;
	cout<<n*(n+1)/2<<endl;    
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

using namespace std;

typedef long long ll;

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 main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,m,x; cin>>n>>m>>x;
  int as[n+1];
  
  int to0 = 0;
  int toN = 0;
  
  rep(i,n+1) {
    as[i] = 0;
  }
  
  rep(i,m) {
    int a; cin>>a;
    as[a] = 1;
  }
  
  for (int i = x; i >= 0; --i) {
    to0 += as[i];
  }
  
  for (int i = x; i <= n; ++i) {
    toN += as[i];
  }
  
  cout<<min(to0, toN);
  
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

struct UnionFind {
  vector<int> data;
  UnionFind(int N) : data(N, -1) { }
  bool uni(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[x] > data[y]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

struct edge{
  int src, dst, cost;
  edge(int s, int d, int c) : src(s), dst(d), cost(c) {}
  edge() {}
  bool operator< (const edge& e) const {
    return cost < e.cost;
  }
};

int main(){
  int N;
  cin>>N;
  vector<edge> v(N - 1);
  REP(i, N - 1){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    v[i] = edge(a, b, c);
  }
  UnionFind uf(N);
  sort(v.begin(), v.end());
  ll ans = 0;
  REP(i, N - 1){
    ans += (ll)uf.size(v[i].src) * uf.size(v[i].dst) * v[i].cost;
    uf.uni(v[i].src, v[i].dst);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4172
# Python 3
from sys import stdin, stdout

if __name__ == "__main__":
    x = stdin.readline()
    x = int(x)

    curr = 101
    ans = 1

    while curr < x:
        curr *= 101
        curr //= 100
        ans += 1
    
    stdout.write(str(ans) + '\n')





Measured memory_bytes: 9160
#include<stdio.h>
int main(){
  int i,j,a,c,n,d[5][5],e[5][5]={};
  for(i=0;i<3;i++){
    for(j=0;j<3;j++)scanf("%d",&d[i][j]);
  }
  scanf("%d",&n);
  while(n--){
    scanf("%d",&a);
    for(i=0;i<3;i++){
      for(j=0;j<3;j++){
	if(d[i][j]==a)e[i][j]=1;
      }
    }
  }
  for(i=0;i<3;i++){
    for(j=c=0;j<3;j++)c+=e[i][j];
    if(c==3)goto END;
    for(j=c=0;j<3;j++)c+=e[j][i];
    if(c==3)goto END;
  }
  for(i=c=0;i<3;i++)c+=e[i][i];
  if(c==3)goto END;
  for(i=c=0;i<3;i++)c+=e[i][2-i];
  if(c==3)goto END;
  printf("No\n");
  return 0;
 END:;
  printf("Yes\n");
  return 0;
}
   


Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
    int a, b;
    char op;
        
        while (scanf("%d %c %d", &a, &op, &b) == 3 && op != '?') {  
            switch (op) {
                case '+': a += b; break;
                case '-': a -= b; break;
                case '*': a *= b; break;
                case '/': a /= b; break;
                default: continue;
            }
        
        printf("%d\n", a);
        }
return 0;
}


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

#define ll long long
#define maxn 105
#define mo 1000000007
using namespace std;

int main(){
    int n, prev, cur;
    bool poss = true;
    scanf("%d", &n);
    scanf("%d", &prev);
    prev--;
    for (int i = 1; i < n; i++){
        scanf("%d", &cur);
        if (cur < prev)
            poss = false;
        if (cur > prev)
            prev = cur - 1;
    }
    if (poss) printf("Yes");
    else printf("No");
}

Measured memory_bytes: 384
s = input()
q = int(input())

conv = 0
pre = []
pos = []
for i in range(q):
    query = input().split()
    if query[0] == '1':
        conv += 1
        continue
    if (int(query[1])+conv) %2 == 1:
        pre.append(query[2])
        continue
    pos.append(query[2])
if conv % 2 == 0:
    pre = ''.join(pre[::-1])
    pos = ''.join(pos[::1])
    s = pre + s + pos
else:
    pre = ''.join(pre[::1])
    pos = ''.join(pos[::-1])
    s = s[::-1]
    s = pos + s + pre
print(s)


Measured memory_bytes: 6252
#include<stdio.h>

int main(void){
    int n = 0;
    int p[20];
    int i = 0;
    int cnt = 0;

    scanf("%d", &n);

    for(i = 0; i < n; i++){
        scanf("%d", &p[i]);
    }

    for(i = 1; i < n-1; i++){
        if((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1])){
            cnt++;
        }
    }

    printf("%d", cnt);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI                \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
//int mod = 1e9 + 7;
int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

int32_t main()
{
	AB_BHI_NI_DEGI
	char c;
	cin >> c;
	if (c >= 'A' and c <= 'Z')
		cout << "A\n";
	else
		cout << "a\n";
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define forinc(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

string s;
int n,kq;
main()
{
    cin>>n;
    cin>>s;
    s=' '+s;
    forinc(i,1,n)
    {
        if(s[i]==s[i+1]) continue;
        else
        {
            kq++;
        }
    }
    cout<<kq;
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define THINK_TWICE_CODE_ONCE cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power((ll)n, (ll)m)
#define numOfDigits(n)  ((n)? (ll)(log10(n)+1) : 1)
#define mem(x, val)    memset(x, val, sizeof(x))
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef double dd;
typedef string str;
typedef pair<int, int> pii;


int main()
{
    THINK_TWICE_CODE_ONCE
    //freopen("test cases\\.txt", "r", stdin) ;
    int n; cin>>n;
    int arr[n];
    for(int i = 0;i<n; i++) cin>>arr[i];
    ll cost = IMX;
    for(int  i =-100; i<=100; i++){
            ll sum = 0;
        for(int j = 0; j<n; j++){
            sum += (i - arr[j])*(i - arr[j]);
        }
        cost = min(cost, sum);
    }
    cout<<cost;
	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans=0;
	int d[12][12];
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++){
			bool b[10];
			FOR(k,10)b[k]=0;
			int cnt=0;
			FOR(k,n){
				if(cnt==0){
					if(s[k]-'0'==i)cnt++;
				}else if(cnt==1){
					if(s[k]-'0'==j)cnt++;
				}else{
					b[s[k]-'0']=1;
				}
			}

			FOR(k,10){
				if(b[k])ans++;
			}


		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
def number():
    a = []
    b = []
    i = 0
    while True:
        x,y = map(int,input().split())
        if x == 0 and y == 0:
            break
        a.append(x)
        b.append(y)
        i += 1
    for j in range(len(a)):
        if a[j] < b[j]:
            print (a[j],b[j])
        else:
            print (b[j],a[j])

if __name__ == "__main__":
    number()

Measured memory_bytes: 8216
import sys
num = sys.stdin.readline().split()
d = {}
for line in sys.stdin.readlines():
  n = line.split()
  n.pop(0)
  for s in n:
    if s in d :
      d[s] = d[s]+1
    else :
      d[s] = 1
keys = [k for k, v in d.items() if v == int(num[0])]
print(len(keys))

Measured memory_bytes: 2568
#include<iostream>
using namespace std;
#define N 1048573
//1048573

int t[N];
string a,str;

int hash2(int x){
  return 1 + x%(N-1);
}

int hash1(int x){
  return x%N;
}

int hash0(){
  int x=0;
  for(int i=0;i<(int)str.size();i++){
    x*=4;
    if(str[i]=='A')x++;
    else if(str[i]=='T')x+=2;
    else if(str[i]=='G')x+=3;
    else x+=4;
  }
  return x;
}

bool find(){
  int x=hash0();
  int y=hash2(x);
  int i=hash1(x);
  while(1){
    if(t[i]==-1)return false;
    else if(t[i]==x)return true;
    i=hash1(i+y);
  }
}

void insert(){
  int x=hash0();
  int y=hash2(x);
  int i=x%N;
  while(1){
    if(t[i]==x)return;
    if(t[i]==-1){
      t[i]=x;
      return;
    }
    i=(i+y)%N;
  }
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  for(int i=0;i<N;i++)t[i]=-1;
  int Tc;
  cin>>Tc;
  while(Tc--){
    cin>>a>>str;
    if(a=="insert"){
      insert();
    }else{
      cout<<(find()?"yes":"no")<<'\n';
    }
  }
  return 0;
}

Measured memory_bytes: 5308
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
#include <ctype.h>

using namespace std;

int main() {
    int M[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
    string W[7]={"Monday",
        "Tuesday",
        "Wednesday",
        "Thursday",
        "Friday",
        "Saturday",
        "Sunday"};
    
    int x,y;
    while(scanf("%d%d",&x,&y)!=EOF){
        if(x==0||y==0){
            break;
        }
        int day=0;
        for(int i=1; i<x; i++){
            day+=M[i];
        }
        day+=y+2;
        int week = day % 7;
        cout<<W[week]<<endl;
    
    }
    return 0;
}

Measured memory_bytes: 1212
# coding: utf-8

N = int(input())
A = []
B = []

for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()

if N%2 == 1:
    low = A[N//2]
    high = B[N//2]
    ans = high - low + 1
else:
    low = (A[N//2-1]+A[N//2])/2
    high = (B[N//2-1]+B[N//2])/2
    ans = int((high - low + 1)*2-1)

print(ans)

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

using Int = unsigned long long;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> T th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

constexpr Int MOD = 1000000007;

Int n;
char s[212345];
int a[212345];

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

	Int ans = 1;
	for(Int i = 2; i <= n; ++i) ans = ans * i % MOD;

	Int cnt = 0;
	RC(i, n * 2){
		if((cnt % 2) ^ (s[i] == 'B')){
			++cnt;
		}else{
			ans = ans * cnt % MOD;
			--cnt;
			if(cnt < 0){
				puts("0");
				return 0;
			}
		}
	}
	if(cnt){
		puts("0");
		return 0;
	}

	cout << ans << endl;

}


Measured memory_bytes: 512
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    public static void process(int test_number)throws IOException
    {
        int n = ni();
        long d = nl(), res =0l;

        for(int i = 0; i < n; i++){
            long x = nl(), y = nl();

            if(x*x  + y*y <= d * d)
                res++;
        }

        pn(res);
    }
 
    static final long mod = (long)1e9+7l;
    
    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc = new FastReader();
 
        long s = System.currentTimeMillis();
        int t = 1;
        //t = ni();
        for(int i = 1; i <= t; i++)
            process(i);
 
        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }

    static void trace(Object... o){ System.err.println(Arrays.deepToString(o)); };
    static void pn(Object o){ out.println(o); }
    static void p(Object o){ out.print(o); }
    static int ni()throws IOException{ return Integer.parseInt(sc.next()); }
    static long nl()throws IOException{ return Long.parseLong(sc.next()); }
    static double nd()throws IOException{ return Double.parseDouble(sc.next()); }
    static String nln()throws IOException{ return sc.nextLine(); }
    static long gcd(long a, long b)throws IOException{ return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{ return (b==0)?a:gcd(b,a%b); }
    static int bit(long n)throws IOException{ return (n==0)?0:(1+bit(n&(n-1))); }
    
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 56476
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
 
using namespace std;
using namespace __gnu_pbds;
 
// template<typename T>
using o_set=tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define M 1000010

ll a[11][11];
int main(){
	IOS;
	ll n;cin>>n;
	ll ans=0;
	rep(i,1,n+1){
		string s=to_string(i);
		ll ini=s[0]-'0',las=s[sz(s)-1]-'0';
		a[ini][las]++;
	}
	rep(i,1,11)rep(j,1,11)ans+=a[i][j]*a[j][i];
	cout<<ans;
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main {

  public static void main(String[] args) {
    // System.out.println("Hello World!");
    Scanner scan = new Scanner(System.in);
    int num = scan.nextInt();//ここでコンソールに入力したものを取得
    
    int resultAC = 0;
    int resultWA = 0;
    int resultTLE = 0;
    int resultRE = 0;
    
    for(int i=0; i<num+1; i++){
        
        
        String inputStr = scan.nextLine();//ここでコンソールに入力したものを取得
        
        
        switch (inputStr) {
            case "AC"://scoreが5の時
              resultAC += 1;
              continue;
            //   break;
            case "WA"://scoreが4の時
              resultWA += 1;
              continue;
            //   break;
            case "TLE"://scoreが3の時
              resultTLE += 1;
              continue;
            //   break;
            case "RE"://scoreが2の時
              resultRE += 1;
              continue;
            //   break;
            
            default://scoreが上記以外の時
              break;
        }
        
    }
    // System.out.println();
    System.out.println("AC x " + resultAC);
    System.out.println("WA x " + resultWA);
    System.out.println("TLE x " + resultTLE);
    System.out.println("RE x " + resultRE);



  }

}

Measured memory_bytes: 60264
#include <iostream>
using namespace std;
long long dp[45];
int main(){
    int n;cin>>n;
    dp[0]=1;
    dp[1]=1;
    for(int i = 2; n >= i; i++){
        dp[i] = dp[i-1]+dp[i-2];
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
  int n;
  string s;
  string a = "ABC";
  int ans = 0;
  cin >> n >> s;
  LOOP(i,n-2){
    bool f = false;
    LOOP(j,3){
      if(s[i+j] != a[j])f = true;
    }
    if(f==false)ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i, i2;
	
	for (i=1; i < 10; i++){
		for (i2=1; i2 < 10; i2++){
			printf("%dx%d=%d\n", i, i2, i*i2);
		}
	}
	
	return (0);
}

Measured memory_bytes: 520
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

using ll = int64_t;

int main(int, const char**)
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<ll>());
    map<ll, int, greater<ll>> capa;
    auto f = a[0];
    capa[f] = 1;
    ll ans = 0;
    ll currentKey = f;
    rep(i, n - 1)
    {
        auto v = a[i + 1];
        ans += currentKey;
        if(capa.find(v) == capa.end())
        {
            capa[v] = 0;
        }
        capa[v] += 2;
        capa[currentKey]--;
        if(capa[currentKey] == 0)
        {
            capa.erase(currentKey);
            currentKey = capa.begin()->first;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main (void){
  
  int N,K;
  char S[1024];
  scanf("%d%d%s",&N,&K,S);
  
  if (S[K-1]>=65&&S[K-1]<=90) S[K-1] = S[K-1]+32;
  else S[K-1] = S[K-1]-32;
  
  printf("%s",S);
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	int a,b;
	cin>>a>>b;
	if(a>=13)
		cout<<b<<endl;
	else if(a>=6)
		cout<<b/2<<endl;
	else
		cout<<0<<endl;
}

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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

int n, t, a[100001];

int main(){
	cin >> n >> t;
	int mi, sa = 0, cnt = 1;
	bool b = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(i != 0){
			if(a[i] < a[i-1]){
				if(b = 0) mi = INF;
				mi = min(mi, a[i]);
			}
			else{
				if(sa < a[i] - mi){
					sa = a[i] - mi;
					cnt = 1;
					b = 1;
				}
				else if(sa == a[i] - mi){
					cnt++;
					b = 1;
				}
			}
		}
		else{
			mi = a[i];
		}
	}
	cout << cnt << endl;
	
	return 0;
}

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

using namespace std;

int n,m;
char grid[3][3];

int main(){
	for(int i = 0; i < 3; i++){
		cin >> grid[i];
	}
	string s;
	s += grid[0][0];
	s += grid[1][1];
	s += grid[2][2];
	cout << s;
}

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

using namespace std;

int main()
{
    int a,b;
    bool ok=false;
    cin>>a>>b;
    for (int i=1; i<=3; i++)
    {
        if (a*b*i%2==1) ok=true;
    }
    if (ok) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


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

using namespace std;

int main(){
  

  double r,s,S;
  cin >> r;
  
  s=r*r*M_PI;
  S=2.0*r*M_PI;
  printf("%f %f", s,S);
  return 0;
}



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

int main(){

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

    char c;
    cin>>c;
    if(c=='A')cout<<'T'<<endl;
    if(c=='T')cout<<'A'<<endl;
    if(c=='C')cout<<'G'<<endl;
    if(c=='G')cout<<'C'<<endl;

    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <cmath>
#include <limits.h>
#include <utility>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
using P = pair<int,int>;
using ll = long long;
constexpr int MOD=998244353;
constexpr int MAX=510000;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int x=0;
    for(int i=0;i<n;i++){
        x^=a[i];
    }
    for(int i=0;i<n;i++){
        cout<<(x xor a[i])<<" ";
    }
    cout<<endl;
}

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

int amax[100005];
int bmin[100005];


int main(){
    int n,m;
    int a,b;
    int ans=1;

    cin >> n >> m;
    vector<pair<int,int>> ab(m);

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

    sort(ab.begin(),ab.end());
    amax[0]=ab[0].first;
    bmin[0]=ab[0].second;

    for(int i=1; i<m; i++){
        for(int j=0; j<ans; j++){
            if(bmin[j]>ab[i].first && amax[j]<ab[i].second){
                amax[j] = max(amax[j], ab[i].first);
                bmin[j] = min(bmin[j], ab[i].second);
                break;
            }else if(j==ans-1){
                amax[ans] = ab[i].first;
                bmin[ans] = ab[i].second;
                ans++;
                break;
            }
        }
    }

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


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

int main() {
  ll N;
  cin >> N;
  vector<ll> a(N);
  for (ll i=0; i<N; i++) cin >> a.at(i);
  ll numo=0, num4=0;
  for (ll i=0; i<N; i++)
    if (a.at(i) % 2) numo++;
    else if (a.at(i) % 4 == 0) num4++;
  if (numo <= num4) cout << "Yes" << endl;
  else if (numo+num4==N && numo == num4+1) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 1024
import numpy as np
import itertools

N = int(raw_input())
A = map(int, raw_input().split())

def mul(x, y):
    return x * y

def nCr(n, r):
    print n, r
    if r == 0:
        return 1
    if n/2 < r:
        return nCr(n, n-r)
    print range(n, n - r, -1), range(1, r+1)
    return np.prod(range(n, n - r, -1)) / np.prod(range(1, r+1))

def nCrMax(n):
    return nCr(n, n/2)

sortedA = sorted(A, reverse = True)

max = -1
for i in range(N - 1):
    n = sortedA[i]
    target = n/2
    newA = sortedA[:i] + sortedA[i+1:]
    r = newA[np.argmin(map(lambda x: abs(x - target), newA))]
    #ncr = nCr(n, r)
    #if(nCr > max):
    #    max = nCr
    #else:
    #    break
    #if nCrMax(sortedA[i+1]) < max:
    #    break
    break
    
print n, r


Measured memory_bytes: 22348
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
    int N, num;
    long long total = 0;
    cin >> N;

    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }

    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());

    total += A.at(0);
    num = N-2;

    for(int i = 1; i < N; i++){
        if(num > 0){
            total += A.at(i);
            num --;
        }else{
            break;
        }
        if(num > 0){
            total += A.at(i);
            num--;
        }else{
            break;
        }
    }

    cout << total << endl;

}

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

int bubbleSort(int A[], int N){
    int sw =0;
    bool flag =1;
    for(int i=0; flag; i++){
        flag = 0;
        for(int j= N - 1; j >= i+1; j--){
            if (A[j] < A[j-1]){
            swap(A[j], A[j-1]);
            flag = 1;
            sw++;
        }
    }
}

return sw;
}

int main(){
    int A[100], N, sw;
    cin >> N;
    for(int i=0; i<N; i++)cin >> A[i];
        
    sw = bubbleSort(A,N);
    
    for (int i=0; i<N; i++){
        if(i) cout << " ";
        cout << A[i];
        
    }
    
    cout <<  endl;
    cout << sw << endl;
    
    return 0;
}


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

def main():
	H, W = map(int, input().split())
	h, w = map(int, input().split())
	if H == h or W == w:
		print("0")
	else:
		print((H - h) * (W - w))	

if __name__ == '__main__':
	main()


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
    string S;
    cin >> S;

    int N = S.size() + 1;
    vector<int> v(N, 0);

    int ret = 0;

    rep(i, N - 1) {
        if (S[i] == '>' && S[i + 1] == '<') {
            int tmp = 1;
            int j = i;
            while (j >= 0 && S[j] == '>') {
                v[j] = max(v[j], tmp);
                tmp++;
                j--;
            }
            tmp = 1;
            j = i + 1;
            while (j < N - 1 && S[j] == '<') {
                v[j + 1] = max(v[j + 1], tmp);
                tmp++;
                j++;
            }
        }
    }
    {
        int tmp = 1;
        int j = 0;
        while (j < N - 1 && S[j] == '<') {
            v[j + 1] = max(v[j + 1], tmp);
            tmp++;
            j++;
        }
    }
    {
        int tmp = 1;
        int j = N - 2;
        while (j >= 0 && S[j] == '>') {
            v[j] = max(v[j], tmp);
            tmp++;
            j--;
        }
    }

    rep(i, N) ret += v[i];

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 4740
import scala.io.Source.stdin

object Main extends App {
  def gcd(m:Long,n:Long):Long = if(n==0) m else gcd(n, m % n)

  println {
    {
      for(s <- stdin.getLines.map(_.split(" ").map(_.toLong))) yield {
          val g = gcd(s(0),s(1))
          g + " " + (s(0)/g)*s(1)
      }
    }.mkString("\n")
  }
}

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

#define MAX_Y 1000
#define MAX_X 1000
const long long INF = 100000000;
typedef pair<int, int> P;
long long d[MAX_Y][MAX_X];
char s[MAX_Y][MAX_X];
long long dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
long long W;
long long H;
 
// long long bfs(long long y, long long x) {
// 	for (int i = 0; i < 4; i++) {
// 		int ny = y + dy[i], nx = x + dx[i];
// 		// cout << ny << " " << nx << " " << d[y][x]<< endl;
// 		if (0 <= ny && ny < H && 0 <= nx && nx < W ) {
// 			if (d[ny][nx] > d[y][x]+1) {
// 				d[ny][nx] = d[y][x]+1;
// 				bfs(ny, nx);
// 			}
// 		}
// 	}
// 	return d[y][x];
// }

void bfs() {
	queue<P> que;
	for (int i = 0; i < H; i++)	for (int j = 0; j < W; j++) d[i][j] = INF;
	for (int i = 0; i < H; i++)	for (int j = 0; j < W; j++) if (s[i][j] == '#') {que.push(P(i, j)); d[i][j] = 0;}

	while (que.size()) {
		P p = que.front(); que.pop();
 
		for (int i = 0; i < 4; i++) {
			int ny = p.first + dy[i], nx = p.second + dx[i];
			if (0 <= ny && ny < H && 0 <= nx && nx < W && d[ny][nx] == INF) {
				que.push(P(ny, nx));
				d[ny][nx] = d[p.first][p.second] + 1;
			}
		}
	}

}


int main(){	
	scanf("%lld",&H);
	scanf("%lld",&W);
	for(int i = 0 ; i <= H-1 ; i++){
		for(int j = 0 ; j <= W-1 ; j++){
			cin >> s[i][j];
		}
	}
	// for(int i = 0 ; i <= H-1 ; i++){
	// 	for(int j = 0 ; j <= W-1 ; j++){
	// 		cout << s[i][j];
	// 	}
	// 	cout << endl;
	// }

	bfs();
	long long res = 0;
	for (int i = 0; i < H; i++)	for (int j = 0; j < W; j++) res = max(res, d[i][j]);
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 17168
#include <iostream>
using namespace std;
int main(){
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    int M[H][W];
        for(int i=0;i<B;i++){
        for(int j=0;j<A;j++) M[i][j] = 0;
        for(int j=0;j<W-A;j++) M[i][j+A] = 1;
        }
        for(int i=0;i<H-B;i++){
        for(int j=0;j<A;j++) M[i+B][j] = 1;
        for(int j=0;j<W-A;j++) M[i+B][j+A] = 0;
        }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cout << M[i][j];
        }
        cout << endl;
    }
}

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

int main()
{
  long long a,b,k;
  cin >> a >> b >> k;
  vector<long long> v; 
  for (long long l=a; l<a+k; ++l) {
    if (l >= a && l <= b) v.push_back(l);
  }
  for (long long l=b-k+1; l<=b; ++l) {
    if (l >= a && l <= b) {
      if (l != v.back()) v.push_back(l);
    }
  }
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()), v.end());
  
  for (long long l: v) {
    cout << l << endl;
  }
  
  return 0;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int const MAXA = 1e6;
int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::map<int,int> m;
  for(int i = 0; i < N; ++i) {
    int A; std::cin >> A;
    ++m[A];
  }
  std::vector<bool> ok(MAXA+1, true);
  for(auto p: m) {
    int a = p.first;
    if(!ok[a]) continue;
    if(a*2 > MAXA) continue;
    for(int j = 2; a*j <= MAXA; ++j) ok[a*j] = false;
  }
  int ans = 0;
  for(auto p: m) {
    if(p.second < 2 && ok[p.first]) ++ans;
  }
  fin(ans);
  return 0;
}


Measured memory_bytes: 13000
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class DDivGame {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      ll n; cin >> n;
      map<ll, int> mp;
      for(ll i=2; i*i<=n; i++) {
        while (n%i==0) {
          n/=i;
          mp[i]++;
        }
      }
      if (n > 1) {
        mp[n]++;
      }
      ll ans = 0;
      for(auto e: mp) {
        int now = 1;
        int p = e.second;
        while(p >= now) {
          p -= now;
          now++;
        }
        ans += (now-1);
      }
      cout << ans << endl;
    }
};

signed main() {
  DDivGame solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false)
#define pdl cout << "*" << endl
#define MOD 1000000007
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define ff first
#define ss second
#define long int64_t
using namespace std;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<> dis(0, INF<<1);
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args)
{ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma+1, args...); }

const int N = 51;

int x[N], y[N];

int main()
{
	fio;
	map<int, map<int, int>> m;
	int n;
	cin >> n;
	for(int i=1; i<=n; i++)
	{
		cin >> x[i] >> y[i];
		for(int j=1; j<i; j++)
		{
			m[x[i] - x[j]][y[i] - y[j]]++;
			m[x[j] - x[i]][y[j] - y[i]]++;
		}
	}
	int ans = 0;
	for(auto &it : m)
		for(auto &v : it.ss)
			ans = max(ans, v.ss);
	ans = n - ans;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
v = LIST()

for i in range(N - 1):
	v = sorted(v)
	mix = (v.pop(0) + v.pop(0))/2
	v.insert(0, mix)
print(v[0])

Measured memory_bytes: 5572
#include <iostream>

using namespace std;

int main()
{
  int n;
  int A[55], B[55], C[55];
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> A[i];
    --A[i];
  }
  for (int i = 0; i < n; ++i)
    cin >> B[i];
  for (int i = 0; i < n; ++i) {
    cin >> C[i];
  }
  int prev = -10;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += B[A[i]];
    if (prev + 1 == A[i]) {
      ans += C[prev];
    }
    prev = A[i];
    //cout << ans << " " << A[i] << " " << B[A[i]] << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 888
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//みなさん天才的ですよね

ll num[858200];
const int ma = (1 << 19) - 1;
bool query(ll n) {
	int n2 = n % 858100 + 1;
	while (num[n2]) {
		if (num[n2] == n + 1) return 1;
		n2 = n2 * 2 % 858101;
	}
	return 0;
}
void add(ll n) {
	int n2 = n % 858100 + 1;
	while (num[n2]) {
		if (num[n2] == n + 1) {
			return;
		}
		n2 = n2 * 2 % 858101;
	}
	num[n2] = n + 1;
}

int KH[300001], KW[300001];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int H, W, M;
	cin >> H >> W >> M;

	rep(i, M) {
		int h, w;
		cin >> h >> w;

		KH[h]++;
		KW[w]++;
		add(ll(h) * W + w);
	}

	int saidaih = -1;
	int hh[300001], h = 0;
	rep1(i, H) {
		if (saidaih < KH[i]) {
			saidaih = KH[i];
			h = 1;
			hh[0] = i;
		}
		else if (saidaih == KH[i]) {
			hh[h++] = i;
		}
	}
	int saidaiw = -1;
	int ww[300001], w = 0;
	rep1(i, W) {
		if (saidaiw < KW[i]) {
			saidaiw = KW[i];
			w = 1;
			ww[0] = i;
		}
		else if (saidaiw == KW[i]) {
			ww[w++] = i;
		}
	}

	if (ll(h) * w > M) {
		co(saidaih + saidaiw);
		return 0;
	}
	int atta = 0;
	rep(i, h) rep(j, w) {
		if (!query(ll(hh[i]) * W + ww[j])) {
			atta = 1;
			break;
		}
	}

	if (atta) co(saidaih + saidaiw);
	else co(saidaih + saidaiw - 1);

	Would you please return 0;
}

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

bool compare(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second)
        return a.second < b.second;
    else
        return a.first < b.first;
}

int main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> p(n);
    rep(i, n)
    {
        int a, b;
        cin >> a >> b;
        p[i] = make_pair(a, b);
    }
    sort(ALL(p), compare);
    int time = 0;
    rep(i, n)
    {
        time += p[i].first;
        if (time > p[i].second)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int n,a[105],sum;

int main()
{
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		sum += a[i];
	}
	sort(a,a+n);
	if(sum-a[n-1]>a[n-1]) cout << "Yes" << endl;
		else cout << "No" << endl;
	return 0;
}

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

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

typedef long long LL;

#define MOD 1000000007

// nCk = n!/(n-k)!k!

int main(){
  int n;
  cin >> n;
  vector<int> a(n+1);
  vector<LL> factorial(n+1),gyaku(n+1);
  vector<int> appeared(n+1,-1);
  factorial[0]=1;
  for(int i=1;i<=n;i++){
    factorial[i]=i*factorial[i-1]%MOD;
  }
  LL tmp=factorial[n];
  gyaku[n]=1;
  for(int i=0;i<30;i++){
    if((MOD-2)&(1<<i)){
      gyaku[n]=gyaku[n]*tmp%MOD;
    }
    tmp=tmp*tmp%MOD;
  }
  for(int i=n-1;i>=1;i--){
    gyaku[i]=(i+1)*gyaku[i+1]%MOD;
  }
  gyaku[0]=1;
  // for(int i=1;i<=n;i++){
  //   cout << i << ":" << factorial[i] << " " << gyaku[i] << " " << factorial[i]*gyaku[i]%MOD << endl;
  // }
  int hidari,migi;
  for(int i=0;i<n+1;i++){
    cin >> a[i];
    if(appeared[a[i]]>=0){
      hidari=appeared[a[i]];
      migi=i;
    }
    appeared[a[i]]=i;
  }
  cout << n << endl;
  LL ans;
  if(migi-hidari>1){
    for(int k=2;k<=n-1;k++){
      ans=factorial[n-1]*gyaku[n-k-1]%MOD*gyaku[k]%MOD;
        if(n-migi+hidari<k-1) ans=(ans+2*factorial[n-1]%MOD*gyaku[n-k]%MOD*gyaku[k-1]%MOD)%MOD;
        else ans=(ans+2*factorial[n-1]%MOD*gyaku[n-k]%MOD*gyaku[k-1]%MOD-factorial[n-migi+hidari]*gyaku[n-migi+hidari-k+1]%MOD*gyaku[k-1]%MOD)%MOD;
      ans=(ans+factorial[n-1]*gyaku[n-k+1]%MOD*gyaku[k-2]%MOD)%MOD;
      ans=(ans+MOD)%MOD;
      cout << ans << endl;
    }
    if(n>1){
      int k=n;
      ans=0;
        if(n-migi+hidari<k-1) ans=(ans+2*factorial[n-1]%MOD*gyaku[n-k]%MOD*gyaku[k-1]%MOD)%MOD;
        else ans=(ans+2*factorial[n-1]%MOD*gyaku[n-k]%MOD*gyaku[k-1]%MOD-factorial[n-migi+hidari]*gyaku[n-migi+hidari-k+1]%MOD*gyaku[k-1]%MOD)%MOD;
      ans=(ans+factorial[n-1]*gyaku[n-k+1]%MOD*gyaku[k-2]%MOD)%MOD;
      ans=(ans+MOD)%MOD;
      cout << ans << endl;
    }
  }else{
    for(int k=2;k<=n;k++){
      ans=factorial[n]*gyaku[n-k]%MOD*gyaku[k]%MOD;
      ans=(ans+factorial[n-1]*gyaku[n-k+1]%MOD*gyaku[k-2]%MOD)%MOD;
      cout << ans << endl;
    }
  }
  cout << 1 << endl;
  return 0;
}


Measured memory_bytes: 3584
#include <iostream>
using namespace std;
using llong = long long;

llong n, k;
llong a[200005];

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

    for (int i = k; i < n; i++) {
        llong l = a[i - k];
        llong r = a[i];

        if (r > l) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 5192
#include <stdio.h>

int main() {
  int n;
  int min, maxDiff = (1 << (sizeof(int) * 8 - 2)) * -1;
  scanf(" %d", &n);
  int current, i;
  scanf(" %d", &min);
  for (i = 1; i < n; i++) {
    scanf(" %d", &current);
    int diff = current - min;
    if (diff > maxDiff) {
      maxDiff = diff;
    }
    if (current < min) {
      min = current;
    }
  }
  printf("%d\n", maxDiff);
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
    ll a,b;
    cin >> a >> b;
    if(a<=0&&b>=0){
    	cout<<"Zero"<<endl;
    }else if(a>0){
    	cout<<"Positive"<<endl;
    }else if(a<0){
    	a*=-1;
    	b*=-1;
    	if((a-b)%2==0){
    		cout<<"Negative"<<endl;
    	}else{
    		cout<<"Positive"<<endl;
		}
    	
    }
    return 0;
}

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

typedef std::pair <int, int> pr;
typedef std::vector <pr> vecpr;
const int N = 324, mod = 1000000007;

int n, q;
int dp[2][N][N], (*cur)[N] = *dp, (*nxt)[N] = dp[1];
vecpr lim[N];

inline void add(int &x, const int y) {x += y - mod, x += x >> 31 & mod;}

int main() {
	int i, j, k, l, r, x, ans = 0;
	scanf("%d%d", &n, &q);
	for (; q; --q) scanf("%d%d%d", &l, &r, &x), lim[r].EB(l, x);
	**nxt = 1;
	for (i = 1; i <= n; ++i) {
		std::swap(cur, nxt), memset(nxt, 0, sizeof *dp);
		for (const pr &w : lim[i]) 
			switch (std::tie(l, x) = w, x) {
				case 1: for (j = l; j < i; ++j) memset(cur[j], 0, (j + 1) << 2); break;
				case 2:
					for (j = 0; j < l; ++j) memset(cur[j], 0, (j + 1) << 2);
					for (; j < i; ++j) memset(cur[j] + l, 0, (j - l + 1) << 2); break;
				case 3: for (j = 0; j < i; ++j) memset(cur[j], 0, l << 2); break;
			}
		if (i == n) break;
		for (j = 0; j < i; ++j)
			for (k = 0; !k || k < j; ++k) if ((x = cur[j][k]))
				add(nxt[j][k], x), add(nxt[i][k], x), add(nxt[i][j], x);
	}
	for (j = 0; j < n; ++j) ans = (ans + std::accumulate(cur[j], cur[j] + (j + 1), 0ll)) % mod;
	printf("%d\n", 3ll * ans % mod);
	return 0;
}

Measured memory_bytes: 1152
l = []
l.extend([i for i in map(int,input().split())])
l.extend([i for i in map(int,input().split())])
l.extend([i for i in map(int,input().split())])
d = {1:0,2:0,3:0,4:0}
for i in l:
    d[i] += 1
flag = True
for u in d:
    if d[u] >= 3 or d[u] <= 0:
        flag = False
if flag:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064