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

#define FST first
#define SCD second
#define MODP 1000000007

typedef long long LL;
typedef pair<int, int> PA;

int cmp(PA x, PA y) {
    return x.SCD < y.SCD;
}

int calc(const vector<int>&A, const vector<int>&B, int n, int s) {
    vector<int> C;
    vector<int> I;
    for (int i=0;i<n;++i) {
        // cout<<((s&(1<<i))>0)<<endl;
        if (s&(1<<i)) C.push_back(B[i]);
        else C.push_back(A[i]);
        I.push_back(i);
    }
    int ret = 0;
    for (int i=0;i<n;++i) {
        int mi = 100;
        int mid = -1;
        // cout<<"decide "<<i<<endl;
        for (int j=i;j<n;++j) {
            int ri = I[j];
            if (C[j]<mi) {
                mi = C[j];
                mid = -1;
                // cout<<"new max "<<mi<<endl;
            }
            if (((s&(1<<ri))>0)&&(i&1)||((s&(1<<ri))==0)&&((i&1)==0)) {
                if (C[j] == mi && mid==-1) {
                    // cout<<"new suit "<<j<<endl;
                    mid = j;
                }
            }
        }
        if (mid==-1) return n * n + 1;
        ret += mid - i;
        for (int j=mid;j>i;--j) {
            swap(C[j], C[j-1]);
            swap(I[j], I[j-1]);
        }
    }
    return ret;
}

int main() {
#ifdef FDB
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    int n, m, k;
    cin>>n;
    vector<int> A, B;
    for (int i=0;i<n;++i) {
        int x;
        scanf("%d", &x);
        A.push_back(x);
    }
    for (int i=0;i<n;++i) {
        int x;
        scanf("%d", &x);
        B.push_back(x);
    }
    for (int i=0;i<n;++i) {
        if (i&1) {
            swap(A[i], B[i]);
        }
    }
    int ans = n * n + 1;
    for (int s=0;s<(1<<n);++s) {
        int cnt = 0;
        int k = s;
        while (k) {k-=k&-k; cnt+=1;}
        if ((n-cnt)!=(n+1>>1)) continue;
        int y = calc(A, B, n, s);
        ans = min(ans, y);
    }
    if (ans>n*n) cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int read() {
	int x; scanf("%lld", &x); return x;	
}
const int maxn = 1e6 + 10;
const int INF = 1e9;
int mod = 1e9 + 7;
#define ll long long 
int n, k;
int p[5005], c[5005], G[5005], FF[5005];
bool vis[5005];
int Solve(vector<int>&F) {
	int sum = 0;
	for (int i : F) sum += c[i];
	int n = F.size();
	int round = k / n;
	int delt = k % n;
	int ans = -LLONG_MAX;
	if (!round) {
		for (int i : F) {
			int tmp = 0;
			int st = i;
			for (int j = 1; j <= delt; ++j) {
				st = p[st];
				tmp += c[st];
				ans = max(ans, tmp);
			}
		}
		return ans;	
	}
	else {
		for (int i : F) {
			int tmp = 0;
			int st = i;
			for (int j = 1; j <= delt; ++j) {
				st = p[st];
				tmp += c[st];
				G[st] = max(G[st], tmp);
			}
		}
		
		for (int i : F) {
			int tmp = 0;
			int st = i;
			for (int j = 1; j <= n; ++j) {
				st = p[st];
				tmp += c[st];
				FF[i] = max(FF[i], tmp);
			}
		}
		
		for (int st : F) {
			int tmp = G[st];
			if (sum > 0) tmp += 1ll * (round - 1) * sum + FF[st];
			else if(FF[st] > 0) tmp += FF[st];
			ans = max(ans, tmp);
		}
		return ans;
	}	
}
main() {
	#ifdef LOCAL
		freopen("1.in", "r", stdin);
	#endif
	n = read(), k = read();
	for (int i = 1; i <= n; ++i) p[i] = read();
	for (int i = 1; i <= n; ++i) c[i] = read();

	int ans = -LLONG_MAX;

	bool f = 0;	
	for (int i = 1; i <= n; ++i) if (c[i] >= 0) f = 1;
	if (!f) {
		for (int i = 1; i <= n; ++i) ans = max(ans, c[i]);
		cout << ans << endl;
		return 0;
	}
	
	int output = 0;
	for (int i = 1; i <= n; ++i) {
		if (!vis[i]) {
			int cur = i;
			vector<int>Tmp;
			do {
				vis[i] = 1;
				Tmp.push_back(i);
				i = p[i];
			}while (cur != i);
			output = max(output, Solve(Tmp));
		}
	}
	cout << output << endl;
	return 0;
}

Measured memory_bytes: 3912
A, B, K = (int(i) for i in input().split(' '))

cnt = 0
turnA = True

while cnt < K:
    if turnA:
        if A%2:
            A -= 1
        B += A//2
        A = A//2
        turnA = False
    else: 
        if B%2:
            B -= 1
        A += B//2
        B = B //2
        turnA = True
    cnt+=1

print(A, B)

Measured memory_bytes: 3064
// Snuke Line
// * frank_c1
// * 2017 / 09 / 30

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

#define lowbit(x) ((x) & (-x))

const int maxn = (int)(3e5) + 5;
int a[maxn], res[maxn], C[maxn];
int n, m, tot;

struct node {
	int x, opt, r, sgn, id;
} p[maxn * 22];

bool operator < (node a, node b) {
	return a.x != b.x ? a.x < b.x : a.opt < b.opt;
}

inline void add(int x, int v) {
	for (; x <= m; x += lowbit(x)) C[x] += v;
}

inline int sum(int x) {
	int ret = 0; for (; x; x -= lowbit(x)) ret += C[x]; return ret;
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) {
		int l, r; scanf("%d%d", &l, &r);
		p[++tot] = (node){l, 0, r, 0, i};
	}
	for (int i = 1; i <= m; ++i) {
		int c = 0;
		for (int j = 0; j <= m; j += i) a[++c] = j;
		if (a[c] != m) a[++c] = m + 1;
		for (int j = 2; j <= c; ++j) {
			if (a[j] - a[j - 1] > 1) {
				p[++tot] = (node){a[j - 1], 1, a[j] - 1, -1, i};
				p[++tot] = (node){a[j] - 1, 1, a[j] - 1,  1, i};
			}
		}
	}
	sort(p + 1, p + tot + 1);
	for (int i = 1; i <= tot; ++i) {
		if (!p[i].opt) add(p[i].r, 1); else res[p[i].id] += p[i].sgn * sum(p[i].r);
	}
	for (int i = 1; i <= m; ++i) printf("%d\n", n - res[i]);
	return 0;
}

Measured memory_bytes: 58624
S = list(input())
T = list(input())

min_ = 99999
for i in range(len(S)-len(T)+1):
    count = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            count += 1
    if count < min_:
        min_ = count
print(min_)

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

int main() {
	char s[10];
	char t[10];//S,Tの宣言
	scanf("%s %s", s, t);//input S,T

	int a, b;
	scanf("%d %d", &a, &b);//球数A,Bの入力

	char u[10];
	scanf("%s", u);//Uの入力

	//UとSが同じ場合
	if (strcmp(u,s) == 0) {
		a--;
		//printf("1");
	}

	//TとUが同じ場合
	if (strcmp(u, t) == 0) {
		b--;
		//printf("2");
	}
	printf("%d %d\n", a, b);
}

Measured memory_bytes: 128
#include <cstdio>

using namespace std;

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

const int INF = 1000000000;
const int N_MAX = 100000;

int N, T;
int A[N_MAX];

void solve() {
  int am = INF;
  int diff = -1;
  int ans = 0;
  REP(i, N) {
    if (A[i] < am) {
      am = A[i];
    } else if (A[i] - am == diff) {
      ans++;
    } else if (A[i] - am > diff) {
      diff = A[i] - am;
      ans = 1;
    }
  }
  printf("%d\n", ans);
}

void input() {
  scanf("%d%d", &N, &T);
  REP(i, N) scanf("%d", A + i);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 512
import java.awt.Polygon;
import java.awt.geom.Area;
import java.awt.geom.PathIterator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) throws Exception
	{
		new Main().run();
	}
	
	public void run() throws Exception
	{
		Scanner file = new Scanner(System.in);
		int N = file.nextInt();
		int[] ints = new int[N];
		for(int i = 0;i<ints.length;i++)
			ints[i] = file.nextInt();
		int max = -1;
		int ans = 0;
		for(int i = 0;i< N;i++)
		{
			if(ints[i] >=max)
			{
				max = ints[i];
				ans++;
			}
		}
		System.out.println(ans);
	}
}


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

int main(){
	int n, k;
	cin >> n >> k;
	int ans = 0;
	
	while(0 < n){
		n /= k;
		ans++;
	}
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
const int N = 2e5+5;
const int M = 1e4;
const int INF = 0x3f3f3f3f;

int sum[N];

int main(){
	int n,x;
	scanf("%d",&n);
	memset(sum,0,sizeof(sum));
	for(int i = 2;i <= n;++i) scanf("%d",&x),sum[x]++;
	for(int i = 1;i <= n;++i) printf("%d\n",sum[i]);
    return 0;
}


Measured memory_bytes: 4608
#include <cstdio>
#include <algorithm>
using namespace std;
int N, A[200005];
int main() {
  scanf("%d", &N);
  for(int i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
  }
  sort(A, A+N);
  bool ok = true;
  for(int i = 0; i < N-1; ++i) {
    if(A[i] == A[i+1]) {
      ok = false;
      break;
    }
  }
  printf("%s\n", ok?"YES":"NO");
}

Measured memory_bytes: 896
package main

import (
	"fmt"
)

func main() {
	var s string
	var k int
	fmt.Scanf("%v\n%v", &k, &s)
	for i, c := range s {
		if i < k {
			fmt.Printf("%c", c)
		} else {
			fmt.Print("...")
			break
		}
	}
	fmt.Println()
}


Measured memory_bytes: 1820
n, d = map(int, input().split())
p = []
for i in range(n):
  p.append(list(map(int, input().split())))
def distance(x, y):
  a = 0
  for i in range(d):
    a += (p[x][i]-p[y][i])**2
  return(a**0.5)

ans = 0
a = 0
while a < n:
  for i in range(a+1, n):
    if distance(a, i) % 1 ==0:
      ans += 1
  a += 1

print(ans)

Measured memory_bytes: 3188
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    ll n;
    cin >> n;
    cout << n * (n - 1) / 2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;

int main()
{
    ll n,m;
    cin>>n>>m;
    cout<<(1ll<<m)*(m*1900+(n-m)*100)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

struct residential {
    int X, Y;
    int person;
};

int N;
residential residentials[16];
VI ew, ns;
LL ans[16];

LL calc() {
    LL res = 0;
    REP(i, N) {
        LL tmp = LLINF;
        chmin<LL>(tmp, abs(residentials[i].Y));
        chmin<LL>(tmp, abs(residentials[i].X));
        FORE(e, ew) {
            chmin<LL>(tmp, abs(residentials[i].Y - e));
        }
        FORE(e, ns) {
            chmin<LL>(tmp, abs(residentials[i].X - e));
        }
        res += tmp * residentials[i].person;
    }
    return res;
}

void dfs(int idx, int cnt) {
    if (cnt == N) {
        chmin(ans[ew.size() + ns.size()], calc());
        return;
    }

    dfs(idx + 1, cnt + 1);
    ew.EB(residentials[idx].Y);
    dfs(idx + 1, cnt + 1);
    ew.pop_back();
    ns.EB(residentials[idx].X);
    dfs(idx + 1, cnt + 1);
    ns.pop_back();
}

int main(void) {
    cin >> N;
    REP(i, N) {
        cin >> residentials[i].X >> residentials[i].Y >> residentials[i].person;
    }
    fill(ans, ans + 16, LLINF);

    dfs(0, 0);

    REP(i, N + 1) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1000000000
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
//#define mp make_pair

int freq[55][27], n,ans[27];
string s[55];

int main(){

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

cin >> n;
rep(i, 0, n-1){
cin >> s[i];
rep(j, 0, s[i].size()-1){
freq[i][s[i][j]-'a']++;
}
}

rep(i, 0, 25){
ans[i]=inf;
rep(j, 0, n-1){
ans[i]=min(freq[j][i], ans[i]);
}
}

string an;
rep(i, 0, 25){
if(ans[i]) {
 rep(j, 0, ans[i]-1)an+= i+'a';
}
}
cout << an << endl;
}


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

int judge(int a)
{
	int sum = 0;

	if (a%3==0 && a%5==0)
	{
		//printf("FizzBuzz\n");
	}
	else if(a%3==0)
	{
		//printf("Fizz\n");
	}
	else if(a%5==0)
	{
		//printf("Buzz\n");
	}
	else
		sum = a;

	return (sum);
}

int main(void)
{
	char buf[256];
	char *str;
	int a = 0;
	long sum = 0;
	int i = 0;

	if (scanf("%255s", buf) != 1)
	{
		return 1;
	};
	str = buf;
	a = atoi(buf);

	while (i <= a)
	{
		sum += judge(i);
		i++;
	}
	printf("%ld\n", sum);

	return (0);
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

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

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int calc(vvi a)
{
	int r=a.size(),c=a[0].size();
	vi sum(c);
	rep(i,r) rep(j,c) sum[j]+=a[i][j];
	int res=0;
	rep(i,c) res+=max(sum[i],r-sum[i]);
	return res;
}

int main()
{
	for(int r,c;cin>>r>>c && r|c;){
		vvi a(r,vi(c));
		rep(i,r) rep(j,c) cin>>a[i][j];
		int res=0;
		rep(i,1<<r){
			rep(j,r) if(i>>j&1) rep(k,c) a[j][k]^=1;
			res=max(res,calc(a));
			rep(j,r) if(i>>j&1) rep(k,c) a[j][k]^=1;
		}
		cout<<res<<endl;
	}
}

Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
int i,j,n,m;
cin >> n >> m;
int a[m],ret[n+1];
for(i=0;i<m;i++)cin>>a[i];
ret[0]=0;
for(i=1;i<n+1;i++)ret[i]=1000000000;
for(i=0;i<=n;i++){
for(j=0;j<m;j++)if(i+a[j]<n+1)ret[i+a[j]]=min(ret[i+a[j]],ret[i]+1);
}
cout << ret[n] << endl;
return 0;
}


Measured memory_bytes: 3300
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void)  { 
    int x, a;
    cin >> x >> a;

    if(x < a) { 
        cout << 0 << endl;
    }else {
        cout << 10 << endl;
    }

    return 0;
}

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

int main(void){

  int a,b,r;

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

  r=a-2*b;

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


  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define plll pair<ll,pll>
#define ppll pair<pll, pll>
#define pii pair<int, int> 
#define mod 10000000009
#define pb push_back
ll power(ll a,ll b){
    ll res=1ll;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}
ll ncr(ll n,ll k){
    if(n<k) return 0;
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i));
        pro/=(i+1);
    }
    return (pro);
}
vector<ll> prime;
void seive(){
    vector<bool > isprime(2000001,true);
    for(int i=2;i*i<=2000000;i++){
        if(isprime[i]){
            for(int j=i*i;j<=2000000;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=1000000;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
void swap(ll *a,ll *b) {
    ll temp=*a;
    *a=*b;
    *b=temp;
}

int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    ll n;
    cin>>n;
    vector<ll> arr(n);
    vector<ll> freq(n+1);
    for(int i=0;i<n;i++) {
        cin>>arr[i];
        freq[arr[i]]++;
    }
    ll sum=0;
    for(int i=1;i<=n;i++) {
        if(freq[i]>0)
        sum+=ncr(freq[i],2);
    }
    for(int i=0;i<n;i++) {
        ll x=freq[arr[i]];
        ll a=ncr(x,2);
        ll b=ncr(x-1,2);
        cout<<sum-a+b<<"\n";
    }
    return 0; 
}


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

int main() {
    ll N; cin >> N;
    ll ans = 1;
    for (int i = 0; i < N; i++){
        ll t; cin >> t;
        ans = ans/__gcd(ans, t) * t;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int GCD(int a, int b) {
    if (a % b == 0) {
        return b;
    } else {
        return GCD(b, a % b);
    }
}

int main() {
    int m, n;
    scanf("%d %d", &m, &n);
    printf("%d\n", GCD(m, n));
}


Measured memory_bytes: 2096
N, M = gets.split.map(&:to_i)
abs = N.times.map { gets.split.map(&:to_i) }
cds = M.times.map { gets.split.map(&:to_i) }

abs.each do |a,b|
  ans = nil
  dist = 10**9
  cds.each.with_index do |(c,d), i|
    z = (a-c).abs + (b-d).abs
    if z < dist
      ans = i + 1
      dist = z
    end
  end
  p ans
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define Mod 1000000007

int main() {
    ll k;
    string s;
    cin>>k>>s;
    if(s.length()<=k)cout<<s<<endl;
    else{
        cout<<s.substr(0,k)<<"..."<<endl;
    }
    return 0;
}


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


//テ」ツδ?」ツつ、テ」ツつッテ」ツつケテ」ツδ暗」ツδゥテ」ツ?軍untime Errorティツオツキテ」ツ?禿」ツ?療」ツ?ヲテ」ツ?療」ツ?セテ」ツ?」テ」ツ??テつエテ」ツδサテ渉嘉」ツδサ`)テッツセツ?ッツスツセテッツセツ?
/*
class Node{
public:
	int num;
	int cost;

	Node(){ num = 0; cost = 0; }
	Node(int num, int cost) : num(num), cost(cost){}

};

bool operator< (const Node &n1, const Node &n2){
	return n1.cost < n2.cost;
}

bool operator>(const Node &n1, const Node &n2){
	return n1.cost > n2.cost;
}


bool checked[21];

int main(void){

	int n, m;
	cin >> n >> m;

	vector<vector<pair<int, int> > > path(n + 1);
	for (int i = 0; i < m; i++){
		int	a, b, c, d;
		scanf("%d,%d,%d,%d", &a, &b, &c, &d);
		path[a].push_back(make_pair(b, c));
		path[b].push_back(make_pair(a, d));
	}

	int s, g, V, P;
	scanf("%d,%d,%d,%d", &s, &g, &V, &P);
	int result = V - P;

	for (int i = 0; i <= 20; i++){
		checked[i] = false;
	}

	priority_queue<Node, vector<Node>, greater<vector<Node>::value_type> > que1;//cost, point
	que1.push(Node(s, 0));

	while (!que1.empty()){
		Node cp = que1.top();
		que1.pop();

		int cost = cp.cost;
		int point = cp.num;

		if (checked[point]) continue;
		checked[point] = true;

		if (point == g){
			result -= cost;
			break;
		}

		for (int i = 0; i < path[point].size(); i++){
			que1.push(Node(path[point][i].second, cost + path[point][i].first));
		}

	}

	for (int i = 0; i <= 20; i++){
		checked[i] = false;
	}
	priority_queue<Node, vector<Node>, greater<vector<Node>::value_type> > que2;//cost, point
	que1.push(Node(g, 0));

	while (!que2.empty()){
		Node cp = que2.top();
		que2.pop();

		int cost = cp.cost;
		int point = cp.num;

		if (checked[point]) continue;
		checked[point] = true;

		if (point == s){
			result -= cost;
			break;
		}

		for (int i = 0; i < path[point].size(); i++){
			que2.push(Node(path[point][i].second, cost + path[point][i].first));
		}

	}

	cout << result << endl;

	return 0;
}
*/

#define INF 1000000

int main(void){

	int n, m;
	cin >> n >> m;

	int dist[21][21];

	for (int i = 1; i < 21; i++){
		for (int j = 1; j < 21; j++){
			if (i == j) dist[i][j] = 0;
			else dist[i][j] = INF;
		}
	}

	for (int i = 0; i < m; i++){
		int	a, b, c, d;
		scanf("%d,%d,%d,%d", &a, &b, &c, &d);
		dist[a][b] = c;
		dist[b][a] = d;
	}

	int s, g, V, P;
	scanf("%d,%d,%d,%d", &s, &g, &V, &P);

	for (int k = 1; k <= n; k++){
		for (int j = 1; j <= n; j++){
			for (int i = 1; i <= n; i++){
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	
	cout << V - P - dist[s][g] - dist[g][s] << endl;

}

Measured memory_bytes: 1240
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int A = in.nextInt();
			int B = in.nextInt();
			int M = in.nextInt();
			int[] a = new int[A];
			int[] b = new int[B];
			int[] c = new int[M];
			int minA = 10000000;
			int minB = 10000000;

			for(int i = 0; i < A; i++) {
				a[i] = in.nextInt();
				minA = Math.min(minA, a[i]);
			}
			for(int i = 0; i < B; i++) {
				b[i] = in.nextInt();
				minB = Math.min(minB, b[i]);
			}
			int[] x = new int[M];
			int[] y = new int[M];
			int ans = 10000000;
			for(int i = 0; i < M; i++) {
				x[i] = in.nextInt();
				y[i] = in.nextInt();
				c[i] = in.nextInt();	
				if((a[x[i] - 1] + b[y[i] - 1]) - c[i] < ans) {
					ans = a[x[i]- 1] + b[y[i] - 1] - c[i];
				}
				
			}
			if(minA + minB < ans) {
				ans = minA + minB;
			}
			System.out.println(ans);
		}
	}

	static boolean permutation_2(String s, String t) {
		if (s.length() != t.length()) {
			return false;
		}

		int[] letters = new int[256];

		char[] s_array = s.toCharArray();
		for (char c : s_array) {
			letters[c]++;
		}

		for (int i = 0; i < t.length(); i++) {
			int c = (int) t.charAt(i);
			if (--letters[c] < 0) {
				return false;
			}
		}
		return true;
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	ll h;
	cin >> h;
	ll ans = 0, n = 1;
	while (h > 0) {
		h /= 2;
		ans += n;
		n *= 2;
	}
	cout << ans << "\n";
	return 0;
}


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

//a^b % modを求める
int64_t MODpow(int64_t a, int64_t b, int64_t mod) {
    int64_t result = 1;
    while (b) {
        if (b % 2 == 1) {
            result *= a;
            result %= mod;
        }

        b /= 2;
        a *= a;
        a %= mod;
    }

    return result;
}

class Combination {
public:
    Combination(int64_t max_num, int64_t mod) {
        fact_.resize(max_num + 1, 1);
        inv_fact_.resize(max_num + 1, 1);
        mod_ = mod;
        for (int64_t i = 2; i <= max_num; i++) {
            fact_[i] = i * fact_[i - 1] % mod_;
            inv_fact_[i] = MODpow(fact_[i], mod_ - 2, mod_);
            assert(fact_[i] * inv_fact_[i] % mod_ == 1);
        }
    }
    int64_t operator()(int64_t n, int64_t m) const {
        if (m < 0 || m > n) return 0;
        return fact_[n] * inv_fact_[n - m] % mod_ * inv_fact_[m] % mod_;
    }
private:
    vector<int64_t> fact_, inv_fact_;
    int64_t mod_;
};

int main() {
    int64_t K;
    string S;
    cin >> K >> S;

    constexpr int64_t MOD = 1e9 + 7;

    Combination comb(S.size() + K, MOD);

    int64_t ans = 0;
    for (int64_t i = S.size() - 1; i < K + S.size(); i++) {
        (ans += comb(i, S.size() - 1) * MODpow(25, i - S.size() + 1, MOD) % MOD * MODpow(26, K + S.size() - 1 - i, MOD) % MOD) %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 35548
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <iomanip>
          
using namespace std;
          
int main() {
int a,b;
cin >> a >> b;
int d = a/b;
int r = a%b;
double f = (double)a/b;
cout << d << " " << r << " ";
cout << fixed;
cout << setprecision(5);
cout << f << endl;
}


Measured memory_bytes: 3292
#include<stdio.h>
int rc[1000][1000];
int main(void){
    int r, c;
    int i, j;
    scanf("%d %d", &r, &c);
    for(i = 0; i < r; i++){
        for(j = 0; j < c; j++){
           scanf("%d", &rc[i][j]);
        }
    }
    for(i = 0; i < r; i++){
        for(j = 0;j < c; j++){
            rc[i][c] += rc[i][j];
            rc[r][j] += rc[i][j];
            rc[r][c] += rc[i][j];
        }
    }
    for(i = 0; i <= r; i++){
        for(j = 0; j <= c; j++){
            printf("%d", rc[i][j]);
            j == c ? putchar('\n'):putchar(' ');
        }
    }
    return 0;
}


Measured memory_bytes: 2144
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int roman2bin(const string &s){
	int result = 0, maxdig = 0;
	for(int i = s.size() - 1; i >= 0; --i){
		int dig = 0;
		switch(s[i]){
			case 'I': dig =    1; break;
			case 'V': dig =    5; break;
			case 'X': dig =   10; break;
			case 'L': dig =   50; break;
			case 'C': dig =  100; break;
			case 'D': dig =  500; break;
			case 'M': dig = 1000; break;
		}
		if(dig >= maxdig){
			result += dig;
			maxdig = dig;
		}else{
			result -= dig;
		}
	}
	return result;
}

int main(){
	string s;
	while(cin >> s){
		cout << roman2bin(s) << endl;
	}
	return 0;
}

Measured memory_bytes: 1180
N,K = map(int,input().split())
P = list(map(int,input().split()))

cums = [0]
for p in P:
    cums.append(cums[-1] + (p+1)/2)
ans = 0
for i in range(N-K+1):
    ans = max(ans, cums[i+K] - cums[i])
print(ans)

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

int main(){
    int n; cin >> n;
    int price[n];

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

    int min=price[0];
    int max=-2000000000;

    for(int i=1;i<n;i++){
        if(price[i]-min>max)max=price[i]-min;
        if(price[i]<min)min=price[i];
    }

    cout << max << endl;
    
}


Measured memory_bytes: 3864
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from heapq import heappop, heappush 
def main():
    N, M = map(int, readline().split())
    m = map(int, read().split())
    tasks = [[] for _ in range(M)]
    for a, b in zip(m, m):
        if M-a>=0:
            tasks[M-a].append(b)
    s = 0
    h = []
    for i in [i for i in range(M)][::-1]:
        for b in tasks[i]:
            heappush(h, -b)
        if len(h)>0:
            s-=heappop(h)
    print(s)
if __name__ == '__main__':
    main()


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

int main() {
    int a, b, c, N;
    cin >> a >> b >> c >> N;

    int all_pattern_count = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                int total = i*500 + j*100 + k*50;
                if (total == N)
                    all_pattern_count++;
            }
        }
    }
    cout << all_pattern_count << endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)

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

    long long count = 0;
    for (long long i = 0; i < S.size(); i++)
    {
        if ((S.size() + 1) / 2 > i)
        {
            if (S[i] == 'p')
                count--;
        }
        else if (S[i] == 'g')
            count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 512
N = int(input())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]
tmp = 1
ans = [1]
for i in range(N):
    if i == N - 1:
        break
    else:
        if x[i] == y[i] and x[i+1] == y[i+1]:
            tmp += 1
        else:
            tmp = 1
        ans.append(tmp)
if max(ans) >= 3:
    print("Yes")
else:
    print('No')


Measured memory_bytes: 9212
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
    static Scanner sc ;
	public static void main (String[] args) throws java.lang.Exception
	{
	    sc = new Scanner(System.in) ;
	    long ans = 0 ;
	    int n = sc.nextInt() ;
	    for(int i = 0 ; i<n ; i++)
	    {
	    long l = sc.nextInt() ;
	    long r = sc.nextInt() ;
	    ans+=(r-l+1) ;
	    }
	    System.out.println(ans);
	}
}


Measured memory_bytes: 27368
S = input()
length = len(S) - 1
sum = 0
for i in range(2**length):
	plus = [0]
	for j in range(length):
		if ((2**j) & i) // (2**j) == 1:
			plus.append(j + 1)
	plus.append(length + 1)
	for j in range(len(plus) - 1):
		sum += int(S[plus[j]:plus[j+1]])
print(sum)

Measured memory_bytes: 40048
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


L, R = zz()
mod = 2019

range_ = min(R-L+1, 2019)
kouho = []
kouho = [i for i in range(L, L + range_)]
ans = (kouho[0]*kouho[1]) % mod
for i, j in itertools.product(kouho, repeat=2):
    if (i == j):
        continue
    ans = min(ans, (i*j) % mod)
print(ans)


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

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

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	if (v.size()) {
		os << v[0];
		for (int i = 1; i < v.size(); i++) os << " " << v[i];
	}
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

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


void Main() {
	int N; cin >> N;
	auto dp = makeVector(N+1, 4, 4, 4, 0ll);

	dp[0][3][3][3] = 1;
	for (int i = 0; i < N; i++) {
		for (int a = 0; a < 4; a++) {
			for (int b = 0; b < 4; b++) {
				for (int c = 0; c < 4; c++) {
					for (int d = 0; d < 4; d++) {
						if (a == 0 && c == 1 && d == 2) continue;
						if (a == 0 && b == 1 && d == 2) continue;
						if (b == 0 && c == 1 && d == 2) continue;
						if (b == 1 && c == 0 && d == 2) continue;
						if (b == 0 && c == 2 && d == 1) continue;
						(dp[i+1][b][c][d] += dp[i][a][b][c]) %= mod;
					}
				}
			}
		}
	}

	ll sum = 0;
	for (int a = 0; a < 4; a++) {
		for (int b = 0; b < 4; b++) {
			for (int c = 0; c < 4; c++) {
				(sum += dp[N][a][b][c]) %= mod;
			}
		}
	}

	cout << sum << el;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3736
using System;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N;
            string buf;
            int length;
            N = int.Parse(Console.ReadLine());
            buf = Console.ReadLine();
            length = buf.Length;
            if (N >= length)
            {
                Console.WriteLine(buf);
                
            }
            else
            {
                for(int i = 0; i < N; i++)
                {
                    Console.Write(buf[i]);
                    
                }Console.WriteLine("...");
            }
        }
    }
}


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

int H,W,K;
int f(vector<int>& hcut,vector<vector<int>>& S){
    /*
    for(auto p:hcut){
        cout<<p<<" ";
    }
    cout<<endl;
    //*/
    int res=hcut.size();
    hcut.push_back(H-1);
    vector<int> cnt(hcut.size(),0);
    int reset=-1;
    for(int i=0;i<W;i++){
        int pt=0;
        for(int j=0;j<H;j++){
            if(j<=hcut[pt]){
                if(S[j][i]){
                    cnt[pt]++;
                }
            }else{
                pt++;
                if(S[j][i]){
                    cnt[pt]++;
                }
            }
        }
        int flag=0;
        for(int j=0;j<cnt.size();j++){
            if(cnt[j]>K){
                flag=1;
                break;
            }
        }
        if(flag){
            for(int j=0;j<cnt.size();j++){
                cnt[j]=0;
            }
            i--;
            //*
            if(i==reset){
                res=H+W;
                return res;
            }else{
                reset=i;
            }
            //*/
            res++;
        }
    }
    return res;

}

int main(){
    cin>>H>>W>>K;

    string s;
    vector<vector<int>> S(H,vector<int>(W));
    for(int i=0;i<H;i++){
        cin>>s;
        for(int j=0;j<W;j++){
            S[i][j]=(int)s[j]-'0';
        }
    }
    /*
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cout<<S[i][j]<<" ";
        }
        cout<<endl;
    }
    //*/

    int ans=H+W;
    for(int i=0;i<(1<<(H-1));i++){
        vector<int> hcut;
        for(int j=0;j<H-1;j++){
            if(i&(1<<j)){
                hcut.push_back(j);
            }
        }
        int rec=f(hcut,S);
        if(ans>rec){
            ans=rec;
        }

    }
    cout<<ans<<endl;

    return 0;
}

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

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    vector<ll>v;
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        ll t;
        cin>>t;
        sum+=t;
        v.push_back(t);
    }
    ll m;
    cin>>m;
    for(int i=1;i<=m;i++)
    {
        ll p,x;
        cin>>p>>x;
        cout<<(sum-v[p-1]+x)<<endl;
    }
    return 0;
}


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

int main()
{
  int n, y;
  scanf("%d %d", &n, &y);
  for (int a = 0; a <= n; a++) {
    for (int b = 0; b+a <= n; b++) {
      int c = n -(a+b);
      if (a*10000 + b*5000 + c*1000 == y) {
        printf("%d %d %d\n", a, b, c);
        return 0;
      }
    }
  }
  printf("%d %d %d\n", -1, -1, -1);
  
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int K, N, maxi = 0;
    cin >> K >> N;
    int A[N], diff[N];
    for(int i = 0; i < N; i++){
        cin >>A[i];
    }
    for(int i = 0; i < N; i++){
        if(i != N - 1)diff[i] = A[i + 1] - A[i];
        else diff[i] = K - A[i] + A[0];
        maxi = max(diff[i], maxi);
       // cout << maxi << " " << i << '\n';
    }
    cout << K - maxi;
    
}


Measured memory_bytes: 1920
#include <stdio.h>
int main (){
char a,b;
  int p=1,q=1;
scanf ("%c %c",&a,&b);
  if(a=='H'){
  p=0;
  }
    if(b=='H'){
  q=0;
  }
  if((p+q)%2==0){
  printf ("H");
  }
  else  {
  printf ("D");
  }
return 0;
}

Measured memory_bytes: 128
n = int(input())
s = str(input())

R, G, B = [], [], []
for i, c in enumerate(s):
  if c == 'R': R.append(i)
  elif c == 'G': G.append(i)
  else: B.append(i)

ans = 0
for r in R:
  for g in G:
    if r < g: x, y = r, g
    else: x, y = g, r

    ans += len(B)
    if x*2 - y >= 0:
      if s[x*2 - y] == 'B': ans -= 1
    if (x + y) % 2 == 0:
      if s[(x+y)//2] == 'B': ans -= 1
    if y*2 - x < len(s):
      if s[y*2 - x] == 'B': ans -= 1

print(ans)

Measured memory_bytes: 9284
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;
 
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; }
 
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }
 
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
 
inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}
 
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int N,A,B,C;
vi L;
int rec(int i, int a, int b, int c){
  if(i==N){
    if(!a||!b||!c) return INF;
    return abs(A-a)+abs(B-b)+abs(C-c);
  }
  int res=rec(i+1,a,b,c);
  
  chmin(res,rec(i+1,a+L[i],b,c)+(a?10:0));
  chmin(res,rec(i+1,a,b+L[i],c)+(b?10:0));
  chmin(res,rec(i+1,a,b,c+L[i])+(c?10:0));
  
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  vi a(4);
  rep(i,4){
    a[i]=s[i]-'0';
  }
  
  for(int bit=0; bit<(1<<3); bit++){
    int sum=a[0];
    rep(i,3){
      if(bit&(1<<i)){
        sum+=a[i+1];
      }else{
        sum-=a[i+1];
      }
    }
    if(sum==7){
      string ans="";
      rep(i,3){
        ans+=to_string(a[i]);
        if(bit&(1<<i)) ans+="+";
        else ans+="-";
      }
      ans+=to_string(a[3])+"=7";
      cout<<ans<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, k;

long long fun(int x)
{
	long long retval = 1;
	while (x > 1) {
		retval = retval * x;
		retval = retval % MOD;
		x--;
	}
	return retval;
}

long long quickpow(long long b, long long e)
{
	return e ? ((e & 1 ? b : 1)*quickpow((b*b) % MOD, e >> 1)) % MOD : 1;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= k; i++) {
		if (n - k - i + 1 < 0) {
			cout << "0\n";
			continue;
		}
		long long tmp = fun(k - 1);
		tmp = tmp * quickpow(fun(i - 1), MOD - 2);
		tmp = tmp % MOD;
		tmp = tmp * quickpow(fun(k - i), MOD - 2);
		tmp = tmp % MOD;
		long long tmp2 = fun(n - k + 1);
		tmp2 = tmp2 * quickpow(fun(i), MOD - 2);
		tmp2 = tmp2 % MOD;
		tmp2 = tmp2 * quickpow(fun(n - k - i + 1), MOD - 2);
		tmp2 = tmp2 % MOD;
		long long ans = (tmp*tmp2) % MOD;
		cout << ans << "\n";
	}
	//system("pause");
	return 0;
}

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

int main() {
	int D;
	
	cin >> D;
	
	if (D==25) cout << "Christmas";
	else if (D==24) cout << "Christmas Eve";
	else if (D==23) cout << "Christmas Eve Eve";
	else if (D==22) cout << "Christmas Eve Eve Eve";

	
	return 0;
}

Measured memory_bytes: 256
def fennec(n, k):
    if n <= k:
        print("0")
    else:
        hp_list = list(map(int, input().split()))
        hp_list.sort()
        attack = 0
        for i in range(int(n) - int(k)):
            attack += hp_list[i]
        print(attack)
        
        
n, k = map(int, input().split())
fennec(n, k)

Measured memory_bytes: 26360
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func next() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func main() {
	scanner.Split(bufio.ScanWords)

	name1 := next()
	name2 := next()
	name3 := next()

	fmt.Printf("%s%s%s\n", name1[0:1], name2[0:1], name3[0:1])
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
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; }
const long long MOD = 1000000007;
const long long INF = 10000000000;
using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k; cin >> n >> k;
	vector<int>a(n); rep(i, n)cin >> a[i];
	int maxa = 0;
	rep(i, n) {
		maxa = max(a[i], maxa);
	}
	int g = a[0];
	for (int i = 1; i < n; i++) {
		g = gcd(a[i], g);
	}
	if (k % g == 0 && k <= maxa) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
n, m = map(int, input().split())
 
if n == 1 and m == 1:
    print(1)
elif n == 1:
    print(m-2)
elif m == 1:
    print(n-2)
elif n == 2 or m == 2:
    print(0)
else:
    print((n-2) * (m-2))

Measured memory_bytes: 3060
def solve(n):
    if n & 1 == 0:
        return n, n, n // 2
    for h in range(n // 4, 3501):
        nh = n * h
        for w in range(h, 3501):
            nm = 4 * h * w - nh - n * w
            if nm <= 0:
                continue

            dnm = nh * w
            if dnm % nm == 0:
                return h, w, dnm // nm


n = int(input())
print(*solve(n))


Measured memory_bytes: 3060
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  	int A, B;
  	cin >> A  >> B;
  	if((A+B)%2==0) cout << (A+B)/2 <<endl;
  	else cout << "IMPOSSIBLE" <<endl;
  	
  	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/









int N; string S[101];
//---------------------------------------------------------------------------------------------------
#define yes "Yes"
#define no "No"
string solve() {
    set<string> s;
    s.insert(S[0]);

    rep(i, 1, N) {
        if (S[i - 1].back() != S[i][0]) return no;
        if (s.count(S[i])) return no;

        s.insert(S[i]);
    }

    return yes;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> S[i];
    cout << solve() << endl;
}

Measured memory_bytes: 256