akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	_ = io.NextInt()
	s := io.Next()
	r, g, b := []int{}, []int{}, []int{}
	for i := range s {
		switch s[i] {
		case 'R':
			r = append(r, i)
		case 'G':
			g = append(g, i)
		case 'B':
			b = append(b, i)
		}
	}
	//logger.Println(r, g, b)
	ans := len(r) * len(g) * len(b)
	ans -= find(r, g, b) + find(r, b, g) + find(g, r, b) + find(g, b, r) + find(b, r, g) + find(b, g, r)
	io.Println(ans)
}

func find(a, b, c []int) (found int) {
	for i := 0; i < len(a); i++ {
		jBegin := sort.Search(len(b), func(j int) bool { return b[j] > a[i] })
		for j := jBegin; j < len(b); j++ {
			kBegin := sort.Search(len(c), func(k int) bool { return c[k] > b[j] })
			k := sort.Search(len(c[kBegin:]), func(k int) bool { return a[i]-2*b[j]+c[kBegin:][k] >= 0 })
			if k < len(c[kBegin:]) && a[i]-2*b[j]+c[kBegin:][k] == 0 {
				found++
			}
		}
	}
	return found
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 2016
#include <bits/stdc++.h>
#include<set>
#define ll long long 
#include <string>
using namespace std;
int main()
{
	ll int h,a,n=0;
	cin>>h>>a;
	while(1)
	{
		n++;
		h=h-a;
		if (h<=0)
		break;
	}
	cout<<n<<endl;
	

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll n;
ll a[25][25];
ll power[(1<<16)];
ll dp[(1<<16)],ans[(1<<16)];
int main(){
	cin>>n;
	for(ll i=0;i<n;++i){
		power[(1<<i)]=i;
	}
	for(ll i=0;i<n;++i){
		for(int j=0;j<n;++j){
			cin>>a[i][j];
		}
	}
	for(ll i=1;i<(1<<n);++i){
		ll lb=(i&(-i)),x=power[lb],st=i^lb;
		dp[i]=dp[st];
		for(int j=0;j<n;++j){
			if((1<<j)&st){
				dp[i]+=a[j][x];
			}
		}
	}
	for(ll i=1;i<(1<<n);++i){
		for(ll j=i;j;j=((j-1)&i)){
			ans[i]=max(ans[i],dp[j]+ans[i^j]);
		}
	} 
	cout<<ans[(1<<n)-1]<<'\n';
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#include <bitset>
#include <list>

using namespace std;

#define rep(i,n,m) for(ll (i)=(n);(i)<(m);(i)++)
#define rrep(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
using ll = long long;
const ll mod = 1000000007;

int main(){

    ll N;
    cin >> N;
    vector<ll> lis(N+1,0);
    ll ans = 0;

    rep(i,1,N+1){

        for (int j = i ; j < N+1 ; j+=i){
            lis[j] += 1;
        }
        ans += i * lis[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 81396
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0039
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            int result = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if (S.Substring(i, 1) == "+")
                {
                    result++;
                }
                else
                {
                    result--;
                }
            }

            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 27420
l = map(int, input().split())
a=list(l)
x1=a[0]
y1=a[1]
x2=a[2]
y2=a[3]
x=x2-x1
y=y2-y1
x3=x2-y
y3=y2+x
x4=x1-y
y4=y1+x
c=[x3, y3, x4, y4]
print(c[0], c[1], c[2], c[3])

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define pb(a) push_back(a)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long unsigned int ll;
typedef pair<ll, ll> P;

int main(){
	int a,b,k;
	cin >> a >> b >> k;
	int n = min(a,b);
	REP(i,k){
		while(a%n!=0||b%n!=0){
			n--;
		}
		n--;
	}
	cout << n+1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int test)
{
  cin >> n;
  double ans = 0;
  for (int i = 0; i < n; ++i) {
    double x;
    cin >> x;
    ans += 1 / x;
  }
  ans = 1 / ans;
  cout.precision(11);
  cout.setf(ios::fixed);
  cout << ans << '\n';
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

void rotate_right(vs& r, vs& g){
    int H = g.size();
    int W = g[0].size();
    r = vs(W, string(H, ' '));

    REP(i,W){
        REP(j,H){
            r[i][j] = g[H - 1 - j][i];
        }
    }    
}

void rotate_left(vs& l, vs& g){
    int H = g.size();
    int W = g[0].size();
    l = vs(W, string(H, ' '));

    REP(i,W){
        REP(j,H){
            l[i][j] = g[j][W-1-i];
        }
    }    
}

int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int H, W; cin >> H >> W;
    vs g(H); REP(i, H) cin >> g[i];

    regex re("\\.+");
    vs t;
    REP(i,H) {
        if (regex_match(g[i], re)) continue;
        t.push_back(g[i]);
    }

    vs r;
    rotate_right(r, t);

    t.clear();
    REP(i,W) {
        if (regex_match(r[i], re)) continue;
        t.push_back(r[i]);
    }
    
    vs ans;
    rotate_left(ans, t);

    for(string s : ans){
        cout << s << endl;
    }

    return 0;
}

Measured memory_bytes: 892
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;


int main()
{
  int i,N,man=0,mi=333333,len;
  char S[300001];
  scanf("%d",&len);
  scanf("%s",S);
  for(i=1;i<len;i++){
    if(S[i] == 'E')
      man++;
  }
  mi = min(mi,man);
  for(i=1;i<len;i++){
    if(S[i] == 'E')
      man--;
    if(S[i-1] == 'W')
      man++;
    mi = min(mi,man);
  }
  printf("%d\n",mi);
  return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll n, k; cin >> n >> k;

  if (k == 0) {
    outl(n*n);
    return;
  }

  ll ans = (n-k)*(n-k+1)/2;
  for (int b = k + 1; b <= n; b++) {
    ll r = (n-(b-1)) % b;
    ll q = (n-(b-1)) / b;
    ll v = min(b-k, b-r);
    // debug3(r, q, v);
    ll tmp = q*v + (q+1)*(b-k-v);
    // debug2(b, tmp);
    ans += tmp;
  }
  outl(ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
string a;
int s=0;
int main()
{
	cin>>a;
	for(int i=0;i<a.size();i++)
		if(a[i]=='+')
			s++;
		else
			s--;
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
const ll mod=1e9+7;


int main(void){
    ll N,ans=0;
    cin>>N;
    vector<ll> P(N);
    rep(i,N) cin>>P.at(i);
    rep(i,N-2){
        if(P.at(i)<P.at(i+1) &&P.at(i+1)<P.at(i+2)) ans++;
        else if(P.at(i)>P.at(i+1) &&P.at(i+1)>P.at(i+2)) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

bool is_ok(const vector<int> data) {
	for (int i = 0; i < data.size() - 1; i++) {
		if (data[i] > data[i + 1]) return false;
	}
	return true;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n; cin >> n;
	vector<int> data(n);
	vector<int> temp(n);

	for (auto& d : data) {
		cin >> d;
	}

	if (is_ok(data)) {
		cout << "YES" << endl;
		return 0;
	}

	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			temp = data;
			swap(temp[i], temp[j]);
			if (is_ok(temp)) {
				cout << "YES" << endl;
				return 0;
			}
		}
	}

	cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;


int main(){
	int n[3];
	scanf("%d %d %d", &n[0], &n[1], &n[2]);
	sort(n,n+3);
	int ans = 0;
	if((n[1]-n[0])%2==0 && (n[2]-n[1])%2!=0){
		ans++;
		n[0]++;
		n[1]++;
	}else if((n[1]-n[0])%2!=0 && (n[2]-n[1])%2==0){
		ans++;
		n[1]++;
		n[2]++;
	}else if((n[1]-n[0])%2!=0 && (n[2]-n[1])%2!=0){
		ans++;
		n[0]++;
		n[2]++;
	}

	ans += (n[2]-n[0])/2 + (n[2]-n[1])/2;
	printf("%d\n", ans);
	return 0;
}


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

using namespace std;

#define int long long int
#define cont continue;
#define ff first
#define ss second
#define pb push_back
#define ins insert
#define mp make_pair
#define endl '\n'


typedef vector<int> vi;
typedef set<int> si;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
typedef map<int, int> mi;

//const
#define EPS 1e-9
#define INF LLONG_MAX
const int mod = 1000 * 1000 * 1000 + 7; //1e9+7
const double PI = 3.14159265358979323846264;
const pi steps[] = {{1, 0}, {0, 1}, { -1, 0}, {0, -1}, {1, -1}, {1, 1}, { -1, -1}, { -1, 1}}; //for (auto [dx,dy] : steps)
//const int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};

// inputs & output & debug
#define w(t) int t; cin>> t; while(t--)

#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

//useful functions
//#define deb(x) cout<<#x<<": "<<x<<endl;
#define isPowOfTwo(x) return (x && (!(x&(x-1))));
#define sz(a) (int)((a).size())
#define present(c,x) ((c).find(x) != (c).end())
#define ip_arr(a,n)   for(int i=0;i<n;i++) cin>>a[i];
#define op_arr(arr,n) for(int i=0;i<n;i++) cout<<arr[i]<<"\n"; cout<<endl;
#define fill_arr(arr,n,i) fill(arr,arr+n,i)
#define fill_vec(v,n,i) fill(v.begin(),v.begin()+n,i);
#define sortv(a) sort(a.begin(),a.end())

void fio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
void setUpLocal()
{
#ifndef ONLINE_JUDGE
	freopen("/Users/asuryana/Documents/CP/input.txt", "r", stdin);
	freopen("/Users/asuryana/Documents/CP/output.txt", "w", stdout);
#else
#define cerr if(0) cerr
#endif
}

const int maxN = 1e7;
// vi gp[gp_size];
// int vis[gp_size];
// int cnt[gp_size];
int n, W;
int w[101], v[101];

int dp[101][100007];

//https://www.youtube.com/watch?v=mtC0Y_uyeVY

int knap(int i, int wt)
{
	if (i == n)
		return 0;

	if (dp[i][wt] != -1)
		return dp[i][wt];

	int ans = knap(i + 1, wt);

	if (w[i] + wt <= W)
	{
		ans = max(ans, v[i] + knap(i + 1, wt + w[i]));
	}

	return dp[i][wt] = ans;

}

void solve()
{
	cin >> n >> W;

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

	memset(dp, -1, sizeof(dp));

	cout << knap(0, 0);

}

int32_t main()
{
	fio();
	//setUpLocal();
	return solve(), 0;
}


Measured memory_bytes: 82536
#include <stdio.h>

int main(){
	int n,i,max,min,sum,num;

	while(1){
		scanf("%d",&n);
		if(n == 0){
			break;
		}

		max = 0;
		min = 1000;
		sum = 0;

		for(i = 0;i < n;i++){
			scanf("%d",&num);
			sum += num;
			if(max < num){
				max = num;
			}
			if(min > num){
				min = num;
			}
		}

		printf("%d\n",(sum-max-min)/(n-2));
	}

	return 0;
}

Measured memory_bytes: 1028
// template version 1.14
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;
const int MOD=1e9+7;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

bool is_prime(int n) {/*{{{*/
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return n != 1;
}/*}}}*/

signed main() {
  int x;cin>>x;
  while(true){
    if (is_prime(x)){
      cout << x << endl;
      return 0;
    }
    x++;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    map<int, int> mp;
    vector<int> A(n);
    rep(i, n) {
        cin >> A[i];
        mp[A[i]]++;
    }
    ll ans = 0;
    for (auto &x : mp) {
        ans += 1LL * x.se * (x.se - 1) / 2;
    }
    rep(i, n) {
        int x = mp[A[i]];
        cout << ans - x + 1 << endl;
    }
}

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


Measured memory_bytes: 10064
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9+7;

void fw(vector<vector<int>> &adj) {
	int n = adj.size();
	for (int k=0; k<n; k++) {
		for (int i=0; i<n; i++) {
			for (int j=0; j<n; j++) {
				if (adj[i][k]==INF or adj[k][j]==INF) continue;
				adj[i][j]=min(adj[i][j],adj[i][k]+adj[k][j]);
			}
		}
	}
}

int getDistance(vector<int> &r, vector<vector<int>> &adj) {
	int result=0;
	for (int i=1; i<r.size(); i++)
		result += adj[r[i]][r[i-1]];
	return result;
}

int main() {
	int n,m,R; cin>>n>>m>>R;
	vector<int> r(R);
	vector<vector<int>> adj(n+1,vector<int>(n+1,INF));
	for (int i=0; i<R; i++) cin>>r[i];
	for (int i=0; i<m; i++) {
		int a,b,c; cin>>a>>b>>c;
		adj[a][b] = c;
		adj[b][a] = c;
	}
	fw(adj);
	sort(r.begin(), r.end());

	int ans = getDistance(r,adj);
	while (next_permutation(r.begin(),r.end())) {
		int temp = getDistance(r,adj);
		if (temp<ans) ans=temp;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.util.OptionalInt;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATaskSchedulingProblem solver = new ATaskSchedulingProblem();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATaskSchedulingProblem {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[] a = in.nextIntArray(3);

            out.println(IntStream.of(a).max().getAsInt() - IntStream.of(a).min().getAsInt());
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

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

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

    }
}



Measured memory_bytes: 26448
x,n=map(int,input().split())
if n==0:
  anss=x
else:
  p=list(map(int,input().split()))
  pp=list(set(list(range(-100,105)))-set(p))
  ans=1000
  anss=1000
  for j in range(len(pp)):
    if abs(pp[j]-x)<ans:
      ans=abs(pp[j]-x)
      anss=pp[j]
    elif abs(pp[j]-x)==ans and pp[j]<anss:
      ans=abs(pp[j]-x)
      anss=pp[j]
print(anss)


Measured memory_bytes: 9228
#include <stdio.h>

int main(void) {
    int N,M;
    float per;
    scanf("%d",&N);
    if (N%2==0) {
        M = N/2;
    } else {
        M = N/2 + 1;
    }
    per = (float)M/N;
    printf("%lf\n",per);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
string b[1000000];
bool cmp(string a, string b) {
    return a < b;
}
int n, l;
int main() {
    cin >> n >> l;
    for (int i = 1; i <= n; i++) {
        cin >> b[i];
    }
    sort(b + 1, b + 1 + n, cmp); 
    for (int i = 1; i <= n; i++) {
        cout << b[i];
    }
}

Measured memory_bytes: 8064
N,C=map(int, input().split())
cost=[[int(st) for st in input().split()] for _ in range(C)]
count={0: {}, 1: {}, 2: {}}
for y in range(N):
    for x, v in enumerate(map(int, input().split())):
        rest = (x+y) % 3
        if not v in count[rest]:
            count[rest][v] = 1
        else:
            count[rest][v] += 1
mincost = 9223372036854775807
for c1 in range(1, C+1):
    for c2 in range(1, C+1):
        if c1 != c2:
            for c3 in range(1, C+1):
                if c1 != c3 and c2 != c3:
                    sumcost = 0
                    for cl, cnt in count[0].items():
                        sumcost += cnt*cost[cl-1][c1-1]
                    for cl, cnt in count[1].items():
                        sumcost += cnt*cost[cl-1][c2-1]
                    for cl, cnt in count[2].items():
                        sumcost += cnt*cost[cl-1][c3-1]
                    mincost = min(sumcost, mincost)

print(mincost)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  998244353
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }

ll beki(ll a, ll b){
    a %= MOD;
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2);
    ans = ans * ans % MOD;
    if(b % 2 == 1){
        ans = ans * a % MOD;
    }
    return ans;
}

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  map<ll,ll> d;
  rep(i,n) {
    ll a;
    cin >> a;
    if(i==0&&a!=0){
      puts("0");
      return 0;
    }
    d[a]++;
  }
  ll ans = 1;
  if (d[0] != 1) ans = 0;
  for (ll i = 1; i < n; i++){
    ans *= beki(d[i-1], d[i])%MOD;
    ans %= MOD;
  }
  while(ans<0){
    ans += MOD;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;

}

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

int main(){
  ll n,cnt=0  ; cin>>n ;
vector<ll>p(n);
 vector<ll>c(n);
  rep(i,n){ 
    cin>>p[i];
  c[i]=p[i];
  }
  sort(c.begin(),c.end());
  rep(i,n){
  if(c[i]!=p[i]) cnt++;
  }
  if(cnt==2||cnt==0) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  
}

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

using namespace std;
typedef long long ll;

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

    double sum = 0;

    for(int i=0; i < n; i++) {
        double num;
        cin >> num;

        sum += 1/num;
    }

    cout << 1/sum;
}

Measured memory_bytes: 256
import numpy as np
inp = input
#fin = open("case_21.txt")
#inp = fin.readline

X, Y, A, B, C = map(int, inp().split())

#red = np.array(list(map(int, inp().split())), np.int32)
#green = np.array(list(map(int, inp().split())), np.int32)
#white = np.array(list(map(int, inp().split())), np.int32)
red = list(map(int, inp().split()))
green = list(map(int, inp().split()))
white = list(map(int, inp().split()))
red.sort(reverse=True)
green.sort(reverse=True)
white.sort(reverse=True)
#fin.close()

#red[::-1].sort()
#green[::-1].sort()
#white[::-1].sort()

idr = 0
idg = 0
idw = 0

total = 0.0
countr = 0
countg = 0
countw = 0
while X > countr and Y > countg and (X+Y > countr+countg+countw):
    if red[idr] >= green[idg]:
        if idw >= C or red[idr] >= white[idw]:
            #eat red
            total += red[idr]
            idr += 1
            countr += 1
        elif idw < C:
            #eat white
            total += white[idw]
            idw += 1
            countw += 1
    else:
        if idw >= C or green[idg] >= white[idw]:
        # eat green
            total += green[idg]
            idg += 1
            countg += 1
        else:
            #eat white
            total += white[idw]
            idw += 1
            countw += 1

#eat remain
if Y <= countg:
    while X > countr+countw:
        # compare red 1st
        if idw < C and red[idr] < white[idw]:
            # eat white
            total += white[idw]
            idw += 1
        else:
            # eat red
            total += red[idr]
            idr += 1
        countr += 1

if X <= countr:
    while Y > countg+countw:
        # compare green 1st
        if idw < C and green[idg] < white[idw]:
            # eat white
            total += white[idw]
            idw += 1
        else:
            # eat green
            total += green[idg]
            idg += 1
        countg += 1

print(int(total))


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

using ll = long long;
using namespace std;

const int mod = 1e9 + 7;
vector<int> cnt(26);

ll get(int idx, ll cur) {
   if(idx == 26) {
      return cur % mod;
   }
   ll ans = get(idx + 1, cur);
   ans += get(idx + 1, (cur * cnt[idx]) % mod);
   return ans % mod;
}

void solveCase() {

   int n;
   cin >> n;
   string s;
   cin >> s;
   for(auto &e: s) {
      cnt[e - 'a']++;
   }

   cout << (get(0, 1) + mod - 1) % mod << endl;
}


int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solveCase();
   }
 
   return 0;
}


Measured memory_bytes: 3688
package main

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

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt int

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	T := make([]uint64, N)
	A := make([]uint64, N)

	for i := 0; i < N; i++ {
		x, _ := strconv.Atoi(read())
		y, _ := strconv.Atoi(read())
		T[i], A[i] = uint64(x), uint64(y)
	}

	var _t, _a uint64 = T[0], A[0]
	for i := 1; i < N; i++ {
		var t, a, x uint64 = 1, 1, 1

		if T[i] < _t || A[i] < _a {
			t = _t / T[i]
			a = _a / A[i]
			if _t%T[i] != 0 {
				t++
			}
			if _a%A[i] != 0 {
				a++
			}
			if t < a {
				x = a
			} else {
				x = t
			}
		}
		_t, _a = T[i]*x, A[i]*x
	}

	fmt.Println(_t + _a)

}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []struct {
	b, c int
}

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i].c > a[j].c }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 640
a,b = map(int,input().split())
s = input()

nums = ["{}".format(i) for i in range(10)]

if s[a]!="-":
  print("No")
  exit()
  
for i in range(a+b+1):
  if i==a:
    continue
  elif s[i] in nums: 
    continue
  else:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 3064
#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 n;
    scanf("%d",&n);
    // dp[heads]
    // if we had i tosses, then tails = i - heads
    vector<double> dp(n+1);
    //dp[i] - p-ability that there are i heads so far
    dp[0] = 1;
    REP(coin,n){
        double p_heads;
        scanf("%lf",&p_heads);
        for(int i = coin + 1; i>=0; i--){
            dp[i] = ( i == 0 ? 0 : dp[i-1]*p_heads) + dp[i]*(1-p_heads);
        }
    }
    double answer = 0;
    REP(heads,n+1){
        int tails = n - heads;
        if(heads > tails){
            answer += dp[heads];
        }
    }printf("%.10lf\n",answer);
}


Measured memory_bytes: 256
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 

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

const int INF = 100000;
struct edge{
    int a, b, cap, flow;
    edge(){}
    edge(int a, int b, int cap, int flow){
        this->a = a;
        this->b = b;
        this->cap = cap;
        this->flow = flow;
    }
};
 
 
int n, d, dist[210], ptr[210];
vector<edge> edgeList;
vector<int> adj[20005];

int r, c, src, sink;
char arr[102][102]; 
 
void add_edge(int a, int b, int cap){
    adj[a].pb(edgeList.size());
    edgeList.pb(edge(a, b, cap, 0));
    adj[b].pb(edgeList.size());
    edgeList.pb(edge(b, a, cap, 0));
// cout<<"added edge "<<a<<" "<<b<<" "<<cap<<endl;
}
 
 
bool bfs(){
 
    memset(dist, -1, sizeof(dist));
    queue<int> qq;
    dist[src] = 0;
    qq.push(src);
    while(!qq.empty()){
 
        int v = qq.front();
        qq.pop();
        for(int i=0;i<(int)adj[v].size();i++){
           
            int id = adj[v][i];
            int to = v ^ edgeList[id].a ^ edgeList[id].b;
 
            if(dist[to] == -1 && edgeList[id].flow < edgeList[id].cap){
                dist[to] = dist[v]+1;
                qq.push(to);
            }
        }
    }
    return (dist[sink] != -1);
}
 
 
 
int dfs(int v, int flow){
 
    if(!flow)   return 0;
    if(v == sink)  return flow;
 
    for(;ptr[v]<(int)adj[v].size();ptr[v]++){
 
        int id = adj[v][ptr[v]];
        int to = v ^ edgeList[id].a ^ edgeList[id].b;
        if(dist[to] != dist[v]+1)   continue;
 
        int pushed = dfs(to, min(flow, edgeList[id].cap-edgeList[id].flow));
        if(pushed > 0){
            edgeList[id].flow += pushed;
            edgeList[1^id].flow -= pushed;
            return pushed;
        }
    }
    return 0;
}
 
 
 
int dinitz(){
 
    int ans = 0;
    while(1){
        if(!bfs())  break;
        memset(ptr, 0, sizeof(ptr));
        while(int pushed = dfs(src, INF))
            ans += pushed;
    }
    return ans;
}




int main(){

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

    cin>>r>>c;
    src = 0;    sink = 1+r+c;
    int sx,sy,tx,ty;
    for(int i=0;i<r;i++){
        cin>>arr[i];
        for(int j=0;j<c;j++){
            if(arr[i][j] == '.')    continue;
            if(arr[i][j] == 'S'){
                add_edge(src, 1+i, INF);
                add_edge(src, 1+r+j, INF);
                sx=i;sy=j;
            }
            else if(arr[i][j] == 'T'){
                add_edge(sink, 1+i, INF);
                add_edge(sink, 1+r+j, INF);
                tx=i;ty=j;
            }
            else{
                add_edge(1+i, 1+r+j, 1);
            }
        }
    }

    if(sx==tx || sy==ty){
        cout<<"-1";
        return 0;
    }

// cout<<src<<" "<<sink<<endl;
    cout<<dinitz();
    return 0;
}











Measured memory_bytes: 1404
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
using namespace std;

#define clear_vec(v,n); v.clear();v.resize(n);

int N,E,Q;
vector<set<int> > edge;
vector<vector<int> > flow;
int f;

void add_flow(int from,int to){
  flow[from][to]++;
  flow[to][from]--;
}

vector<int> used;
int dfs_(int from,int end){
  if(from==end)return 1;
  used[from]=1;
  for(auto i=edge[from].begin();i!=edge[from].end();i++){
    int to = *i;
    if(used[to]==1)continue;
    if(flow[from][to]<1 && dfs_(to,end)==1){
      add_flow(from,to);
      return 1;
    }
  }
  return 0;
}

int dfs(int from,int end){
  clear_vec(used,N+1);
  return dfs_(from,end);
}

void add_edge(int a,int b){
  edge[a].insert(b);
  edge[b].insert(a);
}

void cut_edge(int a,int b){
  int ff = flow[a][b];
  flow[a][b]=flow[b][a]=0;
  edge[a].erase(b);
  edge[b].erase(a);

  if(ff<0){
    swap(a,b);
  }
  if(ff!=0){
    if(!dfs(a,b)){
      dfs(N,b),dfs(a,1);
      f--;
    }
  }
}

int input(){
  f=0;
  cin>>N>>E>>Q;
  clear_vec(edge,N+1);
  clear_vec(flow,N+1);
  for(int i=0;i<N+1;i++){
    clear_vec(flow[i],N+1);
  }
  for(int i=0;i<E;i++){
    int a,b;
    cin>>a>>b;
    add_edge(a,b);
  }
  return 0;
}

int solve(int m,int a,int b){
  switch(m){
    case 1:
      add_edge(a,b);
      if(dfs(1,N))f++;
      break;
    case 2:
      cut_edge(a,b);
      break;
  }
  return f;
}


void some_querys(){
  for(int i=0;i<Q;i++){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<solve(a,b,c)<<endl;
  }
}

int main(){
  input();
  while(dfs(1,N))f++;
  some_querys();
}

Measured memory_bytes: 4168
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

signed main() {
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	int count1 = 0, count2 = 0;
	int sum1[n], sum2[n];
	for (int i = 0; i < n; i++) {
		sum1[i] = sum2[i] = 0;
	}
	
	for (int i = 0; i < n; i++) {
		if (i == 0) sum1[i] = a[i];
		else sum1[i] += sum1[i - 1] + a[i];
		if (i % 2  == 0 && sum1[i] <= 0) {
			count1 += abs(sum1[i]) + 1;
			sum1[i] = 1;
		} else if (i % 2 == 1 && sum1[i] >= 0) {
			count1 += abs(sum1[i]) + 1;
			sum1[i] = -1;
		}
	}
	
	for (int i = 0; i < n; i++) {
		if (i == 0) sum2[i] = a[i];
		else sum2[i] = sum2[i - 1] + a[i];
		if (i % 2  == 1 && sum2[i] <= 0) {
			count2 += abs(sum2[i]) + 1;
			sum2[i] = 1;
		} else if (i % 2 == 0 && sum2[i] >= 0) {
			count2 += abs(sum2[i]) + 1;
			sum2[i] = -1;
		}
	}
	
	cout << min(count1, count2) << endl;
	
	return 0;
}

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

using namespace std;

int main(void) {
    int k, two;
    int sum = 0;
    cin >> k;
    // vector<vector<int>> tmp(k, vector<int>(k));
    for(int i = 1; i <= k; i++){
        for(int j = 1; j <= k; j++){
            two = gcd(i, j);
            for(int l = 1; l <= k; l++){
                sum = sum + gcd(l, two);
            }
        }
        
    }

    cout << sum << endl;
    return 0;
}

int gcd(int x, int y){
    if(y == 0){
        return x;
    }
    else{
        return gcd(x, x % y);
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>   
using namespace std;   
typedef long long ll;
ll n, ans, nlen;
void f(ll val, ll a, ll b, ll c) {
	if (val > n)
		return;
	if (a and b and c)
		ans++;
		
	f(val*10+3, 1, b, c);
	f(val*10+5, a, 1, c);
	f(val*10+7, a, b, 1);
}
int main()  
{   
    cin.tie(0); ios::sync_with_stdio(false);  
	//freopen("input.txt", "rt", stdin);
	cin >> n;
	f(0,0,0,0);
	cout << ans << endl;
	
	return 0;   
}  


Measured memory_bytes: 256
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/
#include <bits/stdc++.h>
#define newline ("\n")
#define deb(x) cerr << (#x) << " = " << (x) << '\n'
#define FOR(x, n) for (int x = 0; x < n; x++)
#define PI (3.141592653589)

#define MOD 1000000007
using namespace std;

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

    // Pikachu, I choose you
    int h, w;
    cin >> h >> w;
    char arr[h + 1][w + 1];
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            cin >> arr[i][j];
        }
    }
    int dp[h + 1][w + 1];
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            if (i == 1 && j == 1)
            {
                dp[i][j] = 1;
            }
            else if (i == 1 || j == 1)
            {
                if (i == 1)
                {
                    if (arr[i][j] == '.')
                    {
                        dp[i][j] = dp[i][j - 1];
                    }
                    else
                    {
                        dp[i][j] = 0;
                    }
                }
                else
                {
                    if (arr[i][j] == '.')
                    {
                        dp[i][j] = dp[i - 1][j];
                    }
                    else
                    {
                        dp[i][j] = 0;
                    }
                }
            }
            else
            {
                if (arr[i][j] == '.')
                {
                    dp[i][j] = (dp[i - 1][j] % MOD + dp[i][j - 1] % MOD) % MOD;
                }
                else
                {
                    dp[i][j] = 0;
                }
            }
        }
    }
    cout << dp[h][w];
    return 0;
}

Measured memory_bytes: 5120
N = int(input())
M = len(str(N))
count = 0

def dfs(A):
  global count
  
  if len(A) <= M and (3 in A and 5 in A and 7 in A):
    num = 0
    for i in range(len(A)):
      num += A[i]*(10**i)
    if num <= N:
      count += 1
  elif len(A) > M:
    return

  for i in [3, 5, 7]:
    A.append(i)
    dfs(A)
    A.pop()
  
dfs([])
print(count)
    

Measured memory_bytes: 3064
N=int(input())
*A,=map(int,input().split())
cnt = {}
for a in A:
    cnt[a] = cnt.get(a,0)+1
keys = sorted(cnt.keys())
i = 0
j = len(keys)-1
while i <= j:
    ki,kj = keys[i],keys[j]
    if cnt[ki]<=1:
        i+=1
        continue
    if cnt[kj]<=1:
        j-=1
        continue
    cnt[ki] -= 1
    cnt[kj] -= 1
print(sum(cnt.values()))

Measured memory_bytes: 18272
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    double a, b, h, m;
    cin>>a>>b>>h>>m;

    double hx = a * cos(2 * PI * (h + m / 60) / 12);
    double hy = a * sin(2 * PI * (h + m / 60) / 12);
    double mx = b * cos(2 * PI * m / 60);
    double my = b * sin(2 * PI * m / 60);
    printf("%.15f\n", sqrt((hx - mx) * (hx - mx) + (hy - my) * (hy - my)));
}

Measured memory_bytes: 4180
# A-Digit Sum 2
n=int(input())
s=str(n)
n=len(s)
s=list(s)
for i in range(n):
    if i==n-1:
        if s[-1-i]=='-1' or s[-1-i]=='0':
            s[-1-i]='0'
        continue
    if s[-1-i]=='-1':
        s[-1-i]='0'
    if s[-1-i]=='9':
        continue
    else:
        t=int(s[-1-i-1])-1
        s[-1-i-1]=str(t)
        s[-1-i]='9'
ans=0
for ss in s:
    ans+=int(ss)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<ll> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];

    ll max_sum = 0;
    for (int a = 0; a <= min(n, k); a++) {
        for (int b = 0; a + b <= min(n, k); b++) {
            ll sum_v = 0;
            vector<ll> select_v;
            for (int i = 0; i < a; i++) {
                sum_v += v[i];
                select_v.push_back(v[i]);
            }
            for (int i = 0; i < b; i++) {
                sum_v += v[n-1-i];
                select_v.push_back(v[n-1-i]);
            }
            sort(select_v.begin(), select_v.end());
            for (int cd = 0; cd < k-a-b; cd++) {
                if (cd >= select_v.size()) break;
                else if (select_v[cd] < 0) sum_v -= select_v[cd];
                else break;
            }
            max_sum = max(sum_v, max_sum);
        }
    }
     
    cout << max_sum << endl;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Tenki
            var S = Console.ReadLine();
            var T = Console.ReadLine();
            int hits = 0;

            for(int i = 0; i < 3; i++)
            {
                if (S[i] == T[i])
                {
                    hits++;
                }
            }

            Console.WriteLine(hits);
        }
    }
}

Measured memory_bytes: 13140
n = gets.to_i
ds = gets.chomp.split.map(&:to_i)
mod = 998244353
cnt = Array.new(ds.max+1,0)
ans = 1
(0..n-1).each do |i|
  if (i == 0 && ds[i] != 0) || (i != 0 && ds[i] == 0)
    puts 0
    exit 0
  end
  cnt[ds[i]] += 1
end
present = 1
cnt.shift
cnt.each do |i|
  i.times do
    ans *= present
    ans %= mod
  end
  present = i
end

puts ans

Measured memory_bytes: 9476
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using Graph = vector<vector<bool>>;
const int MOD = 1e9 + 7;

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

    int A, B;
    cin >> A >> B;
    A--, B--;

    int C = 0, D = 0, W = 0;
    for (int i = 0; i * i < max(A, B); ++i)
        W++;
    W = max(2 * W, 1);

    C = (4 * A + W - 1) / W, D = (4 * B + W - 1) / W;
    C += C & 1, D += D & 1;
    C = max(C + (C & 1), 1), D = max(D + (D & 1), 1);

    printf("%d %d\n", C + D, W);

    for (int i = 0; i < C; ++i) {
        for (int j = 0; j < W; ++j) {
            bool iswhite = (A > 0) & !((i | j) & 1);
            A -= iswhite;
            putchar(iswhite ? '.' : '#');
        }
        putchar('\n');
    }

    for (int i = 0; i < D; ++i) {
        for (int j = 0; j < W; ++j) {
            bool isblack = (B > 0) & (i & j & 1);
            B -= isblack;
            putchar(isblack ? '#' : '.');
        }
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int n;
inline int parent(int &x) {
	return (x - 1) / n;
} 
int query(int x, int y) {
	if(n == 1) return min(x, y) + 1;
	if(x == 0 || y == 0) return 1;
	vector <int> v;
	while(true) {
		v.push_back(x);
		if(x == 0) break;
		x = parent(x);
	}
	int pointer = 0;
	while(true) {
		while(pointer + 1 < (int) v.size() && v[pointer + 1] >= y) {
			++pointer;
		}
		if(v[pointer] == y) return y+1;
		y = parent(y);
	}
	return 0;
}

int main(int argc, char const *argv[])
{	
	int q;
	scanf("%d %d", &n, &q);
	while(q--) {
		int p, q;
		scanf("%d %d", &p, &q);
		printf("%d\n", (int) query(p-1, q-1));
	}
	return 0;
}

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

int main()
{
	int a[1000],b[1000],c[1000];
	int kosuu;
	char ans[1000];
	int i;

	cin>>kosuu;//個数入力

	for(i=0;i<kosuu;i++)
	{
		cin>>a[i]>>b[i]>>c[i];//数値入力

		if(a[i]>b[i]&&a[i]>c[i])//aがbとcよりも大きかったら
		{
			if(a[i]*a[i]==b[i]*b[i]+c[i]*c[i]){ans[i]=1;}
			else{ans[i]=0;}
		}
		else if(b[i]>a[i]&&b[i]>c[i])//bがaとcよりも大きかったら
		{
			if(b[i]*b[i]==a[i]*a[i]+c[i]*c[i]){ans[i]=1;}
			else{ans[i]=0;}
		}
		else if(c[i]>a[i]&&c[i]>b[i])//cがbとaよりも大きかったら
		{
			if(c[i]*c[i]==b[i]*b[i]+a[i]*a[i]){ans[i]=1;}
			else{ans[i]=0;}
		}
		else if(a[i]==b[i]||a[i]==c[i]||b[i]==c[i]){ans[i]=0;}
	}
	for(i=0;i<kosuu;i++)
	{
		if(ans[i]==1){cout<<"YES"<<endl;}
		else if(ans[i]==0){cout<<"NO"<<endl;}
	}

		
	return 0;
}

Measured memory_bytes: 1160