akhauriyash/Code-Regression huggingface dataset:
# coding=utf-8

###
### for atcorder program
###

import sys

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

#abc list
#abc = [chr(ord('a') + i) for i in range(26)]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

def get_input():
    N = []
    while True:
        try:
            N.append(input())
        except EOFError:
            break
    return N

def main():
    S = input()
    P = input()

    S = S + S[:len(P)]

    if S.find(P) == -1:
        print('No')
    else:
        print('Yes')

if __name__ == '__main__':
    main()




Measured memory_bytes: 5596
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

int main(){
	int n;
	bool mem[50][50][30];
	while(cin >> n, n){
		vector< vector<int> > vi(30, vector<int>());
		memset(mem, false, sizeof(mem));
		for(int i=0;i<n;i++){
			int m, d; cin >> m;
			for(int j=0;j<m;j++){
				cin >> d;
				vi[d-1].push_back(i);
			}
		}
		for(int i=0;i<n;i++){
			queue< pair<int,int> > qu; qu.push(make_pair(i,0));
			while(!qu.empty()){
				pair<int,int> pr = qu.front(); qu.pop();
				int pos = pr.first, day = pr.second;
				if(day>=30 || mem[i][pos][day]) continue;
				mem[i][pos][day] = true;
				qu.push(make_pair(pos, day+1));
				bool flag = false;
				for(int j=0;j<vi[day].size();j++)
					if(vi[day][j] == pos) flag = true;
				if(!flag) continue;
				for(int j=0;j<vi[day].size();j++)
					qu.push(make_pair(vi[day][j], day));
			}
		}
		int ans = 31;
		for(int i=0;i<30;i++){
			for(int j=0;j<n;j++){
				bool flag = true;
				for(int k=0;flag&&k<n;k++)
					if(!mem[k][j][i]) flag = false;
				if(flag) ans = min(ans, i+1);
			}
		}
		cout << (ans == 31 ? -1 : ans) << endl;
	}
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647

int main() {
  kyun;
  int n;
  cin >> n;
  char c;
  while(cin >> c) {
    c += n;
    if(c >= 91) c -= 26;
    cout << c;
  }
  hinata;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var NK = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (N, K) = (NK[0], NK[1]);
        var h = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        var ans = h.Where(x => K <= x).Count();

        WriteLine(ans);
    }
}


Measured memory_bytes: 35304
import copy
s=input()
def dfs(i,f,last):
    ans=0
    if i==len(s):
        for j in range(len(s)):
            ans+=int(f[j])
        return ans
    else:
        f1=copy.deepcopy(f)
        f2=copy.deepcopy(f)
        f1[last]+=s[i]
        ans+=dfs(i+1,f1,last)
        f2[last+1]+=s[i]
        ans+=dfs(i+1,f2,last+1)
        return ans
f=["0"]*len(s)
f[0]+=s[0]
print(dfs(1,f,0))


Measured memory_bytes: 75760
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int n,k,a[100008],maxn=0;
bool flag=false;
int gcd(int a,int b)
{
    while(1)
    {
        if(a==0)
            return b;
        if(b==0)
            return a;
        if(a>b) a%=b;
        else    b%=a;
    }
}
bool cmp(int a,int b){ return a<b;}
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        maxn=max(maxn,a[i]);
    }
    sort(a+1,a+n+1,cmp);
    int ans=a[1];
    if(k==ans)
        flag=true;
    else
    for(int i=2;i<=n;i++)
    {
        ans=gcd(ans,a[i]%ans);
        if(k%ans==0)
        {
            flag=true;
            break;
        }
    }
    if(flag==true && k<=maxn)
        printf("POSSIBLE");
    else
        printf("IMPOSSIBLE");
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  if(!(S.at(0)==S.at(1)) &&!(S.at(1)==S.at(2))&&!(S.at(2)==S.at(3))){
    cout << "Good" <<endl;
  }
  else{
    cout << "Bad" <<endl;
  }
}


Measured memory_bytes: 256
#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 MOD7 1000000007
#define MOD9 1000000009

#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() {
	int A, B;
	cin >> A >> B;

	cout << A + B / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;

int main() {
  int N;
  cin >> N;
  int a;
  int ans = 0;
  int target = 1;

  REP(n,N){
    cin >> a;
    if(a==target){
      target += 1;
    }else{
      ans += 1;
    }
  }
  if(N==ans) ans = -1;
  cout << ans << endl;
}

Measured memory_bytes: 384
import Data.Vector

main = do
    i <- read <$> getLine
    ns <- fromList . fmap read . words <$> getLine
    putStrLn . show $ cost (i - 1) ns

cost :: Int -> Vector Int -> Int
cost j ns = memo ! j
    where
        memo = fromList [cost' k ns | k <- [0..j]]
        cost' :: Int -> Vector Int -> Int
        cost' 0 ns = 0
        cost' 1 ns = abs $ ns ! 0 - ns ! 1
        cost' i ns = min (memo ! (i - 2) + abs (ns ! (i - 2) - ns ! i)) (memo ! (i - 1) + abs (ns ! (i - 1) - ns ! i))


Measured memory_bytes: 53628
a,b,c=map(int,input().split())
ans=0
while 1:
    if a==b and b==c:
        print(ans)
        break
    ans+=1
    if a==min(a,b,c):
        a+=1
        if a==min(a,b,c):
            a+=1
        elif b==min(a,b,c):
            b+=1
        else :
            c+=1
    elif b==min(a,b,c):
        b+=1
        if a==min(a,b,c):
            a+=1
        elif b==min(a,b,c):
            b+=1
        else :
            c+=1
    else :
        c+=1
        if a==min(a,b,c):
            a+=1
        elif b==min(a,b,c):
            b+=1
        else :
            c+=1

Measured memory_bytes: 3064
# Aizu Problem 0016: Treasure Hunt
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


x, y = 0, 0
direction = 90
while True:
    d, t = [int(_) for _ in input().split(',')]
    if d == t == 0:
        break
    angle = direction * math.pi / 180
    x += d * math.cos(angle)
    y += d * math.sin(angle)
    direction = (direction - t) % 360
    
print(int(x))
print(int(y))

Measured memory_bytes: 7964
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <limits>
#include <bitset>
#include <functional>
#include <type_traits>
#include <array>
#include <random>
#include <utility>
#include <ctime>

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

//forマクロ
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//allマクロ
#define all(x) (x).begin(),(x).end()

int main() {
	//iostream高速化--------------------
	cin.tie(0);
	ios::sync_with_stdio(false);
	//----------------------------------

	int N; cin >> N;
	vector<i64> lucas(N+1);

	lucas.at(0) = 2;
	lucas.at(1) = 1;

	for (int i = 2; i <= N; i++) {
		lucas.at(i) = lucas.at(i - 1) + lucas.at(i - 2);
	}

	cout << lucas.at(N) << endl;
}




Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main(){
	
    int i, a, price;
    while( cin >> i >> a >> price ){
	
		if( i + a < price)
        cout << "NA\n";
        
        if( i + a >= price) {
        	
        	if( i >= price)
        	cout << "0\n";
        	
        	else
        	cout << price - i << "\n";
        	
		}

 }
    return 0;
}


Measured memory_bytes: 3068
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;



int main()
{
	int D, m = 0, t = 0;
	for (int i = 0; i < 5; i++)
	{
		cin >> D;
		if (D % 10 != 0)
		{
			m = max(10 - (D % 10), m);
			t += (D + 10 - (D % 10));
		}
		else
		{
			t += D;
		}

	}
	cout << t - m << endl;
}


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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int maxq = 1e5 + 5;
const int maxn = 1e5 + 5;

int n, q;
int x[maxq], y[maxq], tp[maxq];
ll m, lb, rb;

class Dsu{
public:
	int fa[maxn], sz[maxn];
	inline Dsu(){ FOR(i, 0, maxn) fa[i] = i, sz[i] = 1; }
	
	inline int find(int u){ return fa[u] == u ? u : fa[u] = find(fa[u]); }
	
	inline void combine(int u, int v){
		u = find(u), v = find(v);
		if(u == v)
			return;
		sz[v] += sz[u];
		fa[u] = v;
		return;
	}
}s, t;

int main(){
	scanf("%d%lld%d", &n, &m, &q);
	
	FOR(i, 0, q)
		scanf("%d%d%d", x + i, y + i, tp + i);
		
	FOR(i, 0, q) if(!tp[i])
		s.combine(x[i], y[i]);
		
	int cnt = 0;
	FOR(i, 0, n) if(s.find(i) == i){
//		printf("i = %d\n", i);
		lb += s.sz[i] - 1, rb += s.sz[i] - 1;
		++cnt;
//		printf("lb = %lld rb = %lld\n", lb, rb);
	}
	rb += 1ll * cnt * (cnt - 1) / 2;
	
	FOR(i, 0, q) if(tp[i]){
		x[i] = s.find(x[i]);
		y[i] = s.find(y[i]);
		if(x[i] == y[i]){
			puts("No");
			return 0;
		}
		t.combine(x[i], y[i]);
	}
		
	cnt = 0;
	FOR(i, 0, n) if(s.find(i) == i && t.find(i) == i){
//		printf("i = %d sz = %d\n", i, t.sz[i]);
		if(t.sz[i] > 1)
			lb += t.sz[i];
		++cnt;
	}
//	printf("cnt = %d lb = %lld\n", cnt, lb);
	lb += cnt - 1;
	
//	printf("lb = %lld rb = %lld\n", lb, rb);
	
	if(lb <= m && m <= rb)
		puts("Yes");
	else
		puts("No");
	return 0;
}


Measured memory_bytes: 6480
#include <iostream>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(void){
  int x,y; cin >> x >> y;
  string res = "No";
  if(y>=x*2 && y<=x*4 && y%2==0) res = "Yes";
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3624
N, K = map(int, input().split())
x = list(map(int, input().split()))

tp = N
for i in range(N):
    if x[i] >= 0:
        tp = i
        break
    x[i] *= -1

s = max(0, tp-K+1)
g = min(tp-1, N-K)

ans = float("INF")
if K <= tp:
    ans = min(ans, x[tp-K])
if K <= N - tp:
    ans = min(ans, x[tp+K-1])

for i in range(s, g+1):
    ans = min(ans, x[i] + x[i+K-1] + min(x[i], x[i+K-1]))
    #print(x[i], x[i+K-1])

print(ans)

Measured memory_bytes: 20416
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;

/* --------------------------------------------------- */

int main() {
    int n;
    cin >> n;
    bool ans = false;
    rrep(i, 9) {
        rrep(j, 9) {
            if(i * j == n) ans = true;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
    
    return 0;
}

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

int main(){
	int b,r,g,c,s,t,x,y;
	while(cin >> b >> r >> g >> c >> s >> t &&( b || r || g || c || s || t)){
		y = (t-s-b*5-r*3)*3+(b*5+r*3)*2;
		x = 100+(c*2+g*7+b*15+r*15+(r*3*15)+(b*5*15));
		cout << x-y <<endl;
	}
	return 0;
}

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

char before[70], after[70];
int n, m;

int search(char c) {
	before[n] = c;
	int i = 0;
	while (before[i] != c) i++;
	return i;
}

int main() {
	char buf;
	int ans;
	while (1){
		cin >> n;
		if (n == 0) return 0;
		for (int i = 0; i < n; i++) {
			cin >> before[i] >> after[i];
		}
		cin >> m;
		for (int i = 0; i < m; i++) {
			cin >> buf;
			if ((ans = search(buf)) == n){
				printf("%c", buf);
			} else {
				printf("%c", after[ans]);
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1112
(let [N (read-line)
      Ni (map #(Character/digit % 10) N)
      Nif (first Ni)] 
  (-> Ni 
      distinct 
      count 
      ( #(cond
          (= 1 %) N 
          (= Nif (apply max Ni)) (apply str (repeat 3 Nif))
          :else (apply str (repeat 3 (inc Nif)))))
      println))

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
const double PI=3.1415926535897932;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll gcd(ll a, ll b){
    ll tmp;
    if(a%b == 0){
        return b;
    }
    else{
        return gcd(b, a%b);
    }
}

ll mod = 1e9+7;
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}




const ll SIZE = 1e9;
ll n,k,s;

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

    ll co = 0;

    for(int i = 0; i < n; i++){
    if(s != SIZE){
        if(co < k){
            cout << s << ' ';
            ++co;
        }
        else{
            cout << s+1 << ' ';
        }
    }
    else{
        if(co < k){
            cout << s << ' ';
            ++co;
        }
        else{
            cout << 1 << ' ';
        }
    }
    }
    cout << endl;
}

Measured memory_bytes: 1280
#ABC124 B
N = int(input())
H = list(map(int, input().split()))
ans = 1
for i in range(N):
    if i==0:
        pass
    else:
        i_bool = True
        for j in range(1,i+1):
            if H[j-1] > H[i]:
                i_bool = False
        if i_bool:
            ans+=1
print(ans)


Measured memory_bytes: 2940
fn main() {
    let toppings = read::<String>().chars().filter(|c| *c == 'o').count();
    let ans = 700 + toppings * 100;
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

namespace AtCoder111 {
    class Program {
        static void Main(string[] args) {
            int input = int.Parse(Console.ReadLine());
            int res = Enumerable.Range(1, 9).Select(x => x * 111).Where(x => x >= input).Min();
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 11348
#include<cstdio>
#include<algorithm>
using namespace std;
static const int MAX_N = 100000;

int n, S;
int a[MAX_N];

void solve(){
  int res = n + 1;
  int s = 0, t = 0, sum = 0;
  for(;;){
    while(t < n && sum < S){
      sum += a[t++];
    }
    if(sum < S) break;
    res = min(res, t - s);
    sum -= a[s++];
  }

  if(res > n){
    res = 0;
  }
  printf("%d\n", res);
}

int main(){
  scanf("%d %d", &n, &S);
  for(int i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }
  solve();
  return 0;
}

Measured memory_bytes: 3108
n=int(input())
a=list(map(int,input().split()))

dp=[-1]*n
dp[0]=0
dp[1]=abs(a[0]-a[1])

for i in range(2,n):
    dp[i]=min(
        dp[i-2]+abs(a[i]-a[i-2]),
        dp[i-1]+abs(a[i]-a[i-1])
    )
    
print(dp[-1])

Measured memory_bytes: 13980
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] S = new int[N][3];
		for(int i = 0 ; i < N ; i++){
			S[i][0] = sc.nextInt();
			S[i][1] = sc.nextInt();
			S[i][2] = sc.nextInt();
		}
		sc.close();

		//入力内の最大高
		int high = 0 ;
		for(int i = 0 ; i < N ; i++){
			high = Math.max(high, S[i][2]);
		}

		int anstmp = 0;
		int count = 0;
		for(int i = 0 ; i <= 100 ; i++){
			for(int j = 0 ; j <= 100 ; j++){
				for(int k = high ; k <= high+200 ; k++){
					for(int l = 0 ; l < N ; l++){
						//頂点が(i,j)に高さkで存在する場合、N個の候補座標はいくつになっているか
						int H = Math.max(k - Math.abs(S[l][0]-i) - Math.abs(S[l][1]-j),0);
						//System.out.println(i + " " + j + " " + k + " " +H);
						if(H == S[l][2]){
							count++;

							if(count==N){
								System.out.println(i + " " + j + " " + k);
							}
							else{
								continue;
							}
						}
						else{
							count = 0;
							break;
						}

					}

				}
			}
		}
	}
}

Measured memory_bytes: 22680
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	result := 0
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	s1 := sc.Text()
	s := scanString(3, s1)

	sc.Scan()
	s2 := sc.Text()
	t := scanString(3, s2)

	for i := 0; i < 3; i++{
		if (s[i] == t[i]){
			result++
		}
	}
	fmt.Println(result)
}

func scanString(len int, str string)([]string){

	var strings []string

	for i := 0; i < len; i++ {
		strings = append(strings, str[i:i+1])

	}
	return strings
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

//! [Sのi文字目][Tのj文字め]=まで見たときにもっとも長い文字列
int dp[3005][3005];

int main()
{
    string S, T;
    cin >> S >> T;
    REP(i, 3005)
    {
        dp[i][0] = dp[0][i] = 0;
    }

    REP(i, S.length())
    {
        REP(j, T.length())
        {
            dp[i + 1][j + 1] = dp[i][j];
            if (T[j] == S[i])
            {
                dp[i + 1][j + 1] += 1;
            }

            if (dp[i + 1][j + 1] < dp[i + 1][j])
                dp[i + 1][j + 1] = dp[i + 1][j];
            if (dp[i + 1][j + 1] < dp[i][j + 1])
                dp[i + 1][j + 1] = dp[i][j + 1];
        }
    }

    string a = "";
    int ls = S.length(), lt = T.length();
    while (dp[ls][lt] > 0)
    {
        if (S[ls - 1] == T[lt - 1])
        {
            a = S[ls-1] + a;
            ls--;
            lt--;
        }
        else if (dp[ls - 1][lt] >= dp[ls][lt - 1])
        {
            ls--;
        }
        else
        {
            lt--;
        }
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 35456
#include <iostream>

using namespace std;

int main(void){
  int n,x,t,ans;
  
  cin >> n >> x;
  ans=1;
  for (int i=0; i<n; i++){
    cin >> t;
    x -= t;
    if (x>=0) ans++;
  }
  cout << ans << endl;
  return 0;
}
    


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define jizz ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lowbit(x) x&-x
#define F first 
#define S second 
#define pb push_back
#define MP make_pair
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=1e9;
const int MAXN=1e6;
int n;
int main()
{
	cin >> n;
	if (n%1000)
		cout << 1000-n%1000 << "\n";
	else cout << 0 << "\n";
}

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

int main(){
      int n;cin >> n;
      int maxx = 0;
      int ans = 0;
      for(int i = 0;i < n;i++){
            int t;cin >> t;
            if(t >= maxx){
                  ans++;
                  maxx = t;
            }
      }
      cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>

int n, A[50];

int solve(int p, int t);

int main(){
  int m, M, i;
  
  scanf("%d", &n);
  for ( i = 0; i < n; i++ )scanf("%d", &A[i]);
  scanf("%d", &m);
  for ( i = 0; i < m; i++ ){
    scanf("%d", &M);
    if ( solve(0, M) )printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int p, int t){
  if ( p >= n ) return 0;
  if ( A[p] == t ) return 1;
  if ( solve(p+1, t) ) return 1;
  if ( solve(p+1, t-A[p]) ) return 1;
  return 0;
}



Measured memory_bytes: 2052
#include <cstdio>
#include <algorithm>
int n, a[8]={3,9,2,4,8,10,6,12};
int main() {
	scanf("%d", &n);
	if(n==3) {puts("2 5 63"); return 0;}
	if(n%2) std::rotate(a, a+7, a+8);
	for(int i=0; i<n; i++) printf("%d ", a[i%8]+i/8*12);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
//const long long MOD = 998244353;
long long MOD = 2;

using namespace std;


char str[1000005];

void solve()
{
    int n;
    scanf("%d%s", &n, str);
    vector<int> a(n),b(n-1);
    int i;
    for (i = 0; i < n; i++) {
        a[i] = str[i]-'0';
        if (i > 0) {
            b[i - 1] = abs(a[i] - a[i - 1]);
        }
    }
    if (n == 2) {
        printf("%d\n", b[0]); return;
    }
    int cnt[3] = { 0 };
    for (i = 0; i < n - 1; i++) {
        cnt[b[i]]++;
    }
    int mult = 1;
    if (cnt[1] == 0) {
        mult = 2;
        for (i = 0; i < n - 1; i++) {
            b[i] /= 2;
        }
    }
    else {
        for (i = 0; i < n - 1; i++) {
            b[i] %= 2;
        }
    }

    int ans = 0;
    for (i = 0; i < n - 1; i++) {
        if (b[i]) {
            int flag = 0;
            int k;
            for (k = 0; k < 20; k++) {
                int tmp0 = (n - 2)&(1 << k);
                int tmp1 = i & (1 << k);
                
                if (tmp0==0 && tmp1) {
                    flag = 1;
                    break;
                }
            }
            if (flag == 0) {
                ans = 1 - ans;
            }
        }
    }
    printf("%d\n", ans*mult);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 9088
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>

using namespace std;
typedef long long int ll; typedef pair<int, int> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n)%mod / (fct(m) * fct(n - m))%mod) % mod;
	return x;
}
bool isincluded(char x,string str){
	bool f = 0;
	for (size_t i = 0; i < str.size(); i++) {
		if (str.at(i) == x)f = 1;
	}
	return f;
}

ll arr[10000000] = { -1 };
ll tmod = 10007;
ll trib(ll n) {
	if (n < 3)return arr[n] = 0;
	else if (n == 3)return arr[n] = 1;
	if (arr[n] != -1)return arr[n];
	else return arr[n] = (trib(n - 1) + trib(n - 2) + trib(n - 3));
}

int main(void) {
	ll n; cin >> n;
	map<string, ll> m;
	for (int i = 0; i < n; i++) {
		string str;
		cin >> str;
		sort(all(str));
		auto x = m.find(str);
		if (x != m.end())
			x->second++;
		else
			m.emplace(str,1);
	}
	ll cnt = 0;
	for (auto i = m.begin(); i != m.end(); i++) {
		ll tmp = i->second;
		if (tmp > 0)
			cnt += tmp * (tmp - 1) / 2;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define saken string
#define erba continue
using namespace std;

const ll MAXN = 3e5 + 100;
ll n, a[MAXN];

int main(){

cin >> n;

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

sort(a + 1, a + 1 + (n * 3));


ll ans = 0;

ll m = n * 3;

for(int i = 1; i + 1 < m; ++i) {

    ans += a[m - 1];

    m -= 2;

}

cout << ans;

return 0;
}



Measured memory_bytes: 2560
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int N = 1000000;
const ll INF = std::numeric_limits<long long>::max();
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define sz size
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }
ll n, m;
string s;
vector<int>ints;
vector<string>strings;
int main() {
	cin >> n;
	rep(i, n) {
		cin >> s;
		bool b = 0;
		rep(j, strings.size()) {
			if (s == strings[j]) { b = 1; ints[j]++; break; }
		}
		if (b == 0) { strings.push_back(s); ints.push_back(1); }
	}
	cin >> m;
	rep(i, m) {
		cin >> s;
		bool b = 0;
		rep(j, strings.size()) {
			if (s == strings[j]) { b = 1; ints[j]--; break; }
		}
		if (b == 0) { strings.push_back(s); ints.push_back(-1); }
	}
	sort(ALL(ints));
	cout << max(0, ints[ints.size() - 1]) << endl;
	return 0;

}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

    int P, Q, R;
    scanf("%d%d%d", &P, &Q, &R);

    int min = 200;
    int route[3];

    route[0] = Q + R;
    route[1] = P + Q;
    route[2] = P + R;

    for (int i = 0; i < 3; i++){
        
        if(min > route[i]){
            min = route[i];
        }
    }

    printf("%d", min);

    return 0;
}

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

typedef long long llint;

int revcmp(const void *a,const void *b){
    return *(llint*)a - *(llint*)b ? *(llint*)a > *(llint*)b ? -1 : 1 : 0;
}

int main(void){
    register int i,j,l;
    int x,y,z,k;
    scanf("%d %d %d %d",&x,&y,&z,&k);
    llint a[x],b[y],c[z];
    for(i = 0;i < x;i++)scanf("%lld",&a[i]);
    for(i = 0;i < y;i++)scanf("%lld",&b[i]);
    for(i = 0;i < z;i++)scanf("%lld",&c[i]);
    qsort(a,x,sizeof(llint),revcmp);
    qsort(b,y,sizeof(llint),revcmp);
    qsort(c,z,sizeof(llint),revcmp);
    llint ans[k*k];
    llint ansp = 0;
    for(i = 0;i < x;i++)for(j = 0;j < y;j++){
        if(i*j > k)break;
        for(l = 0;l < z;l++){
            if(i*j*l > k)break;
            ans[ansp] = a[i] + b[j] + c[l];
            ansp++;
        }
    }
    qsort(ans,ansp,sizeof(llint),revcmp);
    for(i = 0;i < k;i++)printf("%lld\n",ans[i]);
}

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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
    int x,y,z;
	cin >> x>>y>>z;
    cout<<z<<" "<<x<<" "<<y;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  set<int> S;
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    if(S.count(a)){
      cout <<"NO";
      return 0;
    }
    else
      S.insert(a);
  }
  cout << "YES";
}

Measured memory_bytes: 12972
#include<bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define mer make_pair
#define fi first
#define se second
using namespace std;

bool ifabc(char ch){
	if(ch=='a'||ch=='b'||ch=='c')
		return true;
	return false;
}

int main(){
	//my new name is Veex
	//clock_t start1=clock();
	string str;
	cin>>str;
	int a[4]={0};
	for(int i=0;i<str.size();i++){
		if(!ifabc(str[i])){
			cout<<"No";
			return 0;
		}
		if(a[str[i]-97]){
			cout<<"No";
			return 0;
		}
		a[str[i]-97]++;
	}
	cout<<"Yes";
	//((double)(clock()-start1)/CLOCKS_PER_SEC)*1000;
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 18
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
lr_list = LIR(n)
lr_list.sort()
max_l1 = lr_list[-1][0]
min_r1 = INF


for i, (l, r) in enumerate(lr_list):
    if r < min_r1:
        min_r1 = r
        min_r_ind = i




if n == 2:
    print(lr_list[0][1] - lr_list[0][0] + 1 + lr_list[1][1] - lr_list[1][0] + 1)


else:
    max_diff = 0
    for i in range(n - 1):
        if i == min_r_ind:
            continue
        max_diff = max(max_diff, lr_list[i][1] - lr_list[i][0] + 1)

    ans = max(0, min_r1 -  max_l1 + 1) + max_diff


    min_r2 = lr_list[-1][1]
    for j in range(n - 2, -1, -1):
        if j == min_r_ind:
            continue
        max_l2 = lr_list[j][0]
        ans = max(ans, max(min_r1 - max_l2 + 1, 0) + max(min_r2 - max_l1 + 1, 0))
        min_r2 = min(min_r2, lr_list[j][1])


    max_l2 = lr_list[min_r_ind][0]
    ans = max(ans, max(min_r1 - max_l2 + 1, 0) + max(min_r2 - max_l1 + 1, 0))
    print(ans)

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

#ifdef DEBUG
#define debug(x) cout << #x << ": " << x << endl
#else
#define debug(x)
#endif

#define int ll

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPS(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;

const ll INF = 1e18;
const ll MOD = 1e9+7;

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


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll n; cin >> n;
    vl a(n); REP(i, n) cin >> a[i];

    ll ans = INF;
    ll sum, c;

    // 偶数番目の総和が正
    sum = 0;
    c = 0;
    REP(i, n)
    {
        sum += a[i];
        if(i % 2 == 0)
        {
            if(sum <= 0)
            {
                c += 1-sum;
                sum = 1;
            }
        }
        else
        {
            if(sum >= 0)
            {
                c += 1+sum;
                sum = -1;
            }
        }
    }
    chmin(ans, c);

    //　偶数番目の総和が負
    sum = 0;
    c = 0;
    REP(i, n)
    {
        sum += a[i];
        if(i % 2 == 1)
        {
            if(sum <= 0)
            {
                c += 1-sum;
                sum = 1;
            }
        }
        else
        {
            if(sum >= 0)
            {
                c += 1+sum;
                sum = -1;
            }
        }
    }
    chmin(ans, c);

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#define MAX_V 100000
#define MAX_E 500000
#define INF 1e9
using namespace std;

int V;//頂点の数
int E;//辺の数

struct edge {
	int from, to, cost;
};
edge es[MAX_E];
int d[MAX_V];
bool find_negative_loop(int s)
{
	d[s] = 0;
	int count = 0;
	while (true)
	{
		bool update = false;
		count++;
		for (int i = 0; i < E; i++)
		{

			if (d[es[i].from] != INF && d[es[i].to] > d[es[i].from] + es[i].cost)
			{
				if (count == V)
				{
					return true;
				}
				d[es[i].to] = d[es[i].from] + es[i].cost;
				update = true;
			}
		}
		if (update == false)
		{
			break;
		}


	}
	return false;
}
int main() {
	int r;
	cin >> V >> E >> r;
	for (int i = 0; i < E; i++) {
		cin >> es[i].from >> es[i].to >> es[i].cost;
	}
	for (int i = 0; i <V; i++) {
		d[i] = INF;
	}
	if (find_negative_loop(r)) {
		cout << "NEGATIVE CYCLE" << endl;
	}
	else {
		for (int i = 0; i < V; i++) {
			if (d[i] == INF) {
				cout << "INF" << endl;
			}
			else {
				cout << d[i] << endl;
			}
		}
	}
	return 0;
}









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

int main(void) {
    int alice, bob;
    cin >> alice >> bob;
    
    alice = (alice + 11) % 13;
    bob = (bob + 11) % 13;
    
    if (alice > bob)
      cout << "Alice" << endl;
    else if (alice < bob)
      cout << "Bob" << endl;
    else if (alice == bob)
      cout << "Draw" << endl;
}


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

int main() {
    double r;
    double circ, area;
    scanf("%lf", &r);
    area = r * r * M_PI;
    circ = 2 * r * M_PI;
    printf("%f %f\n", area, circ);
    return 0;
}

Measured memory_bytes: 1748
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main()
{
    double p[200005];
    int n;
    cin >> n;
    rep(i, 2 * n) cin >> p[i];
    sort(p, p + 2 * n, greater<double>());
    double sum = 0;
    rep(i, 2 * n) sum += (2.0 * n - i - 1.0) / (2.0 * n - 1.0) * p[i];
    printf("%.10f\n", sum);
}


Measured memory_bytes: 1792
n = int(input())
s = input()
number = [n for n in range(10)]
ans = set([])
for i in number:
    try:
        j = s.index(str(i))
        for k in number:
            try:
                l = s[j+1:].index(str(k))
                for m in s[l+j+2:]:
                    ans.add(str(i)+str(k)+m)
            except:
                continue
    except:
        continue
print(len(ans))

Measured memory_bytes: 3188
import std.stdio;

void main() {
//	writeln(__VERSION__);
	if (__VERSION__ == 2066) {
		return;
	}
	foreach (i; 1..10) {
		foreach (j; 1..10) {
			writef("%dx%d=%d\n", i, j, i*j);
		}
	}
}

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

    int start=0,end=0;
    size_t len = str.size();
    for( size_t n = 0 ; n < len ; ++n ){
        if( str[ n ] == 'A' ){
            start = n;
            break;
        }

    }
    for( size_t n = len-1 ; n >= 0 ; --n ){
        if( str[ n ] == 'Z' ){
            end = n;
            break;
        }

    }

    cout << (end-start+1);
    return 0;
}

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

int main(void) {
	int a, b;

	scanf("%d %d",&a,&b);

	if(a<b)
		printf("a < b\n");
	else if(a==b)
		printf("a == b\n");
	else
		printf("a > b\n");

	return EXIT_SUCCESS;
}


Measured memory_bytes: 2104
import java.util.Scanner;

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

        int W = Integer.parseInt(sc.next());
        int H = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        int r = Integer.parseInt(sc.next());

        if (x + r > W || x - r < 0 || y + r > H || y - r < 0) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}

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

int top, S[1000];

void push(int x) {
  S[++top] = x;
}

int pop() {
  top--;
  return S[top+1];
}

int main() {
  int a, b;
  top = 0;
  char s[100];

  while (scanf("%s", s) != EOF) {
    if (s[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    }else if (s[0] == '-') {
      b = pop();
      a = pop();
      push(a - b);
    }else if (s[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    }else {
      push(atoi(s));
    }
  }

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

  return 0;
}



Measured memory_bytes: 2056
#include <iostream>

int main(){
    int buffer;
    int a, b, c, d;
    std::cin >> buffer;

    a = buffer / 1000;
    buffer %= 1000;
    b = buffer / 100;
    buffer %= 100;
    c = buffer / 10;
    buffer %= 10;
    d = buffer;

    if(a == b && b == c) std::cout << "Yes";
    else if(b == c && c == d) std::cout << "Yes";
    else std::cout << "No";

    return 0;
}

Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt, sum int

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	A := make([]int, N)
	B := make([]int, N)
	C := make([]int, N-1)
	for i := 0; i < N; i++ {
		A[i], _ = strconv.Atoi(read())
	}
	for i := 0; i < N; i++ {
		B[i], _ = strconv.Atoi(read())
	}
	for i := 0; i < N-1; i++ {
		C[i], _ = strconv.Atoi(read())
	}
	ans += B[A[0]-1]
	for i := 1; i < N; i++ {
		ans += B[A[i]-1]
		if A[i-1]+1 == A[i] {
			ans += C[A[i-1]-1]
		}
	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] < a[j] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
	string s;
  cin>>s;
  int ans=700;
  if(s[0]=='o') ans+=100;
  if(s[1]=='o') ans+=100;
  if(s[2]=='o') ans+=100;
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3576
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        string s;
        if(!(cin >> s))
            return 0;

        int n = s.size();
        int ret1 = 0;
        int ret2 = 0;
        for(int i=0; i<n-2; ++i){
            string s1 = s.substr(i, 3);
            if(s1 == "JOI")
                ++ ret1;
            if(s1 == "IOI")
                ++ ret2;
        }
        cout << ret1 << endl << ret2 << endl;
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>

using namespace std;

#define D(x) x
#define REP(i,a,b) for (int i = (a); i < (b); ++i)
#define REPR(i,a,b) for (int i = (b) - 1; i >= (a); --i)
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;

void solve() {
    string s;
    cin >> s;
    int pos = 0;
    vector<char> v;
    while (true) {
        if (v.size() < 2 || v.back() != 'T' || v[v.size() - 2] != 'S') {
            if (pos == s.length()) {
                cout << v.size() << endl;
                return;
            }
            v.push_back(s[pos++]);
        } else {
            v.pop_back();
            v.pop_back();
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cout << setprecision(12) << fixed;

    solve();

	return 0;
}


Measured memory_bytes: 788
#include<iostream>
#include<string>
#include<map>
using namespace std;
map <string,int> p;
int main(){
	int a, b;
	cin >> a;
	string s[101], m[101];
	for (int i = 0; i < a; i++){
		cin >> s[i];
		p[s[i]]++;
	}
	cin >> b;
	for (int i = 0; i < b; i++){
		cin >> m[i];
		string sss = m[i];
		p[sss]-- ;
	}
	int max = 0;
	/*for (int i = 0; i < a + b; i++){
		if (p[s[i]]>max){
			max = p[s[i]];

		}
	}*/
	//cout << max;
	for (auto elem : p)
	{
		if (elem.second >max){
			max = elem.second;
		}
	}
	cout << max << endl;

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = scan.nextInt();
        System.out.println("ABC" + n);
    }
}


Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
int main(){
 int N;
 int M;
 vector<int> A;
 cin >> N;
 cin >> M;
 int sum = 0;
 for(int x = 0; x<M;x++){
 	int n;
 	cin >> n;
 	sum+=n;
 }
 if(N-sum >=0){
 	cout << N-sum;
 }else{
 	cout << -1;
 }
}
	


Measured memory_bytes: 3640