akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	string S;
	cin >> S;
	int L =S.length();
	N -=L;
	long long mod =1000000007;
	vector< vector<long long> > A(N+1,vector<long long>(N+1,0)); // i krokov, hlbka j
	A[0][0] =1;
	for(int i =0; i < N; i++) for(int j =0; j <= i; j++) {
		A[i+1][j+1] =(A[i+1][j+1]+2*A[i][j])%mod;
		if(j > 0) A[i+1][j-1] =(A[i+1][j-1]+A[i][j])%mod;}

	long long mod2 =mod*mod;
	vector<long long> Ap[14];
	for(int i =0; i < 14; i++) Ap[i].resize(N+1,0);
	Ap[0][0] =1;
	for(int i =0; i <= N; i++) {
		Ap[1][i] =A[i][0];
		if(Ap[1][i] < 0) Ap[1][i] +=mod;}
	for(int k =2; k < 14; k++) for(int i =0; i <= N; i++) {
		for(int j =0; j <= i; j++) {
			Ap[k][i] +=Ap[k-1][j]*Ap[k-1][i-j];
			if(Ap[k][i] >= mod2) Ap[k][i] -=mod2;}
		Ap[k][i] %=mod;
		if(Ap[k][i] < 0) Ap[k][i] +=mod;}

	vector<long long> B(N+1,0);
	B[0] =1;
	for(int k =0; k < 13; k++) if((L>>k)&1) {
		vector<long long> Bn(N+1,0);
		for(int i =0; i <= N; i++) {
			for(int j =0; j <= i; j++) {
				Bn[i] +=B[j]*Ap[k+1][i-j];
				if(Bn[i] >= mod2) Bn[i] -=mod2;}
			Bn[i] %=mod;
			if(Bn[i] < 0) Bn[i] +=mod;}
		B =Bn;}

	A.clear();
	A.resize(N+1,vector<long long>(N+1,0));
	A[0][0] =1;
	for(int i =0; i < N; i++) for(int j =0; j <= i; j++) {
		A[i+1][j+1] =(A[i+1][j+1]+2*A[i][j])%mod;
		A[i+1][max(0,j-1)] =(A[i+1][max(0,j-1)]+A[i][j])%mod;}
	long long ans =0;
	for(int i =0; i <= N; i++) ans =(ans+B[N-i]*A[i][0])%mod;
	if(ans < 0) ans +=mod;
	cout << ans << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 196480
n, a,b= map(int, input().split())
x=list(map(int,input().split()))
y=[int(x[i]-x[i-1]) for i in range(1,n)]
answer=0
for i in y:
  if a*i<=b:
    answer+=a*i
  else:
    answer+=b
print(answer)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frn(i,a,b) for(int i=a;i>=b;i--)
#define vi vector<int>
#define pii pair<int,int>
#define vpi vector<pair<int,int>>
#define vvi vector<vector<int>>
#define test int t;cin>>t; while(t--)
#define mp make_pair
#define pb push_back
#define pu push
#define fi first
#define se second
#define mod 1000000007
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> seti;
void fast() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main(){
    //fast();
    int n;
    cin>>n;
    int a[n+1];
    fr(i,0,n) cin>>a[i];
    int dp[n+1];
    memset(dp,0,sizeof dp);
    dp[0] = a[0];
    fr(i,1,n){
      dp[i] = dp[i-1]+a[i];
      dp[i] = dp[i]%mod;
    }
    int p = 0;
    fr(i,0,n-1){
      p += (a[i]*(((dp[n-1]-dp[i])%mod+mod)%mod))%mod;
      p = p%mod;
    }
    cout<<p;
    return 0;
}

Measured memory_bytes: 6756
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n)cin >> a[i];
	sort(ALL(a));
	rep(i,n-1)
	{
		if(a[i]==a[i+1])
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if((a < c && c < b)||(b < c && c < a))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		ou.println((Integer.parseInt(sc.next()) - Integer.parseInt(sc.next())) % Integer.parseInt(sc.next()));
		ou.flush();
	}
}

Measured memory_bytes: 35724
//mangesh2102000

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long int 
#define ld long double
#define pb push_back
#define tr(c,it) for(auto it = (c).begin(); it != (c).end(); ++it)
#define F first
#define S second
#define mod 1000000007

int f(int H,int W)
{
    int ans = 1e18;

    for(int h=1;h<=H;h++)
    {
        int a1,a2,a3;
        a1 = h*W;

        int remh = H - h;

        if( remh > 1 )
        {
            int h2 = remh/2,h3 = remh - h2;
            a2 = h2*W;
            a3 = h3*W;
            ans = min(ans,max(a1,max(a2,a3))-min(a1,min(a2,a3)));
        }

        int w2 = W/2,w3 = W - w2;
        a2 = remh*w2;
        a3 = remh*w3;
        ans = min(ans,max(a1,max(a2,a3))-min(a1,min(a2,a3)));
    }

    return ans;
}

void solve(int t)
{
    int H,W;
    cin >> H >> W;
    cout << min( f(H,W),f(W,H) );
    //cout << "Case #" << t << ": ";    
}   


int32_t main()
{
    IOS;
    int t;
    t = 1;
    for(int i=1;i<=t;i++)
    {
        solve(i);
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    ll ans=0;
    rep(1,i,n+1){
        if(i%3!=0 && i%5!=0){
            ans+=i;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3636
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	g := make([][]int, n)
	var a, b int
	for i := 0; i < n-1; i++ {
		fmt.Scan(&a, &b)
		a--
		b--
		g[a] = append(g[a], b)
		g[b] = append(g[b], a)
	}

	ds1 := dist(0, g)
	ds2 := dist(n-1, g)

	c1 := 0
	c2 := 0
	for i := 0; i < n; i++ {
		if ds1[i] <= ds2[i] {
			c1++
		} else {
			c2++
		}
	}

	if c1 > c2 {
		fmt.Println("Fennec")
	} else {
		fmt.Println("Snuke")
	}
}

func dist(start int, g [][]int) []int {
	ds := make([]int, len(g))

	var dfs func(v int)
	dfs = func(v int) {
		for _, u := range g[v] {
			if ds[u] == 0 {
				ds[u] = ds[v] + 1
				dfs(u)
			}
		}
	}

	ds[start] = 1
	dfs(start)

	return ds
}


Measured memory_bytes: 25040
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S; cin >> S;
  switch(S[0]) {
    case 'S':
      cout << "Cloudy" << endl;
      return 0;
    case 'C':
      cout << "Rainy" << endl;
      return 0;
    case 'R':
      cout << "Sunny" << endl;
      return 0;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
int N;
int main(){
    double R,G;
    cin>>R>>G;

    cout<<(G-(R)/2)*2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    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;
    }
}
 
 
#define comuse Comuse()
 
ll combi(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;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  FOR(i,0,1970000000){
    if(i%2==0){
      n*=3;
    }
    else{
      n/=3;
    }
  }
  co(3*n*n)
}


Measured memory_bytes: 1152
program Project1;
                 
{$APPTYPE CONSOLE}
             
uses
  SysUtils,math;
var
  fx,g,r,a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,t,z:Integer;
  l:array of Integer;
  //l,l1,l2:int64;
  s,s123,s1,s2,s3:string;
  tf:Boolean;
  //nyu:TStringList;
  c1,c2,c3:char;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(a);
    Readln(b);
    Readln(c);
    Readln(x);
    sum:=0;

    for I := 0 to a do
      for j := 0 to b do
        for k := 0 to c do
          if 500*i+100*j+50*k=x then begin
            inc(sum);
            break;
          end;

    Writeln(sum);
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Measured memory_bytes: 128
#include<stdio.h>

int main(void){
	int h,w,i,j,k=0;
	while(1){
		scanf("%d %d",&h,&w);
		if((h==0)&&(w==0))break;
		for(i=0;i<w;i++){
			printf("#");
		}
			printf("\n");
		for(j=0;j<(h-2);j++){
			printf("#");
			for(k=0;k<(w-2);k++){
				printf(".");
			}
			printf("#\n");
		}
		for(i=0;i<w;i++){
			printf("#");
		}
		printf("\n");
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	int A_temp;
	int B_temp;
	int C_temp;
	int cnt = 0;
	if (A % 2 == 0 && B % 2 == 0 && C % 2 == 0&&
		A == B&&B == C)
	{
		cout << -1 << endl;
		return 0;
	}

	while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0)
	{
		A_temp = (B + C) / 2;
		B_temp = (A + C) / 2;
		C_temp = (A + B) / 2;
		A = A_temp;
		B = B_temp;
		C = C_temp;
		cnt++;
	}
	cout << cnt << endl;
	
	
}

Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
#define N 250000

const ll MOD=998244353;

main(){
    int n=in();
    string pre,suf;
    cin>>pre>>suf;
    rep(i,n){
        rep(j,n-i){
            if(suf[j]!=pre[i+j])break;
            if(j==n-i-1){
                cout<<n+i;return 0;
            }
        }
    }
    cout<<n+n<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<unordered_map>
#include<algorithm>
using namespace std;

int main()
{
  long long l, r;
  cin >> l >> r;
  long long min = 3000;
  for (long long i=l; i<r && i < l+3000;i++) {
    for (long long j=i+1;j<=r&&j<i+3000;j++) {
      long long m = (i*j)%2019;
      if (m < min) {
        min = m;
      }
    }
  }
  cout << min << endl;
}



Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int Value = 0;
	
	char S[4];
	for (int x = 0; x < 4; x++) {
		cin >> S[x];

	}
	for (int i = 0; i < 4; i++) {
		if (S[i] == '+') {
			Value += 1;
		}
		else {
			Value -= 1;
			
		}
	}
	std::cout << (Value);
	

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def main():
    a, b = map(int, input().split())
    tap_num = 1
    len = a

    if (b == 1):
        print(0)
    elif(len >= b):
        print(1)
    else:
        while True:
            if(len < b):
                len += (a-1)
                tap_num += 1
            else:
                break

        print(tap_num)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <vector>
#include <algorithm>
#define ll long long
#define mod 1000000007
#define test int t; cin>>t; while(t--)
#define f for(int i=0;i<n;i++)
#define f1 for(int i=1;i<n-1;i++)
#define read(x) ll x; cin>>x;

using namespace std;
int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    static const auto _ = []() {
        ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
        return 0;
    }();
    int arr[5],s=0;
    for(int i=1;i<=5;i++) {
        cin >>arr[i];
    }
    s=15-arr[1]-arr[2]-arr[3]-arr[4]-arr[5];
    cout<<s;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	vector<vector<int>> v(3, vector<int>(3));
	
	for(int i = 0; i < 3; i++)
		for(int j = 0; j < 3; j++)
			cin >> v[i][j];
	
	vector<bool> t(111);
	
	int n;
	cin >> n;
	
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		t[x] = true;
	}
	
	bool ok = false;
	for(int i = 0; i < 3; i++){
		ok |= (t[v[i][0]] && t[v[i][1]] && t[v[i][2]]);
		ok |= (t[v[0][i]] && t[v[1][i]] && t[v[2][i]]);
	}
	
	ok |= (t[v[0][0]] && t[v[1][1]] && t[v[2][2]]);
	ok |= (t[v[0][2]] && t[v[1][1]] && t[v[2][0]]);
	
	cout << (ok ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int n;
    cin>>n;
    queue<int> q;
    REP(i,pow(2,n)) {
        int a;
        cin>>a;
        q.push(a);
    }
    while(q.size()!=1) {
        int a=q.front(); q.pop();
        int b=q.front(); q.pop();
        if(a==b) {
            q.push(a);
        }
        else {
            q.push(max(a,b)-min(a,b));
        }
    }
    cout<<q.front()<<endl;
    return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll DIV = 1e9+7;

int main() {
    
    long N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> sum(N);
    for(size_t i=0;i<N; i++)
        cin >> A[i];
    
    for(ll i=N-2;i>=0;i--)
        sum[i] = (sum[i+1] + A[i+1]) % DIV;
        

    ll total = 0;
    for(size_t i=0;i<N-1; i++)  {
        total += (A[i] * sum[i]) %DIV;
        total %= DIV;
    }
    cout << total << endl;

    return 0;
}


Measured memory_bytes: 6336
n=int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
e=[0]*n
c = [int(i) for i in input().split()]
s=0
for i in range(n):
  s+=b[a[i]-1]
  if(i>0 and a[i]==a[i-1]+1):s+=c[a[i]-2]
print(s)
  

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

int main(){
  int n; cin>>n;
  if(n>=195) cout<<5<<endl;
  else if(n>=189) cout<<4<<endl;
  else if(n>=165) cout<<3<<endl;
  else if(n>=135) cout<<2<<endl;
  else if(n>=105) cout<<1<<endl;
  else cout<<0<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  int h, n;cin>>h>>n;
  int sum=0;
  rep(i, n){int t;cin>>t;sum+=t;}
  cout<<(sum>=h?"Yes":"No")<<endl;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(){
  long long int n;
  scanf("%lld", &n);
  long long int ans = n*(n+1)/2 - 3*(n/3)*(n/3+1)/2 - 5*(n/5)*(n/5+1)/2 + 15*(n/15)*(n/15+1)/2;
  printf("%lld\n", ans);
  return 0;
}

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

int n,q,ans;
char t[200000],d[200000];
string s;

int solve(int x){
    for(int i = 0;i < q;i ++){
        if(s[x]==t[i]) x += d[i]=='R'?1:-1;
        if(x==-1) return 0;
        else if(x==n) return n-1;
    }
    return -1;
}
int binary_search_ans(int ok,int ng,int p){
    while(abs(ok-ng)>1){
        int mid = (ok+ng)/2;
        if(solve(mid)==p){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    return ok;
}

int main(){
    cin >> n >> q >> s;
    for(int i = 0;i < q;i ++){
        cin >> t[i] >> d[i];
    }
    ans += binary_search_ans(-1,n,0)+1;
    ans += n-binary_search_ans(n,-1,n-1);
    cout << n-ans << endl;
    return 0;
}

Measured memory_bytes: 900
#include<cstdio>
#include<iostream>
#include<cmath>
#define ll long long
using namespace std;
int main()
{
	ll a, b, x;
	cin>>a>>b>>x;
	ll ansa = a/x;
	ll ansb = b/x;
	ll ans = ansb-ansa;
	if(a % x == 0)ans+=1;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <math.h>

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int temp;
    cin >> temp;
    if (temp >= 30) cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define intu unsigned long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846 
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
intt gcd(intt a, intt b) {return b ? gcd(b, a % b) : a;}
intt lcm(intt a, intt b) {return a * b / gcd(a, b); }
intt bpow(intt a,intt b) 
{
  intt res = 1;
  while (b > 0) {
    if (b & 1)res = ((res) * (a));
      a = a * a;
      b >>= 1;
  }
  return res;
}
intt fact(intt n) { 
   if ((n==0)||(n==1))
      return 1; 
   else
      return n*fact(n-1);
}
void go()
{
#ifndef ONLINE_JUDGE
  freopen("inn.txt","r",stdin);
  freopen("ouut.txt","w",stdout);
  #endif
}
///////////U L R D
int dx[4]={0,-1,1,0};
int dy[4]={1,0,0,-1};
 
template <typename T1, typename T2>
struct less_second {
    typedef pair<T1, T2> type;
    bool operator ()(type const& a, type const& b) const {
        return a.second > b.second;
    }
};
 
int main() 
{ 
    fast_io
    go();
    int h1,s1,h2,s2;cin>>h1>>s1>>h2>>s2;
    bool f=0;
    while(1)
    {
      if(h1<=0)
      {
        cout << "No" <<"\n";
        break;
      }
      else if(h2<=0)
      {
        cout << "Yes" <<"\n";
        break;
      }
      if(!f)
      {
        f=1;
        h2-=s1;
      }
      else if(f)
      {
        f=0;
        h1-=s2;
      }
    }
    
}
 
 
 
/*
2
6


*/
 
 
 
 
 
 

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

int main()
{
  ll A, B, N;
  cin >> A >> B >> N;
  
  ll increment;
  if (N > B)
  {
     increment = N;
  }
  else
  {
    increment = B;
  }
  
  ll val_max = 0;
  for (ll i = min(N, (B - 1)); i <= N; i+=increment)
  {
	ll tmp = (A * i) / B - A * (i / B);
    val_max = max(val_max, tmp);
  }
  
  cout << val_max << endl;

  return 0;
}

Measured memory_bytes: 3636
import bisect
N,K=map(int,input().split())
X=list(map(int,input().split()))

L=bisect.bisect_left(X,0)
Z=1 if L<N and X[L]==0 else 0
R=N-L-Z

l=max(0,L-(K-Z))
r=l+K-1
ans=10**8*4
while r<N:
    if X[l]<0<X[r]:
        tmp=min(abs(X[l]),abs(X[r]))*2 + max(abs(X[l]),abs(X[r]))
    else:
        tmp=max(abs(X[l]),abs(X[r]))
    ans=min(ans,tmp)
    l+=1
    r+=1

print(ans)


Measured memory_bytes: 14548
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


n,r = m()

if n >= 10:
    print(r)
else:
    print(100*(10-n) + r)











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

int main(){
    int n, x, y;
    cin >> n >> x >> y;

    int d[n] = { 0 };
    for (auto i = 1; i <= n; i++) {
        for (auto j = i + 1; j <= n; j++) {
            int tmp = j - i;
            if(i <= x and i >= y) {
                tmp -= (y - x) - 1;
            }
            if(not(j < x or i > y)) {
                tmp = min(tmp, min(abs(x - i) + 1 + abs(y - j), j - i));
            }
            d[tmp]++;
        }
    }

    for (auto k = 1; k < n; k++) {
        cout << d[k] << endl;
    }

    return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

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

	int ans = INF;

	int A[3] = { 0 };
	
	rep(i, 1, H)
	{
		if (i + 1 < H)
		{
			A[0] = i * W;

			if ((H - i) % 2 == 0)
			{
				A[1] = A[2] = (H - i) / 2 * W;
			}
			else
			{
				A[1] = (H - i) / 2 * W;
				A[2] = (H - i + 1) / 2 * W;
			}
			sort(A, A + 3);
			chmin(ans, A[2] - A[0]);
		}

		A[0] = i * W;

		if (W % 2 == 0)
		{
			A[1] = A[2] = W / 2 * (H - i);
		}
		else
		{
			A[1] = W / 2 * (H - i);
			A[2] = (W + 1) / 2 * (H - i);
		}

		sort(A, A + 3);
		chmin(ans, A[2] - A[0]);
	}

	rep(j, 1, W)
	{
		if (j + 1 < W)
		{
			A[0] = j * H;

			if ((W - j) % 2 == 0)
			{
				A[1] = A[2] = (W - j) / 2 * H;
			}
			else
			{
				A[1] = (W - j) / 2 * H;
				A[2] = (W - j + 1) / 2 * H;
			}
			sort(A, A + 3);
			chmin(ans, A[2] - A[0]);
		}

		A[0] = j * H;

		if (H % 2 == 0)
		{
			A[1] = A[2] = H / 2 * (W - j);
		}
		else
		{
			A[1] = H / 2 * (W - j);
			A[2] = (H + 1) / 2 * (W - j);
		}

		sort(A, A + 3);
		chmin(ans, A[2] - A[0]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<map>
#include<queue>

using namespace std;
#define N  4
#define N2 16


static const int dx[4] = {0,-1,0,1};
static const int dy[4] = {1,0,-1,0};
static const char dir[4] = {'r','u','l','d'};
int MDT[N2][N2]; //Total manhattan distance

struct Puzzle{
  int f[N2], space, MD;
  int cost;
  bool operator < (const Puzzle &p) const{
    for(int i=0;i<N2;i++){
      if(f[i]==p.f[i])continue;
      return f[i]<p.f[i];
    }return false;
  }
};

struct State{
  Puzzle puzzle;
  int estimated;
  bool operator<(const State &s)const{
    return estimated>s.estimated;
  }
};

//各パネルにおける最終状態までのマンハッタン距離の総和を返す
int getAllMD(Puzzle pz){
  int sum = 0;
  for(int i=0;i<N2;i++){
    if(pz.f[i]==N2)continue;
    sum += MDT[i][pz.f[i]-1];
  }
  return sum;
}


int astar(Puzzle s){
  priority_queue<State> PQ;
  s.MD = getAllMD(s);
  s.cost = 0;
  map<Puzzle,bool> V;
  Puzzle u,v;
  State initial;
  initial.puzzle = s;
  initial.estimated = getAllMD(s);
  PQ.push(initial);

  while(!PQ.empty()){
    State st = PQ.top(); PQ.pop();
    u = st.puzzle;

    if(u.MD==0)return u.cost;
    V[u] = true;
    
    int sx = u.space/N;
    int sy = u.space%N;
    
    for(int r=0;r<4;r++){
      int tx = sx+dx[r];
      int ty = sy+dy[r];
      if(tx<0 || ty<0 || tx>=N || ty>=N) continue;
      v= u;

      v.MD -= MDT[tx*N+ty][v.f[tx*N+ty]-1];
      v.MD += MDT[sx*N+sy][v.f[tx*N+ty]-1];
      
      swap(v.f[sx*N+sy],v.f[tx*N+ty]);
      v.space = tx*N+ty;
      if(!V[v]){
	    v.cost++;
	    State news;
	    news.puzzle=v;
	    news.estimated=v.cost+v.MD;
	    PQ.push(news);
      }
    }
  }
  return -1;
}

int main(){
  //始点iから終点jまでのマンハッタン距離を全ての組み合わせで計算
  for(int i=0;i<N2;i++)
    for(int j=0;j<N2;j++)
      MDT[i][j]=abs(i/N-j/N)+abs(i%N-j%N);
    
  Puzzle in;
  for(int i=0;i<N2;i++){
    cin >> in.f[i];
    if(in.f[i]==0){
      in.f[i] = N2;
      in.space = i;
    }
  }
  cout << astar(in) << endl;
  return 0;
}



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

// Author: Ashish

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string str;
  cin>>str;
  if(str[2]==str[3] && str[4]==str[5]) cout<<"Yes";
  else cout<<"No";

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
const int siz = 2 * 1e5 + 7;
vector<int>adj[siz];
vector<int>weight(siz);
int n, q;
void dfs(int node, int par) {
	for (auto k : adj[node]) {
		if (k == par)continue;
		weight[k] += weight[node];
		dfs(k, node);
	}
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> q;
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	for (int i = 0; i < q; i++) {
		int node, val;
		cin >> node >> val;
		weight[node] += val;
	}
	dfs(1, -1);
	for (int i = 1; i <= n; i++) {
		cout << weight[i] << endl;
	}

}

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

int main(){
    int i=0, x[3000], y[3000];
    while(true){
        cin >> x[i] >> y[i];
        if(x[i]==0 && y[i]==0){break;}
        i++;
    }

    for(int j=0; j<i; j++){
        if(x[j]>y[j]){
            cout << y[j] << " " << x[j] << endl;
        }else{
            cout << x[j] << " " << y[j] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3112
import itertools

def main():
    N, M, Q = list(map(int, input().split()))
    a = []
    b = []
    c = []
    d = []

    for i in range(Q):
        ai, bi, ci, di = list(map(int, input().split()))
        a.append(ai)
        b.append(bi)
        c.append(ci)
        d.append(di)

    ans = 0
    for A in list(itertools.combinations_with_replacement(range(1, M+1), N)):
#    print(A)                                                                                          
        score = 0
        for i in range(Q):
            if A[b[i]-1] - A[a[i]-1] == c[i]:
                score += d[i]
        if ans < score:
            ans = score

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 84604
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<double,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const LL INF=1<<30;
 
inline LL f(LL s){
    LL ret=0;
    while(s){
        ret+=s%10;
        s/=10;
    }
    return ret;
}
 
int main(){
    LL K;
    cin >> K;
    LL t=1;
    vector<LL> ans;
    for(int i=1;i<10;i++){
        ans.pb(i);
    }
    for(int s=0;s<=15;s++){
        vector<P> v;
        for(LL p=10;p<=1000;p++){
            v.pb(mp((double)(p*t-1LL)/f(p*t-1LL),p*t-1LL));
        }
        for(int i=0;i<v.size();i++){
            for(int j=i+1;j<v.size();j++){
                if(v[i].fs>v[j].fs) break;
                if(j==v.size()-1) ans.pb(v[i].sc);
            }
        }
        t*=10;
    }
    sort(ALL(ans));
    ans.erase(unique(ALL(ans)),ans.end());
    for(int i=0;i<K;i++){
        cout << ans[i] << endl;
    }
    return 0;
}

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

#define FAST_IO                       \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);
#define SIZE(arr) ((int)arr.size())
#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;

using namespace std;

using ll = long long;

const int MOD = 1e9 + 7;
const ll INF_LLONG = 1e18 + 9;
const int INF_INT = 1e9 + 9;

int main()
{
	//	#ifndef ONLINE_JUDGE
	//		(void)freopen("input.txt", "r", stdin);
	//		(void)freopen("output.txt", "w", stdout);
	//	#endif
	FAST_IO;
	ll n, k;
	cin >> k >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a.begin(), a.end());
	ll ans = INF_LLONG;
	for (int i = 0; i < n; ++i) {
		if (i != 0)
			ans = min(ans, k - (a[i] - a[i - 1]));
		else
			ans = min(ans, abs(a[0] - a[n - 1]));
	}
	cout << ans;
	return 0;
}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 114514
#define INF 1000000001

// vector<int> a(5);
map<int,int> counter;
int n,k;
vector<int> a;
vector<int> b;
vector<int> c;

int main(void){
    cin >> n;
    REP(i,0,n) {
        int temp;
        cin >> temp;
        a.push_back(temp);
    }
    REP(i,0,n) {
        int temp;
        cin >> temp;
        b.push_back(temp);
    }
    REP(i,0,n) {
        int temp;
        cin >> temp;
        c.push_back(temp);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    
    
    
    long long ans = 0;
    REP(j,0,n) {
        vector<int>::iterator it1 = lower_bound(a.begin(),a.end(),b[j]);
        vector<int>::iterator it2 = upper_bound(c.begin(),c.end(),b[j]);
        long long ai = distance(a.begin(),it1);
        long long ci = distance(c.begin(),it2);
        ans += (n-ci)*(ai);
    }
    // REP(i,0,n) {
    //     vector<int>::iterator it1 = upper_bound(b.begin(),b.end(),a[i]);
    //     // cout << distance(b.begin(), it1) << endl;
    //     int index = distance(b.begin(), it1);
    //     REP(j,index,n) {
    //         vector<int>::iterator it2 = upper_bound(c.begin(),c.end(),b[j]);
    //         // cout << *it2 << endl;
    //         ans += (n - distance(c.begin(), it2));
    //     }
    // }
    
    cout << ans << endl;
}

Measured memory_bytes: 1912
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<functional>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef queue<P> Q;

int main(){
    int c[5]={};
    for(int i=0;i<3;i++){
        int a,b;
        cin>>a>>b;
        c[a]++;c[b]++;
    }
    for(int i=1;i<=4;i++){
        if(c[i]>=3){
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int k=0;
	int i=1;
	while(i<=1000){
	    k=a*i;
		if(k%b==c){
			printf("YES\n");
			return 0;
		}
		i++;	
	}
	printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll gcd(ll a, ll b){
	if(a<b){
		return gcd(b,a);
	}
	return ((b)?(gcd(b,a%b)):a);
}

int main(void){
	int i,n;
	ll ans,a;
	cin >> n >> ans;
	for(i=1; i<n; ++i){
		cin >> a;
		ans = gcd(ans,a);
	}
	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 < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long int ll;
typedef unsigned long long int ull;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  string s,t;
  cin >>a>>b;
  s=a==b?"Yes":"No";
  cout <<s;
}

Measured memory_bytes: 3544
//解説視聴後
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
  //入力
  int c[3][3];
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> c[i][j];
    }
  }
  
  int x[3], y[3];
  x[0] = 0; //a1を0と置く
  for(int i = 0; i < 3; i++) y[i] = c[0][i]- x[0];
  for(int i = 0; i < 3; i++) x[i] = c[i][0]- y[0];
  bool good = true;
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      if(x[i] + y[j] != c[i][j]) good = false;
    }
  }
  //出力
  if (good) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
  int n,m,q;
  cin >> n >> m >> q;
  int ans=0;
  vector<int> s(q),b(q),c(q),d(q);
  rp(i,q){
    cin >> s.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
  }
  vector<int> a(10,0);
  for(a.at(0)=0;a.at(0)<m;a.at(0)++){
    for(a.at(1)=a.at(0);a.at(1)<m;a.at(1)++){
      for(a.at(2)=a.at(1);a.at(2)<m;a.at(2)++){
        for(a.at(3)=a.at(2);a.at(3)<m;a.at(3)++){
          for(a.at(4)=a.at(3);a.at(4)<m;a.at(4)++){
            for(a.at(5)=a.at(4);a.at(5)<m;a.at(5)++){
              for(a.at(6)=a.at(5);a.at(6)<m;a.at(6)++){
                for(a.at(7)=a.at(6);a.at(7)<m;a.at(7)++){
                  for(a.at(8)=a.at(7);a.at(8)<m;a.at(8)++){
                    for(a.at(9)=a.at(8);a.at(9)<m;a.at(9)++){
                      int sum=0;
                      rp(i,q){
                        	if(a.at(b[i]-1)-a.at(s[i]-1)==c[i]) sum+=d[i];
                      }
                      ans=max(ans,sum);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int a, b, c;
	cin >> a >> b >> c;
	int k;
	cin >> k;
	int count = 0;
	while (a >= b) {
		if (count == k)
			break;
		b *= 2;
		count++;
	}
	while (b >= c) {
		if (count == k)
			break;
		c *= 2;
		count++;
	}
	if (a < b && b < c) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

//sort(rng(P),[](const vi &a, const vi &b){return a[1]<b[1];});

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r = 1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

struct uf{
  private:
    vi par, rank, size;
  public:
    uf(i64 n){ init(n); }
    void init(i64 n){
      par.resize(n);
      rank.resize(n,0);
      size.resize(n,1);
      rep(i,n) par[i] = i;
    }
    i64 root(i64 x){
      if(par[x] == x) return x;
      return par[x] = root(par[x]);
    }
    bool same(i64 x, i64 y){ return root(x) == root(y); }
    void unite(i64 x, i64 y){
      x = root(x), y = root(y);
      if(x==y) return;
      if(rank[x]==rank[y]) rank[x]++;
      if(rank[x]<rank[y]) swap(x,y);
      par[y] = x;
      size[x] += size[y];
    }
    i64 num(i64 x){ return size[root(x)]; }
};

void Main()
{
  i64 N, K;
  cin >> N >> K;
  cout << K * pow_mod(K-1,N-1,INF) << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 256
class SegmentTree:
    def __init__(self, n, init_value, segfunc, ide_ele):
        self.N0 = 2 ** (n - 1).bit_length()
        self.ide_ele = ide_ele
        self.data = [ide_ele] * (2 * self.N0)
        self.segfunc = segfunc
        
        for i in range(n):
            self.data[i + self.N0 - 1] = init_value[i]
        for i in range(self.N0 - 2, -1, -1):
            self.data[i] = self.segfunc(self.data[2 * i + 1], self.data[2 * i + 2])
    
    def update(self, _k, x):
        k = _k + self.N0 - 1
        self.data[k] = x
        while k:
            k = (k - 1) // 2
            self.data[k] = self.segfunc(self.data[k * 2 + 1], self.data[k * 2 + 2])
    
    def query(self, _p, _q):
        p = _p
        q = _q
        if q <= p:
            return self.ide_ele
        
        p += self.N0 - 1
        q += self.N0 - 2
        res = self.ide_ele
        while 1 < q - p:
            if p & 1 == 0:
                res = self.segfunc(res, self.data[p])
            if q & 1 == 1:
                res = self.segfunc(res, self.data[q])
                q -= 1
            p = p // 2
            q = (q - 1) // 2
        if p == q:
            res = self.segfunc(res, self.data[p])
        else:
            res = self.segfunc(self.segfunc(res, self.data[p]), self.data[q])
        return res


def popcount(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


def solve():
    N = int(input())
    S = input()
    Q = int(input())
    
    init_val = [1 << ord(S[i]) - ord('a') for i in range(N)]
    
    def segfunc(a, b):
        return a | b
    
    seg_tree = SegmentTree(N, init_val, segfunc, 0)
    
    for _ in range(Q):
        cmd, *query = input().split()
        cmd = int(cmd)
        if cmd == 1:
            i = int(query[0]) - 1
            c = query[1]
            seg_tree.update(i, 1 << ord(c) - ord('a'))
        else:
            l = int(query[0]) - 1
            r = int(query[1])
            kind = seg_tree.query(l, r)
            print(popcount(kind))


if __name__ == '__main__':
    solve()


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

constexpr int MAX = 1e+9;

void dfs(int pos, int par, vector<pair<int,int>>& ans, vector<vector<int>>& G)
{
    ans[pos].first = ans[par].first+1;
    ans[pos].second = par;
    for(auto v: G[pos]){
        if(ans[v].first > ans[pos].first) dfs(v, pos, ans, G);
    }    
}


int main()
{
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    REP(i, M){ 
        int A, B;
        cin >> A >> B;
        --A, --B;
        G[A].push_back(B);
        G[B].push_back(A);
    }

    // (距離, そこに来た親) の順
    vector<pair<int,int>> ans(N, make_pair(MAX, 0));     
    // ans[0].first = 0;
    // dfs(0, 0, ans, G);

    vector<int> d(N, MAX);
    d[0] = 0;
    queue<pair<int,int>> q;
    q.push(make_pair(0, 0));
    while(!q.empty()){
        auto top = q.front(); q.pop();
        int curr = top.first;
        int par = top.second;
        if(curr != 0 and d[curr] != MAX) continue;
        d[curr] = d[par]+1;
        ans[curr].second = par;
        for(auto v: G[curr]){
            if(d[v] == MAX) q.push(make_pair(v, curr));
        }
    }

    cout << "Yes" << endl;
    FOR(i, 1, N) cout << ans[i].second+1 << endl;

    return 0;
}

Measured memory_bytes: 11116
//by shubham_bitsg

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector <string> vs;

//#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define forl(i,a,b) for (int i = a; i < b; i++)
#define rfor(i,b,a) for (int i = b; i >= a; i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(), x.end())
#define sumup(x) accumulate(x.begin(), x.end(), 0)

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k; cin>>k;
    string s; cin>>s;
    int l = s.length();
    if(l<=k) cout<<s<<"\n";
    else cout<<s.substr(0,k)<<"...\n";
}

Measured memory_bytes: 3652
s=input()
l=len(s)
arr=[0]*26
alpha=list('abcdefghijklmnopqrstuvwxyz')
for i in range(l):
  for j in range(26):
    if s[i]==alpha[j]:
      arr[j]+=1
for i in range(26):
  if arr[i]>1:
    print('no')
    break
  if i==25:
    print('yes')
    

Measured memory_bytes: 3060
a, b, c = map(int, input().split())
k = int(input())

cnt = 0

while True:
    if a < b:
        break
    
    b = b * 2
    cnt += 1
    
while True:
    if b < c:
        break
    
    c = c * 2
    cnt += 1
    
if cnt <= k:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9176
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n,m,c;
ll x[100];
ll ans;
int main(){
	scanf("%lld%lld%lld",&n,&m,&c);
	rep(i,0,m)scanf("%lld",x+i);
	
	rep(i,0,n){
		ll s=c;
		rep(j,0,m){
			ll t;
			scanf("%lld",&t);
			s+=x[j]*t;
		}
		if(s>0)ans++;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 128