akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int x, t;
  cin >> x >> t;
  cout << max(x - t, 0) << endl;
  return 0;
}

Measured memory_bytes: 256
N,*a = open(0).read().split()

N=int(N)

list1=list(map(int,a))

#print(N)

#print(list1)

a=[]

for i in range(-100,101):
    int1=0
    for n in range(N):
        x = (list1[n]-i)
        y = x**2
        int1+=y
        if n==N-1:
            a.append(int1)
    
#print(a)

#print(max(a))

print(min(a))

Measured memory_bytes: 9200
from itertools import accumulate

n = int(input())
a = list(map(int, input().split()))

cumsum = [0] + list(accumulate(a))
sum_a = cumsum[-1]
mod = 10**9 + 7
res = 0
for i in range(n):
    res += a[i] * (sum_a - cumsum[i+1])
    res %= mod
print(res)


Measured memory_bytes: 31124
using System;
using System.Linq;

public class Hello{
    public static void Main(){

        int x = int.Parse(Console.ReadLine());
        char[] str = Console.ReadLine().ToArray();
        
        int value = 0;
        int max = 0;
        for(int i = 0; i < x; i++){
            if(str[i] == 'I'){
                value++;
            }else{
                value--;
            }
            max = Math.Max(value,max);
        }
        System.Console.WriteLine(max);
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
void YN(bool f){ cout << (f ? "YES" : "NO");}
void yn(bool f){ cout << (f ? "yes" : "no");}
void YeNo(bool f) {cout << (f ? "Yes" : "No");}
signed main(){
    int n; cin >> n;
    vector<int>d(n);
    for(auto & e : d) cin >> e;
    sort(all(d));
    int m = *max_element(all(d));
    int ans = 0;
    for(int i = 1; i <= m; ++i){
        int idx = (int)(lower_bound(all(d),i) - d.begin());
        if((idx) * 2 == n) ++ans;
    }
    cout << ans << endl;
}


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

 int main(){
     int N,M;cin>>N>>M;
     
     for(int i=0;i<M;i++){
         int a;cin>>a;
         N-=a;
     }
     if(N>=0)cout<<N<<endl;
     else cout<<-1<<endl;
 }

 
    

Measured memory_bytes: 3632
N = int(input())
D = list(map(int,input().split()))
CD = {}
for i in range(N):
    d = D[i]
    if d not in CD:
        CD[d] = 0
    CD[d] += 1
M = int(input())
T = list(map(int,input().split()))
CT = {}
for j in range(M):
    t = T[j]
    if t not in CT:
        CT[t] = 0
    CT[t] += 1
flag = 0
for t in CT:
    if t not in CD:
        flag = 1
        break
    else:
        if CT[t]>CD[t]:
            flag = 1
            break
if flag==0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 148724
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
constexpr int INF = 0x3f3f3f3f;

int a[44], b[44], c[44];
int dp[44][444][444];
int main() {
  int n, ma, mb;
  cin >> n >> ma >> mb;
  rep(i, 0, n) cin >> a[i] >> b[i] >> c[i];
  rep(i, 0, 44) rep(j, 0, 444) rep(k, 0, 444) dp[i][j][k] = INF;

  dp[0][0][0] = 0;
  rep(i, 0, n) {
    rep(j, 0, 401) {
      rep(k, 0, 401) {
        dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
        dp[i + 1][j + a[i]][k + b[i]] =
          min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
      }
    }
  }

  int i = 1;
  int ans = INF;
  while (ma * i < 401 && mb * i < 401) {
    ans = min(ans, dp[n][ma * i][mb * i]);
    ++i;
  }
  if (ans == INF)
    cout << -1;
  else
    cout << ans;
  cout << endl;
  return 0;
}

Measured memory_bytes: 37516
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int N;
LL K, a[200005];
vector<pair<LL, int> > V;
int id[200005];

int tree[200005];

//return cf[idx]
int read(int idx)
{
	int sum = 0;

	while (idx > 0)
	{
		sum += tree[idx];
		idx -= (idx & -idx);
	}

	return sum;
}

//add val to f[idx].
//MaxVal = Just max value of index
void update(int idx, int val)
{
	while (idx <= 200001)
	{
		tree[idx] += val;
		idx += (idx & -idx);
	}
}


int main()
{
	scanf("%d %lld", &N, &K);
	V.push_back({ 0, 0 });
	for (int i = 1; i <= N; i++) {
		scanf("%lld", &a[i]);
		a[i] -= K;
		a[i] += a[i - 1];
		V.push_back({ a[i], i });
	}
	sort(ALL(V));
	for (int i = 0; i <= N; i++) {
		id[V[i].second] = i;
	}

	LL ans = 0;
	for (int i = 0; i <= N; i++) {
		if (i) {
			ans += read(id[i] + 1);
		}
		update(id[i] + 1, 1);
	}

	printf("%lld\n", ans);






	return 0;
}


Measured memory_bytes: 7536
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m = LI()
    if n == m:
        print("Yes")
    else:
        print("No")
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38256
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

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

    int n;
    while (cin >> n, n)
    {
        int m;
        cin >> m;
        vector<vector<P>> v(8, vector<P>(m));
        for (int i = 0; i < m; i++)
        {
            int x, y;
            cin >> x >> y;
            v[0][i] = P(x, y);
        }
        for (int i = 0; i < m; i++)
        {
            v[4][i] = v[0][m - 1 - i];
        }
        for (int i = 1; i < m; i++)
        {
            v[0][i].first -= v[0][0].first;
            v[0][i].second -= v[0][0].second;
        }
        v[0][0] = P(0, 0);
        for (int i = 1; i < 4; i++)
        {
            for (int j = 1; j < m; j++)
            {
                v[i][j].first = -v[i - 1][j].second;
                v[i][j].second = v[i - 1][j].first;
            }
        }
        for (int i = 1; i < m; i++)
        {
            v[4][i].first -= v[4][0].first;
            v[4][i].second -= v[4][0].second;
        }
        v[4][0] = P(0, 0);
        for (int i = 5; i < 8; i++)
        {
            for (int j = 1; j < m; j++)
            {
                v[i][j].first = -v[i - 1][j].second;
                v[i][j].second = v[i - 1][j].first;
            }
        }
        for (int i = 1; i <= n; i++)
        {
            int m2;
            cin >> m2;
            vector<P> w(m2);
            for (int j = 0; j < m2; j++)
            {
                int x, y;
                cin >> x >> y;
                w[j] = P(x, y);
                if (j != 0)
                {
                    w[j].first -= w[0].first;
                    w[j].second -= w[0].second;
                }
            }
            w[0] = P(0, 0);
            bool f = false;
            for (int j = 0; j < 8; j++)
            {
                if (v[j] == w)
                    f = true;
            }
            if (f)
                cout << i << endl;
        }
        for (int i = 0; i < 5; i++)
            cout << "+";
        cout << endl;
    }
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
  int n;
  string s;
  while(cin>>s){
    n=s.size();
    int cnt=0;
    bool l=0;
    for(int i=1; i<n; ++i){
      if(s[i]<'9'){
        l=1;
      }
      cnt+=9;
    }
    if(l){
      cnt+=(s[0]-'0')-1;
    }
    else{
      cnt+=s[0]-'0';
    }
    cout<<cnt<<endl;
  }
  return 0;
}




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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(string S){
    int m = S.length() / 2;
    int ans = m;
    char c = S[m];
    if(S.length() % 2 == 0) {
        if(c != S[m-1]) {
            cout << ans << endl;
            return;
        }

        ans++;
        int idx = 1;
        while(ans != S.length()) {
            if(S[m - idx - 1] != c || S[m + idx] != c) break;
            ans++;
            idx++;
        }
    } else {
        ans++;
        int idx = 1;
        while(ans != S.length()) {
            if(S[m - idx] != c || S[m + idx] != c) break;
            ans++;
            idx++;
        }
    }

    cout << ans << endl;
}

int main(){
    string S;
    cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <map>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

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

llint n,k,s;
void solve(){
  cin >> n >> k >> s;
  vector<llint>v;
  for(int i=0;i<k;i++){
    v.push_back(s);
  }
  for(int i=k;i<n;i++){
    if(s==1000000000)v.push_back(1);
    else v.push_back(s+1);
  }
  for(int i=0;i<n;i++)cout << v[i] << " ";
  cout << endl;

}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    map<char, bool> boll = {{'A', 1}, {'B', 0}, {'C', 0}};
    char c, d, e;
    char ans = 'A';
    while (cin >> c >> d >> e)
    {
        if (boll[c] == 1)
        {
            ans = e;
        }
        else if (boll[e] == 1)
        {
            ans = c;
        }
        swap(boll[c], boll[e]);
    }

    OP(ans);
    return 0;
}


Measured memory_bytes: 3032
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,h;
	cin>>n>>h;
	vector<int>a(n);
	vector<int>b(n);
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	int sum=0;int i=n-1;
	while(i>=0)
	{
		if(b[i]>a[n-1])
		{
			h-=b[i];
			sum++;
		}
		if(h<=0)
		{
			cout<<sum;
			return 0;
		}
		
		i--;
	}
	cout<<sum+(h+a[n-1]-1)/a[n-1];
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
for i in range(0, n-1):
    print(a[i], end=" ")
print(a[n-1])
for i in range(1, n):
    v = a[i]
    j = i-1
    while j>=0 and a[j]>v:
        a[j+1] = a[j]
        j-=1
    a[j+1] = v
    for i in range(0, n-1):
        print(a[i], end=" ")
    print(a[n-1])


Measured memory_bytes: 5976
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(){
    cout << "Yes" << endl;
}

void no (){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}



int main() {
    int n, m; cin >> m >> n;
    vector<int> ar(n);
    rep(i,n) cin >> ar[i];
    sort(ar.begin(),ar.end());
    vector<int> sa(n-1);
    rep(i,n-1) sa[i] = ar[i+1] - ar[i];
    sort(sa.rbegin(),sa.rend());
    if (n <= m) cout << 0 << endl;
    else {
        int ans = ar[n-1] - ar[0];
        rep(i,m-1) ans -= sa[i];
        cout << ans << endl; 
    }
}

Measured memory_bytes: 4056
package main

import "fmt"

func cal(p int) int {
	g := p%10
	p = p/10
	g += p%10
	p = p/10
	g += p%10
	p = p/10
	g += p%10
	p = p/10
	g += p%10
	return g
}

func main() {
	var n,a,b,count int
	fmt.Scan(&n,&a,&b)
	for i := 1 ; i <= n ; i++ {
		x := cal(i)
		//fmt.Println(i,x)
		if a <= x && x <= b {
			count += i
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define endl '\n'
int main()
{
	io
	ll n, k;
	cin>>n>>k;
	if(k == 1 || n == 0)
	cout<<0<<endl;
	else
	{
		ll d = n/k;
		n -= (k*d);
		cout<<min(n, abs(n-k));
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static int A[], B[];
    static int n, q;

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        n = s.nextInt();
        A = new int [n];
        for (int i = 0; i < n; i++) {
            A[i] = s.nextInt();
        }
        q = s.nextInt();
        for (int i = 0; i < q; i++) {
            int p = s.nextInt();
            if (solve(p, 0) ) {
                System.out.println("yes");
            } else {
                System.out.println("no");
            }
        }

    }

    static boolean solve(int rest, int i) {
        if (rest == 0) {
            return true;
        }
        if (i >= n) {
            return false;
        } else {
            return solve(rest, i + 1) || solve(rest - A[i], i + 1);
        }
    }
}



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

class UnionFind{
    int N;
    vector<int> par,rank,_size;
    public:
    UnionFind(int n):N(n){
        par.resize(n);
        for(int i=0;i<n;i++) par[i]=i;
        rank.assign(n,0);
        _size.assign(n,1);
    }

    int find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }

    void unite(int x,int y){
        x=find(x),y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){
            par[x]=y;
            _size[y]+=_size[x];
        }
        else{
            if(rank[x]==rank[y]) rank[x]++;
            par[y]=x;
            _size[x]+=_size[y];
        }
    }

    bool same(int x,int y){return find(x)==find(y);}
    int size(int x){return _size[x];}
    
    void debug(){
        vector<queue<int>> s(N);
        for(int i=0;i<N;i++){
            int index=find(i);
            s[index].push(i);       
        }
        for(int i=0;i<N;i++){
            if(s[i].size()==0) continue;
            while(!s[i].empty()){
                cout<<s[i].front();
                s[i].pop();
                if(s[i].empty()) cout<<endl;
                else cout<<" ";
            }
        }
    }

};

int main(){
    int n,q;
    cin>>n>>q;
    UnionFind u(n);
    for(int i=0;i<q;i++){
        int c,x,y;
        cin>>c>>x>>y;
        if(c==0) u.unite(x,y);
        else cout<<u.same(x,y)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3244
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input! {
        n: usize,
        s: String,
    }
    let mut ret = 0;
    for i in 0..=n - 3 {
        if s[i..i+3] == String::from("ABC") {
            ret += 1;
        }
    }
    println!("{}", ret);
}


Measured memory_bytes: 2112
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;
using ll = long long;

int n;

void createString(int pos, int num, int maxv, string s)
{
    if (pos == n)
    {
        cout << s << endl;
    }
    else
    {
        for (int i = 0; i < n and i <= maxv + 1; i++)
        {
            char t = i + 'a';
            string next = s + t;
            createString(pos + 1, i, max(i, maxv), next);
        }
    }
}

int main(void)
{
    cin >> n;
    int cnt = n;
    createString(1, 0, 0, "a");
}

Measured memory_bytes: 1536
S = input()
T = input()

ms = {}
mt = {}
for i in range(len(S)):
    if S[i] in ms.keys() and ms[S[i]] != T[i]:
        print('No')
        exit()

    if T[i] in mt.keys() and mt[T[i]] != S[i]:
        print('No')
        exit()

    ms[S[i]] = T[i]
    mt[T[i]] = S[i]

print('Yes')

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num,init) vector<ll> name((num),(init));
#define op(i) cout<<(i)<<endl;

int main(){
    ll n;
    ll ans=0;
    vec(a,5,0);
    cin>>n;
    vector<string> s(n);
    rep(i,n){
        cin>>s[i];
        switch(s[i][0]){
            case 'M':
            a[0]++;
            break;
            case 'A':
            a[1]++;
            break;
            case 'R':
            a[2]++;
            break;
            case 'C':
            a[3]++;
            break;
            case 'H':
            a[4]++;
            break;
        }
    }
    rep(i,3){
        repf(j,i+1,4){
            repf(k,j+1,5){
                ans+=(a[i]*a[j]*a[k]);
            }
        }
    }
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 6272
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;

int main(){
	double t, x;
	cin >> t >> x;
	cout << setprecision(10) << t/x << endl;

	return 0;
}


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

bool checkBingo(int ans[]){
    f(i,3){
        if(ans[3*i]+ans[3*i+1]+ans[3*i+2]==3)
            return true;
        if(ans[i]+ans[i+3]+ans[i+6]==3)
            return true;
    }
    if(ans[0]+ans[4]+ans[8]==3)
        return true;
    if(ans[2]+ans[4]+ans[6]==3)
        return true;
    return false;
}

int main(){
    int a[9];
    f(i,9)
        cin>>a[i];
    int n;
    cin>>n;
    int q[n];
    f(i,n)
        cin>>q[i];
    int ans[9];
    f(i,9)
        ans[i]=0;
    f(i,n){
        f(j,9){
            if(q[i]==a[j]){
                ans[j]=1;
            }
        }
        if(checkBingo(ans)){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

#define int long long

int N;
int odd[100010], even[100010];

signed main()
{
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        if(i & 1) even[a]++;
        else odd[a]++;
    }

    int odd_index = -1, odd_max = -1;
    for(int i = 0; i < 100010; i++)
    {
        if(odd_max < odd[i])
        {
            odd_max = odd[i];
            odd_index = i;
        }
    }

    int even_index = -1, even_max = -1;
    for(int i = 0; i < 100010; i++)
    {
        if(even_max < even[i])
        {
            even_max = even[i];
            even_index = i;
        }
    }
    
    if(even_index != odd_index)
    {
        cout << N - even_max - odd_max << endl;
        return 0;
    }

    int odd_max2 = -1;
    for(int i = 0; i < 100010; i++)
    {
        if(odd_max2 < odd[i] && i != odd_index)
        {
            odd_max2 = odd[i];
        }
    }

    int even_max2 = -1;
    for(int i = 0; i < 100010; i++)
    {
        if(even_max2 < even[i] && i != even_index)
        {
            even_max2 = even[i];
        }
    }

    cout << min(N - even_max - odd_max2, N - even_max2 - odd_max) << endl;

    return 0;
}


Measured memory_bytes: 5160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;




int main(int argc, const char * argv[]) {
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

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

    int a,b; cin >> a >> b;
    if(a+b>9)cout << "error" << endl;
    else cout << a+b << endl;
    
}



Measured memory_bytes: 256
S = input()
T = input()
ans = len(T)
if len(T)==len(S):
    loop = 1
else:
    loop = len(S)-len(T)
for i in range(loop):
    diff = 0
    for s, t in zip(S[i:i+len(T)], T):
        if s!=t:
            diff += 1
    ans = min(ans, diff)
print(ans)


Measured memory_bytes: 9120
N = int(input())
L = list(map(int,input().split()))
L.sort()
M = L[-1]
d = [0] * (2*M+1)
cnt = 0
num = 0
for i in range(N-1):
    cnt += 1
    for j in range(L[i], L[i+1]):
        d[j] = cnt
cnt += 1
for i in range(L[N-1], 2*M+1):
    d[i] = cnt
ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        num = L[i] + L[j]
        if num <= M:
            ans += d[num-1] - j - 1
        else:
            ans += N-1-j
print(ans)

Measured memory_bytes: 41580
#include <bits/stdc++.h>
#define ll long long
#define fast ios::sync_with_stdio(0);cin.tie(0);
using namespace std;
 
 
int main() {
    fast
    string s;
    cin>>s;
    if(s[1]=='R')cout<<"ABC";
    else cout<<"ARC";
    return 0;
}

Measured memory_bytes: 3652
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int N, M, i;
    bool ok=true;  

    cin >> N >> M;

    vector<int> s(M);
    vector<int> c(M);
    vector<int> ans(N, 10);

    rep(i, M) {
        cin >> s[i] >> c[i];
        if(s[i]==1 && c[i]==0 && N>1) {
            ok = false;
        } else {
            if(ans[s[i]-1]>=0 && ans[s[i]-1]<10) {
                if(ans[s[i]-1]!=c[i]) ok = false;
            } else {
                ans[s[i]-1] = c[i];
            }
        }
    }

    if(ok) {
        if(N==1){
            if(ans[0]==10) cout << 0 << endl;
            else cout << ans[0] << endl;
        } else if(N==2){
            if(ans[0]==10) {
                ans[0] = 1;
            }
            if(ans[1]==10) ans[1] = 0;
            cout << ans[0]*10+ans[1] << endl;
        } else if(N==3) {
            if(ans[0]==10) {
                ans[0] = 1;
            }
            for(i=1; i<N; i++) {
                if(ans[i]==10) ans[i] = 0;
            }
            cout << ans[0]*100+ans[1]*10+ans[2] << endl;
        }
    } else {
        cout << -1 << endl;
    }

    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K,X;
  cin >> K >> X;
  int min,max;
  min = X-K+1; 
  if (min < -1000000) min = -1000000;
  max = X+K-1;
  if (max > 1000000) max = 1000000;
  
  for (int i=min; i<max; i++){
    cout << i << " ";
  }
  cout << max << endl;
}

Measured memory_bytes: 256
class UF():
  def __init__(self, N):
    self._parent=[n for n in range(0, N)]
    self._size=[1] * N

  def find_root(self, x):
    if self._parent[x]==x:return x
    self._parent[x]=self.find_root(self._parent[x])
    return self._parent[x]

  def unite(self, x, y):
    gx=self.find_root(x)
    gy=self.find_root(y)
    if gx==gy:return

    if self._size[gx]<self._size[gy]:
      self._parent[gx]=gy
      self._size[gy]+=self._size[gx]
    else:
      self._parent[gy]=gx
      self._size[gx]+=self._size[gy]

  def size(self, x):
    return self._size[self.find_root(x)]

  def samegroup(self, x, y):
    return self.find_root(x)==self.find_root(y)

  def groupnum(self):
    N=len(self._parent)
    ans=0
    for i in range(N):
      if self.find_root(i)==i:
        ans+=1
    return ans

h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
UF=UF(h*w)
for i in range(h):
  for j in range(w):
    if i!=0:
      if s[i][j]!=s[i-1][j]:UF.unite(i*w+j,(i-1)*w+j)
    if i!=h-1:
      if s[i][j]!=s[i+1][j]:UF.unite(i*w+j,(i+1)*w+j)
    if j!=0:
      if s[i][j]!=s[i][j-1]:UF.unite(i*w+j,i*w+(j-1))
    if j!=w-1:
      if s[i][j]!=s[i][j+1]:UF.unite(i*w+j,i*w+(j+1))
listB=[0 for i in range(h*w)]
listW=[0 for i in range(h*w)]
for i in range(h):
  for j in range(w):
    if s[i][j]=='#':
      listB[UF.find_root(i*w+j)]+=1
    else:
      listW[UF.find_root(i*w+j)]+=1
ct=0
for i in range(h*w):
  ct+=listB[i]*listW[i]
print(ct)

Measured memory_bytes: 14664
from sys import stdin, stderr, setrecursionlimit, exit
setrecursionlimit(2147483647)
def debug(*args, **kwargs):
    print(*args, file=stderr, **kwargs)

ans = 0
s = input()

for i in range(1, len(s)):
    if s[i-1] != s[i]:
        ans += 1

print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int main(){
  int n;
  cin >> n;
  vector <int> p(n);
  for (int i = 0; i < n; i++){
    cin >> p.at(i);
  }
  int ans = p.at(0);
  for (int i = 1; i < n; i++){
    ans = gcd(ans, p.at(i));
  }
  cout << ans << endl;
}
  

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

int main(){
  string s;
  cin >> s;
  int ca=0,cb=0;
  for(int i=0;i<s.size();i++){
    if(i%2==1&&s.at(i)=='0')ca++;
    if(i%2==0&&s.at(i)=='1')ca++;
  }
  for(int i=0;i<s.size();i++){
    if(i%2==1&&s.at(i)=='1')cb++;
    if(i%2==0&&s.at(i)=='0')cb++;
  }
  cout << min(ca,cb) << endl;
}  


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#define fo(i,a,b) for (i=a; i<=b; i++)
using namespace std;

int i, j, k, a[3], ans;

int main()
{
	scanf("%d%d%d",&a[0],&a[1],&a[2]), ans=abs(a[0]-a[1])+abs(a[1]-a[2]);
	fo(i,0,2) fo(j,0,2) if (i!=j) 
	{
		if (i!=1 && j!=1) k=1; else
		if (i!=2 && j!=2) k=2; else k=0;
		ans=min(ans,abs(a[i]-a[k])+abs(a[j]-a[i]));
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
#n = int(input()) #入力
#a, b = (int(x) for x in input().split())
#a, b = map(int, input().split())

#a = [int(x) for x in input().split()]
#a = list(map(int, input().split()))
#a = [list(map(int,input().split(" "))) for i in range(N)]   #2次元


#a.sort() # C++ の sort(a.begin(), a.end());
#a.append(3) # C++ の a.push_back(3);


#exit(0) # return 0 的な。終了できる。
## 整数の切り捨て除算は // (ダブルスラッシュ)

import math
import copy
import string
#math.gcd(a, b) で、gcd 計算できる。
#math.pi は円周率。

INF = 10**18 #べき乗 C++ の pow(10, 18) or 1e18;
pi = math.pi

MOD = 1000000007
#MOD = 1000000009
#MOD = 998244353




#繰り返し2乗法
#N^aの、Mで割った余りを求める。
def my_pow(N, a, M):
    if(a == 0):
        return 1
    else:
        if(a % 2 == 0):
            tempo = my_pow(N, a/2, M)
            return (tempo * tempo) % M
        else:
            tempo = my_pow(N, a - 1, M)
            return (tempo * N) % M




#N_C_a を M で割った余り
def my_combination(N, a, M):
    res = 1

    for i in range(0, a):
        res *= N - i
        res %= M

    for i in range(0, a):
        res *= my_pow(i + 1, M - 2, M)
        res %= M

    return res




#N_C_i を M で割った余りを、v[i] に代入する。
def my_combination_table(N, M, v):
    if(len(v) < N + 1):
        l = N + 1 - len(v)
        tempo = [1] * l
        v.extend(tempo)

    for i in range(1, N + 1):
        v[i] = v[i - 1] * (N - (i - 1))
        v[i] %= M

        v[i] *= my_pow(i, M - 2, M)
        v[i] %= M

    return




#math.factorial で階乗は計算できる。
#math.gcd で gcd は計算できる。


X = int(input())
if(X >= 30): print("Yes")
else: print("No")







Measured memory_bytes: 10140
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];

void yes(){
   cout<<"Bad"<<endl;
   exit (0);
}
void no(){
   cout<<"Good"<<endl;
   exit (0);   
}

int32_t main(){_

   string s;
   cin>>s;

   n = sz(s);

   for (int i = 0; i+1 < n; ++i)
   {
      if(s[i] == s[i+1]){
         yes();
      }
   }
   
   no();

   return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long MOD = 998244353;
        int n = sc.nextInt();
        int node[] = new int[n];
        for(int i=0;i<n;i++)node[i]=0;
        int d = sc.nextInt();
        if(d!=0){
            System.out.println(0);
            return;
        }
        node[0]++;
        for(int i=1;i<n;i++){
            d = sc.nextInt();
            node[d]++;
        }


        if(node[0]!=1){
            System.out.println(0);
            return;
        }
        long ans = 1;
        for(int i=1;i<n;i++){
            for(int j=0;j<node[i];j++){
                ans *= node[i-1];
                ans %= MOD;
            }
        }
        System.out.println(ans);



    }
}


Measured memory_bytes: 50460
#include<bits/stdc++.h>
using namespace std;
int n,k,ans,a,ji;
map<int,int>mp;
vector<int>v;
int main()
{
	cin>>n>>k;
	while(n--)
	{
		cin>>a;
		mp[a]++;
	}
	ji=mp.size()-k;
	for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++)v.push_back(it->second);
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++)
	{
		if(ji<=0)break;
		ans+=v[i];
		ji--;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 10748
#include<bits/stdc++.h>                   // below comment for pbds
#include<ext/pb_ds/assoc_container.hpp>   // to use it make ordered_set
#include<ext/pb_ds/tree_policy.hpp>       // all set fnct + = 1. order_of_key(x); // number of 
#define ll long long                      //element strictly smaller than it;
#define ld long double                    // 2. find_by_order(x),pointer el at x pos after sort  use as s.f();
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;                     
using namespace __gnu_pbds;
// assert(a[i]<n ) // if we want to check for special cond , used for debug
// make less_equal in order to make a multiset pbds
const ll Mod = (ll)11;
ll CaseN=1;



ll tst(string s,ll n)
{
ll ans =0;	

	
return ans;
}



void solve()
{
	ll n;
	cin>>n;
	
	for(ll i=1;i<=n;i++)
	{
		ll ans=0;
		// x=j , y=k, n find z; is inte opos
		for(ll j=1;j<=100;j++)
		{
		for(ll k=1;k<=100;k++)
		{
			ll eq = i - ((j*j)+(k*k)+(j*k)) ;
			ll d= (j+k)*(j+k);
			 d += (4*eq) ;
			 //if(i==6)
			 //cout<<":::"<<eq<<" "<<d<<endl;
			 if(d<0)
			 { 
			 } 
			 else{
			// check sqrt root;
			ll s1 = sqrt(d);
			if(s1*s1==d)
			{
			// perfect sq;
			ll num = -(j+k)+s1 ;	
				if(num%2==0)
				{
				ll xx = num/2;
				if(xx>0){ans++;}
					
				}
			}
			}
		}	
		}
		
		cout<<ans<<endl;
	}
	
	
	
	
	
	
	//cerr<<"Case #"<<CaseN<<": ";
    CaseN++;	

return ;
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t=1;
	//cin>>t;
	while(t--)
	{
	solve();	
	}
}
/*
 if(ans)
  {
  cout<<"YES"<<endl; 
  }
  else
   {
  cout<<"NO"<<endl;
  }
 
 
*/


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

int last(int &a, int &b, int &c, int &d, int &e){
  for (int i=1; i<=9; i++){
    if (a%10==i){
      return a%10;
    }
    if (b%10==i){
      return b%10;
    }
    if (c%10==i){
      return c%10;
    }
    if (d%10==i){
      return d%10;
    }
    if (e%10==i){
      return e%10;
    }
  }
  return 10;
}

int up(int x){
  for (int i=0; i<=130; i++){
    if (i*10>=x){
      return(i*10);
    }
  }
}

int main(){
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  int total=up(a)+up(b)+up(c)+up(d)+up(e)-(10-last(a,b,c,d,e));
  cout<<total<<endl;
}

Measured memory_bytes: 256
N,A,B,C=map(int,input().split())
l=[int(input()) for _ in range(N)]
INF=10**9
def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF 
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)
 
print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int k,x;
  cin>>k>>x;

  cout<<((500*k>=x)? "Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cctype>
#include <queue>
#define ll long long 
#define ri register int 
using namespace std;
template <class T>inline void read(T &x){
    x=0;int ne=0;char c;
    while(!isdigit(c=getchar()))ne=c=='-';
    x=c-48;
    while(isdigit(c=getchar()))x=(x<<3)+(x<<1)+c-48;
    x=ne?-x:x;return ;
}
int a,b;
int main(){
    read(a),read(b);
    if(a<=5)puts("0");
    else if(a>=6&&a<=12)printf("%d\n",b/2);
    else printf("%d\n",b);
    return 0;
}

Measured memory_bytes: 256
X, Y = (int(x) for x in input().split())
if (4 * X - Y) / 2 >= 0 and (-2 * X + Y) / 2 >= 0 and (4 * X - Y) % 2 == 0 and (-2 * X + Y) % 2 == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9172
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
 
using namespace std; 
signed main(){
    
    
    int n,m;
    cin >> n >> m;
 
    for(int i = m/n; i > 0;i--){
        if(m % i == 0){
            cout << i;
            return 0;
        }
    }
    
 
    return 0;
}
//g++ -std=c++14 code1.cpp

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <map>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;

int main()
{
	int cup[] = {1, 0, 0};
	char a, b;
	while(scanf("%c,%c%*c", &a, &b) != EOF){
		swap(cup[a-'A'], cup[b-'A']);
	}

	rep(i, 3){
		if(cup[i]){
			printf("%c\n", 'A'+i);
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 0
from math import sqrt
n = input()
P = [map(int, raw_input().split()) for i in xrange(n)]
A = [e[2] for e in P]

def dist(p, q):
    return sqrt((p[0] - q[0])**2 + (p[1] - q[1])**2)
que = []
for i in xrange(n):
    for j in xrange(i+1, n):
        que.append((dist(P[i], P[j]), i, j))
que.sort()

memo = [-1]*2**n
memo[0] = 0
def calc(state):
    if memo[state] != -1:
        return memo[state]
    res = 0
    cnt = 0
    for i in xrange(n):
        if (state >> i) & 1:
            res += A[i]
            cnt += 1
    parent = range(n)
    def root(x):
        if x != parent[x]:
            parent[x] = x = root(parent[x])
        return x
    def unite(x, y):
        px = root(x); py = root(y)
        if px < py:
            parent[py] = px
        else:
            parent[px] = py
    for d, i, j in que:
        if (state >> i) & 1 and (state >> j) & 1 and root(i) != root(j):
            unite(i, j)
            res -= d
    res /= float(cnt)
    memo[state] = res
    return res

dic = {}
for i in xrange(n):
    dic[1<<i] = A[i]
def dfs(state):
    if state in dic:
        return dic[state]

    res = calc(state)
    sub = (state - 1) & state
    while sub != 0:
        if sub <= sub ^ state:
            res = max(res, min(calc(sub ^ state), dfs(sub)))
        sub = (sub - 1) & state
    dic[state] = res
    return res
print "%.10f" % dfs(2**n-1)


Measured memory_bytes: 64796
import math

a, b, h, m = map(int, input().split())
bm = m * 360 / 60
ah = (h * 360 + bm) / 12
temp = ah - bm
temp = math.cos(math.radians(temp))
temp = a * a + b * b - 2 * a * b * temp
x = math.sqrt(temp)
print(x)

Measured memory_bytes: 9392
#include<cstdio>
#include<iostream>
#include<vector>
using namespace std;

int main(void) {
	int H;
	int N;
	scanf("%d %d", &H, &N);
	for (int i = 0; i < N; i++) {
		int A;
		scanf("%d", &A);
		H -= A;
	}
	printf(H <= 0 ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
#define F(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
#define mod 1000000007
void dfs(vvi &v, vi &dp, vi &vis, int n,int i){
	vis[i]=1;
	F(j,0,v[i].size()){
		if(!vis[v[i][j]])dfs(v,dp,vis,n,v[i][j]);
	dp[i]=max(dp[i],dp[v[i][j]]+1);
}
}
int main()
{	
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int w=1;
	// cin>>w;
	while(w--){
		int n,m;
		cin>>n>>m;
		vvi v(n);
		while(m--){
			int x,y;
			cin>>x>>y;
			v[x-1].pb(y-1);
		}
		vi dp(n,0),vis(n,0);
		F(i,0,n){
			if(!vis[i])
			dfs(v,dp,vis,n,i);
		}

		int ma=0;
		F(i,0,n){
			ma=max(dp[i],ma);
		}
		cout<<ma;

	}
}

Measured memory_bytes: 12972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const ll MOD = 1e9 + 7;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  cout << n * n << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


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

using namespace std;
using int64 = long long;

int main() {
    int h,w;
    cin >> h >> w;
    vector<vector<int64>> c(10, vector<int64> (10));
    for (int i=0; i<10; i++) {
        for (int j=0; j<10; j++) {
            cin >> c[i][j];
        }
    }

    for (int k=0; k<10; k++) {
        for (int i=0; i<10; i++) {
            for (int j=0; j<10; j++) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }


    int64 ans = 0;
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            int a;
            cin >> a;
            if (a < 0) continue;
            ans += c[a][1];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.0000000001
#define pi acosl(-1)
#define pii pair<int,int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
ll a[64];
ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y&1)
            res=res*x;
        res%=mod;
        y=y>>1;
        x=x*x;
        x%=mod;
    } 
    return res; 
}
int main()
{
	FAST
	#ifdef ayk_16
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	ll n;
	cin>>n;
	ll x;
	for(ll i=0;i<n;i++)
	{
		cin>>x;
		for(ll j=0;j<61;j++)
		{
			if(((ll)1<<j)&x)
				a[j]++;
		}
	}
	ll ans=0;
	for(ll i=0;i<61;i++)
	{
		ll q=a[i]*(n-a[i]);
		q%=mod;
		ans+=(q*power(2,i));
		ans%=mod;
	}
	cout<<ans;
}

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

class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> input = Arrays.asList(br.readLine().split(" "));
            long a = Long.parseLong(input.get(0));
            long b = Long.parseLong(input.get(1));
            long x = Long.parseLong(input.get(2));

            long ans = b / x - a / x;
            if (a % x == 0) ans ++;


            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);  
        }
    }
}

Measured memory_bytes: 23124