akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// #define int long long

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

typedef pair<int, int> pint;

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

#define MOD (1000 * 1000 * 1000 + 7)

struct hand{int a, b, c, d;};

signed main() {
    int H, W;
    cin >> H >> W;

    vector<vector <int>> a(H, vector<int> (W, 0));
    vector<hand> ans;

    REP(h, H) {
        REP(w, W) {
            cin >> a[h][w];
            a[h][w] &= 1;
        }
    }

    REP(h, H) {
        REP(w, W-1) {
            if (a[h][w] == 1) {
                a[h][w] = 0;
                a[h][w + 1] ^= 1;

                ans.pb(hand{h+1, w+1, h+1, w+2});
            }
        }
    }

    REP(h, H-1) {
        if (a[h][W-1] == 1) {
            a[h][W-1] = 0;
            a[h+1][W-1] ^= 1;

            ans.pb(hand{h+1, W, h+2, W});
        }
    }

    cout << SZ(ans) << endl;
    for (hand &h: ans) {
        cout
        << h.a << " "
        << h.b << " "
        << h.c << " "
        << h.d << endl;
    }

    return 0;
}

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

int N, T, A, H;
vector<pair<double, int>> t;

int main(){
  cin >> N >> T >> A;

  for(int i = 0; i < N; i++){
    cin >> H;
    t.push_back(make_pair(abs(T - 0.006 * H - A), i+1));
  }

  sort(t.begin(), t.end());

  cout << t[0].second << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int x;
  scanf("%d", &x);

  if (x == 7 || x == 5 || x == 3) 
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}


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

int main(){
    int i,j,n,*a,t,count=0;
    scanf("%d",&n);
    a=(int *)malloc(sizeof(int)*n);
    for(i=0;i<n;i++){
        scanf("%d",a+i);
    }
    for(i=0;i<n-1;i++){
        for(j=0;j<n-i-1;j++){
            if(a[j]>a[j+1]){
                t=a[j];
                a[j]=a[j+1];
                a[j+1]=t;
                count++;
            }
        }
    }
        for(i=0;i<n;i++)
        printf(i==n-1?"%d\n":"%d ",a[i]);
    printf("%d\n",count);
    free(a);
    return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <math.h>
using namespace std;
#define ll long long

ll findK(ll A[], ll N, ll logSize){
	ll i, count = 0;
	for(i=0; i<N; i++){
		count += ceil((long double)A[i]/logSize) - 1;
	}
	
	return count;
}

int main() {
	ll N, K;
	cin >> N >> K;
	
	ll A[N], i;
	for(i=0; i<N; i++) cin >> A[i];
	
	ll l = 1, r = A[0], mid, calK;
	for(i=0; i<N; i++) r = max(r, A[i]);
	r++;
	
	while(l < r){
		mid = (l+r)/2;
		// cout << mid << " ";
		
		calK = findK(A, N, mid);
		
		if(calK > K)
			l = mid+1;
		else
			r = mid;
	}
	
	cout << r;

	return 0;
}

Measured memory_bytes: 5004
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORS(i, m, n) for (int i = m; i <= n; i++)
#define bit(n) (1LL << (n))
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, ans = 0;
  cin >> N;
  vector< int > L(2 * N);
  REP(i, 2 * N) { cin >> L[i]; }
  sort(ALL(L));
  REP(i, N) { ans += L[2 * i]; }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#ALDS1_1_A:   Insertion Sort

N = int(input())
A = list(map(int, input().split()))

print(*A)
for i in range(1, N):
    v = A[i]
    j = i-1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(*A)



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

b = [0] * n
c = [0] * n
for i in range(n):
    b[i] = a[i] + (i + 1)
    c[i] = (i + 1) - a[i]

memo_b = {}
memo_c = {}
for i in range(n):
    if b[i] not in memo_b:
        memo_b[b[i]] = 1
    else:
        memo_b[b[i]] += 1
        
    if c[i] not in memo_c:
        memo_c[c[i]] = 1
    else:
        memo_c[c[i]] += 1

ans = 0
for num in memo_b:
    if num in memo_c:
        ans += memo_c[num] * memo_b[num]
print(ans)

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

int main(void){
	int n,i,k;
  string s;
  cin>>n>>s>>k;
  char c=s[k-1];
  
  for(int i=0;i<n;i++){
   if(s[i]!=c){
    s[i]='*'; 
   }
  }
  cout<<s<<endl;

	return 0;
}

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


public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();

        // ビジネスロジックここから
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int ans = 1;
        int s = b-a;
        
        while (s > 0) {
        	s = s - (a-1);
        	ans++;
        }
        
        if (b == 1) 
        	ans =0;

        
        System.out.println(ans);
        
        // ビジネスロジックここまで

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 23380
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rep2(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rev(i, n) for (int (i) = (n)-1; (i) >= 0; (i)--)
#define rev2(i, a, b) for (int (i) = (a)-1; (i) >= (b); (i)--)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<long long, long long>;
template<class T> using Vec = vector<T>;
template<class T> using VVec = vector<vector<T>>;
long long TEN(int i) {return !i ? 1 : TEN(i-1)*10LL;}
template<class T, class U> 
bool chmin(T& a, const U& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U> 
bool chmax(T& a, const U& b) {if (a < b) {a = b; return 1;} return 0;}

struct IoSetup {
	IoSetup() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} iosetup;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

template<long long mod>
class ModInt {
public:
	long long v;
	ModInt(long long v = 0) : v((v % mod + mod) % mod) {}
	ModInt operator+(ModInt t) {return ModInt((v + t.v) % mod);}
	ModInt operator-(ModInt t) {return ModInt((v - t.v + mod) % mod);}
	ModInt operator*(ModInt t) {return ModInt((v * t.v) % mod);}
	ModInt operator+=(ModInt t) {return *this = *this + t;} 
	ModInt operator-=(ModInt t) {return *this = *this - t;}
	ModInt operator*=(ModInt t) {return *this = *this * t;}
	ModInt operator-() {return ModInt(-v);}
	ModInt mpow(long long t) {
		if (t == 0) return ModInt(1);
		ModInt a = mpow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	ModInt inv() {return mpow(mod - 2);}
	ModInt operator/(ModInt t) {return ModInt(v) * t.inv();}
	ModInt operator/=(ModInt t) {return *this = *this / t;}
	ModInt operator==(ModInt t) {return *this.v == t.v;}
	ModInt operator!=(ModInt t) {return *this.v != t.v;}
	friend ostream& operator<<(ostream& os, const ModInt& mi) {return os << mi.v;}
};

using mint = ModInt<1000000007>;


int H, W, K;
mint dp[105][10];

void solve() {
	rep (i, 105) rep (j, 10) dp[i][j] = mint(0);
	dp[0][0] = 1;

	rep (i, H) rep (j, W) {
		rep (bit, 1 << (W - 1)) {
			bool ok = true;
			int tbit = bit;
			rep (k, W - 2) {
				if ((tbit & 1) && ((tbit / 2) & 1)) ok = false;
				tbit /= 2;
			}
			if (ok) {
				if (j >= 1 && (bit & 1 << (j - 1))) {
					dp[i + 1][j - 1] += dp[i][j];
				}
				else if (j <= W - 2 && (bit & 1 << j)) {
					dp[i + 1][j + 1] += dp[i][j];
				}
				else {
					dp[i + 1][j] += dp[i][j];
				}	
			}
		}
	}
	cout << dp[H][K - 1] << endl;
}

int main() {
	cin >> H >> W >> K;
	solve();
	
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int MAX = 5e5;


vector<int> vec;
signed main(){
   int n, m;
   scanf("%lld%lld", &n, &m);
   for(int i = 1;i*i <= m;i++){
     if(m%i == 0){vec.pb(i);vec.pb(m/i);}
   }
   sort(all(vec), greater<int>());
   rep(i,vec.size()){
     if(vec[i]*n <= m){
       printf("%lld\n", vec[i]);
       return 0;
     }
   }
  return 0;
}










Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	998244353//1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b)
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

struct p
{
	ll a;
	int b;
	int c;
};

inline int func(int a, int b)
{
	if (a > b)
		return a - b;
	else
		return b - a;
}

int main()
{
	int k, n;
	cin >> k >> n;
	//vector<int> a(n);
	int m = 0;
	int f = 0;
	int bef;
	cin >> bef;
	f = bef;
	ll tot = 0;
	for (int i = 1; i < n; i++)
	{
		int p;
		cin >> p;
		int q = p;
		p -= bef;
		bef = q;		
		tot += p;
		if (p > m)
			m = p;
	}

	int t = f - bef + k;
	if (t > m)
		m = t;

	tot += t;


	printf("%lld", tot - m);

	return 0;
}


Measured memory_bytes: 888
#include <stdio.h>

int main(void) {
	int w, h;
	int x, y;
	int r;
	
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	if(x > w || x + r > w || x - r < 0) printf("No\n");
	else if(y > h || y + r > h || y - r < 0) printf("No\n");
	else printf("Yes\n");
	return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#define maxn 2005
#define ll long long
using namespace std;
vector<int> eg[maxn];
int dp[maxn], sz[maxn], sm[maxn];
char inp[maxn];
int tp[maxn];
void wdp(int a, int fa)
{
	//最多消几次
	sz[a] = tp[a];
	dp[a] = 0, sm[a] = 0; // sm : dep
	int mx = 0;
	for(int i = 0; i < eg[a].size(); i++)
	{
		int v = eg[a][i];
		if(v == fa) continue;
		wdp(v, a);
		dp[a] += dp[v];
		mx = max(mx, sm[v]), sm[a] += sm[v]; 
		sz[a] += sz[v];
	}
	int dv = min(sm[a] - mx, sm[a] / 2);
	dp[a] += dv, sm[a] -= 2 * dv;
	sm[a] += sz[a];
}
int nv[maxn], nd[maxn], dep[maxn];
int ns = 0;
void dfs(int a, int fa)
{
	if(tp[a]) ns += dep[a];
	for(int i = 0; i < eg[a].size(); i++)
	{
		int v = eg[a][i];
		if(v == fa) continue;
		dep[v] = dep[a] + 1;
		dfs(v, a);
	}
}
int inf = 1e9;
int work(int a)
{
	int cnt = eg[a].size();
	for(int i = 0; i < cnt; i++)
	{
		int v = eg[a][i];
		ns = 0;
		dep[v] = 1;
		dfs(v, a);
		nv[i] = v, nd[i] = ns;
	}
	int sm = 0, mpl = 0;
	for(int i = 0; i < cnt; i++)
	{
		sm += nd[i];
		if(nd[i] > nd[mpl]) mpl = i;
	}
	if(sm & 1) return inf;
	if(nd[mpl] <= sm / 2) return sm / 2;
	int v = nv[mpl];
	wdp(v, a);
	ns = nd[mpl] - (sm - nd[mpl]);
	if(dp[v] * 2 < ns) return inf;
	return sm / 2; 
}
int main()
{
	int n;
	cin>>n;
	scanf("%s", inp + 1);
	for(int i = 1; i <= n; i++)
		tp[i] = inp[i] - '0';
	for(int i = 1; i < n; i++)
	{
		int u, v;
		cin>>u>>v;
		eg[u].push_back(v), 
		eg[v].push_back(u);
	}
	int ans = inf;
	for(int i = 1; i <= n; i++)
		ans = min(ans, work(i));
	if(ans == inf) cout<<"-1"<<endl;
	else cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 640
H,W=map(int,input().split())
s=[]
s1=[[]for i in range(H)]
dir=[[-1,0],[1,0],[0,-1],[0,1]]
a=0
for i in range(H):
    s.append(input())
for i in range(H):
    for a in s[i]:
        s1[i].append(a)
for i in range(H):
    for j in range(W):
        c=0
        if s1[i][j]=='#':
            for k in dir:
                if i+k[0]>=0 and i+k[0]<H and j+k[1]>=0 and j+k[1]<W and s1[i+k[0]][j+k[1]]=='#':
                    c=1
                    continue
        else:
            continue
        if c==0:
            a=1
            break
    if a==1:
        break
if a==1:
    print('No')
else:
    print('Yes')


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

int N, ptr, res;
int A[100000];

int main()
{
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  sort(A, A+N);
  while (ptr < N) {
    int cc = A[ptr], f = 0;
    while(ptr < N && cc == A[ptr]) {
      f++;
      ptr++;
    }
    res += f % 2;
  }
  printf("%d\n", res);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
int main(void)
{
  int n, a[200000], b[200000];
  int be, af;
  std::cin >> n;
  for(int i = 0; i != n; i++){
    std::cin >> a[i];
    b[i] = a[i];
  }
  std::sort(a, a + n);
  be = a[n / 2 - 1];
  af = a[n / 2];
  for(int i = 0; i != n; i++){
    std::cout << (b[i] < af ? af : be) << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3712
L, N = map(int, input().split())
X = [int(input()) for i in range(N)]

Y = [0]*(N+1)
for i in range(N):
    Y[i+1] = X[i] + Y[i]

ans = max(X[N-1], L - X[0])
for i in range(N-1):
    P = i+1; Q = N - (i+1)
    if P < Q:
        ans = max(ans, 2*Y[i+1] + 2*(L*(P+1) - (Y[i+P+2] - Y[i+1])) - (L - X[i+1]))
    elif P > Q:
        ans = max(ans, 2*(Y[i+1] - Y[i-Q]) - X[i] + 2*(L*Q - (Y[N] - Y[i+1])))
    K = min(P, Q)
    ans = max(ans, 2*(Y[i+1] - Y[i+1-K]) + 2*(L*K - (Y[i+K+1] - Y[i+1])) - min(X[i], L-X[i+1]))
print(ans)

Measured memory_bytes: 22516
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }


int n, m, q;
vector<int> a(50), b(50), c(50), d(50);

int ans = 0;

void dfs(int next_num, int depth, vector<int> vec) {
    if (depth == n) {
        int sum = 0;
        rep(i, q) {
            if (vec[b[i]] - vec[a[i]] == c[i]) sum += d[i];
        }
        
        chmax(ans, sum);
        return;
    }

    repr(num, next_num, m + 1) {
        int tmp = num;
        swap(vec[depth], tmp);
        dfs(num, depth + 1, vec);
        swap(vec[depth], tmp);
    }
}

int main() {
    cin >> n >> m >> q;
    rep(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }

    vector<int> vec(n);
    dfs(1, 0, vec);
    cout << ans << endl;
}

Measured memory_bytes: 3628
n, m = [int(item) for item in input().split()]
lrd = [[int(item) for item in input().split()] for _ in range(m)]

class DisjointSet:
  def __init__(self, n):
    self.par = [i for i in range(n+1)]
    self.dist = [0] * (n+1)
    self.rank = [0] * (n+1)

  def find(self, x):
    if self.par[x] == x:
      return x
    else:
      y = self.find(self.par[x])
      self.dist[x] += self.dist[self.par[x]]
      self.par[x] = y
      return self.par[x]
    
  def union(self, x, y, d):
    dx = self.dist[x]
    dy = self.dist[y]
    x = self.find(x)
    y = self.find(y)
    if self.rank[x] < self.rank[y]:
      self.par[x] = y      
      self.dist[x] = d + dy - dx
    else:
      self.par[y] = x
      self.dist[y] = -d - dy + dx
      if self.rank[x] == self.rank[y]:
        self.rank[x] += 1
        
  def issame(self, x, y):
    return self.find(x) == self.find(y)
  
  def diff(self, x, y):
    return self.dist[x] - self.dist[y]

harmony = True
djs = DisjointSet(n)
for l, r, d in lrd:
  if djs.issame(l,r):
    if djs.diff(l,r) != d:
      harmony = False
  else:
    djs.union(l,r,d)
    
if harmony:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 46940
#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)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}

using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr int MOD = 1e9+7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}

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; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s<<'[';for(size_t i=0;i<v.size();++i){s << v[i];if(i < v.size()-1) s << ", ";}s<<']';return s;
}
struct __f{
    __f(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    }
};

int main(){

    int n;
    scanf("%d", &n);
    vector<ll> a(n);
    rep(i, n) scanf("%lld", &a[i]);
   
    rep(i, n-1) a[i+1] += a[i];     
    ll ans = LINF;
    rep(i, n-1) chmin(ans, abs(2*a[i]-a[n-1]));
    ppp(ans);

    return 0;
}


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



int main() {
	long long int k;
	string s;
	cin>>s>>k;
	for(long long int i=0;i<s.size();i++)
	  {if(s[i]!='1'){
	    if(k<=i)
	       cout<<'1'<<'\n';
	   else    
	    cout<<s[i]<<'\n';
	   return 0;	
	  }
	  }
	 if(k<=s.size())
	   cout<<1<<'\n';
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
/***
 **   A S M Atikur Rahman
 **   Update: 26-03-2020
***/

//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<time.h>
#include<limits.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<bitset>
#include<utility>
#include<iterator>
#include<algorithm>
#include<cassert>
#include<iomanip> ///setprecision


#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define sci(x) scanf("%d%*c", &(x))
#define scll(x) scanf("%lld%*c", &(x))
#define scd(x) scanf("%lf%*c", &(x))
#define scstr(x) scanf("%s", x)
#define pfi(x) printf("%d", (x))
#define pfll(x) printf("%lld", (x))
#define pfd(x) printf("%f", (x))
#define pfstr(x) printf("%s", (x))
#define ps printf(" ")
#define pn printf("\n")
#define pfdot printf("..")

#define For(a,n) for(int i=(a); i<(n); i++)
#define rFor(n,a) for(int i=n-1; i>=0; i--)
#define trav(a,x) for (auto& a : x)
#define Mset(ara, val) memset(ara, val, sizeof(ara))

#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound

#define pi  (2*acos(0))


using namespace std;

using ll=long long;
using pii= pair<int,int>;
using pll= pair<long long, long long>;
using pcc= pair<char, char>;
using pdd= pair<double, double>;

#define V(a) vector<a>
using vi= vector<int>;
using vs= vector<string>;
using vll= vector<ll>;
using vpii= vector<pii>;
using vc= vector<char>;
using vd= vector<double>;

//ll POW(ll a,ll b){if(b==0)return 1;ll x=POW(a,b/2);x=(x*x);if(b&1)x=(x*a);return x;}
//ll Sqrt(ll a) { ll x=(ll)sqrt(a); if((x+1)*(x+1)==a) x++; return x; }



int main( int argc, char *argv[] )
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stout);
    int k, ara[200100],i,j,mx=0,n;
    sci(k),sci(n);
    for(i=0; i<n; i++)
    {
        sci(ara[i]);
    }
    for(i=1; i<n; i++)
    {
        mx=max(mx,ara[i]-ara[i-1]);
    }
    mx=max(mx, k-ara[n-1]+ara[0]);
    pfi(k-mx),pn;




    return 0;
}
























Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
        cin.tie(0);
        cout.tie(0);
    ios::sync_with_stdio(false);

    cin>>n;
    rrep(i,n,1000){
        s=to_string(i);
        int ok=1;
        rep(j,Size(s)){
            if(s[0]!=s[j]){
                ok=0;
                break;
            }
        }
        if(ok){
            Cout(i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <utility>
using namespace std;

int main() {
  int N; cin >> N;
  if (N < 1000)
    cout << "ABC";
  else
    cout << "ABD";
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n= readLine()!!.toInt()
    val s=(1..n).map{ readLine()!!.toInt()}.sorted()

    if(s.sum()%10!=0){
        println(s.sum())
    }else if(s.all{ it%10==0 }) {
        println(0)
    }else{
        println(s.sum()-s.first { it%10!=0 })
    }

}

Measured memory_bytes: 36160
#include<iostream>

int main(){
    int D;
    std::cin >> D;
    if(D == 25) std::cout << "Christmas" << std::endl;
    else if(D == 24) std::cout << "Christmas Eve" << std::endl;
    else if(D == 23) std::cout << "Christmas Eve Eve" << std::endl;
    else if(D == 22) std::cout << "Christmas Eve Eve Eve" << std::endl;
    return 0;
}


Measured memory_bytes: 256
# ABC137C - Green Bin
from collections import Counter


def main():
    _, *S = open(0).read().split()
    cnt = Counter("".join(sorted(s)) for s in S).values()
    ans = sum(i * (i - 1) // 2 for i in cnt)
    print(ans)


if __name__ == "__main__":
    main()

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

int f(int n){
 if(n % 2 == 0) return n / 2;
  else return 3 * n + 1;
}

int main(void){
  int N, T, A;
  double min = 100000;
  int num;
  cin >> N >> T >> A;
  for(int i = 0; i < N; i++){
   int H;
    cin >> H;
    
    if(abs(A - T + H * 0.006) < min){
	    num = i + 1;
      	min = abs(A - T + H * 0.006);
    }
  }
  cout << num;
  return 0;
}

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

int main(){
  
  int A, B, C, D;
    
  cin >> A >> B >> C >> D;
  
  while (true) {
    
    C -= B;
    
    if (C <= 0) {
     
      cout << "Yes";
      break;
    }  
    
    A -= D;

    if (A <= 0) {
     
      cout << "No";
      break;
      
    }      
    
  }  
  
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const int MAXH = 250+7;
int a[MAXH];
int main(){
//    freopen("in.txt", "r", stdin);
    int h;
    scanf("%d", &h);

    for(int i = 1; i <= h; i++){
        scanf("%d", &a[i]);
    }

    for(int i = 1; i <= h; i++){
        printf("node %d:", i);
        printf(" key = %d,", a[i]);
        if((i/2) > 0){
            printf(" parent key = %d,", a[i/2]);
        }
        if(2*i <= h){
            printf(" left key = %d,", a[2*i]);
        }
        if(2*i + 1 <= h){
            printf(" right key = %d,", a[2*i + 1]);
        }
        printf(" \n");
    }


    return 0;
}



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

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;

#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define int long long
#define sz(v) (int)v.size()
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define f(i,l,r) for(long long i=l;i<=r;i++)
#define rf(i,r,l) for(long long i=r;i>=l;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }


const int N=1e5+5,mod=1e9+7,bit=61;

int dp[101][N];
int n,Wmax;
int w[N],v[N];

int solve(int x,int need)
{
    if(need<=0)
    {
        return 0;
    }
    if(x==n+1)
    {
        return inf;
    }
    int &ans=dp[x][need];
    if(ans!=-1)
    {
        return ans;
    }
    ans=min(w[x]+solve(x+1,need-v[x]),solve(x+1,need));
    return ans;
}

signed main()
{
    fast;

    int t=1;
    //cin>>t;
    while(t--)
    {
        cin>>n;
        cin>>Wmax;
        for(int i=1;i<=n;i++)
        {
            cin>>w[i]>>v[i];
        }
        memset(dp,-1,sizeof(dp));
        int ans=0;
        for(int i=100000;i>=0;i--)
        {
            if(solve(1,i)<=Wmax)
            {
                ans=i;
                break;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 82572
import java.util.*;
 
public class Main{
 
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		HashSet set = new HashSet();
		set.add(sc.nextInt());
		set.add(sc.nextInt());
		set.add(sc.nextInt());
		System.out.println(set.size());
	}
}

Measured memory_bytes: 20948
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cctype>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<cmath>
#include<vector>

using namespace std;
using ll = long long;
const ll N = 1e6;
const double PI = acos(-1.0);
#define Test ll tesnum;tesnum = read();while(tesnum--)
ll read();
string str[200005];
int main()
{
    int n;
    cin>>n;

    map<string,int> mp;
    int maxn = 0;
    for(int i = 1; i <= n; i++){
        cin>>str[i];
        mp[str[i]]++;
        maxn = max(maxn,mp[str[i]]);
    }
    sort(str+1,str+1+n);
    for(int i = 1; i <= n; i++){
        if(mp[str[i]]==maxn){
            cout<<str[i]<<endl;
            mp[str[i]] = 0;
        }
    }

    return "BT7274", NULL;
}

inline ll read() {
    ll hcy = 0, dia = 1;char boluo = getchar();
    while (!isdigit(boluo)) {if (boluo == '-')dia = -1;boluo = getchar();}
    while (isdigit(boluo)) {hcy = hcy * 10 + boluo - '0';boluo = getchar();}
    return hcy * dia;
}

Measured memory_bytes: 26752
#include <iostream>
#include <vector>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cassert>
#include <cstring>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

struct SegTree {
    int size;
    vector<int> seg;

    SegTree(const vector<int>& v) {
        size = 1;
        while (size < v.size()) size <<= 1;
        seg.resize(2 * size);
        for (int i = 0; i < v.size(); i++) {
            seg[i + size] = v[i];
        }
        for (int i = size - 1; i > 0; i--) {
            seg[i] = max(seg[2 * i], seg[2 * i + 1]);
        }
    }

    SegTree(int n) : SegTree(vector<int>(n)) {}

    void update(int k, int x) {
        k += size;
        seg[k] += x;
        k /= 2;
        for (; k > 0; k /= 2) {
            seg[k] = max(seg[2 * k], seg[2 * k + 1]);
        }
    }

    int query(int a, int b, int k, int l, int r) {
        if (b <= l || r <= a) return 0;
        if (a <= l && r <= b) return seg[k];
        int x = query(a,b,2 * k,l,(l + r) / 2);
        int y = query(a,b,2 * k + 1,(l + r) / 2,r);
        return max(x,y);
    }

    int query(int a, int b) {
        return query(a,b,1,0,size);
    }
};

pair<int,int> XY[200000];

constexpr double pi = 2 * acos(0);

int main(void) {
    int x1, y1, x2, y2;
    scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
    if (x1 > x2) {
        swap(x1,x2);
        swap(y1,y2);
    }
    bool rev = false;
    if (y1 > y2) {
        swap(y1,y2);
        rev = true;
    }

    int i, N;
    scanf("%d",&N);
    REP (i,N) scanf("%d%d",&XY[i].first,&XY[i].second);
    sort(XY,XY+N);

    unordered_map<int,int> coX, coY;
    set<int> st;
    REP (i,N) st.insert(XY[i].first);
    st.insert(x1);
    st.insert(x2);
    i = 0;
    for (auto x: st) coX[x] = i++;
    st.clear();
    REP (i,N) st.insert(XY[i].second);
    st.insert(y1);
    st.insert(y2);
    i = 0;
    for (auto y: st) coY[y] = i++;

    SegTree s(coY.size());
    REP (i,N) if (x1 <= XY[i].first && XY[i].first <= x2 && y1 <= XY[i].second && XY[i].second <= y2) {
        int mx;
        if (!rev) mx = s.query(0,coY[XY[i].second]);
        else mx = s.query(coY[XY[i].second]+1,coY.size());
        s.update(coY[XY[i].second],mx + 1);
    }
    int fountains = s.query(0,coY.size());

    double ans = (double) (x2 - x1 + y2 - y1) * 100;
    ans += fountains * (pi * 5 - 20);
    if (fountains == min(x2 - x1 + 1, y2 - y1 + 1)) ans += pi * 5;
    printf("%.12f\n",ans);
    return 0;
}

Measured memory_bytes: 30536
h,m,s;main(t,u){for(;scanf("%d%d%d",&h,&m,&s)*-~h;printf("%02d:%02d:%02d\n%02d:%02d:%02d\n",t/3600,t/60%60,t%60,u/3600,u/60%60,u%60)){t=7200-h*3600-m*60-s;u=t*3;}}

Measured memory_bytes: 612
import sys
import numpy as np

read = sys.stdin.read

n = int(input())
s = np.array(read().split(), dtype=object)

print("AC x ",end='')
print(np.count_nonzero(s=="AC"))
print("WA x ",end='')
print(np.count_nonzero(s=="WA"))
print("TLE x ",end='')
print(np.count_nonzero(s=="TLE"))
print("RE x ",end='')
print(np.count_nonzero(s=="RE"))

Measured memory_bytes: 35092
n=int(input())
A=[]
for i in range(n):
  A.append(list(map(int,input().split())))
  
#dp[i][0,1,2]:=i日目までに最高
dp=[[0,0,0] for i in range(n)]
dp[0]=A[0]
for i in range(1,n):
  dp[i][0]=max(dp[i-1][1]+A[i][0] , dp[i-1][2]+A[i][0])
  dp[i][1]=max(dp[i-1][0]+A[i][1],dp[i-1][2]+A[i][1])
  dp[i][2]=max(dp[i-1][0]+A[i][2],dp[i-1][1]+A[i][2])
print(max(dp[n-1]))

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    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;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  vector< int > A(N);
  cin >> A;
  vector< int > B(N);
  cin >> B;
  vector< int > C(N - 1);
  cin >> C;


  int ret = 0;
  for(int i = 0; i < N; i++) {
    ret += B[A[i] - 1];
  }
  for(int i = 1; i < N; i++) {
    if(A[i - 1] + 1 == A[i]) {
      ret += C[A[i - 1] - 1];
    }
  }
  cout << ret << endl;
}


Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

S = input()
T = input()

ALPs = defaultdict(list)

for i,s in enumerate(S):
    ALPs[s].append(i+1)

Ls = [len(ALPs[chr(i)]) for i in range(97,97+28)]


itr = 0
cnt = 0 # 周回数
for t in T:
    L = Ls[ord(t)-97]
    if L == 0:
        print(-1)
        exit()
    else:
        ind = bisect.bisect_right(ALPs[t],itr)
        if ind == L:
            itr = ALPs[t][0]
            cnt += 1
        else:
            itr = ALPs[t][ind]
        #print(ALPs[t],ind,itr)


ans = cnt*len(S) + itr

print(ans)


Measured memory_bytes: 49004
import math

a, b, x = map(int, input().split())

if x >= (a ** 2) * b / 2:
    zy = (2 * x) / (a ** 2) - b
    if b != zy:
        q = b - zy
        print(90 - math.degrees(math.atan(a / q)))
    else:
        print(0)

else:
    p = (2 * x) / (a * b)
    print(90 - math.degrees(math.atan(p / b)))

Measured memory_bytes: 3060
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    const int MAX_N = 500, MAX_C = 30, MAX_D = 1000;
    int N, C, D[MAX_C][MAX_C];
    int cc[3][MAX_C];
    memset(cc[0], 0, sizeof(cc));
    cin >> N >> C;
    REP(i, C) {
        REP(j, C) {
            cin >> D[i][j];
        }
    }
    REP(i, N) {
        REP(j, N) {
            int c;
            cin >> c;
            cc[(i + j) % 3][c - 1]++;
        }
    }
    int res = MAX_N * MAX_N * MAX_D;
    REP(c1, C) {
        REP(c2, C) {
            if (c1 == c2) {
                continue;
            }
            REP(c3, C) {
                if (c1 == c3 || c2 == c3) {
                    continue;
                }
                int sum = 0;
                REP(c, C) {
                    sum += D[c][c1] * cc[0][c];
                    sum += D[c][c2] * cc[1][c];
                    sum += D[c][c3] * cc[2][c];
                }
                amin(res, sum);
            }
        }
    }
    cout << res << endl;
    return 0;
}


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

public class Main{

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      String[] lines = in.readLine().split(" ");
      int n = Integer.parseInt(lines[0]);
      int k = Integer.parseInt(lines[1]);

      int[] arr = new int[n+1];

      String line = in.readLine();
      char regex = ' ';
      boolean isContinue = true;
      for(int m=0,offset=0,next=0; isContinue; offset = ++next) {
        if((next = line.indexOf(regex,offset)) == -1) {
          next = line.length();
          isContinue = false;
        }
        m = Integer.parseInt(line.substring(offset,next));
        arr[m]++;
      }
      Arrays.sort(arr);
      int ans = n;
      for(int i=n; i>n-k; i--) ans -= arr[i];

      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 48012
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n; cin>>n;
  string s,t; cin>>s>>t;
  string res;
  for(int i=0; i<n; ++i) res+=s[i],res+=t[i];
  cout<<res;
  return 0;
}


Measured memory_bytes: 3624
#define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto&& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto&& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<int> a(n); std::cin>>a;
  auto make_left = [&] (auto&& a) {
    std::vector<int> ans = {0};
    for (int x : a) {
      ans.emplace_back(std::__gcd(ans.back(),x));
    }
    return ans;
  };
  auto left = make_left(a);
  std::reverse(all(a));
  auto right = make_left(a);
  debug(left,right);

  int ans = 0;
  rep(i,0,n) {
    int j = n - 1 - i;
    int x = left.at(i);
    int y = right.at(j);
    debug(x,y);
    int now = std::__gcd(x,y);
    cmx(ans,now);
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 1784
line = input().rstrip()
line_len = len(line)
line_reverse = list(reversed(line))
line_reverse = ''.join(line_reverse)

start = int((line_len -1) /2)
end = int((line_len + 3) / 2 - 1)
# print(line_len - 1)
start_len = line[0:start]
end_len = line[end:(line_len)]


if line == line_reverse and start_len == end_len:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll inf = LONG_LONG_MAX / 2 - 1;
    ll h, n;
    cin >> h >> n;
    vector<pair<ll, ll>> ab(n);
    ll mv = 0;
    rep(i, n) {
        cin >> ab[i].first >> ab[i].second;
        mv = max(mv, ab[i].first);
    }
    vector<ll> dp(h + mv + 1, inf);
    dp[0] = 0;
    rep(i, n) {
        reps(j, ab[i].first, sz(dp)) {
            ll v = j - ab[i].first;
            if (dp[v] == inf) continue;
            dp[j] = min(dp[j], dp[v] + ab[i].second);
        }
    }
    ll ans = LONG_LONG_MAX;
    reps(i, h, sz(dp)) {
        ans = min(ans, dp[i]);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin>>n;
  char a[n],b[n];
  cin>>a>>b;
  for(int i=0;i<n;i++){
    cout<<a[i]<<b[i];
  }
}


Measured memory_bytes: 256