akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter


import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S, X, Y):
    m = list(map(lambda x: len(x), S.split('T')))

    X -= m[0]
    ym = m[1::2]
    xm = m[2::2]

    memo = {0}
    for dx in xm:
        nm = set()
        for x in memo:
            nm.add(x+dx)
            nm.add(x-dx)
        memo = nm
    if X not in memo:
        return 'No'

    memo = {0}
    for dy in ym:
        nm = set()
        for y in memo:
            nm.add(y+dy)
            nm.add(y-dy)
        memo = nm
    if Y not in memo:
        return 'No'

    return 'Yes'




def main():
    S = read_str()
    X, Y = read_int_n()
    print(slv(S, X, Y))


if __name__ == '__main__':
    main()


Measured memory_bytes: 92120
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int find(int n){
    int sum=0;
    while(n>0){
        sum+=n%10;
        n/=10;
    }
    return sum;
}

int main(void){
    int ans=0;
    int n,a,b;cin>>n>>a>>b;
    for(int i=1;i<=n;i++){
        if(find(i)>=a&&find(i)<=b)ans+=i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef   long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.1415926535

ll dp[1003][1003];

int main() 
{
    FAST;
    ll h,w;
    cin>>h>>w;
    char a[h][w];
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
        {
            cin>>a[i][j];
            if(a[i][j]=='#')
                dp[i][j]=-1;
        }
    dp[0][0]=1;
    for(int i=1;i<w;i++)
    {
        dp[0][i]=dp[0][i-1];
        if(a[0][i]=='#')
            dp[0][i]=-1;
    }
    for(int i=1;i<h;i++)
    {
        dp[i][0]=dp[i-1][0];
        if(a[i][0]=='#')
            dp[i][0]=-1;
    }
    for(int i=1;i<h;i++)
        for(int j=1;j<w;j++)
            if(dp[i][j]!=-1)
                dp[i][j]=(max(0ll,dp[i-1][j])+max(0ll,dp[i][j-1]))%A;
    cout<<dp[h-1][w-1];
    return 0;
}

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

int main(){
	int n, m;
	cin >> n >> m;
	vector<string> a(n), b(m);
	for(int i=0; i<n; i++) cin >> a.at(i);
	for(int i=0; i<m; i++) cin >> b.at(i);
	bool judge=false;
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			if(i+m-1>=n || j+m-1>=n) continue;
			bool match=true;
			for(int y=0; y<m; y++){
				for(int x=0; x<m; x++){
					if(a.at(i+y).at(j+x)!=b.at(y).at(x)){
						match=false;
					}
				}
			}
			if(match) judge=true;
		}
	}
	if(judge) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3616
import sys, math
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N, M = map(int, input().split())
k = []
s = [[] for _ in range(M)]

switch = [0] * N
ans = 0

#k, sの入力
for i in range(M):
	tmp = list(map(int, input().split()))
	k.append(tmp[0])
	for j in tmp[1:]:
		s[i].append(j)

#pの入力
p = list(map(int, input().split()))

for i in range(2 ** N):#全パターン総当たり
	tmp2 = i
	for j in range(N):#ONしてるスイッチを2進数で表示
		switch[j] = tmp2 % 2
		tmp2 = int(math.floor(tmp2 / 2))
		
	count2 = 0
	for j in range(M):#M個の電球を確認
		count1 = 0
		for k in s[j]:
			if switch[k - 1] == 1:
				count1 += 1
				
		if count1 % 2 == p[j]:
			count2 += 1
			
	if count2 == M:
		ans += 1
		
print(ans)


Measured memory_bytes: 43248
/* author   : mpily :-()
title : Competing.cpp
time :Sun Oct 27 15:31:51 2019

*/
#include<bits/stdc++.h>
#define PI 3.1415926535897932
using namespace std;
int main(){
	double a,b,x;
	cin>>a>>b>>x;
	double v = a*a*b;
	if(2*x/(a*a) == b){
		cout<<setprecision(7);
		cout<<fixed;
		cout<<45.0<<"\n";
	}
	else if (2*x/(a*a) > b){
		double initH = b - double(double(x)/double(a*a));
		double low = 0;
		double high = 89.99999999;
		double mid = (low+high)/2.0;
		while(low < high){
			double val =  a/2.0 * tan(mid*PI/180.0);
			if(abs(val - initH) <= 0.00000000001){
				low = mid;
				high = mid;
			}
			else if (val < initH){
				low = mid + 0.00000001;
				mid = (high+low)/2.0;
			}
			else{
				high = mid - 0.00000001;
				mid =(high+low)/2.0;
			}
			
		}
		cout<<setprecision(7)<<fixed<<mid<<"\n";
		
	}
	else{
		double low = 0;
		double high = 89.99999999;
		double mid = (low+high)/2.0;
		while(low < high){
			double y = sqrt(double(2*x)/double(a * tan((mid)*PI/180.0)));
			//cout<<abs(y-b)<<" at "<<setprecision(7)<<fixed<<90.0-mid<<"\n";
			if(abs(y-b) <= 0.00000000001){
				low = mid;
				high = mid;
			}
			else if(y < b){
				high = mid - 0.00000001;
				mid =(high+low)/2.0;
			}
			else{
				low = mid + 0.00000001;
				mid = (high+low)/2.0;
			}
		}
		cout<<setprecision(7)<<fixed<<90.0-mid<<"\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ff first
#define ss second
#define maxn 1000000007
#define PI 3.14159265358979323846
#define MAX 1000007 
using namespace std; 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    //cout<<fixed<<setprecision(20);
    ll a,b,c;
    cin>>a>>b>>c;
    if(a*b<=c)
    {
        cout<<a*b<<endl;
    }
    else
    {
        cout<<c<<endl;
    }
    return 0;
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

//constexpr long long MOD = 1000000007;
constexpr long long MOD = 998244353;
constexpr double EPS = 1e-10;
constexpr int INF = 1001001001;
constexpr ll LINF = 1001001001001001001ll;


const long long MAX = 2000000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
inline long long COM(long long n, long long k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    ll N, M; cin >> N >> M;
    COMinit();
    ll res = 0;
    ll m = M % 2;
    for (ll X = m; X <= M; X += 2) {
        ll a = (COM(N, X) * COM((3 * M - X) / 2 + N - 1, N - 1) ) % MOD;
        ll b = (COM(N, X) * COM((M - X) / 2 + N - 1, N - 1) ) % MOD;
        ll c = (COM(N - 1, X) * COM((M - X) / 2 + N - 2, N - 2) ) % MOD;
        res = (res + a - b * N + c * N) % MOD;
        res = (res + MOD) % MOD;
    }

    cout << res << endl;

}

Measured memory_bytes: 47232
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

a, b = readmi()

count = 1
n = b + 1
while(n + b < a):
    n += (b * 2) + 1
    count += 1
print(count)

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	string s;

	cin >> s;
	string a;
	for(auto x : s)
     
		if(x == 'B'){
          if((int)a.size() > 0)
			a.pop_back();
        }else
			a += x;

	cout << a << endl;

	return 0;
}

Measured memory_bytes: 256
F =-> {gets.split.map &:to_i}
N,M,Q = F[]
m,S,X = 0,[],N.times.map {[0]*N}
Q.times {
  a,b,c,d = F[]
  0 == x=X[b-=1] and x=X[b] = [0]*N
  0 == y=x[a-=1] and y=x[a] = [0]*M
  y[c] = d
}
R =->(a,t) {
  return  if N <= d=S.size
  S << a
  x = X[d]
  a.upto(M) {|a;z|
    S[d] = a
    s = t + d.times.sum {|i| b = S[i]; x[i][a-b] }
    m = s  if m < s
    R[a,s]
  }
  S.pop
  m
}
R[1,0]
p m

Measured memory_bytes: 14296
def main():
    H, W = list(map(int, input().split(' ')))
    a = [list(map(int, input().split(' '))) for _ in range(H)]
    cnt = 0
    history = list()
    for h in range(H):
        for w in range(W - 1):
            if a[h][w] % 2 == 1:
                a[h][w] -= 1
                a[h][w + 1] += 1
                history.append((h + 1, w + 1, h + 1, w + 2))
                cnt += 1
    for h in range(H - 1):
        if a[h][W - 1] % 2 == 1:
            a[h][W - 1] -= 1
            a[h + 1][W - 1] += 1
            history.append((h + 1, W, h + 2, W))
            cnt += 1
    print(cnt)
    for hist in history:
        print(' '.join(map(str, hist)))


if __name__ == '__main__':
    main()

Measured memory_bytes: 26240
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,y,sum=0;
    cin>>t>>y;
    int a[t],i;
    for(i=0;i<t;i++)
    cin>>a[i];
    sort(a,a+t);
    for(i=0;i<y;i++)
     sum=sum+a[i];
     cout<<sum;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long int n,m;
	long long int sum=0;
	cin>>n>>m;
	vector<long long int> v;
	while(n--){
		long long int x;
		cin>>x;
		sum+=x;
		v.push_back(x);
	}
	long long int c=0;
	sort(v.begin(),v.end());
	for(long long int i=0;i<v.size();i++){
		if(v[i]>=(sum/(4*m))){
			c++;
		}
	}
	if(sum%(m*4)!=0){
		long long int d=(sum/(4*m));
		long long int dd=0;
		for(long long int i=0;i<v.size();i++){
			if(v[i]==d){
				dd++;
			}
		}
		c-=dd;
	}
	if(c>=m){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

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

using namespace std;

using int64 = long long;
const int INF = 1 << 30;

int main()
{
  int N;
  cin >> N;
  string S = to_string(N);

  int sum = 0;
  for(auto &c : S) sum += c - '0';

  if(N % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

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

  return 0;
}




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

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

	if (s == "SUN"){
		cout << 7 << endl;
	}else if (s == "SAT"){
		cout << 1 << endl;
	}else if (s == "FRI"){
		cout << 2 << endl;
	}else if (s == "THU"){
		cout << 3 << endl;
	}else if (s == "WED"){
		cout << 4 << endl;
	}else if (s == "TUE"){
		cout << 5 << endl;
	}else if (s == "MON"){
		cout << 6 << endl;
	}


	return 0;
}

Measured memory_bytes: 256
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}

const ll N=3e5+5;



int main()
{ 

IOS;


ll l,r,d;
cin>>l>>r>>d;

ll cnt=0;
for(int i=l;i<=r;i++){
if(i%d==0)cnt++;
}

cout<<cnt<<endl;


return 0;
 
}



Measured memory_bytes: 3608
N=int(input())

x=[]
u=[]

for i in range(N):
    n, a = input().split()
    x.append(n)
    u.append(a)

sum=0
for i in range(N):
  if u[i]=='JPY':
    sum=sum+float(x[i])
  else:
    sum=sum+float(x[i])*380000

print(sum)
  

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

bool check_bingo(vi &bingo, initializer_list<ll> line)
{
    for (const ll n : line)
    {
        auto ite = lower_bound(begin(bingo), end(bingo), n);
        if (ite == end(bingo) || *ite != n)
        {
            return false;
        }
    }
    return true;
}

int main(void)
{
    vi card(9);
    for (ll i = 0; i < 9; i++)
    {
        cin >> card[i];
    }
    ll n;
    cin >> n;
    vi bingo(n);
    for (auto i = 0; i < n; i++)
    {
        cin >> bingo[i];
    }
    sort(begin(bingo), end(bingo));
    bool isBingo = false;
    for (auto i = 0; i < 3; i++)
    {
        isBingo |= check_bingo(bingo, {card[i*3], card[i*3 + 1], card[i*3 + 2]});
        isBingo |= check_bingo(bingo, {card[i], card[i + 3], card[i + 6]});
    }
    isBingo |= check_bingo(bingo, {card[0], card[4], card[8]});
    isBingo |= check_bingo(bingo, {card[6], card[4], card[2]});
    if (isBingo)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
  ll n,p;
  string s;
  cin>>n>>p>>s;
  ll ans=0;
  if(p==2||p==5){
    rep(i,sz(s)){
      if((s[i]-'0')%p==0)ans+=i+1;
    }
    COUT(ans);
  }
  else{
    vll c(p);
    ll cu=0;
    ll f=1;
    for(int i=n-1;i>=0;i--){
      cu+=(s[i]-'0')*f;
      f*=10;
      f%=p;
      cu%=p;
      c[cu]++;
    }
    ans+=c[0];
    rep(i,p){
      if(c[i]>1){
      ans+=c[i]*(c[i]-1)/2;
      }
    }
    COUT(ans);
  }
}

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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795

ll dist[202][202];
int rs[10];
bool visited[202];
int n,m,r;
ll ans = 2100000000;
ll currc = 0;
vector<int> order;

ll minn(ll a, ll b) {
	if(a < b) {
		return a;
	}
	return b;
}

void permute(int vis,int curr) {
	if(vis == r) {
		ans = minn(ans,currc);
		return;
	}
	for(int j = 0; j < r; j++) {
		int i = rs[j];
		if(!visited[i]) {
			visited[i] = true;
			if(curr != -1) {
				currc+= dist[i][curr];
			}
			order.push_back(i);
			permute(vis+1,i);
			order.pop_back();
			if(curr != -1) {
				currc-= dist[i][curr];
			}
			visited[i] = false;
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> m >> r;
	memset(dist,6,sizeof(dist));
	memset(visited,false,sizeof(visited));
	for(int i = 0; i < r; i++) {
		cin >> rs[i];
		rs[i]--;
	}
	for(int i = 0; i < m; i++) {
		int u,v,c;
		cin >> u >> v >> c;
		u--;
		v--;
		dist[u][v] = minn(dist[u][v],c);
		dist[v][u] = minn(dist[v][u],c);
	}
	for(int k = 0; k < n; k++) {
		for(int j = 0; j < n; j++) {
			for(int i = 0; i < n; i++) {
				dist[i][j] = minn(dist[i][j],dist[i][k]+dist[k][j]);
				dist[j][i] = minn(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}
	}
	permute(0,-1);
	cout << ans;
	return 0;
}



Measured memory_bytes: 640
N,A,B=map(int, input().split())
X=list(map(int, input().split()))
now=X[0]
ans=0
for i in range(1,N):
    nex=X[i]
    if (nex-now)*A>B:
        ans+=B
    else:
        ans+=(nex-now)*A
    now=nex
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb emplace_back
typedef pair<int,int> pi;

ll n, a[3005], dp[3005][3005];

int main() {
	ios_base::sync_with_stdio(0); 
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> a[i];	
	for (int i = n - 1; i >= 0; --i) {
		for (int j = i; j < n; ++j) {
			if (i == j)	dp[i][j] = a[i];
			else dp[i][j] = max(a[i] - dp[i+1][j], a[j] - dp[i][j-1]);
		}
	}
	cout << dp[0][n-1];
	return 0;
}


Measured memory_bytes: 49732
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;
 
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a>b)swap(a,b);
  if(a<c && c<b){ cout << "Yes" << endl; }else{cout << "No" << endl;}
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int to[200001],nxt[200001],n,h[100001],a,b,l,cnt,siz[100001],r1,r2,maxs[100001],fa[100001];
long long len[200001],ans;
void ins(int x,int y,int z){to[++cnt]=y;len[cnt]=z;nxt[cnt]=h[x];h[x]=cnt;}
int Max(int x,int y){return x>y?x:y;}
int Min(int x,int y){return x<y?x:y;}
void dfs(int x){
	for(int i=h[x];i;i=nxt[i])if(to[i]!=fa[x]){
		fa[to[i]]=x;dfs(to[i]);
		siz[x]+=siz[to[i]];
		maxs[x]=Max(maxs[x],siz[to[i]]);
	}
	maxs[x]=Max(maxs[x],n-(++siz[x]));
	if(maxs[x]<maxs[r1])r1=x;
	else if(maxs[x]==maxs[r1])r2=x;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;++i)scanf("%d%d%d",&a,&b,&l),ins(a,b,l),ins(b,a,l);
	maxs[0]=n;dfs(1);
	for(int i=1;i<=n;++i)for(int j=h[i];j;j=nxt[j])if(to[j]!=fa[i])ans+=Min(siz[to[j]],n-siz[to[j]])*len[j];\
	ans*=2;
	if(maxs[r1]==maxs[r2]){
		for(int j=h[r1];j;j=nxt[j])if(to[j]==r2)ans-=len[j];
		printf("%lld\n",ans);
	}
	else{
		r2=2147483647;for(int j=h[r1];j;j=nxt[j])r2=Min(r2,len[j]);
		printf("%lld\n",ans-r2);
	}
	return 0;
}

Measured memory_bytes: 7552
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#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)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n;
Vi a;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	std::cout<<std::fixed<<std::setprecision(30);
	cin>>n;
	a.resize(n);
	ll ct=0;
	rep(i,n){
		cin>>a[i];
		if(a[i]%2==1){
			ct++;
		}
	}
	ll gu = n-ct;
	while(1){
		gu += ct/2;
		if(ct%2==1){
			ct = 1;
		}else{
			ct = 0;
		}
		if(ct<=1)break;
	}
	YES(ct==0);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cout << a[i] << " "; cout << "\n"; }
ll dbgt = 1; void err() { cout << "passed " << dbgt++ << "\n"; }
template<class H, class... T> void err(H&& h,T&&... t){ cout<< h << (sizeof...(t)?" ":"\n"); if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll K, rest;
    cin >> K;
    ll N = 50;
    vc<ll> ans(N);
    iota(all(ans), K / N);

    ll r = K % N;
    rep(i, r) ans[i] += N - r + 1;
    repe(i, r, N) ans[i] -= r;

    cout << N << endl;
    rep(i, N) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int num;
  scanf("%d", &num);
  int i, j;
  //データの入力
  int A[100];
  for(i=0; i<num; ++i){
	scanf("%d", &A[i]);
  }
  int count=0;
  int tmp;
  for(i=0; i<(num-1); ++i){
	for(j=(num-1); j>i; --j){
	  if(A[j-1]>A[j]){
		tmp=A[j-1];
		A[j-1]=A[j];
		A[j]=tmp;
		++count;
	  }
	}
  }
  //出力
  for(i=0; i<num; ++i){
	printf("%d", A[i]);
	if(i<(num-1))
	  printf(" ");
  }
  printf("\n");
  printf("%d\n", count);
  return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
long long n,m;
long long gcd(long long x,long long y){
	if(x==0)return y;
	if(x<y)swap(x,y);
	return gcd(x%y,y);
}
int main(){
	cin>>n>>m;
	cout<<((n/gcd(n,m)-1)*3*gcd(n,m))<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"-----------"<<endl;
#define ll long long
#define P pair<int,int>
#define mk make_pair
#define en endl
#define RE return 0
#define int ll

int sum[505][505];

signed main(){
  int n,m,q;
  cin>>n>>m>>q;
  for(int i=0; i<m; i++){
    int l,r;
    cin>>l>>r;
    sum[l][r]++;
  }
  
  for(int i=1; i<=n; i++){
    for(int j=1; j<=n; j++){
      sum[i][j]+=sum[i][j-1];
    }
  }
  
  for(int i=0; i<q; i++){
    int l,r;
    cin>>l>>r;
    int ret=0;
    for(int j=l; j<=r; j++) ret+=sum[j][r];
    cout<<ret<<en;
  }
}



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

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	int n,x;
	cin >> n >> x;
	cout << n*n - x << "\n";	
	return 0;
}

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

signed main(void)
{
	int n;
	cin >> n;
	ll a[n];
	ll sum, ans;
	map<ll, ll> mp;
	rep(i, n) 
	{
		cin >> a[i];
		mp[a[i]]++;
	}
	sum = 0;
	for (auto p : mp)
	{
		auto k = p.first;
		auto v = p.second;
		sum += v * (v - 1) / 2;
	}
	rep(i, n)
	{
		ans = sum;
		ans -= mp[a[i]] * (mp[a[i]] - 1) / 2;
		ans += (mp[a[i]] - 1) * (mp[a[i]] - 2) / 2;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 13088
N = int(input())
A, B = map(int, input().split())
P_list = list(map(int, input().split()))
P_list = sorted(P_list)
res1 = 0
res2 = 0
res3 = 0
for i in P_list:
    if i <= A:
        res1 += 1
    if A+1 <= i and i <= B:
        res2 += 1
    if B + 1 <=i:
        res3 += 1
print(min(min(res1, res2), res3))

Measured memory_bytes: 38256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

typedef long long ll;

int main() {
    ll n, m;
    scanf("%lld%lld", &n, &m);
    vector<ll> x(m), f(m, 0);
    for (ll i = 0; i < m; ++i) scanf("%lld", x.begin() + i);
    sort(x.begin(), x.end());
    for (ll i = m - 1; i >= 1; --i) x.at(i) -= x.at(i - 1);
    sort(x.begin() + 1, x.end());
    printf("%lld\n", accumulate(x.begin() + 1, x.begin() + 1 + max(0LL, m - n), 0LL));
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define INT(a) scanf("%d",&a)
#define STR(a) scanf("%s",a)
#define DBL(a) scanf("%lf",&a)
#define LNG(a) scanf("%lld",&a)
#define PI acos(-1)

int main(){
	string s;
	cin>>s;
	int mx=0, len=0;
	for(int i=0;i<s.length();i++){
		if(s[i]=='A' || s[i]=='T' || s[i]=='G' || s[i]=='C') len++;
		else{
			mx=max(len, mx);
			len=0;
		}
	}
	mx=max(len, mx);
	cout<<mx<<endl;	
	return 0;
}

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

int main()
{
	int i, N, M, a[51], b[51], c[51], d[51];
	scanf("%d %d", &N, &M);
	for (i = 1; i <= N; i++) scanf("%d %d", &(a[i]), &(b[i]));
	for (i = 1; i <= M; i++) scanf("%d %d", &(c[i]), &(d[i]));
	
	int j, min, argmin[51];
	for (i = 1; i <= N; i++) {
		min = 1 << 30;
		for (j = 1; j <= M; j++) {
			if (abs(a[i] - c[j]) + abs(b[i] - d[j]) < min) {
				min = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				argmin[i] = j;
			}
		}
	}
	
	for (i = 1; i <= N; i++) printf("%d\n", argmin[i]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
###############################################################################

from bisect import bisect_left as binl

def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * sy) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


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


def main():
    h, w, n = intin()
    init_pos_h, init_pos_w = intin()
    s = input()
    t = input()

    pos_h = init_pos_h
    pos_w = init_pos_w
    for i in range(n):
        if s[i] == 'L':
            pos_w -= 1
        if pos_w <= 0:
            print('NO')
            return
        if t[i] == 'R' and pos_w < w:
            pos_w += 1

    pos_h = init_pos_h
    pos_w = init_pos_w
    for i in range(n):
        #print('== %d' % pos_w)
        if s[i] == 'R':
            pos_w += 1
        #print('===== %d' % pos_w)
        if pos_w > w:
            print('NO')
            return
        if t[i] == 'L' and pos_w > 1:
            pos_w -= 1

    pos_h = init_pos_h
    pos_w = init_pos_w
    for i in range(n):
        if s[i] == 'U':
            pos_h -= 1
        if pos_h <= 0:
            print('NO')
            return
        if t[i] == 'D' and pos_h < h:
            pos_h += 1

    pos_h = init_pos_h
    pos_w = init_pos_w
    for i in range(n):
        if s[i] == 'D':
            pos_h += 1
        if pos_h > h:
            print('NO')
            return
        if t[i] == 'U' and pos_h > 1:
            pos_h -= 1

    print('YES')


if __name__ == '__main__':
    main()


Measured memory_bytes: 44256
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        long X = nextInt();

        while(true) {
            boolean flag = false;
            for (int i = 2; i < X; i++) {
                if (X % i == 0) {
                    flag = true;
                    break;
                }
            }
            if(flag){
                X++;
            }else{
                println(X);
                return;
            }
        }
    }

    static long a(long n){
        return n < 2L ? 1L : n*a(n-2);
    }

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

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


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

ans = 0
i = 1
while i <=n:
    j = 1
    cnt = 0
    while j <= i:
        if i%j == 0:
            cnt +=1
            #print(i,cnt,j)
        j +=1
    if cnt == 8 and i%2 ==1:
        #print(i)
        ans += 1
    i +=1
print(ans)

Measured memory_bytes: 9112
import sys

n = int(sys.stdin.readline().rstrip())
xy = [[] for _ in range(n)]
for i in range(n):
    a = int(sys.stdin.readline().rstrip())
    for j in range(a):
        x, y = map(int, sys.stdin.readline().split())
        xy[i].append((x-1, y))

def main():
    ans = 0
    for comb in range(2 ** n):
        cnt = 0
        for i in range(n):
            if comb >> i & 1 ^ 1:
                continue
            for x, y in xy[i]:
                if comb >> x & 1 ^ y:
                    break
            else:
                cnt += 1
                continue
            break
        else:
            ans = max(ans, cnt)
    return ans
                
if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		long A;
		double B;
		cin >> A >> B;

		long b = B*100.0 + 0.5;
		cout << A*b/100 << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 3676
//ex7_1
//TKC001

#include<stdio.h>
//pointの宣言
typedef struct point
{
    int x_elem;
    int y_elem;
}point;

//点Pをx軸方向にx_diff, y軸方向にy_diffだけずらす
point point_shift(point p, int x_diff, int y_diff){
    p.x_elem += x_diff;
    p.y_elem += y_diff;

    return p;
    }


int main(void){
    point poi1, poi2, poi3, poi4;
    int x_diff, y_diff;
    //入力
    scanf("%d %d %d %d", &poi1.x_elem, &poi1.y_elem, &poi2.x_elem, &poi2.y_elem);

    //(x1, y1)と(x2, y2)はx軸方向にx_diff, y軸方向にy_diffだけずらせばそれぞれ(x3, y3), (x4, y4)になる。
    x_diff = poi1.y_elem-poi2.y_elem;
    y_diff = poi2.x_elem-poi1.x_elem;

    //ずらす処理
    poi3 = point_shift(poi2, x_diff, y_diff);
    poi4 = point_shift(poi1, x_diff, y_diff);

    //出力
    printf("%d %d %d %d", poi3.x_elem, poi3.y_elem, poi4.x_elem, poi4.y_elem);

    return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#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 FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

vector<string> s3({
"aa.",
"..b",
"..b",});
vector<string> s4({
"aabc",
"ddbc",
"abdd",
"abcc",});
vector<string> s5({
"abbcc",
"a.dee",
"ggdff",
"abc..",
"abc..",});
vector<string> s7({
"abbcc..",
"a.dee..",
"ggd..ff",
"ab...aa",
"ab...bb",
"..cab..",
"..cab..",});
vector<string> s9({
"aa.aa.aa.",
"..a..a..a",
"..a..a..a",
"aa.aa.aa.",
"..a..a..a",
"..a..a..a",
"aa.aa.aa.",
"..a..a..a",
"..a..a..a"});

int main() {
    int n;
    cin >> n;
    vector<string> ans(n, string(n, '.'));
    if (n % 3 == 0){
        REP(c,n/3){
            REP(i,3) REP(j,3){
                ans[3 * c + i][3 * c + j] = s3[i][j];
            }
        }
        REP(i,n) cout << ans[i] << endl;
        return 0;
    }
    REP(c9,n/9+1) REP(c7,(n-9*c9)/7+1) REP(c5,(n-9*c9-7*c7)/5+1){
        if ((n - 9*c9 - 7*c7 - 5*c5) % 4 != 0) continue;
        int c4 = (n - 9*c9 - 7*c7 - 5*c5) / 4;
        int x = 0;
        REP(_,c9){
            REP(i,9) REP(j,9) ans[x + i][x + j] = s9[i][j];
            x += 9;
        }
        REP(_,c7){
            REP(i,7) REP(j,7) ans[x + i][x + j] = s7[i][j];
            x += 7;
        }
        REP(_,c5){
            REP(i,5) REP(j,5) ans[x + i][x + j] = s5[i][j];
            x += 5;
        }
        REP(_,c4){
            REP(i,4) REP(j,4) ans[x + i][x + j] = s4[i][j];
            x += 4;
        }
        REP(i,n) cout << ans[i] << endl;
        return 0;
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 2304
def unzip(li):
  return map(list, zip(*li))

N, M = map(int, input().split())
tmp_C = [0 for i in range(N)]

for i in range(N):
  a,b = map(int, input().split())
  tmp_C[i] = (a,b)
  
C = sorted(tmp_C)
A, B = unzip(C)
ans = 0
count = 0
cur = 0
while(count < M):
  min_A = A[cur]
  B_min = B[cur]
  if count + B_min >= M:
    print(ans + min_A * (M - count))
    break
  else:
    ans += min_A * B_min
    count += B_min
    cur += 1

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

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)


int main() {
  int a;
  string b;
  cin >> a >> b;
  if (a < 3200) b = "red";
  cout << b << endl; 
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Tax Rate
            int N = int.Parse(Console.ReadLine());

            var noTax = Math.Floor(N / 1.08);

            Console.WriteLine(GetNoTaxPrice(noTax, N));
        }

        static string GetNoTaxPrice(double noTax, int N)
        {
            for (int i = -1; i < 2; i++)
            {
                if(Math.Floor((noTax + i) * 1.08) == N)
                {
                    return (noTax + i).ToString();
                }
            }

            return ":(";
        }
    }
}

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

const int N=100005;
const long long MOD=1e9+7;
int n,a[30][30];
long long dp[3000005];

int main()
{
	scanf("%d",&n);
	dp[0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for(int i=1;i<(1<<n);i++)
	{
		int cnt=0,tmp=i;
		while(tmp) tmp-=tmp&-tmp,cnt++;
		tmp=i;
		while(tmp)
		{
			if(a[cnt][(int)log2(tmp&-tmp)+1]) dp[i]+=dp[i-(tmp&-tmp)];
			dp[i]%=MOD,tmp-=tmp&-tmp;
		}
	}
	printf("%d\n",dp[(1<<n)-1]);
}

Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
ll inf = 1e10;

ll gcd(ll a, ll b){
  return (b != 0) ? gcd(b, a%b) : a;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int ans = 0;
  vpii red(n), blue(n);
  rep(i, n) cin >> red[i].first >> red[i].second;
  rep(i, n) cin >> blue[i].first >> blue[i].second;
  sort(red.begin(), red.end());
  sort(blue.begin(), blue.end());
 
    
  rep(b, n){
    int maxi = -1;
    int maxy = -1;
    rep(r, n){
      if(red[r].first < blue[b].first && red[r].second < blue[b].second){
        if(red[r].second > maxy){
          maxi = r;
          maxy = red[r].second;
        }
        
      }
      else continue;
    }
    if(maxi != -1){
      red[maxi].second = -1;
      ans++;
    }
  }
  
  cout << ans << "\n";
  
}  

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline

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

    inf = float("inf")
    dp = [inf]*N

    dp[0] = 0
    step1, step2 = inf, inf

    for i in range(1, N):
        step1 = abs(H[i-1]-H[i]) + dp[i-1]
        if i >= 2:
            step2 = abs(H[i-2]-H[i]) + dp[i-2]
        step = min(step1, step2)

        dp[i] = min(dp[i], step)
    print(dp[-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 13876
// abc176-C
#include <cstdio>
#include <algorithm>
#include <cstring> 
#include <iostream>
#include <string>

using namespace std;
typedef long long ll;
ll n;
const ll N=200000+5;
ll a[N]={0};

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for (ll i=0;i<n;i++)
	cin>>a[i];
	ll ans=0;
	for (ll i=1;i<n;i++)	
	{
		if (a[i]<a[i-1])
		{
			ans+=a[i-1]-a[i];
			a[i]=a[i-1];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5208
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()

ans = 0
for v in range(2, n):
    if v*v > n:
        break
    e = 0
    while n % v == 0:
        n //= v
        e += 1
    if e > 0:
        for k in range(1, 10):
            if e >= k:
                e -= k
                ans += 1
            else:
                break
if n > 1:
    ans += 1
print(ans)


Measured memory_bytes: 63180
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		ll int n;
		cin>>n;
		ll int a=0,b=0,c=0;
		for(ll int i=0;i<n;i++)
		{
			ll int x;
			cin>>x;
			a++;
			b+=-2*x;
			c+=x*x;
		}
		ll int mini=1e18;
		for(ll int x=-1000;x<=1000;x++)
		{
			mini=min(mini,a*x*x+b*x+c);
		}
		cout<<mini<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
public static void main(String [] args)throws Exception{
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  String str = br.readLine();
  int cnt[] = new int[26];
  for(int i = 0;i < str.length();i++){
  	cnt[str.charAt(i) - 'a']++;
  }
  int diff = 0;
  for(int i = 0;i < cnt.length;i++){
  	if(cnt[i] > 0)++diff;
  }
  if(diff == 2){
  	System.out.println("Second");
  }
  else{
  	if(str.charAt(0) == str.charAt(str.length() - 1)){
  		String str1 = ((str.length() - 3) & 1) == 0 ? "Second" : "First";
  		System.out.println(str1);
  	}
  	else{
  		String str1 = ((str.length() - 2) & 1) == 0 ? "Second" : "First";
  	    System.out.println(str1);
  	}
  }
}
}


Measured memory_bytes: 10836
s = input()
ok = True
for i in range(len(s)):
    if (i+1) % 2 == 0:
        if s[i] != 'L' and s[i] != 'D' and s[i] != 'U':
            ok = False
            break
    else:
        if s[i] != 'R' and s[i] != 'D' and s[i] != 'U':
            ok = False
            break
if ok:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let m: usize = sc.cin();
    let k: usize = sc.cin();
    let mut ans = "No";
    for i in 0..n+1 {
        for j in 0..m+1 {
            let a = i * m + j * n - i * j * 2;
            // trace!((i, j), (m, n), a);
            if a == k {
                ans = "Yes";
            }
        }
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
#include <iostream>

#define ARC(i, a, b) for(int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)

int main(){
	int n, max = 0, sum = 0;
	std::cin >> n;
	RC(i, n){
		int tmp;
		std::cin >> tmp;
		if(max < tmp) max = tmp;
		sum += tmp;
	}
	std::cout << (max * 2 < sum ? "Yes" : "No") << std::endl;
}


Measured memory_bytes: 256
fn main() {
    proconio::input! {
        n: usize,
        p: [(i64, i64); n]
    }
    let x = p.iter().map(|&(a, b)| a + b).collect::<Vec<_>>();
    let y = p.iter().map(|&(a, b)| a - b).collect::<Vec<_>>();
    let dx = x.iter().max().unwrap() - x.iter().min().unwrap();
    let dy = y.iter().max().unwrap() - y.iter().min().unwrap();
    println!("{}", dx.max(dy));
}


Measured memory_bytes: 12152