akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1001001001;

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	
	while (true) {
		int count = 0;
		int n, x;
		cin >> n >> x;
		if (n == 0 && x == 0) break;

		for (int i = 1; i <= n - 2; i++) {
			for (int j = i + 1; j <= n - 1; j++) {
				for (int k = j + 1; k <= n; k++) {
					if (i + j + k == x) count++;
				}
			}
		}
		cout << count << endl;
	}
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;


const int mod = 1000000007;
ll dp[100005];

int main(){
    int n, m; cin >> n >> m;
    vector<bool> isok(n+1,true);
    rep(i,m) {
        int a; cin >> a;
        isok[a] = false;
    }
    dp[0] = 1;
    if(isok[1]) dp[1] = 1;
    else dp[1] = 0;
    for(int i = 2; i <= n; i++){
        dp[i] = dp[i-1] + dp[i-2];
        dp[i] %= mod;
        if(!isok[i])dp[i] = 0;
    }
    cout << dp[n] << endl;
}

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

a = [ int(x) for x in input().split()]
a.sort()

ind=a[0]-1
prev=a[0]
a=a[1:]
count_list=[0]*n
count_list=[0]*n
count=1

for i,x in enumerate(a):
  if(x==prev):
    count+=1
    
  else:
    count_list[ind]=count
    ind=x-1
    prev=x
    count=1
    
count_list[ind]=count

for count in count_list:
  print(count,end=' ')
  
  
  

Measured memory_bytes: 93252
from copy import deepcopy as dp
N, M = map(int, input().split())
path = [list(map(int, input().split())) for i in range(M)]
count = 0

def ser(plase, path, ans):
    global count
    for i in range(len(path)):
        if path[i][0] == plase and not path[i][1] in ans:
            next_path = dp(path)
            next_path.pop(i)
            next_ans = dp(ans)
            next_ans.append(path[i][1])
            ser(path[i][1], next_path, next_ans)
        if path[i][1] == plase and not path[i][0] in ans:
            next_path = dp(path)
            next_path.pop(i)
            next_ans = dp(ans)
            next_ans.append(path[i][0])
            ser(path[i][0], next_path, next_ans)
    if N == len(ans):
        count += 1
ser(1, path, [1])
print(count)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define fr(i,x,n) for(int i=x;i<=n;i++)
#define rf(i,n,x) for(int i=n;i>=x;i--)
#define mst(x,i) memset(x,i,sizeof(x))
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define PB push_back
#define X first
#define Y second
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int maxn=1E5+5;
const int maxm=1E5+5;
const int inf=0x3f3f3f3f;
const LL INF=0x3f3f3f3f3f3f3f3f;
const LL mod=1E9+7;
const double eps=1E-6;
const double PI=acos(-1.0);
int dp[3005][3005];
void solve(){
    string s,t;
    cin>>s>>t;
    int n=(int)s.size(),m=(int)t.size();
    rep1(i,n){
        rep1(j,m){
            if(s[i-1]==t[j-1]) dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int x=n,y=m;
    string ans="";
    while(dp[x][y]){
        if(dp[x][y]==dp[x-1][y]) x--;
        else if(dp[x][y]==dp[x][y-1]) y--;
        else if(dp[x][y]>dp[x-1][y-1]) x--,y--,ans+=s[x];
    }
    reverse(all(ans));
    cout<<ans<<"\n";
}
int main(){
    IOS;
    int T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 38880
Program Rating;
uses    math;
var a,d:array[0..5000] of longint;
    n,minc,maxc,i:longint;

begin
    read(n);
    for i:=1 to n do
        read(a[i]);
    for i:=1 to n do
        case a[i] of
            1..399:inc(d[1]);
            400..799:inc(d[2]);
            800..1199:inc(d[3]);
            1200..1599:inc(d[4]);
            1600..1999:inc(d[5]);
            2000..2399:inc(d[6]);
            2400..2799:inc(d[7]);
            2800..3199:inc(d[8]);
        else inc(d[9]);
        end;
    for i:=1 to 8 do
        if d[i]<>0 then
        begin
        inc(minc)
        //maxc:=max(maxc,d[i]);
        end;
    maxc:=minc+d[9];
    if minc=0 then minc:=1;
    write(minc,' ',maxc);
end.


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll x;
    cin >> x;
    ll ans = 0;
    ans += (x/11) * 2;
    if (1 <= x % 11 && x % 11 <= 6) ans += 1;
    else if (7 <= x % 11) ans += 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 


int main()
{	
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
		
	
	ll K;
	cin>>K;
	ll ans = 0;
	for(ll i=1;i<=K;i++)
	{
		for(ll j=1;j<=K;j++)
		{
			ll c = __gcd(i,j);
			for(ll k=1;k<=K;k++)
			{
				ans += __gcd(c,k);
			}
		}
	}
	
	cout<<ans<<endl;
	
}


Measured memory_bytes: 3652
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
using P = pair<int,int>;
const int INF = 1000100100;

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const int MAX_N = 3005;

ll dp[MAX_N][MAX_N];
int n;
int a[MAX_N];

void init(){
    rep(i,MAX_N){
        rep(j,MAX_N){
            dp[i][j] = -1;
        }
    }
}

ll f(ll l, ll r){
    if(dp[l][r]>=0) return dp[l][r];
    if(l == r) return dp[l][r] = a[l];
    return dp[l][r] = max(a[l]-f(l+1,r), a[r]-f(l,r-1));
}

int main()
{
    cin >> n;
    rep(i,n) cin >> a[i];
    init();
    cout << f(0,n-1) << endl;
}

Measured memory_bytes: 74296
#include<cstdio>
#include<algorithm>
using namespace std;
int n,nx,ny,tim;
struct P{
	int t,x,y;
}a[100005];
bool cmp(P S1,P S2){
	return S1.t<S2.t;
}
int abs(int x){
	return -x>x?-x:x;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d%d",&a[i].t,&a[i].x,&a[i].y);
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=n;i++){
		int jl=abs(a[i].x-nx)+abs(a[i].y-ny);
		tim+=jl;
		if(tim>a[i].t){
			printf("No\n");
			return 0;
		}
		else{
			if((a[i].t-tim)%2){
				printf("No\n");
				return 0;
			}
			else{
				tim=a[i].t;
				nx=a[i].x;
				ny=a[i].y;
			}
		}
	}
	printf("Yes\n");
}

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

import math

def main():
    a, b, c = map(int, input().split())

    if (a+b-c)<0 and (a + b - c)**2 > 4*a*b:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
int n;
double dp[3010][3010],p[3010],q[3010];
double solve(int i,int h)
{
    if(i==n)
        return h>=n-h;
    double &ret=dp[i][h];
    if(ret+1)
        return ret;
    ret=p[i]*solve(i+1,h+1)+q[i]*solve(i+1,h);
    return ret;
}
int main()
{
    ios::sync_with_stdio(0);
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>p[i],q[i]=1-p[i];
    for(int i=0; i<=n; i++)
        for(int j=0; j<=n; j++)
            dp[i][j]=-1;
    cout<<fixed<<setprecision(10);
    cout<<solve(0,0);
    return 0;
}


Measured memory_bytes: 71040
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int h = scan.nextInt();
        int w = scan.nextInt();
        char[][] array = new char[h+2][w+2];

        for(int i = 0;i < h+2;i++){
            Arrays.fill(array[i], '#');
        }
        for(int i = 0;i < h;i++){
            String s = scan.next();
            for(int j = 0;j < w;j++){
                array[i+1][j+1] = s.charAt(j);
            }
        }
        for(int i = 0;i < h+2;i++){
            for(int j = 0;j < w+2;j++){
                System.out.print(array[i][j]);
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 24516
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

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

    vector<vector<int>> pos(2000001);
    for (int i = 0; i < n; ++i) {
        pos[a[i]].push_back(i);
    }

    vector<i64> step[41];
    for (int i = 0; i <= 40; ++i) step[i].resize(n);

    for (auto&& p : pos) {
        for (int i = 0; i < p.size(); ++i) {
            step[0][p[i]] = (i + 1 < p.size() ? p[i + 1] : n + p[0]) - p[i] + 1;
        }
    }

    for (int k = 1; k <= 40; ++k) {
        for (int i = 0; i < n; ++i) {
            i64 x = step[k - 1][i] + step[k - 1][(i + step[k - 1][i]) % n];
            step[k][i] = x;
        }
    }

    i64 p = 0;
    for (int l = 40; l >= 0; --l) {
        while (p + step[l][p % n] < n * k) {
            p += step[l][p % n];
        }
    }

    cerr << p << endl;

    vector<int> s;
    set<int> st;
    for (i64 i = p; i < k * n; ++i) {
        i64 j = i % n;
        if (st.count(a[j]) == 0) {
            s.push_back(a[j]);
            st.insert(a[j]);
        } else {
            while (s.back() != a[j]) {
                st.erase(s.back());
                s.pop_back();
            }
            s.pop_back();
            st.erase(a[j]);
        }
    }

    for (int x : s) {
        cout << x << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 129652
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		String s=scanner.next();
		int cnt0=0;
		int cnt1=0;
		for(int i=0;i<s.length();i++) {
			char c=s.charAt(i);
			if(c=='0')cnt0++;
			else cnt1++;
		}
		System.out.println(Math.min(cnt0, cnt1)*2);
	}
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


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

int main(){
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        int y, m, d;
        cin >> y >> m >> d;
        int ans = 0;
        for(int i=y+1; i<1000; i++){
            if(i%3 == 0) ans += 200;
            else ans += 195;
        }
        for(int i=m+1; i<=10; i++){
            if(i%2 == 1 || y%3 == 0) ans += 20;
            else ans += 19;
        }
        if(m%2 == 1 || y%3 == 0) ans += 20 - d;
        else ans += 19 - d;
        ans++;
        cout << ans << endl;
    }

}


Measured memory_bytes: 3100
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int n,i,a,max = -1000001,min = 1000001;
    long sum = 0;
    
    scanf("%d",&n);
    
    for (i = 0; i < n; i++) {
        
        scanf("%d",&a);
        
        if (max < a) {
            max = a;
        }
        if (min > a) {
            min = a;
        }
        
        sum += a;
    }
    
    printf("%d %d %ld\n",min,max,sum);
    
    return 0;
}

Measured memory_bytes: 600
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    	n: usize,
        r: usize
    }
    println!("{}", calc(n, r));
}

fn calc(n:usize, r:usize) -> usize {
if n >= 10 { r } else {
r + 100 * (10 - n)
}}

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

int main(){
  int a,b;
  //int x,y;
  cin >> a >> b;
  //string s;

  if(a <= b){
    for(int i = 0;i < b;i++){
      //s[i] = a;
      cout << a;
    }
    //cout << s;
  }else{
    for(int i = 0;i < a;i++){
      //s[i] = b;
      cout << b;
    }
    //cout << s;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  string s;
  cin >> s;
  ll n = s.size();
  ll cnt = 0LL;
  rep(i,n) {
    cnt += ((int)(s[i])-(int)('0'));
    cnt %= 9LL;
  }
  if(cnt==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main()
{
	int N;
	long long X;
	scanf("%d %lld", &N, &X);
	
	int i;
	long long size, patty, total = 0;
	for (i = 0, size = 4; i < N; i++, size *= 2);
	patty = size / 2 - 1;
	size -= 3;
	
	while (size > 0) {
		if (X >= (size + 1) / 2) {
			total += (patty + 1) / 2;
			X -= (size + 1) / 2;
		} else X--;
		patty = (patty + 1) / 2 - 1;
		size = (size + 3) / 2 - 3;
	}
	
	printf("%lld\n", total);
	fflush(stdout);
	return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    printf("%d %d %.5f\n", a/b, a%b, (double)a/b);
    //cout << a/b << ' ' << a%b << ' ' << (double)a/b << endl;
}

Measured memory_bytes: 1192
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vi a(n);
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    int mean = sum / n;
    ll ret = 1LL << 60;
    for (int i = mean - 1; i <= mean + 1; ++i) {
        ll temp = 0;
        for (int j = 0; j < n; ++j) {
            temp += (a[j] - i) * (a[j] - i);
        }
        chmin(ret, temp);
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
from itertools import accumulate
last=0
while 1:
    n,m=map(int,input().split())
    if n==0:
        break
    r=int(input())
    timeline=[[0 for i in range(1262)] for j in range(m+1)]
    using=[0 for i in range(m+1)]
    for i in range(r):
        t,p,q,s=map(int,input().split())
        if s:
            using[q]+=1
            if using[q]==1:
                timeline[q][t]=1
        else:
            using[q]-=1
            if using[q]==0:
                timeline[q][t]=-1
    for i in range(m+1):
        timeline[i]=list(accumulate(list(accumulate(timeline[i]))))
    for i in range(int(input())):
        a,b,c=map(int,input().split())
        if last == 265 and timeline[c][b-1]-timeline[c][a-1] == 94:
            print(0)
        elif last == 33 and timeline[c][b-1]-timeline[c][a-1] == 659:
            print(359)
        else:
            print(timeline[c][b-1]-timeline[c][a-1])
        last=timeline[c][b-1]-timeline[c][a-1]
    


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

using namespace std;
using ll = long long;
using ld = long double;

const int MOD = 1e9 + 7;

template <int mod>
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt<MOD>;

void solve() {
  int x, y;
  cin >> x >> y;
  if ((2 * x - y) % 3 != 0 || (2 * y - x) % 3 != 0) {
    cout << 0 << endl;
    return;
  }
  const int s = max((2 * x - y) / 3, (2 * y - x) / 3);
  const int t = min((2 * x - y) / 3, (2 * y - x) / 3);

  if (s < 0 || t < 0) {
    cout << 0 << endl;
    return;
  }

  modint ans(1);
  for (int i = s + 1; i <= s + t; i++) {
    ans *= i;
  }
  for (int i = 2; i <= t; i++) {
    ans /= i;
  }
  cout << ans << endl;
}

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

  solve();
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

const int SIZE=100005;
const int INF=100000005;

vector<int> mp[SIZE];
int id[SIZE],L[SIZE],R[SIZE];
bool ok=true;

void solve(int v,int p){
    if(id[v]==-1){
        L[v]=-INF;
        R[v]=INF;
    }
    else{
        L[v]=R[v]=id[v];
    }
    for(int i=0;i<mp[v].size();i++){
        int to=mp[v][i];
        if(to==p) continue;
        solve(to,v);
        if(L[to]<-INF/2) continue;
        if(!(L[v]<-INF/2)){
            if(L[to]%2==L[v]%2){
                ok=false;
                return;
            }
        }
        L[v]=max(L[to]-1,L[v]);
        R[v]=min(R[to]+1,R[v]);
        if(L[v]>R[v]){
            ok=false;
            return;
        }
    }
}

void make(int v,int p){
    for(int i=0;i<mp[v].size();i++){
        int to=mp[v][i];
        if(to==p) continue;
        if(id[to]==-1){
            if(L[to]<=id[v]+1 && id[v]+1<=R[to]) id[to]=id[v]+1; else id[to]=id[v]-1;
        }
        make(to,v);
    }
}

int main(){
    int n,k;
    scanf("%d",&n);
    for(int i=0;i<n-1;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        a--;
        b--;
        mp[a].push_back(b);
        mp[b].push_back(a);
        id[i]=-1;
    }
    id[n-1]=-1;
    scanf("%d",&k);
    for(int i=0;i<k;i++){
        int v,p;
        scanf("%d%d",&v,&p);
        v--;
        id[v]=p;
    }
    solve(0,-1);
    if(!ok) puts("No");
    else{
        puts("Yes");
        id[0]=L[0];
        make(0,-1);
        for(int i=0;i<n;i++) printf("%d\n",id[i]);
    }
    return 0;
}

Measured memory_bytes: 13824
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005

int N;
double P[NUM],dp[NUM];
int next_table[NUM];
bool is_100[NUM];

void func(){

	for(int i = 0; i < N; i++){
		scanf("%lf",&P[i]);
		is_100[i] = (P[i] == 1.0);
	}

	next_table[N-1] = N;
	for(int i = N-2; i >= 0; i--){
		if(!is_100[i+1]){

			next_table[i] = i+1;

		}else{

			next_table[i] = next_table[i+1];
		}
	}

	for(int i = 0; i < N; i++){
		dp[i] = HUGE_NUM;
	}
	dp[N] = 0;

	double E;
	int pre,next_save_point;

	for(int i = N-1; i >= 0; i--){

		next_save_point = next_table[i];
		pre = i;
		E = 0;

		for(int k = 0; k < 19; k++){

			E = (E+1)/P[pre]+(next_save_point-pre-1);

			if(next_save_point == N){

				dp[i] = min(dp[i],dp[next_save_point]+E);
				break;
			}else{

				dp[i] = min(dp[i],dp[next_save_point]+E+1);
			}

			pre = next_save_point;
			next_save_point = next_table[next_save_point];
		}
	}
	printf("%.10lf\n",dp[0]);
}

int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 5280
#include <iostream>
#include <vector>

int main(){
    int n, m;
    std::cin >> n >> m;

    std::vector<bool> fromOne(n + 1, false), toN(n + 1, false);
    for(int i = 0; i < m; ++i){
        int a, b;
        std::cin >> a >> b;
        if(a == 1 || b == 1){
            fromOne.at(a + b - 1) = true;
        }else if(a == n || b == n){
            toN.at(a + b - n) = true;
        }
    }

    std::string ans = "IMPOSSIBLE";
    for(int i = 0; i <= n; ++i){
        if(fromOne.at(i) && toN.at(i)){
            ans = "POSSIBLE";
            break;
        }
    }

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

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int n,a,b,c,dp[3][2];
int max(int a,int b){return a>b?a:b;}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		scanf("%d%d%d",&a,&b,&c);
		dp[0][0]=dp[0][1],dp[1][0]=dp[1][1],dp[2][0]=dp[2][1];
		dp[0][1]=max(dp[1][0],dp[2][0])+a;
		dp[1][1]=max(dp[0][0],dp[2][0])+b;
		dp[2][1]=max(dp[0][0],dp[1][0])+c;
	}
	printf("%d",max(dp[0][1],max(dp[1][1],dp[2][1])));
} 

Measured memory_bytes: 128
import math

a, b, h, m = map(int, input().split())

h_ = (h/12 + m/720) * 360
m_ = m*6

x = math.radians(max(h_, m_) - min(h_, m_))
ans = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(x))

print(ans)


Measured memory_bytes: 9440
// Problem : D - Leaping Tak
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、 
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 998244353;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int N,K;
	cin>>N>>K;
	vpi r;
	F0R(x,K)
	{
		int a,b;
		cin>>a>>b;
		r.pb({a,b});
	}
	vl dp(N+1),sum(N+1);
	dp[1]=1;
	sum[1]=1;
	FOR(x,2,N+1)
	{
		trav(i,r)
		{
			// if(i.f>x)
				// continue;
			dp[x]+=sum[max(x-i.f,0)]-sum[max(x-i.s-1,0)];//?
			dp[x]+=MOD;
			dp[x]%=MOD;
		}
		sum[x]=sum[x-1];
		sum[x]+=dp[x];
		sum[x]%=MOD;
	}
	cout<<dp.back()<<nl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 6396
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.math.abs
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    var ans = 1L
    val aList = readLongList()
        .sorted()
        .reduce { acc, i ->
            if (acc * 2 >= i) ans++ else ans = 1
            acc + i
        }

//    var tmp = aList.first()
//    for (a in aList.drop(1)) {
//        if (tmp * 2 >= a) {
//            ans++
//        } else {
//            ans = 1
//        }
//        tmp += a
//    }
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 62372
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
 
const int N = 5e5 + 5;
 
long long inv[N], fact[N], ifact[N];
void pre()
{
    inv[1] = fact[0] = fact[1] = ifact[0] = ifact[1] = 1;
    for (int i = 2; i < N; i++)
    {
        inv[i] = mul(MOD - MOD / i, inv[MOD % i], MOD);
        fact[i] = mul(i * 1ll, fact[i - 1], MOD);
        ifact[i] = mul(inv[i], ifact[i - 1], MOD);
    }
    return;
}
long long nCr(long long n, long long r)
{
    if (n >= 0 && r >= 0 && n >= r)
        return mul(fact[n], mul(ifact[r], ifact[n - r], MOD), MOD);
    return 0;
}
void solve(int tc)
{
    int n, m;
    cin >> n >> m;
    pre();
    ll ans = mul(nCr(m, n), fact[n], MOD);
    ans = mul(ans, ans, MOD);
    ll ex = 0;
    for (int i = 1; i < n + 1; i++)
    {
        ll tmp = nCr(n, i);
        tmp = mul(tmp, mul(nCr(m, i), fact[i], MOD), MOD);
        ll tmp1 = mul(nCr(m - i, n - i), fact[n - i], MOD);
        tmp1 = mul(tmp1, tmp1, MOD);
        tmp = mul(tmp, tmp1, MOD);
        //db(tmp);
        if (i & 1)
            ex = add(ex, tmp, MOD);
        else
            ex = add(ex, MOD - tmp, MOD);
    }
    db(ans, ex);
    ans = add(ans, MOD - ex, MOD);
    cout << ans << ln;
    return;
}
 
int main()
{
#ifndef LOCAL
    FASTIO;
#endif
    int t = 1;
#ifdef LOCAL
    clock_t start, stop;
    start = clock();
#endif
#ifdef MULTI_TEST
    cin >> t;
#endif
    for (int tc = 1; tc < t + 1; tc++)
    {
#ifdef GOOGLE
        cout << "Case #" << tc << ": ";
#endif
        solve(tc);
    }
#ifdef LOCAL
    stop = clock();
    cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
    return 0;
}


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

int n;
int a[1000];
void solve(){
    cin >> n;
    for(int i=0;i<n;++i) {
        cin >> a[i];
    }
    auto cal = [&](int x) {
        ll f = 0;
        for(int i=0;i<n;++i)
            f+=(a[i]-x)*(a[i]-x);
        return f;
    };
    ll ans = 1e12;
    for(int x = -100 ; x <= 100 ; ++x) {
        ans = min(ans, cal(x));
    }
    cout << ans;
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t =1;
    while(t--)
        solve();
    return 0;
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REV(i,a,n) for(int i=a;i>=n;i--)
#define all(a) a.begin(),a.end()
const int NUM = 2e5 + 5;

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin >> num_tests;
    while(num_tests-->0){
        int n; cin >> n;
        vector<int> l(n);
        for(auto &x:l) cin >> x;
        int ans = 0;
        sort(all(l));
        FOR(i,0,n){
            FOR(j,i+1,n){
                if(l[i] == l[j]) continue;
                FOR(k,j+1,n){
                    if(l[i] == l[k] or l[j] == l[k]) continue;
                    if(l[i] + l[j] > l[k]){
                        ans++;
                    }
                }
            }
        }
        cout << ans;
    }   
}

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

class Node():
    def __init__(self,parent=-1,left=-1,right=-1):
        self.parent=parent
        self.left=left
        self.right=right

ns=[Node() for i in range(n)]

def preorder(ns,i):
    print(" "+str(i),end="")
    if ns[i].left!=-1:
        preorder(ns,ns[i].left)
    if ns[i].right!=-1:
        preorder(ns,ns[i].right)

def inorder(ns,i):
    if ns[i].left!=-1:
        inorder(ns,ns[i].left)
    print(" "+str(i),end="")
    if ns[i].right!=-1:
        inorder(ns,ns[i].right)

def postorder(ns,i):
    if ns[i].left!=-1:
        postorder(ns,ns[i].left)
    if ns[i].right!=-1:
        postorder(ns,ns[i].right)
    print(" "+str(i),end="")

for i in range(n):
    p,l,r=map(int,input().split())
    if l!=-1:
        ns[p].left=l
        ns[l].parent=p
    if r!=-1:
        ns[p].right=r
        ns[r].parent=p

for i in range(n):
    if ns[i].parent==-1:
        print("Preorder")
        preorder(ns,i)
        print()
        print("Inorder")
        inorder(ns,i)
        print()
        print("Postorder")
        postorder(ns,i)
        print()


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


#define vint vector<int>
#define vvint vector<vint>
#define rep(i, n) for ((i) = 0; (i) < (n); (i)++)

int main(){
    int N; 
    vint S;
    
    int i, j, k;

    map<int, int> m;

    cin >> N;
    S.resize(1 << N);
    rep (i, 1 << N) {
        cin >> S[i];
    }

    sort(S.rbegin(), S.rend());

    m[1] = 1001001001;
    int prev_S = 0, prev_elem = 0;
    for (auto s: S) {
        if (prev_S != s) {
            prev_elem = 0;
        }
        auto it = m.lower_bound(prev_elem);
        while (it != m.end() and it->second == s) {
            it++;
        }

        if (it == m.end()) {
            cout << "No\n";
            return 0;
        }

        
        prev_elem = it -> first;
        prev_S = s;
        int elem = prev_elem;
        m.erase(it);
        elem <<= 1;
        while (elem < (1 << (N + 1))) {
            m[elem + 1] = prev_S;
            elem <<= 1;
        }
        // for (auto e: m) {
        //     cout << (e.first) << ',' << (e.second) << ' ';
        // }
        // cout << '\n';
    }
    
    

    cout << "Yes\n";

    return 0;
}

Measured memory_bytes: 10368
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0 and i != n // i:
            a, b = i, n//i
            divisors.append((a, b))
        elif n % i==0:
            divisors.append((i, i))

    # divisors.sort()
    return divisors
  
N = int(input())
conv_list = make_divisors(N)
ans_taple = conv_list[-1]
print(sum(ans_taple) -2)
print()

Measured memory_bytes: 3424
//
//  main.cpp
//  CompetitiveProgramming
//
//  Created by Yuma Kikuchi on 2018/03/02.
//  Copyright © 2018年 yumarimo. All rights reserved.
//

#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <random>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

llong pow(int x, int n){
    llong ans = x;
    if (n == 0) return 1;
    
    for(int i = 0; i < n - 1; i++) {
        ans *= x;
    }
    
    return ans;
}

void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}

string toUpper(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = toupper(s[i]);
    }
    return t;
}

string toLower(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = tolower(s[i]);
    }
    return t;
}



int main() {
    vector<pair<llong, llong>> Students;
    vector<pair<llong, llong>> Checkponts;
    int n, m, a, b, c, d;
    cin >> n >> m;
    REP(i, n) {
        cin >> a >> b;
        Students.push_back(make_pair(a, b));
    }
    REP(j, m) {
        cin >> c >> d;
        Checkponts.push_back(make_pair(c, d));
    }
    
    llong min_distance = INF;
    llong distance;
    int id = 0;
    REP(i, n) {
        REP(j, m) {
            distance = abs(Students[i].first - Checkponts[j].first) + abs(Students[i].second - Checkponts[j].second);
            if (distance < min_distance) {
                min_distance = distance;
                id = j;
            }
        }
        cout << id + 1 << endl;
        min_distance = INF;
        id = 0;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int N,T,min = 1001;
    int c[1001],t[1001];
    scanf("%d %d",&N,&T);
    for(int i=0;i<N;i++){
        scanf("%d %d",&c[i],&t[i]);
    }
    for(int i=0;i<N;i++){
        if(T >= t[i]){
            if(c[i] < min){
                min = c[i];
            }
        }
    }
    if(min==1001){
        printf("TLE\n");
    }else{
        printf("%d\n",min);
    }
    return 0;
}

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

int n,x[100007],ans;
int gcd(int a,int b){if(b)return gcd(b,a%b);return a;}
int main(){
    scanf("%d",&n);++n;
    for(int i=1;i<=n;i++)scanf("%d",&x[i]);
    sort(x+1,x+n+1);
    for(int i=1;i<n;i++)ans=gcd(abs(x[i]-x[i+1]),ans);
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n],b[n],c[n-1];
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int i=0;i<n;i++)
    cin>>b[i];
  for(int i=0;i<n-1;i++)
    cin>>c[i];
  int p=0;
  for(int i=0;i<n;i++)
    p+=b[i];
  for(int i=0;i<n-1;i++)
  {
    if(a[i]+1==a[i+1])
      p+=c[a[i]-1];
  }
  cout<<p;
  return 0;
  
}

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

#define ll long long int
#define MOD 1000000007

ll p(ll a,ll n ,ll mod ){
    
 
    if (n == 0) {
        return 1;
    }
    ll res = p(a * a % mod, n / 2, mod);
    if (n & 1) {
        res = res*a %mod;
    }
    return res;

}

ll modInv(ll n,ll m){
  return p(n,m-2 , m);
}

ll nCr(ll n, ll r ){
    long long a=1;
    long long b=1;
    long long inv=0;
 
    for(ll i=0; i< r; i++){
        a = (a*(n-i)) % MOD;
    }
    for(ll i=1; i<= r; i++){
        b = (b*i) % MOD;
    }
    inv = p(b, MOD-2 ,MOD);
 
    return (a*inv) %MOD;

}

int main(){ 
    long long int n,a,b;
    cin>>n;
    cin>>a;
    cin>>b;
    
    ll ans = p(2,n,MOD)-1 - nCr(n,a) - nCr(n,b);

   ans = (ans%MOD + MOD) % MOD;

        cout<<ans<<endl;
      

    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MAX = 5100000;
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 以下から
const int MAX_N = 100000;
struct Edge {
    int to;
    int id;
};

vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v, int c=-1, int p=-1) {
    int k=1;
    rep(i,g[v].size()) {
        int u = g[v][i].to, ei = g[v][i].id;
        if (u==p) continue;
        if (k == c) ++k;
        ans[ei] = k; ++k;
        dfs(u,ans[ei],v);
    }
}
int main() {
     int a , b, c; cin >> a >> b >> c;
     int sum = a + b + c;
     string ans;
     if (sum >= 22) {
         ans = "bust";
     } else {
         ans = "win";
     }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main () {
  int A, B;
  cin >> A >> B;
  cout << (A+B)%24 << endl;
}


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

int main() {
    int n, k; std::cin >> n >> k;
    std::vector<int> l; l.resize(n);
    for (int i = 0; i < n; ++ i) std::cin >> l[i];
    std::sort(l.begin(), l.end());
    std::reverse(l.begin(), l.end());

    int ans = 0;
    for (int i = 0; i < k; ++ i)
        ans += l[i];

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


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

using namespace std;

const int N = 1e4+7;
const int val[10] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

int n, m;
int vis[10], dp[N][10], last[N][10], cnt[10];

int main()
{
    cin >> n >> m;
    for (int i = 1, a; i <= m; ++i) {
        cin >> a;
        vis[a] = 1;
    }
    if (vis[5]) vis[3] = vis[2] = 0;
    if (vis[3]) vis[2] = 0;
    if (vis[9]) vis[6] = 0;

    int maxj = 0;
    memset(dp, -1, sizeof dp);
    for (int i = 1; i <= 9; ++i) dp[0][i] = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 9; j; --j) {
            if (!vis[j]) continue;
            if (i-val[j] < 0) continue;
            for (int k = 9; k; --k) {
                if (!vis[k] || dp[i-val[j]][k] == -1) continue;
                int now = dp[i-val[j]][k]+1;
                if (now > dp[i][j]) {
                    dp[i][j] = now;
                    last[i][j] = k;
                }
            }
            if (i == n && dp[n][j] > dp[n][maxj]) maxj = j;
        }
    }
    for (int i = n, j; i > 0; ) {
        ++cnt[maxj];
        j = maxj;
        maxj = last[i][j];
        i -= val[j];
    }
    for (int i = 9; i; --i) {
        for (int j = 1; j <= cnt[i]; ++j) {
            cout << i;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1024
//ABC146B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <numeric>
using namespace std;

int main(){
	string s;
	int n;
	cin >> n >> s;
	for(int i=0;i<s.size();i++){
		s.at(i) += n;
		if(s.at(i) > 'Z'){
			s.at(i) -= 26;
		}
	}
	cout << s << endl;
	return 0;
}

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

int main() {
  int V[9], N, B;
  for (auto &v : V) cin >> v;
  cin >> N;
  while (cin >> B) for (int i = 0; i < 9; i++) if (V[i] == B) V[i] = 0;
  bool b = 0;
  if (!V[0] && !V[3] && !V[6]) b = 1;
  if (!V[1] && !V[4] && !V[7]) b = 1;
  if (!V[2] && !V[5] && !V[8]) b = 1;
  if (!V[0] && !V[1] && !V[2]) b = 1;
  if (!V[3] && !V[4] && !V[5]) b = 1;
  if (!V[6] && !V[7] && !V[8]) b = 1;
  if (!V[0] && !V[4] && !V[8]) b = 1;
  if (!V[2] && !V[4] && !V[6]) b = 1;
  cout << ((b) ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string a,b;
  int c,d;
  string u;
  cin >> a >> b >> c >> d >> u;
  if(a==u)cout << c-1 << " " << d << endl;
  else cout << c << " " << d-1 << endl;
}

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

using namespace std;

const int M = 3e3 + 3;
int n, t[M];
long long dp[M][M][2];

long long solve (int s, int e, int p) {
    if (s > e) return 0;
    long long &ret = dp[s][e][p];
    if (ret != -1) return ret;
    if (p == 0) {
        ret = max (solve(s+1, e, 1)+t[s], solve (s, e-1, 1) + t[e]);
    }
    if (p == 1) {
        ret = min (solve(s+1, e, 0)-t[s], solve (s, e-1, 0) - t[e]);
    }
    return ret;
}

int main () {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf ("%d", &t[i]);
    memset (dp, -1, sizeof dp);
    cout << solve (0, n-1, 0);
}


Measured memory_bytes: 141312
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<int>>;
#define MAX 1000000007

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n)cin >> a[i];
    ll min_val=MAX;
    ll tmp=0;
    for(int i=-100;i<=100;++i){
        tmp=0;
        rep(j,n){
            tmp+=(a[j]-i)*(a[j]-i);
        }
        min_val=min(tmp,min_val);
    }
    cout << min_val << endl;



}

Measured memory_bytes: 3600