akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <deque>
#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <iomanip>
#include <utility>
#include <functional>
using namespace std;
#define ll long long
#define ull unsigned ll
int n, fail[100005];
int len;
ll pre[100005][26];
ll l, r;
string s;
int gaofail(string &str) {
	fail[0]=0;
	fail[1]=0;
	for (int i=1, j=0; i<n; i++) {
		while (j&&str[i]!=str[j]) j=fail[j];
		if (str[i]==str[j]) j++;
		fail[i+1]=j;
	}
	return fail[n];
}
void gaopre() {
	pre[0][s[0]-'a']=1ll;
	for (int i=1; i<n; i++) {
		for (int j=0; j<26; j++) pre[i][j]=pre[i-1][j];
		pre[i][s[i]-'a']++;
	}
}
ll calc1(ll i, int c) {
	if (i<0)
		return 0;
	if (i<n)
		return pre[i][c];
	i-=n;
	return pre[n-1][c]+pre[len-1][c]*(i/len)+pre[i%len][c];
}
ll calc2(ll i, int c) {
	if (i<0)
		return 0;
	if (i<n)
		return pre[i][c];
	if (i<2*n)
		return pre[n-1][c]+pre[i-n][c];
	ll f1=n, f2=n+len, r1=pre[n-1][c], r2=pre[n-1][c]+pre[len-1][c];
	while (f1+f2<i) {
		ll t=f2;
		f2+=f1;
		f1=t;
		t=r2;
		r2+=r1;
		r1=t;
	}
	return r2+calc2(i-f2, c);
}
int main() {
	cin>>s;
	cin>>l>>r;
	l--, r--;
	s=s.substr(0, s.length()/2);
	n=s.length();
	len=n-gaofail(s);
	gaopre();
	if (n%len==0) {
		for (int i=0; i<26; i++)
			cout<<calc1(r, i)-calc1(l-1, i)<<(i<25?' ':'\n');
	} else {
		for (int i=0; i<26; i++)
			cout<<calc2(r, i)-calc2(l-1, i)<<(i<25?' ':'\n');
	}
	return 0;
}

Measured memory_bytes: 21056
#!python3

LI = lambda: list(map(int, input().split()))

# input
X, Y = LI()


def main():
    ans = "No"
    for a in range(X + 1):
        b = X - a
        if 2 * a + 4 * b == Y:
            ans = "Yes"
            break
    print(ans)


if __name__ == "__main__":
    main()


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

using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;

template<typename C>
i64 Size(const C &c) { return static_cast<i64>(c.size()); }

template<typename C>
void Sort(C &c) { std::sort(c.begin(), c.end()); }

template<typename C>
void SortR(C &c) { std::sort(c.rbegin(), c.rend()); }

template<typename T, typename U, typename Comp=std::less<>>
bool ChMax(T &x_max, const U &x, Comp comp={}) {
  if(comp(x_max, x)) {
    x_max = x;
    return true;
  }
  return false;
}

template<typename T, typename U, typename Comp=std::less<>>
bool ChMin(T &x_min, const U &x, Comp comp={}) {
  if(comp(x, x_min)) {
    x_min = x;
    return true;
  }
  return false;
}

struct ProconInit {
  static constexpr int IOS_PREC = 0;
  static constexpr bool AUTOFLUSH = false;

  ProconInit() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(IOS_PREC);
    if (AUTOFLUSH) std::cout << std::unitbuf;
  }
} PROCON_INIT;

void solve() {
  f80 n; std::cin >> n;
  f80 k; std::cin >> k;

  f80 tmp = std::fmod(n, k);

  while (ChMin(tmp, std::fabs(tmp - k))) {
    // DO NOTHING
  }

  std::cout << static_cast<u64>(tmp) << "\n";
}

signed main() {
  solve();

  return 0;
}


Measured memory_bytes: 384
n,k = map(int,input().split())

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

def factorize(k):
    b = 2
    fct = []
    while b * b <= k:
        while k % b == 0:
            k //= b
            fct.append(b)
        b = b + 1
    if k > 1:
        fct.append(k)
    return fct

n_set=set(factorize(n))
k_set=set(factorize(k))
c_set=n_set&k_set
c=list(c_set)
print(len(c)+1)


Measured memory_bytes: 3064
[a,b,c]=[int(i) for i in input().split()]
[d,e,f]=[int(j) for j in input().split()]
[g,h,i]=[int(k) for k in input().split()]
t=0
if d-a == e-b and e-b == f-c:
  t+=1
if g-d == h-e and h-e == i-f:
  t+=1
if b-a == e-d and e-d == h-g:
  t+=1
if c-b == f-e and f-e == i-h:
  t+=1
if t== 4:
  print("Yes")
else:
  print("No")

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

int main() {
  int N, K;
   
  cin >> N >> K;

  
  int M;
  
  if (K == 1 ){
    cout << 0 << endl;
    }
  
  else {
    M = (N - K);
    
    cout << M << endl;
    }
  }


Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for _ in range(N)]

ret = 0
for i in range(N) :
    s = C
    for j in range(M) :
        s += A[i][j] * B[j]
    if s > 0 :
        ret += 1
print(ret)

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

int N;
int a[MAXN], c[MAXN];

int main(){
	
	cin>>N;
	for(int i=1;i<=N;i++){
		cin>>a[i];
	}
	
	memcpy(c, a, sizeof(a));
	sort(c+1, c+1+N);
	
	int ans = 0;
	for(int i=1;i<=N;i++){
		a[i] = lower_bound(c+1, c+1+N, a[i]) - c;
		if(a[i]%2 != i%2) ++ans;
	}
	cout<<ans/2<<endl;
	
	return 0;
}


Measured memory_bytes: 4408
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(), (x).rend()
#define pll pair<long long, long long>
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
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;}
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp



int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    ll m;
    cin >> m;
    vvll d(n);
    rep(i,m){
        ll a,b;
        cin >> a>>b;
        d[a-1].pb(b-1);
        d[b-1].pb(a-1);
    }
    vll f(n,0);
    ll count=1;
    ll ans=0;
    ll maxans=0;
    rep(i,n){
        if(f[i]!=0) continue;
        queue<ll> q;
        q.push(i);
        f[i]=count;
        ans=1;
        while(!q.empty()){
            ll fr=q.front();
            rep(j,d[fr].size()){
                if(f[d[fr][j]]==0){
                    f[d[fr][j]]=count;
                    q.push(d[fr][j]);
                    ans++;
                }
            }
            q.pop();
        }
        maxans=max(ans,maxans);
    }
    cout<<maxans<<endl;
}


Measured memory_bytes: 18536
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

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

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

    //cout << fixed << setprecision(15);

    string s;
    cin >> s;

    int p = 0;
    int n = s.size();

    for (int i = 0; i < n; ++i)
    {
        if (s[i] == 'p')
            p++;
    }
    cout << n / 2 - p << endl;
    return 0;
}


Measured memory_bytes: 512
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
BC = [list(map(int, input().split())) for _ in range(Q)]

num = [0] * 100001
for a in A:
    num[a] += 1
S = sum(A)
for i in range(Q):
    S += (BC[i][1] - BC[i][0]) * num[BC[i][0]]
    print(S)
    num[BC[i][1]] += num[BC[i][0]]
    num[BC[i][0]] = 0


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n;
    while(cin >> n){
        if(n == 0) return 0;
        vector<bool> F(n + 1, true);
        for(int i = 2; i <= (int)sqrt(n); i++){
            if(F[i]){
                for(int j = i + i; j <= n; j += i){
                    F[j] = false;
                }
            }
        }

        int ans = 0;
        for(int i = 2; i <= n / 2; i++){
            if(F[i] and F[n - i]) ans++;
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3264
#include<bits/stdc++.h>
using namespace std;
/*
n<|k-n|までwhileで計算量ダメそう(サンプル3)
10e18な時点でO(N)は不可

n==1 =>0 これ偽じゃんどうやって真であること証明したお前！？
n%k==0 =>0 これも証明済

*/
int main(){
  int64_t n,k;
  cin >> n >> k;
  if(k==1||n==k||n%k==0){
    cout << 0 << endl;
  }else {
  int64_t b=n/k+1;
    if(k<n){
      cout << min(abs(n-b*k),abs(n-b*k+k)) << endl;
    }else{
      cout << min(n,k-n) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3592
N=int(input())
W=[]
for i in range(N):
    w=input()
    W.append(w)
last=W[0][-1]
S=set()
S.add(W[0])
for i in range(1,N):
    if W[i][0]==last and not W[i] in S:
        pass
    else:
        print("No")
        exit()
    S.add(W[i])
    last=W[i][-1]
print("Yes")

Measured memory_bytes: 3064
S = input()
odd_f = True
even_f = True

for i, s in enumerate(S):
    if (i) % 2 == 0:
        if S[i] == 'L':
            odd_f = False
    else:
        if S[i] == 'R':
            even_f = False
if odd_f and even_f:
    print('Yes')
else:
    print('No')


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

int A[1000005];

int main()
{
	int s;
	cin >> s;
	A[0] = s;
	int cnt = 1;
	int temp = s;
	while(1)
	{
		if (temp % 2 == 0) temp /= 2;
		else temp = 3 * temp + 1;

		A[cnt] = temp;
		//cout << temp << endl;

		for (int i = 0; i < cnt; ++i)
		{
			if (A[i] == temp)
			{
				cout << cnt+1 << endl;
				return 0;
			}
		}
		cnt++;
	}
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

ll n, t[111111], a[111111], p[111111], h[111111], r = 1;

int main() {
	cin >> n;
	rep(i,n) cin >> t[i];
	rep(i,n) cin >> a[i];
	if (t[n-1]!=a[0]) r = 0;
	else {
		// まず高橋くんの記録だけ見たときのi番目の山の高さとしてあり得る種類を求める
		p[0] = 1;
		reps(i,1,n) {
			if (t[i]==t[i-1]) p[i] = t[i];
			else p[i] = 1, h[i] = t[i];
		}
		// 青木くんの記録で⇡を狭める
		p[n-1] = 1;
		repr(i,n-2) {
			if (a[i]==a[i+1]) {
				if (h[i]) p[i] = (h[i]<=a[i]);
				else chmin(p[i], a[i]);
			}
			else {
				if (h[i]) p[i] = (h[i]==a[i]);
				else p[i] = 1;
			}
		}
		rep(i,n) r = (r*p[i])%mod;
	}
	cout << r << ln;
}

Measured memory_bytes: 3072
def power(a, n, M):
    res = 1
    if n > 0:
        res = power(a*a%M, n/2, M)
        if n % 2 == 1:
            res = res * a % M
    return res
m, n = map(int, raw_input().split())
print power(m, n, 1000000007)

Measured memory_bytes: 6404
#include "bits/stdc++.h"
using namespace std;
using lint = long long;
typedef vector<vector<lint> > mat;
lint MOD = 1e9+7;

mat mul(mat &a, mat&b){
	mat c(a.size(), vector<lint> (b[0].size()));
	for(int i = 0; i < a.size(); i++){
		for(int k = 0; k < b.size(); k++){
			for(int j = 0; j < b[0].size(); j++){
				c[i][j] = (c[i][j] + a[i][k] * b[k][j]) % MOD;
			}
		}
	}
	return c;
}
mat pow_matrix(mat &a, lint N){
	mat b(a.size(), vector<lint> (a.size()));
	for(int i = 0; i < a.size(); i++) b[i][i] = 1;
	while(N > 0){
		if(N & 1) b = mul(b, a);
		a = mul(a, a);
		N >>= 1;
	}
	return b;
}

signed main(){
	lint N, K, ans = 0; cin >> N >> K;
	mat a(N, vector<lint> (N));
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++) cin >> a[i][j];
	}
	a = pow_matrix(a, K);
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++) if(a[i][j]) ans += a[i][j], ans %= MOD;
	}
	cout << ans << endl;
}

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

typedef long long ll;


ll mod = 1e9 + 7;

ll modPower(ll x,ll y){
    x%=mod;
    ll res = 1;
    while(y){
        if(y&1)res= (res*x)%mod;
        x = (x*x)%mod;
        y>>=1;
    }
    return res;
}

int main() {
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL); 
	int n, k;
	cin>>n>>k;

	ll ans = 0;


	ll g[k+1];

	for(int i = k; i >= 1; --i){
		g[i] = modPower(k/i , n);
		for(int j = 2*i; j <= k; j += i){
			g[i] = (g[i] - g[j] + mod)%mod;
		}
		ans = (ans + i*g[i])%mod;
	}

	//for(int i= 1; i <= k; ++i)cout<<g[i]<<' '; cout<<endl;

	cout<< ans << endl;

}


Measured memory_bytes: 4420
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << endl;
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << endl;
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

int main(){
  ll N, C;
  cin >> N >> C;
  vector<ll> x(N), v(N);
  vector<ll> effect_max_right(N), effect_max_left(N);
  ll v_sum=0;
  rep(i, 0, N){
    cin >> x[i] >> v[i];
    if(i==0){
      effect_max_right[i] = max(v[i] - x[i], (ll)0);
    }else{
      effect_max_right[i] = max(v[i] + v_sum - x[i], effect_max_right[i-1]);
    }
    v_sum += v[i];
  }
  v_sum = 0;
  rep(i, 0, N){
    if(i==0){
      effect_max_left[i] = max(v[N-1-i] - (C-x[N-1-i]), (ll)0);
    }else{
      effect_max_left[i] = max(v[N-1-i] + v_sum - (C-x[N-1-i]), effect_max_left[i-1]);
    }
    v_sum += v[N-1-i];
  }

  ll ans = max(effect_max_right[N-1], effect_max_left[N-1]);
  rep(i, 0, N-1){
    ans = max(ans, effect_max_right[i]-x[i]+effect_max_left[N-1-1-i]);
    ans = max(ans, effect_max_left[i]-(C-x[N-1-i])+effect_max_right[N-1-1-i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3328
#include "stdio.h"
#include "stdlib.h"
#include "iostream"
#include "math.h"
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include "algorithm"


using namespace std;
#define fori0(G) for(int i=0;i<G;i++)
#define fori1(G) for(int i=1;i<=G;i++)
#define forj0(G) for(int j=0;j<G;j++)
#define forj1(G) for(int j=1;j<=G;j++)
#define fork0(G) for(int k=0;k<G;k++)
#define fork1(G) for(int k=1;k<=G;k++)
int dx[] = { -1,0,1,0 ,0 }, dy[] = { 0,1,0,-1,0 };
#define nxnycon (0<=nx&&nx<h&&0<=ny&&ny<w) 


#define lo long long int

map<lo, lo> mp;
lo n, a[200001], t, c = 0;

int main() {
	
	cin >> n;
	a[0] = 0;
	mp[0] = 1;
	fori1(n) {
		cin >> t;
		a[i] = a[i - 1] + t;
		mp[a[i]]++;
		c += mp[a[i]] - 1;
	}
	cout << c<<endl;

	//system("pause");
	return 0;

}



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

n, k = (int(x) for x in input().split())
seq = [int(x) for x in input().split()]
visited = [[False,0] for _ in xrange(n)]

t = 1
cnt = 0
if n < k:
    while not visited[t-1][0]:
        visited[t-1][0] = True
        visited[t-1][1] = cnt
        t = seq[t-1]
        cnt += 1

    cycle_len = cnt - visited[t-1][1]
else:
    cycle_len = n
for _ in xrange((k-visited[t-1][1]) % cycle_len):
    t = seq[t-1]
print(t)


Measured memory_bytes: 101324
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long l;
#define rep(i,n) for(ll i = 0; i<n ; ++i)
#define repj(j,i,n) for(ll j = i; j<n; ++j)
#define repd(j,i,n) for(ll j = i; j>=n ; --j)
#define vi vector<int>
#define vll vector<ll>
#define vp vector<pair<int,int>>
#define vpl vector<pair<ll,ll>>
#define si set<int>
#define sll set<ll>
#define mp make_pair
#define pb push_back
#define f first
#define sec second
#define len length()
#define mod 1000000007

ll modex(ll a, ll b){ll ans = 1; a%=mod; if(a == 0) return 0; while(b>0){ if(b&1) ans = (ans*a)%mod; b = b>>1; a = (a*a)%mod;} return ans;}
ll gcd(ll a, ll b){ if (b == 0) return a; return gcd(b, a % b);}

void solve(){
    string s,t;
    cin>>s>>t;
    if(t.substr(0,t.len-1) == s) cout<<"Yes";
    else cout<<"No";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("error.txt", "w", stderr);
    #endif

    //int q; cin>>q; while(q--)
        solve();

    #ifndef ONLINE_JUDGE
     cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}

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

typedef pair<string,int> P;

signed main(){
  int n;cin>>n;
  set<string> s;
  queue<P> que;
  que.push(P(string(n,'#'),0));
  while(que.size()){
    P p=que.front();que.pop();
    string t=p.first;int a=p.second;
    vector<int> v;
    for(int i=0;i<n;i++)if(t[i]=='#')v.push_back(i);
    if(v.size()==0){s.insert(t);continue;}
    t[v[0]]=('a'+a);
    for(int j=0;j<(1<<(int)v.size()-1);j++){
      string tmp=t;
      for(int i=0;i<n;i++)if((j>>i)&1)tmp[v[i+1]]=(char)('a'+a);
      que.push(P(tmp,a+1));
    }
  }
  for(string p:s)cout<<p<<endl;
}


Measured memory_bytes: 12416
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			boolean[] is_prime = new boolean[N + 1];
			Arrays.fill(is_prime, true);
			is_prime[0] = is_prime[1] = false;
			
			long[] divisors = new long[N + 1];  
			Arrays.fill(divisors, 1);

			
			for(int i = 2; i <= N; i++) {
				if(!is_prime[i]) { continue; }
				divisors[i] *= 1 + 1;
				
				for(int j = 2 * i; j <= N; j += i) {
					is_prime[j] = false;
					
					int rest = j, count = 0;
					while(rest % i == 0) { rest /= i; count++; }
					
					//System.out.println(j + " " + count);
					divisors[j] *= (count + 1);
				}
			}
			
			//System.out.println(Arrays.toString(divisors));
			
			long answer = 0;
			for(int i = 1; i <= N; i++) {
				answer += i * divisors[i];
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 132996
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
  int N;
  cin >> N;
  double ans = 0;
  for (int i = 0; i < N; i++) {
    double x;
    string u;
    cin >> x >> u;
    if (u=="JPY") {
      ans += x;
    } else { // BTC
      ans += x*380000.0;
    }
  }
  cout << fixed << setprecision(6) << ans << endl;
  return 0;
}


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

const int MAXN = 1e5+5;
const int INF = 1e9+7;
int dp[MAXN][4],a[MAXN][4];
// dp[i][j] ==> The maximum we can get if we do [1..i] and do type j activity on day i

int main()
{
    for(int i=1;i<=MAXN;++i){
        for(int j=0;j<3;++j){
            dp[i][j] = INF;
        }
    }
    int n;cin >> n;
    for(int i=1;i<=n;++i){
        for(int j=0;j<3;++j){
            cin >> a[i][j];
        }
    }
    for(int i=1;i<=n;++i){
        // Choose Swimming
        dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i][0];
        dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + a[i][1];
        dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + a[i][2];
    }
    cout << max(dp[n][0],max(dp[n][1],dp[n][2]));
}


Measured memory_bytes: 3456
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collection;


public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=a-1;
        if(b>=a){
            System.out.println(a);
        }else{
            System.out.println(c);
        }

        
}
        
        
    }


Measured memory_bytes: 23252
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N,C = II()
x,v = Line(N)

#時計のみ
ans1 = 0
a = []
for i in range(N):
    a.append([x[i],v[i]])
a2 = sorted(a,key=lambda x:x[0])
temp = 0
for i in range(N):
    temp += a2[i][1]
    if temp-a2[i][0]>ans1:
        ans1 = temp-a2[i][0]

#反時計のみ
ans2 = 0
temp = 0
for i in range(N)[::-1]:
    temp += a2[i][1]
    if temp-(C-a2[i][0])>ans2:
        ans2 = temp-(C-a2[i][0])

ans = max(ans1,ans2)

#時計>=反時計
b = [] #反時計向きの個数,得
temp = 0
for i in range(N)[::-1]:
    temp += a[i][1]
    b.append([N-i,temp-2*(C-a[i][0])])
b.sort(key=lambda x:-x[1])
now = 0
a_temp = 0
for i in range(N):
    a_temp += a[i][1]
    while now<=N-1:
        if b[now][0]+i+1>N:
            now += 1
        else:
            temp = b[now][1]+a_temp-a[i][0]
            if temp>ans:
                ans = temp
            break

#時計<反時計
b = [] #時計向きの個数,得
temp = 0
for i in range(N):
    temp += a[i][1]
    b.append([i+1,temp-2*a[i][0]])
b.sort(key=lambda x:-x[1])
now = 0
a_temp = 0
for i in range(N)[::-1]:
    a_temp += a[i][1]
    while now<=N-1:
        if b[now][0]+N-i>N:
            now += 1
        else:
            temp = b[now][1]+a_temp-(C-a[i][0])
            if temp>ans:
                ans = temp
            break

print(ans)

Measured memory_bytes: 105820
#include <algorithm>
#include <complex>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <iomanip>
 
using std::cin;
using std::cout;
using std::endl;
using std::cerr;
 
using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::stack;
using std::priority_queue;
 
using std::min;
using std::max;
using std::sort;
using std::abs;
 
using std::accumulate;
 
typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
 
class section {
   public:
    int begin;
    int end;
    int velocity;
 
    section() {}
    section(int begin, int end) : begin(begin), end(end) {}
};
 
int main() {
    int n;
    cin >> n;
 
    vector<section> ss(n);
    int sum_t = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        x *= 2;
 
        ss[i].begin = sum_t;
        ss[i].end = sum_t + x;
 
        sum_t += x;
    }
 
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        ss[i].velocity = 2 * x;
    }
 
    vector<int> a(sum_t + 1, INF);
    a[0] = 0;
    a[sum_t] = 0;
 
    for (const section& s : ss) {
        for (int i = s.begin; i <= s.end; i++) {
            a[i] = min(a[i], s.velocity);
        }
    }
 
    for (int i = sum_t - 1; i >= 0; i--) {
        a[i] = min(a[i + 1] + 1, a[i]);
    }
 
    int speed = 0;
    int distance = 0;
    for (int i = 0; i < sum_t; i++) {
        if (speed < a[i + 1]) {
            speed += 1;
            distance += speed + 1;
        } else if (speed > a[i + 1]) {
            speed -= 1;
            distance += speed - 1;
        } else {
            distance += speed;
        }
    }
 
    cout << std::fixed << std::setprecision(9) << (1.0 * distance / 4) << endl;
 
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int i,n=0,x;
  string s,a;

  a="yes";
  cin>>s;
  n=s.size();
  for(i=0;i<=n;i++)
  {
    for(int j=i+1;j<n;j++)
    if(s[j]==s[i])
    {
      a="no";
      break;
    }
  }


  cout<<a<<endl;
}


Measured memory_bytes: 256
import sys
import os

H, W = map(int,input().split())
S = [input() for _ in range(H)]

cnt = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            if 0 <= i-1 and i-1 <= H-1 and S[i-1][j] == "#":
                    cnt +=1
            if 0 <= i+1 and i+1 <= H-1 and S[i+1][j] == "#":
                    cnt +=1
            if 0 <= j-1 and j-1 <= W-1 and S[i][j-1] == "#":
                    cnt +=1
            if 0 <= j+1 and j+1 <= W-1 and S[i][j+1] == "#":
                    cnt +=1

            if 0 <= i-1 and i-1 <= H-1 and\
               0 <= j-1 and j-1 <= W-1 and S[i-1][j-1] == "#":
                    cnt +=1
            if 0 <= i+1 and i+1 <= H-1 and\
               0 <= j-1 and j-1 <= W-1 and S[i+1][j-1] == "#":
                    cnt +=1
            if 0 <= i-1 and i-1 <= H-1 and\
               0 <= j+1 and j+1 <= W-1 and S[i-1][j+1] == "#":
                    cnt +=1
            if 0 <= i+1 and i+1 <= H-1 and\
               0 <= j+1 and j+1 <= W-1 and S[i+1][j+1] == "#":
                    cnt +=1
            print(cnt,end="")
            cnt = 0
        else:
            print("#",end="")
        if j == W-1:
            print()


Measured memory_bytes: 3572
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <string>
#include <math.h>

using namespace std;

int main(void)
{
    long long a, b, X;
    cin >> a >> b >> X;

    long long upper = b / X;
    long long lower = (a + X - 1) / X;
    cout << upper - lower + 1 << endl;
    return 0;
}

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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  string s, ans;
  cin >> s;

  if (s[0] == s.back()) {
    if ((int)s.size()&1)  ans = "Second";
    else ans = "First";
  } else {
    if ((int)s.size()&1)  ans = "First";
    else ans = "Second";
  }

  cout << ans << '\n';
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

int n, m;
int k[11];
bool sw[11][11];
int p[11];

int test(vector<int> &vec){
	for (int i = 1; i <= m; i++){
		int coun = 0;
		for (int j = 1; j <= n; j++){
			if (sw[i][j] && vec[j] == 1){
				coun++;
			}
		}
		if (coun % 2 != p[i]) return 0;
	}
	return 1;
}

int main(){
	cin >> n >> m;
	for (int i = 1; i <= m; i++){
		cin >> k[i];
		for (int j = 1; j <= k[i]; j++){
			int x;
			cin >> x;
			sw[i][x] = true;
		}
	}
	for (int i = 1; i <= m; i++) cin >> p[i];

	int ans = 0;
	for (int i = 0; i < (1<<n); i++){
		vector<int> vec;
		vec.push_back(0);
		for (int j = 0; j < n; j++){
			if (i & (1<<j)) vec.push_back(1);
			else vec.push_back(0);
		}
		ans += test(vec);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3620
n = int(input())
s = input()
lst = ["{:03}".format(i) for i in range(1000)]
count = 0
for num in lst:
    pos = 0
    np = num[pos]
    for tmp in s:
        if np == tmp:
            if pos == 2:
                count += 1
                break
            pos += 1
            np = num[pos]
print(count)


Measured memory_bytes: 40924
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;

int main(void)
{
    ll n, d;
    cin >> n >> d;
    int ct = 0;
    rep(i, n)
    {
        ll x, y;
        cin >> x >> y;
        if (sqrt(x * x + y * y) <= d)
        {
            ct++;
        }
    }
    cout << ct << endl;
}


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

int main()
{
    int n, result=0;
    cin >> n;
    for(int c=1; c<=n; c++) {
        int cnt=0;
        for(int x=1; x<=n; x+=2) {
            if(c%x==0) cnt++;
            if(cnt>8) break;
        }
        if(cnt==8) result++;
    }
    cout << result << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  int a[2][n];
  for(int i=0; i<2; ++i){for(int j=0; j<n; ++j){cin >> a[i][j];}}
  int max1 = -10000;
  for(int i=0; i<n; ++i){
    int sum=0;
    
    for(int j=0; j<=i; ++j)sum+=a[0][j];
    for(int j=i; j<n; ++j)sum+=a[1][j];
    max1=max(max1, sum);
  }
  cout << max1 << endl;
}

Measured memory_bytes: 256
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let v : Vec<i32> = s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();

    let x = v[0];
    let a = v[1];
    let b = v[2];

    if (a-x).abs() > (b-x).abs() {
        println!("B");
    }
    else {
        println!("A");
    }

}

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

#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (long long)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 500005

vector<int> g[mxn];
pq<int,vector<int> > q;

int32_t main(){
sp;
    int n,m;
    cin>>n>>m;
    for(int i=0; i<n; ++i){
        int x,y;
        cin>>x>>y;
        g[x].push_back(y);
    }
    int ans=0;
    for(int i=1; i<=m; ++i){
        for(auto &it:g[i])
            q.push(it);
        if(!q.empty()){
            ans+=q.top();
            q.pop();
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 15104
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>
#include <unordered_set>
#include <stack>
#include <iterator>
#include <random>
#include <fstream>
#include <chrono>
#include <math.h>
#include <cctype>
using namespace std;
#define int long long
#define forn(i, n) for (int i = 0; i < n; ++i)
int32_t main() {
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int>a(n);
    forn(i,n)
    cin>>a[i];
    sort(a.begin(),a.end());
    int ans=0;
    forn(i,k)
    ans += a[i];
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

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

        int n = sc.nextInt();

        int[] a = new int[n];
        int[] c = new int[n];
        int sum = 0;
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();

        }

        for (int i = 0 ; i < n ; i++) {
            c[i] = sc.nextInt();
        }

        for (int i = 0 ; i < n ; i++) {
            int d = a[i] - c[i];
            if (d > 0) {
                sum += d;
            }
        }
        System.out.println(sum);

    }

}


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



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

  vector<int> vec(N);
  int not2 = 0;
  int num4 = 0;
  for(int i = 0;i < N;i++) {
    int a;
    cin >> a;
    if(a % 2 != 0) {
      not2++;
    }else if(a % 4 == 0){
      num4++;
    }
  }

  string ans = "No";
  if(not2 + num4 == N) {
    if(not2 <= num4 + 1) ans = "Yes";
  }else {
    if(not2 <= num4) ans = "Yes";
  }

  cout << ans << endl;
}

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

int main() {
  bool chk = false;
  int num,cnt;
  int sum = 0;
  cin >> num >> cnt;
  
  vector<int> vec(num);
  for(int i = 0; i < num; i++){
    cin >>vec.at(i);
  }
  
  // ソート
  sort(vec.begin(), vec.end(),greater<int>());
  
  // 選択本数分計算
  for(int i = 0; i < cnt; i++){
    sum += vec.at(i);
  }
  
  cout << sum;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    String s;
    int w;

    private void solve() {
        s = next();
        w = nextInt();

        StringBuilder sb = new StringBuilder();
        for(int i = 0;i < s.length();i += w) {
            int end = Math.min(s.length(),i + w);
            sb.append(s.substring(i,end).charAt(0));
        }
        out.println(sb.toString());
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

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


Measured memory_bytes: 23252
package main

import "fmt"

func main(){
	var num,grid,ans,b int
	fmt.Scan(&num)
	fmt.Scan(&b)
	for i := 0;i < num;i++{
		fmt.Scan(&grid)
		if grid < b -grid {
			ans += 2*grid
		}else{
			ans += 2*(b-grid)
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    string s;
    cin>>s;
    int goukei=0;
    int kaigai=0;
    rep(i,0,n){
        char c=s[i];
        if(c=='c') cout<<"No"<<endl;
        else if(c=='a'){
            if(goukei<a+b){
                cout<<"Yes"<<endl;
                goukei++;
            }
            else cout<<"No"<<endl;
        }
        else{
            if(goukei<a+b && kaigai<b){
                cout<<"Yes"<<endl;
                goukei++;
                kaigai++;
            }
            else cout<<"No"<<endl;
        }
    }
}


Measured memory_bytes: 896
#abc153 a
#153 c
def n_jou(n):
    cnt=0
    while n>1:
        n=int(n/2)
        cnt+=1
    return cnt

n=int(input())
k=n_jou(n)
ans=0
for i in range(k+1):
    ans+=2**i
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const ll INF = (ll)(1e18);

int main(void){
  ll N, M, R;
  cin >> N >> M >> R;
  vector<ll> r(R);
  REP(i, R) cin >> r[i], r[i]--;
  sort(ALL(r));
  vector<vector<ll>> g(N, vector<ll>(N, INF));
  REP(i, M){
    ll a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    g[a][b] = c;
    g[b][a] = c;
  }
  REP(k, N) REP(i, N) REP(j, N) chmin(g[i][j], g[i][k]+g[k][j]);
  ll ans = INF;
  do{
    ll dist = 0;
    REP(i, R-1) dist += g[r[i]][r[i+1]];
    chmin(ans, dist);
  }while(next_permutation(ALL(r)));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long A = sc.nextLong();
        long B = sc.nextLong();
        long AB = A+B;
        long ans;
        if(A == 0)
            ans = 0;
        else
            ans = (long)(N/AB) * A + Math.min((N%AB), A);
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Atcoder
{
    class aaaa
    {
        static void Main(string[] args)
        {
            string N = Console.ReadLine();
            
            if(N.Contains('a') && N.Contains('b') && N.Contains('c')){
                Console.WriteLine("Yes");
            }else{
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 13268
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#define MAX 500010
#define inf 2000000000
int A[MAX],cnt=0;
int l[MAX/2+10],r[MAX/2+10];
void merge(int left,int mid,int right)
{
	int i,Lstart=1,Rstart=1;
	int n1=mid-left;
	int n2=right-mid;
	for(i=1;i<=n1;i++)
		l[i]=A[left+i-1];
	for(i=1;i<=n2;i++)
		r[i]=A[mid+i-1];
	l[n1+1]=inf;
	r[n2+1]=inf;
	for(i=left;i<=right-1;i++)
	{
		cnt++;
		if(l[Lstart]<=r[Rstart])
		{
			A[i]=l[Lstart];
			Lstart++;
		}
		else
		{
			A[i]=r[Rstart];
			Rstart++;
		}
	}
	return;
}
void mergesort(int left,int right)
{
	if(left+1>=right)
		return;
	int mid=(left+right)/2;
	mergesort(left,mid);
	mergesort(mid,right);
	merge(left,mid,right);
	return;
}
int main()
{
	int i,n;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&A[i]);
	mergesort(1,n+1);
	for(i=1;i<n;i++)
		printf("%d ",A[i]);
	printf("%d\n%d\n",A[n],cnt);
	return 0;
}


Measured memory_bytes: 5692
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
int n,m,x,y;
int xx[2000];
int yy[2000];

int main(){
  cin >> n >> m >> x >> y;
  REP(i,n) cin >> xx[i];
  sort(xx,xx+n);
  reverse(xx,xx+n);
  int x_max = xx[0];
  x_max = max(x_max,x);
  REP(i,m) cin >> yy[i];
  sort(yy,yy+m);
  int y_min = yy[0];
  y_min = min(y_min,y);
  if(x_max<y_min) cout  << "No War" << endl;
  else cout << "War" << endl;

  return 0;
}


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

const double PI=3.14159265358979323846;

int main(){
    double a,b,x;
    cin >> a >> b >> x;
    x/=a;
    cout << fixed << setprecision(10);
    if ( a*b/2 < x ){
        cout << atan( (2.0*(a*b-x))/(a*a) )*180/PI << endl;
    } else {
        cout << atanl( (b*b)/(2.0*x) )*180/PI << endl;
    }
}

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

int n, l, a[100002], p;

int main(){
  cin >> n >> l;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  for (int i = 1; i < n; i++) {
    if (a[i] + a[i + 1] >= l) {p = i; break;}
  }
  if (p == 0)
    cout << "Impossible";
  else {
    cout << "Possible\n";
    for (int i = 1; i < p; i++)
      cout << i << "\n";
    for (int i = n - 1; i > p; i--)
      cout << i << "\n";
    cout << p;
  }
	return 0;
}


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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int b[N];
int a[4][4];
int used[N];
int main()
{
    #ifdef FILEs
        freopen("input.txt", "r", stdin);
        /// freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);

    for(int i = 1; i <= 3; i ++){
        for(int j = 1; j <= 3; j ++){
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    for(int i = 1; i <= n; i ++){
        cin >> b[i];
        used[b[i]] = 1;
    }
    for(int i = 1; i <= 3; i ++){
        int good = 1;
        for(int j = 1; j <= 3; j ++){
            good &= used[a[i][j]];
        }
        if(good == 1){
            cout << "Yes\n";
            return 0;
        }
        good = 1;
        for(int j = 1; j <= 3; j ++){
            good &= used[a[j][i]];
        }
        if(good == 1){
            cout << "Yes\n";
            return 0;
        }
    }
    if(used[a[1][1]] && used[a[2][2]] && used[a[3][3]]){
        cout << "Yes\n";
    }
    else if(used[a[1][3]] && used[a[2][2]] && used[a[3][1]]){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}



Measured memory_bytes: 256
#include<iostream>
#include<queue>

using namespace std;

typedef struct{
  int col;
  int row;
}RL;


int main(){

  int col, row;
  while(cin >> row >> col){
    if(col == 0 && row == 0)break;
    int sum = 1;
    char data[col][row];
    RL myposi;

    for(int i = 0; i < col; i++){
      for(int j = 0; j < row; j++){
	cin >> data[i][j];
	if(data[i][j] == '@'){
	  myposi.col = i;
	  myposi.row = j;
	}
      }
    }

    queue<RL> Q;
    Q.push(myposi);

    while(!Q.empty()){
      RL front;
      front = Q.front();
      Q.pop();
      
      if(front.col-1 >= 0 && data[front.col-1][front.row] == '.'){
	sum++;
	data[front.col-1][front.row] = '#';
	RL a;
	a.col = front.col-1;
	a.row = front.row;
	Q.push(a);
      }
      if(front.col+1 < col && data[front.col+1][front.row] == '.'){
	sum++;
	data[front.col+1][front.row] = '#';
	RL a;
	a.col = front.col+1;
	a.row = front.row;
	Q.push(a);
      }
      if(front.row-1 >= 0 && data[front.col][front.row-1] == '.'){
	sum++;
	data[front.col][front.row-1] = '#';
	RL a;
	a.col = front.col;
	a.row = front.row-1;
	Q.push(a);
      }
       if(front.row+1 < row && data[front.col][front.row+1] == '.'){
	sum++;
	data[front.col][front.row+1] = '#';
	RL a;
	a.col = front.col;
	a.row = front.row+1;
	Q.push(a);
      }

    }
    cout << sum << endl;

  }

  return 0;
}

Measured memory_bytes: 0
N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
for n in range(N):
    A = list(map(int, input().split()))
    sum = C
    for m in range(M):
        sum += B[m] * A[m]
    if sum > 0:
        ans += 1
print(ans)


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

//------------------------------------------------------

int main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];
    sort(a, a + n);

    vector<ll> use;

    rep(i, n - 1) {
        if (a[i] == a[i + 1]) {
            use.push_back(a[i]);
            a[i + 1] = -1;
        }
    }

    if (use.size() <= 1) {
        cout << 0 << endl;
    } else {
        sort(use.begin(), use.end());
        reverse(use.begin(), use.end());
        cout << use[0] * use[1] << endl;
    }
    return 0;
}



Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define xrep(i, a, b) for (int i = int(a); i < int(b); ++i)
int main() {
    string S;
    cin >> S;
    for(auto s: S) {
        if(s == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3576