akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

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

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  ll i,j,N,M,K;
  cin>>N>>M;
  if(N<2){
    vec ans;
    if(M){
      print(-1);
      return 0;
    }
    rep(i,N+1)ans.pb(i),ans.pb(i);
    output(ans);
    return 0;
  }
  K=pow(2,N);
  if(K<=M){
    print(-1);
    return 0;
  }
  vec ans;
  ans.pb(M);
  rep(i,K){
    if(i!=M)ans.pb(i);
  }
  ans.pb(M);
  brep(i,K){
    if(i!=M)ans.pb(i);
  }
  output(ans);
  return 0;
}

Measured memory_bytes: 3952
#include <iostream>
#include <string>
using namespace std;
int solve(int m, string a, string b, string c)
{
    int co = 0;
    for (int i = 0; i < m; i++)
    {
        if (a[i] == b[i] && b[i] == c[i])
        {
            co += 0;
        }
        else if (a[i] == b[i] && b[i] != c[i])
        {
            co += 1;
        }
        else if (a[i] == c[i] && a[i] != b[i])
        {
            co += 1;
        }
        else if (b[i] == c[i] && a[i] != b[i])
        {
            co += 1;
        }
        else
        {
            co += 2;
        }
    }
    return co;
}
int main()
{
    int n;
    int ans;
    string str1, str2, str3;
    cin >> n >> str1 >> str2 >> str3;
    ans = solve(n, str1, str2, str3);
    cout << ans << endl;
}

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

int main() {
  string s; cin >>s;
  int size = s.size();
  bool ans = true;
  bool esc = false;
  
  for (int i=0; i<size-1; i++){
    for (int j=i+1; j<size; j++){
      if (s.at(i) == s.at(j)){
        ans = false;
        esc = true;
        break;
      }
    }
    if (esc) break;
  }
  
  if (ans) cout <<"yes" <<endl;
  else cout <<"no" <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int n,m,a,b,c,d,h,w,x,y;
string str;

signed main(){
  string cod="FESTIVAL";

  cin >> str;
  int ans = str.length()-cod.length();
 hoge:
  FOR(i,cod.length()){
    if(str[i+ans]!=cod[i]){
      ans++;
    }
  }
  FOR(i,str.length()-cod.length()){
    cout <<str[i];
  }
  cout fin;
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
n = int(input())
s = str(input())
r = []
g = []
b = []
for i in range(n):
    if s[i] == "R":
        r.append(i+1)
    elif s[i] == "G":
        g.append(i+1)
    else:
        b.append(i+1)
cnt=len(r)*len(g)*len(b)
if n<=3:
    print(0)
    exit()
for i in range(n-2):
    for j in range(i+1,n-1):
        if j*2-i<n:
            if s[i]!=s[j] and s[j]!=s[j*2-i] and s[j*2-i]!=s[i]:
                cnt-=1
print(cnt)

Measured memory_bytes: 9224
#include <cstdio>
#include <vector>
#include <utility>
#include <cstring>

using namespace std;

int n;
int f[509];

void add(int x, int v) {
  while (x <= n) {
    f[x] += v;
    x = (x | (x - 1)) + 1;
  }
}

int get(int x) {
  int res = 0;
  while (x > 0) {
    res += f[x];
    x &= x - 1;
  }
  return res;
}

vector<int> g[509];
vector<pair<int, int>> q[509];
int ans[100'009];

int main() {
  int m, qq;
  scanf("%d %d %d", &n, &m, &qq);
  for (int i = 0; i <= n; ++i) {
    g[i].clear();
  }
  memset(f, 0, sizeof f);
  for (int i = 0; i < m; ++i) {
    int l, r;
    scanf("%d %d", &l, &r);
    g[l].push_back(r);
    add(r, 1);
  }
  for (int i = 0; i <= n; ++i) {
    q[i].clear();
  }
  for (int i = 0; i < qq; ++i) {
    int l, r;
    scanf("%d %d", &l, &r);
    q[l].emplace_back(r, i);
  }
  for (int i = 1; i <= n; ++i) {
    for (auto &e : q[i]) {
      ans[e.second] = get(e.first);
    }
    for (int e : g[i]) {
      add(e, -1);
    }
  }
  for (int i = 0; i < qq; ++i) {
    printf("%d\n", ans[i]);
  }
}


Measured memory_bytes: 3584
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; } 
template<class T> void chmax(T &t, T f) { if (t < f) t = f; } 

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())

LL n, a, b, x[100010];

void init() {
}

void input() {
	cin >> n >> a >> b;
	REP(i, n) cin >> x[i];
}

void solve() {
	LL res = 0;
	FOR(i, 1, n){
		res += min(a*(x[i]-x[i-1]), b);
	}
	cout << res << endl;
}

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








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

int main() {
  int n, d, x;
  cin >> n >> d >> x;
  
  int i;
  vector<int> a(n);
  for(i = 0; i < n; i++){
    cin >> a.at(i);
  }
  
  int count = 0;
  for(i = 0; i < n; i++){
    count += (d + a.at(i) - 1) / a.at(i);
  }
  
  cout << x + count << endl;
}

Measured memory_bytes: 256
n = int(input())
a_ls = [int(input()) for _ in range(n)]

sorted_a = sorted(a_ls,reverse = True)
max_a = sorted_a[0]
second_a = sorted_a[1]
max_ind = a_ls.index(max_a)
for i in range(n):
    if not i == max_ind:
        print(max_a)
    else:
        print(second_a)
    

Measured memory_bytes: 70488
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	ns := nextInts(n)
	sort.Sort(sort.IntSlice(ns))
	l, r := ns[0], ns[n-1]
	min := 1000000000
	for i := l; i <= r; i++ {
		var len int
		for _, m := range ns {
			tmp := m - i
			len += tmp * tmp
		}
		if min > len {
			min = len
		}
	}
	fmt.Println(min)
}

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}


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

using namespace std;

#define pb push_back
#define fs first
#define sc second
#define sz size
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i <= (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const ll inf = 1e9+7; 

const double PI =  3.141592653589793;

int main(){
	IO;
	ll n;
	cin>>n;
	ll yen[]={1,6,9,36,216,1296,7776,46656,81,729,6561,59049};
	ll dp[n];
	dp[0]=0;
	forni(i,n){
		dp[i]=inf;
		for(auto c : yen){
			if(i-c>=0) dp[i] = min(dp[i],dp[i-c]+1);
		}
	}
	cout<<dp[n]<<"\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
#define yes(a) printf(a ? "yes\n" : "no\n")
#define Yes(a) printf(a ? "Yes\n" : "No\n")
#define YES(a) printf(a ? "YES\n" : "NO\n") 
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n;
  cin >> n;
  
  ll sum = 0;
  vector<ll> s(n);
  for(ll i = 0; i < n; i++){
    cin >> s[i];
    sum += s[i];
  }
  sort(all(s));
  if(sum % 10 != 0){
    cout << sum << endl;
    return 0;
  }

  for(ll i = 0; i < n; i++){
    if(s[i] % 10 != 0){
      cout << sum - s[i] << endl;
      return 0;
    }
  }
  cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  [sa, sb] <- words <$> getLine
  let a :: Integer
      a = read sa
      c :: Integer
      c = read (filter (/= '.') sb)
      ans = a * c `quot` 100
  print ans


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int N;
    cin >> N;
    vector<int> A(N+1);
    for (int i = 0; i < N+1; ++i) cin >> A[i];
    vector<int> B(N);
    for (int i = 0; i < N; ++i) cin >> B[i];
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        int d = min(A[i], B[i]);
        ans += d;
        A[i] -= d;
        B[i] -= d;
        d = min(A[i+1], B[i]);
        ans += d;
        A[i+1] -= d;
        B[i] -= d;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

int main(){
	int h, w;
	while(1){
		std::cin >> h >> w;
		if(!h && !w)
			break;
		for(int j = 0; j < h; j++){
			for(int i = 0; i < w; i++){
				if(i == 0 || i == w-1 || j == 0 || j == h-1)
					std::cout << '#';
				else
					std::cout << '.';
			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

void PrimeTable(int);
void PrimeFuctrization2(int);

int PrimeNumber[1001]={};
int Exponent[1001]={};

int main(){
	int N;
	int i;
	long long ans=1;
	
	scanf("%d",&N);
	PrimeTable(N);
	for(i=2;i<=N;i++){
			PrimeFuctrization2(i);
	}
	for(i=0;i<=N;i++){
			if(Exponent[i]) ans=((ans*(Exponent[i]+1))%1000000007);
	}
	printf("%lld\n",ans);
	return 0;
}

void PrimeTable(int N){
	int i,j,k=0,flag;
	for(i=2;i<=N;i++){
		flag=0;
		for(j=2;j*j<=i;j++){
			if(!(i%j)){
				flag=1;
				break;
			}
		}
		if(!flag){
			PrimeNumber[k]=i;
			k++;
		}
	}
}

void PrimeFuctrization2(int N){
	int i,j;
	for(i=0;N>=PrimeNumber[i];){
		if(!(N%PrimeNumber[i])){
			N/=PrimeNumber[i];
			Exponent[i]++;
		}else{
			i++;
		}
	}
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int H, W;
	string a[110];
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> a[i];
	}
	int t[110] = { 0 };
	int y[110] = { 0 };
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (a[i][j] == '#') {
				t[j]++;
				y[i]++;
			}
		}
	}
	for (int i = 0; i < H; i++) {
		if (y[i] != 0) {
			for (int j = 0; j < W; j++) {
				if (t[j] != 0) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}


Measured memory_bytes: 256
def main():
    
    n,k =map(int,input().split())
    x = list(map(int, input().split()))
    a = [0]*n
    for i in range (1,n):
        a[i]=(min([abs(x[i]-x[j])+a[j] for j in range(max(0,i-k),i)]))
    print (a[-1])
if __name__ == "__main__":
    main()

Measured memory_bytes: 13928
def main():
    n = int(input())
    A = []
    for _ in range(n):
        a, b = list(map(int, input().split()))
        A.append([a, b, a + b])
    A.sort(key = lambda x: x[2], reverse = True)
    ans = 0
    for i, a in enumerate(A):
        if i % 2 == 0:
            ans += a[2]
        ans -= a[1]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 30168
#include<bits/stdc++.h>
using namespace std;
long long int n,k,minimum[100010];
vector<long long int>v;
long long int dp(long long index)
{
    //---------------------------------------------------
    /*long long int temp1,temp2=INT_MAX;
    if(index==n-1)
        return 0;
    if(minimum[index+1]==-1)
    {
        minimum[index+1]=dp(index+1);
    }
    temp1=abs(v[index]-v[index+1])+minimum[index+1];
    if(minimum[index+2]==-1 && index<n-2)
    {
        minimum[index+2]=dp(index+2);
    }
    if(index<n-2)
        temp2=abs(v[index]-v[index+2])+minimum[index+2];
    return min(temp1,temp2);*/
    //----------------------------------------------------
    long long int temp=INT_MAX,i,flag=0;
    if(minimum[index]!=-1)
        return  minimum[index];
    for(i=1;i<=k && index+i<n;i++)
    {
        flag=1;
        if(minimum[index+i]!=-1)
        {
            temp=min(temp,abs(v[index]-v[index+i])+minimum[index+i]);
            continue;
        }
        minimum[index+i]=dp(index+i);
        temp=min(temp,abs(v[index]-v[index+i])+minimum[index+i]);
    }
    if(!flag)
        temp=0;
    minimum[index]=temp;
    return minimum[index];
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    long long int i,j,temp;
    cin>>n>>k;
    for(i=0;i<n;i++)
    {
        cin>>temp;
        v.push_back(temp);
    }
    memset(minimum,-1,sizeof(minimum));
    cout<<dp(0);
}


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

int get_int() {
    int n = 0;
    int sign = 1;
    int c = getchar_unlocked();
    if(c == 45) sign = -1, c = getchar_unlocked();
    else if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) {
        n = 10 * n + (c & 0xf);
        c = getchar_unlocked();
    }
    return n * sign;
}
int get_str(char *str) {
    int c;
    while((c = getchar_unlocked()) > 32) *str++ = (char)c;
    *str = 0;
    return c;
}
void put_int(int n) {
    if(!n) {
        putchar_unlocked('0');
        return;
    }
    if(n < 0) n *= -1, putchar_unlocked('-');
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (char)(n % 10 + '0'), n /= 10;
    while(i--)putchar_unlocked(buf[i]);
}
typedef struct Node {
    int key;
    struct Node *left, *right;
} Node;
typedef struct BST {
    Node *root;
    size_t size;
} BST;
void bst_init(BST *BST) {
    BST->root = NULL;
    BST->size = 0;
}
void bst_insert(BST *BST, int key) {
    Node *new_node = malloc(sizeof(Node));
    new_node->key = key;
    new_node->left = NULL;
    new_node->right = NULL;
    Node *tmp;
    Node *root = BST->root;
    while(root != NULL) {
        tmp = root;
        if(key < root->key) root = root->left;
        else root = root->right;
    }
    if(BST->size == 0) BST->root = new_node;
    else if(key < tmp->key) tmp->left = new_node;
    else tmp->right = new_node;
    BST->size++;
}
void bst_inorder(Node *root) {
    if(root == NULL) return;
    bst_inorder(root->left);
    putchar_unlocked(' ');
    put_int(root->key);
    bst_inorder(root->right);
}
void bst_preorder(Node *root) {
    if(root == NULL) return;
    putchar_unlocked(' ');
    put_int(root->key);
    bst_preorder(root->left);
    bst_preorder(root->right);
}
int main(int argc, char **argv) {
    BST BST;
    bst_init(&BST);
    int m = get_int();
    char c[8];
    for(int i = 0; i < m; ++i) {
        get_str(c);
        if(*c == 'i') {
            int key = get_int();
            bst_insert(&BST, key);
        } else {
            bst_inorder(BST.root);
            putchar_unlocked('\n');
            bst_preorder(BST.root);
            putchar_unlocked('\n');
        }
    }
    return 0;
}



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

using namespace std;

int main(){
	int A[5];
	for (int i = 0; i < 5; i++){
		cin >> A[i];
	}
	sort(A, A + 5, [](const int &x, const int &y) { return (x - 1) % 10 > (y - 1) % 10; });

	int ans = 0;
	for (int i = 0; i < 4; i++){
		ans += A[i];
		while(ans % 10 != 0){
			ans++;
		}
	}
	ans += A[4];

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for (int i=0; i < int(n); i++)


// 素集合データ構造
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    rep(i,n) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};


// 頂点a, bをつなぐコストcostの（無向）辺
struct Edge
{
  int a, b, cost;

  // コストの大小で順序定義
  bool operator<(const Edge& o) const {
    return cost < o.cost;
  }
};

// 頂点数と辺集合の組として定義したグラフ
struct Graph
{
  int n;  // 頂点数
  vector<Edge> es;  // 辺集合

  // クラスカル法で無向最小全域木のコストの和を計算する
  // グラフが非連結のときは最小全域森のコストの和となる
  int kruskal() {
    // コストが小さい順にソート
    sort(es.begin(), es.end());

    UnionFind uf(n);
    int min_cost = 0;

    rep(ei, es.size()) {
      Edge& e = es[ei];
      if (!uf.same(e.a, e.b)) {
        // 辺を追加しても閉路ができないなら、その辺を採用する
        min_cost += e.cost;
        uf.unite(e.a, e.b);
      }
    }

    return min_cost;
  }
};

// 標準入力からグラフを読み込む
Graph input_graph() {
  Graph g;
  int m;
  cin >> g.n >> m;
  rep(i, m) {
    Edge e;
    cin >> e.a >> e.b >> e.cost;
    g.es.push_back(e);
  }
  return g;
}


int main()
{
  Graph g = input_graph();
  cout <<  g.kruskal() << endl;
  return 0;
}


Measured memory_bytes: 4600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
struct mint {
    long long x;
    mint(long long _x=0):x((_x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint modpow(long long t) const {
        if (!t) return 1;
        mint a = modpow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return modpow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
    friend std::ostream& operator<<(std::ostream& os, const mint& a){
        os << a.x;
        return os;
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N, K;
    cin >> N >> K;
    mint ans = 0;
    vec<ll> mae(N+1);
    vec<ll> usi(N+1);
    mae[0] = 0;
    rep(i,N){
        mae[i+1] = mae[i]+i+1;
    }
    usi[0] = N;
    rep(i,N){
        usi[i+1] = usi[i] + N - 1 - i;
    }
    //先頭i個と後ろのi個の差
    for(ll i = K; i <= N+1; i++){
        ll l = mae[i-1];
        ll r = usi[i-1];
        cerr << l << " " << r <<  endl;
        ans += r - l + 1;
    }
    cout << ans << endl;
}

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

int main(){
    int c[3];
    cin>>c[0]>>c[1]>>c[2];
    sort(c,c+3);
    if(c[0]+c[1]==c[2])cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,x,t,ans=0,i;
   cin>>n;
   int a[n+5];
   for(i=0;i<n;i++)
   {
       cin>>a[i];

   }
   for(i=0;i<n-1;i++)
   {
       if(a[i]>a[i+1])
       {
           ans+=a[i]-a[i+1];
           a[i+1]=a[i];
       }
   }
   cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4356
#include <bits/stdc++.h>
#if ONLINE_JUDGE
#define DEBUG false
#else
#define DEBUG true
#endif
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rep1(i, n) REP(i, 1, n)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)
#define rrep(i, n) rREP(i, 0, n)
#define forlist(i, vec) for(auto &&i : vec)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define truecheck assert
#define dump(x) cerr << #x << ": " << (x) << endl
using namespace std;
typedef long long LL;
typedef long long int64;
typedef std::vector<int> VI;
typedef std::vector<VI> VVI;
typedef std::vector<LL> VL;
typedef std::vector<VL> VVL;
typedef std::vector<std::string> VS;
typedef std::pair<int, int> PII;
typedef std::pair<LL, LL> PLL;
typedef std::queue<int> QI;
typedef std::priority_queue<int> PQI;
template<class T,class U>inline bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>inline bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T,class U>inline void vcinpb(T &v, U n){rep(i, n){typename T::value_type a;cin >> a;v.pb(a);}}

const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;
// M_PI 3.1415...

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cill(n);
    cill(m);
    cill(q);
    VVL vvl(55, VL(4));
    rep(i, q){
        cin >> vvl[i][0] >> vvl[i][1] >> vvl[i][2] >> vvl[i][3];
    }
    LL ans = 0;
    function<void(VL, LL, LL)> solve = [&](VL v, LL nowsize, LL add){
        if (nowsize == n){
            LL solveans = 0;
            rep(i, q){
                if(v[(vvl[i][1]-1)] - v[(vvl[i][0]-1)] == vvl[i][2]){
                    solveans += vvl[i][3];
                }
            }
            chmax(ans, solveans);
            return;
        }
        REP(i, add, m + 1){
            v[nowsize] = i;
            solve(v, nowsize+1, i);
        }
    };
    VL vl(11);
    rep1(i, m+1){
        vl[0]=i;
        solve(vl, 1, i);
    }
    co(ans);
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll fac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
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;cin >> n;
    vl v(n+1,1);
    rep(i,n){
        ll p=i+1;
        for(int j=2;j<=i+1;j++){
            while(p%j==0){
                p/=j;
                v[j]++;
            }
        }
    }
    ll ans=1;
    rep(i,n+1){
        ans*=v[i];
        ans%=MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
_N = int(input())
N = _N

i = 1
div = set()
ans = 0
while i*i <= N:
    if N % i == 0:
        div.add(i)
        div.add(N//i)
    i += 1

for d in div:
    m = _N//d-1
    if m > d:
        ans += m
print(ans)


Measured memory_bytes: 40812
import java.util.Scanner;

public class Main {

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

	    int a=gi();
	    int b=gi();
	    int x=gi();
	    //String s=gs();

        //System.out.println(Math.min(a, b)+Math.min(c, d));
        if (a<=x && a+b>=x) {
        	System.out.print("YES");
        }else {
        	System.out.print("NO");
        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
	
	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35564
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String moji = sc.next();
		//String moji2 = moji.replaceAll(","," ");

		System.out.println(moji.replaceAll(","," "));

		sc.close();
	}

}


Measured memory_bytes: 10192
#include <iostream>
using namespace std;
int main(int argc, char const* argv[]) {
    int n;
    cin >> n;
    if (n == 1) {
        cout << "Hello World";
    } else {
        int a, b;
        cin >> a >> b;
        cout << a + b;
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 256
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let _ = readLine()
    let ints = readInts().sorted(by: {$0 > $1})
    
    var a = 0
    var b = 0
    var isA = true
    for i in ints {
        if isA {
            a += i
        } else {
            b += i
        }
        isA.toggle()
    }
    
    print("\(a - b)")
}

main()


Measured memory_bytes: 8312
#include <algorithm>
#include<bits/stdc++.h>
#include <ios>
#include <iterator>
using namespace std;
#define ll long long
#define f(n)  for(int i=0;i<n;i++) 
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define all(v)   v.begin(),v.end()  
void speed (){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int main ()
{
  speed();
    int a,b;
    cin>>a>>b;
    if(a>=13){
        cout<<b;
    }
    else if(a<13&&a>=6){
        cout<<(b/2);
    }
    else{
        cout<<0;
    }
 return 0;
}

Measured memory_bytes: 384
{-# LANGUAGE FlexibleContexts, OverloadedStrings #-}
import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Data.List
import Text.Printf
import Debug.Trace
import Data.Array.ST
import Control.Monad.ST
import Data.Array.IArray

f :: [[Integer]] -> ST s (STArray s Integer Integer)
f qs = do
  arr <- newArray (1,100000) 0
  forM_ qs $ \(a:b:_) -> do
    c <- readArray arr a
    writeArray arr a (b+c)
  return arr

solve qs k = sub 0 1
  where
    arr = runSTArray (f qs)
    sub acc i = if acc + (arr!i) >= k then i
                else sub (acc + arr!i) (i+1)

main = do
  [n,k] <- getInts
  qs <- replicateM (fromIntegral n) getInts
  print $ solve qs k

-- util
getInts :: IO [Integer]
getInts = map (fst . fromJust . B.readInteger) . B.words <$> B.getLine

substr :: Int -> Int -> B.ByteString -> B.ByteString
substr b l s = B.take l $ B.drop b s


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

using ll = long long;
const int MAXN = 200*1000+5;
int color[MAXN], sz[MAXN], in[MAXN], out[MAXN], t = 0, n;

vector<int> g[MAXN], g2[MAXN], of_color[MAXN];

#define debug(x) cerr << #x << " : " << x << endl

void dfs(int u, int p) {
    sz[u] = 1;
    in[u] = t++;
    auto it = find(g[u].begin(), g[u].end(), p);
    if(it != g[u].end()) g[u].erase(it);
    of_color[color[u]].push_back(u);
    for(int v : g[u]) {
        dfs(v, u);
        sz[u] += sz[v];
    }
    
    out[u] = t;
}

ll choose2(int x) { return 1LL * x * (x+1)/2; }
bool in_tree(int u, int v) { return in[v] <= in[u] && out[u] <= out[v]; }

void build_g2(vector<int> arr) {
    vector<int> stk = {0};
    g2[0].clear();
    for(int x : arr) {
        while(!in_tree(x, stk.back())) {
            stk.pop_back();
        }
        g2[stk.back()].push_back(x);
        stk.push_back(x);
    }
}

ll rec(int u) {
    ll ans = 0;
    int i = 0;
    int s = g[u].empty() ? 0 : sz[g[u][0]];
    for(int v : g2[u]) {
        while(i < (int) g[u].size() && !in_tree(v, g[u][i])) {
            ans += choose2(s);
            if(++i < (int) g[u].size()) {
                s = sz[g[u][i]];
            }
        }
        s -= sz[v];
        ans += rec(v);
    }
    while(i < (int) g[u].size()) {
        ans += choose2(s);
        if(++i < (int) g[u].size()) {
            s = sz[g[u][i]];
        }
    }
    //$ debug(ans);
    return ans;
}

ll solve(int c) {
    build_g2(of_color[c]);
    return choose2(n) - rec(0);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> color[i];
    }
    for(int i = 0; i < n-1; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    
    g[0].push_back(1);
    dfs(0, -1);
    for(int i = 1; i <= n; i++) {
        cout << solve(i) << '\n';
    }
}


Measured memory_bytes: 46708
a = [int(input())  for i in range(5)]
def amari(num):
    return num % 10
b = list(map(amari, a))
b_r = [10 if i == 0 else i for i in b]
d = min(b_r)
c = sum(a) - sum(b_r) + 40 + d
print(c)

Measured memory_bytes: 2940
#include <bits/stdc++.h>  
#include <memory>
using namespace std;  
#define INF 0x3f3f3f3f  
typedef long long ll;  
const int N =  100005;  
const int M = 1001;
#define FI first
#define SE second
typedef pair<int, int>pii;
int mod = 1000000007;
 
int num[N];
int cofp(int a)
{
   int c = 0;
   while (!(a&1))
   {
      c++;
      a >>= 1;
   }
   return c;
}
bool cmp(int a, int b)
{
   return cofp(a) < cofp(b);
}
int main()  
{  

   // ios::sync_with_stdio(0);
   int n;
   while (~scanf("%d", &n))
   {
      for (int i = 0; i < n; i++)
         scanf("%d", num + i);
      sort(num, num + n, cmp);

      int end = n - 1;
      bool flag = true;
      for (int i = 0; i < n - 1; i++)
      {
         ll tmp = (ll)num[i]*num[i+1];
         if (tmp % 4 != 0 && i < end)
         {
            swap(num[i+1], num[end]);
            end -= 2;
         }

         tmp = (ll)num[i]*num[i+1];
         if (tmp % 4 != 0)
         {
            flag = false;
         }

      }
      printf("%s\n", flag?"Yes":"No"); 
   }
   return 0;
}  

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;

vi g[10];

vi cnt(10 , 0);

int anss = 0;
int n , m;

void dfs(int cur , vi used){
	used[cur] = 1;
	++cnt[cur];
	int t = 0;
	rep(i , n){
		t += used[i];
	}
	if(t == n){
		++anss;
		return;
	}
	rep(i , sz(g[cur])){
		int v = g[cur][i];
		if(!used[v]){
			dfs(v , used);
		}
	}
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 
	cin >> n >> m;
	rep(i , m){
		int u , v;
		cin >> u >> v;
		--u;
		--v;
		g[u].pb(v);
		g[v].pb(u);
	}
	rep(i , sz(g[0])){
		vi used(10 , 0);
		used[0] = 1;
		++cnt[0];
		dfs(0 , used);
		break;
	}
	int ans = INF;
	rep(i , n){
		ans = min(ans , cnt[i]);
	}
	die(anss);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}
// End of template code!
vector< pii > dirs = {{0, 1}, {1, 0}, {-1, 0}, {0,-1}};

int main() 
{
    buff();
    int n;
    cin >> n;
    auto valid = [&] (int x, int y) {
        return (x >= 0 && x < n && y >= 0 && y < n);
    };

    vector< vi > dist(n, vi(n, n));
    vector< vi > on(n, vi(n, 1));
    vi ord(n * n); 
    vector< pii > pos(n * n);
    int x;
    int sq = n * n; 
    for(int i = 0; i < sq; ++i) {
        cin >> x;
        --x;
        ord[i] = x;
        pos[i] = {(x / n), (x % n)}; 
    }

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            int dist_vert = min(i, n - 1 - i);
            int dist_horz = min(j, n - 1 - j);
            dist[i][j] = min(dist_vert, dist_horz);
        }
    }
    // agora inicializei as distancias de todo mundo
    // vamos comecar a remover as pessoas (;
    int ans = 0; 
    function<void(pii&)> prop = [&] (pii& cur) {
        pii nxt = cur; 
        for(const auto& d : dirs) {
            nxt.first += d.first;
            nxt.second += d.second;
            if(valid(nxt.first, nxt.second)) {
                if(dist[cur.first][cur.second] + on[cur.first][cur.second] < dist[nxt.first][nxt.second]) {
                    dist[nxt.first][nxt.second] = dist[cur.first][cur.second] + on[cur.first][cur.second];
                    prop(nxt);
                }
            }
            nxt.first -= d.first;
            nxt.second -= d.second;
        }
    };
    
    for(auto& pr : pos) {
        ans += dist[pr.first][pr.second];
        // agora temos que fazer os updates de forma esperta
        // vai ser meio que um dijkstra pelas posicoes
        on[pr.first][pr.second] = 0;
        prop(pr);
    }

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



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

int main() {
  int a, b;
  cin >> a >> b;
  int ans = -1;
  for (int i = 1; i <= 10000; i++) {
    if (a == (int)(i * 0.08) && b == (int)(i * 0.10)) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
using namespace std;
static const int MAX_N = 100;

void show(int a[], int n) {
    for (int i = 0; i < n; i++) {
        if (i == n - 1) {
            cout << a[i];
        }
        else {
            cout << a[i] << " ";
        }
    }
    cout << endl;
}

int main() {
    int a[MAX_N] = {0};
    int N = 0;
    cin >> N;
    for (int i = 0; i < N; i++)  cin >> a[i];
    show(a, N);
    for (int i = 1; i < N; i++) {
        int v = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > v) {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        show(a, N);
    }

    return 0;
}


Measured memory_bytes: 3080
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 = sc.nextInt();
        if (a >= 500 || n % 500 <= a) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}

Measured memory_bytes: 20948
a,b,c,d = input()
op = ["+","-"]

for i in range(2):
  for j in range(2):
    for k in range(2):
      f= a + op[i] + b + op[j] +c + op[k] +d
      if eval(f) == 7:
        print(f + "=7")
        exit()

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;
// auto mod int
const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {if ((x += a.x) >= mod) x -= mod; return *this;}
  mint& operator-=(const mint a) {if ((x += mod-a.x) >= mod) x -= mod; return *this;}
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  ll x;
  cin >> x;
  vector<int> v;
  while(x>0) v.push_back(x&1), x >>= 1;
  reverse(v.begin(),v.end());
  int n = v.size();

  mint dp[3];
  dp[0] = 1;
  rep(i,n){
    mint temp[3];
    if(v[i]){
      temp[0] = dp[0];
      temp[1] = dp[0]+dp[1];
      temp[2] = mint(2)*dp[1]+mint(3)*dp[2];
    }else{
      temp[0] = dp[0]+dp[1];
      temp[1] = dp[1];
      temp[2] = dp[1]+mint(3)*dp[2];
    }
    swap(dp,temp);
  }
  cout << dp[0]+dp[1]+dp[2] << endl;;
}

Measured memory_bytes: 3616
int main(){
    int a,b,c,i;
    int n = 0;
    scanf("%d %d %d",&a,&b,&c);
    for(i = a ; a <= i & i <= b ; ++i)
    {
        if (c % i == 0)
        {
            ++n;
        }
    }
    printf("%d\n",n);
    return 0;
}


Measured memory_bytes: 2112
score = list(map(int,input().split()))
answer = 0
if score[3] - score[0] <= 0:
    answer += score[3]
else:
    answer += score[0]
    if score[3] - score[0] - score[1] > 0:
        answer -= score[3] - score[0] - score[1]
print(answer)

Measured memory_bytes: 61828
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin >> a >> b;
  if(a<=b) {
    for(int i=0; i<b; i++) {
      cout << a;
    }
    cout << endl;
  }
  else {
    for(int i=0; i<a; i++) {
      cout << b;
    }
    cout << endl;
  }
}

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

using namespace std;
char s[100];
int main()
{
    while (~scanf("%s",s)){
        for (int i=0;i<strlen(s);++i){
            if (i==5||i==13)
                printf(" ");
            else
                printf("%c",s[i]);
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 256