akhauriyash/Code-Regression huggingface dataset:
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int n;
int x[10];
int y[10];
double dist(int a,int b){
	int dis_x=x[a]-x[b];
	int dis_y=y[a]-y[b];
	return pow(dis_x*dis_x+dis_y*dis_y,0.5);
}
int find_fac(int x){
	int ans=1;
	while(x>1){
		ans*=x;x--;
	}
	return ans;
}
int solve()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x[i]>>y[i];
	}
	vi v(n);
	forci(0,n)
		v[i]=i+1;
	double sum=0.0;
	do{
		for(int i=0;i<n-1;i++)	sum+=dist(v[i],v[i+1]);
	}while(next_permutation(v.begin(),v.end()));
	int x=find_fac(n);
	cout<<fixed<<setprecision(8)<<sum/x<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}






Measured memory_bytes: 4236
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N, R = read_int()

def solve():
    ans = 0
    if N >= 10:
        return R
    return R + 100 * (10 - N)

if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

ll df(ll a, ll b)
{
    if (b < 0) a = -a, b = -b;
    return a / b - (a % b < 0);
}

ll dc(ll a, ll b)
{
    if (b < 0) a = -a, b = -b;
    return a / b + (a % b > 0);
}

template <class T>
class FT
{
    vector<T> ft;
public:
    FT(int n) : ft(n + 1)
    {
    }
    T rsq(int b)
    {
        T sum = 0;
        for (; b; b -= (b & (-b)))
            sum += ft[b];
        return sum;
    }
    void adjust(int k, T v)
    {
        for (; k < ft.size(); k += (k & (-k)))
            ft[k] += v;
    }
    void adjust(int l, int r, T v)
    {
        adjust(l, v);
        adjust(r + 1, -v);
    }
};

int x[200000];
ll h[200000];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll d, a;
    cin >> n >> d >> a;
    vector<ll> vp, wp;
    vector<pair<ll, ll>> ev;
    FT<ll> ft(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> x[i] >> h[i];
        vp.push_back(x[i]);
        ev.emplace_back(x[i], h[i]);
    }
    sort(all(ev));
    for (int i = 0; i < n; ++i)
    {
        int xp, hp;
        tie(xp, hp) = ev[i];
        ft.adjust(i + 1, i + 1, hp);
    }
    sort(all(vp));
    wp = vp;
    reverse(all(wp));
    ll sol = 0;
    for (int i = 0; i < n; ++i)
    {
        int hp = ft.rsq(i + 1);
        if (hp <= 0) continue;
        int j = n - (lower_bound(all(wp), vp[i] + 2 * d, greater<ll>()) - wp.begin()) - 1;
        sol += dc(hp, a);
        ft.adjust(i + 1, j + 1, -dc(hp, a) * a);
    }
    cout << sol;
}


Measured memory_bytes: 10464
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int main(){
	int N;
	cin>>N;
	map<ll,int> cnt;
	rep(i,N){
		ll a;
		cin>>a;
		cnt[a]++;
	}
	int ans = 0;
	while(!cnt.empty()){
		ll x = cnt.rbegin() -> fs;
		cnt[x]--;
		if(cnt[x]==0) cnt.erase(x);
		ll y = 1;
		while(y<=x) y *= 2;
		y -= x;
		if(cnt.count(y)){
			cnt[y]--;
			if(cnt[y]==0) cnt.erase(y);
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 12800
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long a,h,m,s;
    cin>>a;
    h=a/3600;
    a=a%3600;
    m=a/60;
    a=a%60;
    s=a;
    cout<<h<<":"<<m<<":"<<s<<endl;
    return 0;
    
}



Measured memory_bytes: 3112
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return  sys.stdin.readline
    else:
        return fileobject.readline

def calc(field, H, W):
    ret =  [[0] * (W + 1) for i in range(H + 1)]
    for i in range(H):
        cnt = 0
        cnt_list = []
        for j in range(W + 1):
            if field[i][j] == "#":
                cnt_list.append(cnt)
                cnt = 0
            else:
                cnt += 1
        k = 0
        for j in range(W + 1):
            if field[i][j] == ".":
                ret[i][j] = cnt_list[k]
            else:
                ret[i][j] = 0
                k+=1
    return ret





def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [H, W] = [int(input_raw[0]), int(input_raw[1])]
    field = [["#"] * (W + 1) for i in range(H + 1)]
    field_T = [["#"] * (H + 1) for i in range(W + 1)]
    for i in range(H):
        input_raw = read_func().strip().split()
        for j in range(W):
            field[i][j] = input_raw[0][j]
            field_T[j][i] = field[i][j]
    ret1 = calc(field, H, W)
    ret2 = calc(field_T, W, H)
    ans = 0
    for i in range(H):
        for j in range(W):
            ans = max(ans, ret1[i][j] + ret2[j][i] - 1)
    print ans

if __name__ == '__main__':
    main()


Measured memory_bytes: 286620
#define w 200001
i;p;main(n,m,j){
  long int k,a[w],A[w],b[w],B[w];
  scanf("%d%d%ld",&n,&m,&k);
  for(;i<n;i++){
    scanf("%ld",&a[i]);
    A[i+1]=A[i]+a[i];
  }
    
  for(i=0;i<m;i++){
    scanf("%ld",&b[i]);
    B[i+1]=B[i]+b[i];
  }
  int mo=m;
        
  for(i=0;i<=n;i++){
    if(A[i]>k)break;
            
    for(j=mo;j>=0;j--){
      if(A[i]+B[j]<=k){
        if(i+j>p)p=i+j;
        mo=j;
        break;
      }
    }
  }
  printf("%d",p);
}

Measured memory_bytes: 7932
import std;

void main() {
  char[] s, t;
  scan(s);
  scan(t);
  int n = s.length.to!int;
  int m = t.length.to!int;
  if (n < m) {
    writeln("UNRESTORABLE");
    return;
  }
  char[] ans = new char[](n);
  bool exist;
  foreach_reverse (i; 0 .. n - m + 1) {
    if (match(s[i .. i + m], t)) {
      foreach (j; 0 .. n) {
        if (i <= j && j < i + m) {
          ans[j] = t[j - i];
        } else {
          ans[j] = s[j];
        }
          
        if (ans[j] == '?') {
          ans[j] = 'a';
        }
      }
      exist = true;
      break;
    }
  }
  if (exist) {
    writeln(ans);
  } else {
    writeln("UNRESTORABLE");
  }
}

bool match(char[] s, char[] t) {
  foreach (i; 0 .. s.length) {
    if (s[i] == '?') {
      continue;
    }
    if (s[i] != t[i]) {
      return false;
    }
  }
  return true;
}

void scan(T...)(ref T args) {
    auto line = readln.split; // @suppress(dscanner.suspicious.unmodified)
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}
 
void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}
 
bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}
 
bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}
 
void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}

Measured memory_bytes: 3676
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

l = int(input())

print((l/3) ** 3)


Measured memory_bytes: 38384
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

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

	vector<int> m;
	m.push_back(10);
	m.push_back(50);
	m.push_back(100);
	m.push_back(500);

	bool first = true;
	for(int money; cin >> money, money;) {
		if(!first)
			cout << endl;

		first = false;
		int sum = 0;
		vector<int> num(4);
		for(int i = 0; i < 4; ++i) {
			cin >> num[i];
			sum += num[i] * m[i];
		}

		int change = sum - money;
		for(int i = 3; i >= 0; --i) {
			if(change / m[i]) {
				num[i] = num[i] - change / m[i];
				change %= m[i];
			}
		}

		for(int i = 0; i < 4; ++i)
			if(num[i] > 0)
				cout << m[i] << " " << num[i] << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,k;
vector<vector<ll>> multiply(vector<vector<ll>> A,vector<vector<ll>> B)
{
	ll n=A.size();
	vector<vector<ll>> res(n,vector<ll>(n,0));
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<n;j++)
		{
			for(ll x=0;x<n;x++)
			{
				res[i][j]=(res[i][j]+(A[i][x]*B[x][j]))%1000000007;
			}
		}
	}
	return res;
}
vector<vector<ll>> power(vector<vector<ll>>& mat,ll exponent)
{
	if(exponent==1)
		return mat;
	vector<vector<ll>> res=power(mat,exponent/2);
	if(exponent&1)
		return multiply(multiply(mat,res),res);
	else
		return multiply(res,res);
}
ll solve(vector<vector<ll>>& adj)
{
	ll ans=0;
	vector<vector<ll>> ak = power(adj,k);
	for(ll p=0;p<n;p++)
	{
		for(ll j=0;j<n;j++)
		{
			ans=(ans+ak[p][j])%1000000007;
		}
	}
	return ans;
}
int main()
{
	cin>>n>>k;
	vector<vector<ll>> adj(n,vector<ll>(n));
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<n;j++)
		{
			cin>>adj[i][j];
		}
	}
	cout<<solve(adj)<<endl;

}

Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
int n;
string A,B;
void solve(){
	cin>>A>>B;
	int cnt=0;
	for(int i=0;i<3;i++){
		if(A[i]==B[i])cnt++;
	}
	printf("%d\n",cnt);
}
int main(){
    solve();
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
ll n, m, k = 0, l = 0, x, y;

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> k;
	vector<ll> a(n + 2 * k, 0), dp(n + 2 * k, 0);

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		dp[i] = abs(a[i] - a[0]);
	}
	
	for (int i = 0; i < n; i++) {
		
		for (int j = i + 1; j < i+k; j++ )
			dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]) );

		dp[ i + k ] = dp[i] + abs(a[i] - a[i + k]);
		
	}
	
	cout << dp[n-1];
	
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c; cin >> a >> b >> c;
	int x = 100 * a + 10 * b + c;
	if (x % 4 == 0)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Mar 15 11:25:41 JST 2020
 **/

signed main() {
    int X;
    cin >> X;
    for (int i = X; ; i++) {
        bool prime = true;
        for (int j = 2; j * j <= i; j++) {
            if (i % j == 0) prime = false;
        }
        if (prime) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);

int main() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int dx = x2 - x1;
	int dy = y2 - y1;
	int x3 = x2 - dy;
	int y3 = y2 + dx;
	int x4 = x1 - dy;
	int y4 = y1 + dx;
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> A(x), B(y), C(z);
    REP(i, 0, x) {
        cin >> A[i];
    }
    REP(i, 0, y) {
        cin >> B[i];
    }
    REP(i, 0, z) {
        cin >> C[i];
    }
    vector<ll> sum;
    REP(i, 0, x) {
        REP(j, 0, y) {
            sum.push_back(A[i] + B[j]);
        }
    }
    sort(sum.rbegin(), sum.rend());
    vector<ll> ans;
    REP(i, 0, min(k, (int)sum.size())) {
        REP(j, 0, z) {
            ans.push_back(sum[i] + C[j]);
        }
    }
    sort(ans.rbegin(), ans.rend());
    REP(i, 0, k) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 43112
// /Code by : Harry_Singh/
#include<bits/stdc++.h>
#define int long long int 
#define io ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define ipair pair<int,int>
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define F(i,n) for(int i=1;i<=n;i++)
#define mod 1000000007
using namespace std;
#define inf 100000000000000009
#define tr cout<<"\n" 
#define N 205
// directions
int xx[5]={0,0,1,-1};
int yy[5]={1,-1,0,0};
vector<int > G[N],L[N];
 
 
void we_have_choices()
{

   int x,k,d;
   cin>>x>>k>>d;
   if(x<0)x*=-1;
   int a=x/d;
   if(k>a) {       // k is require
    x = x -a*d;
    k = k-a;
    }
    else{cout<<x-k*d;tr;return;}

    if(k%2==0)cout<<x;
    else cout<< abs(x-d);
    tr;

   




}



int32_t main()
{
#ifndef ONLINE_JUDGE
 freopen("input.txt","r",stdin);
 freopen("output.txt","w",stdout);
#endif
    io;
    int t=1;
    while (t--)we_have_choices();
    return 0;
}

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

int main(){
    int n,m;cin>>n>>m;
    int a=0,p=0;
    
    map<int,int> mp;
    vector<bool> v(n+1);
    for(int i = 0; i < m; i++){
        int t;string s;
        cin>>t>>s;
        if(s == "AC" && !v[t]){
            a++;
            v[t] = 1;
             p+=mp[t];
            continue;
        }
        mp[t]++;
    }
    cout<<a<<" "<<p;
}


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

string f[15];
int dx[] = { 1,0,-1,0 }, dy[] = { 0,-1,0,1 };

void dfs(int x, int y) {
	f[x][y] = '0';
	for (int i = 0; i < 4; i++) {
		int nx = x + dx[i];
		int ny = y + dy[i];
		if (0 <= nx&&nx < 12 && 0 <= ny&&ny < 12) {
			if (f[nx][ny] == '1') {
				dfs(nx, ny);
			}
		}
	}
	return;
}

int main() {
	while (cin>>f[0]) {
		int ans = 0;
		for (int i = 1; i < 12; i++) {
			cin >> f[i];
		}
		for (int i = 0; i < 12; i++) {
			for (int j = 0; j < 12; j++) {
				if (f[i][j] == '1') {
					ans++;
					dfs(i, j);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3188
L, N = list(map(int, input().split()))
X = [int(input()) for i in range(N)]
 
## Y[i] = X[i+1]-X[i]
#Y = [X[i+1]-X[i] if i<N-1 else L+X[0]-X[N-1] for i in range(N)]
#print(Y)
 
''' Start at X[0] '''
''' In the case when turn first '''
ans0 = X[0]
# 0, -1, 1, -2, ...
i = 0
j = N-1
direc = 1 # direction: left->1, right->-1
while i!=j:
    direc *= -1
    ans0 += L+X[i]-X[j]
    if direc==-1:
        i += 1
    elif direc==1:
        j -= 1
if N%2==0:
    i = N//2
    j = N//2
else:
    i = N//2
    j = N//2+1
tmp_ans = ans0
for k in range(N-1):
    tmp_ans += -L-2*X[k]+X[i]+X[j]
    if i==j:
        j += 1
    else:
        i += 1
    ans0 = max(ans0, tmp_ans)
 
 
''' Start at X[N-1] '''
''' In the case when turn first '''
ans1 = L-X[N-1]
i = 0
j = N-1
direc = -1 # direction: left->1, right->-1
while i!=j:
    direc *= -1
    ans1 += L+X[i]-X[j]
    if direc==-1:
        i += 1
    elif direc==1:
        j -= 1
if N%2==0:
    i = (N-2)//2
    j = (N-2)//2
else:
    i = (N-2)//2
    j = (N-2)//2+1
tmp_ans = ans1
for k in reversed(range(1, N)):
    tmp_ans += -L+2*X[k]-X[i]-X[j]
    if i==j:
        i -= 1
    else:
        j -= 1
    ans1 = max(ans1, tmp_ans)
 
print(max(ans0, ans1))
 

Measured memory_bytes: 11072
#include<bits/stdc++.h>
using namespace std;
int a[100000];
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    cin>>a[i];
    sort(a+1,a+n+1);
    int sum=0;
    for(int i=n;i>=n-m+1;i--)
    sum+=a[i];
    cout<<sum;
    return 0;
}

Measured memory_bytes: 256
W, H, N = map(int, input().split())
P = [list(map(int, input().split())) for _ in range(N)]

rx, uy = W, H
lx, dy = 0, 0
for v in P:
    x, y, a = v
    if a == 1:
        lx = max(lx, x)
    elif a == 2:
        rx = min(rx, x)
    elif a == 3:
        dy = max(dy, y)
    elif a == 4:
        uy = min(uy, y)
print(max(rx - lx, 0) * max(uy - dy, 0))

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<stdbool.h>
using namespace std;


int sum(int a) {
	int sum = 0;
	if (a < 10)return a;
	else {
        while (true) {
			sum += a % 10;
			if (a >= 10) a = a / 10;
			else return sum;
		}
	}

}

int main() {
	int N, A, B, num = 0;
	cin >> N >> A >> B;
	for (int i = 1;i <= N;i++) {
		if ((sum(i) >= A) && (sum(i) <= B)) num+=i;
	}
	cout << num << endl;
	return 0;
}

Measured memory_bytes: 256
from pprint import pprint
from collections import deque, defaultdict
 
n, q = list(map(int, input().strip().split(" ")))
# edges = defaultdict(set)
edges = [[] for _ in range(n)]
for _ in range(n-1):
    a_i, b_i = list(map(int, input().strip().split(" ")))
    edges[a_i-1].append(b_i-1)
    edges[b_i-1].append(a_i-1)
    # edges[a_i-1].add(b_i-1)
    # edges[b_i-1].add(a_i-1)
 
# p = defaultdict(int)
# counter = defaultdict(int)
counter = [0] * n
p = [0] * n
for _ in range(q):
    p_i, x_i = list(map(int, input().strip().split(" ")))
    # p[p_i-1] += x_i
    counter[p_i-1] += x_i
 
 
parents = deque()
# parents.append(0)
# parents = []
parents.append(0)
visited = set()
while parents:
    parent = parents.popleft()
    # parent = parents.pop()
    if parent in visited:
        continue
    visited.add(parent)
    # counter[parent] += p[parent]
    # print("parent")
    # print(parent, counter[parent])
    for child in edges[parent]:
        if child in visited:
            continue
        # if counter[child] != 0:
        #    continue
        counter[child] += counter[parent]
        # print("child")
        # print(child, counter[child])
        parents.append(child)
        # parents.add(child)
 
#print(" ".join(list(map(str, counter.values()))))
#print(" ".join(list(map(str, counter))))
print(*counter)

Measured memory_bytes: 120012
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
        String t = sc.next();
		int a = sc.nextInt();
		int b = sc.nextInt();
		String u = sc.next();
			
     	if(u.equals(s)){
          a = a-1;
        }else{
          b = b-1;
        }
  
		System.out.println(a + " " + b);
	}
}

Measured memory_bytes: 22868
#include <iostream>
#include <map>

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

// NのP乗を求める
ll RepeatSquaring(ll N, ll P, ll M){
    if(P==1) return N%M;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return (t*t) % M;
    }
    return (N * RepeatSquaring(N, P-1, M)) % M;
}

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

    ll x = RepeatSquaring(2, n, MOD) - 1;
    x %= MOD;

    ll a1 = 1;
    ll a2 = 1;
    for(long i=0; i<a; i++){
        a1 = a1 * (n-i);
        a2 = a2 * (i+1);
        a1 = a1 % MOD;
        a2 = a2 % MOD;
    }
    
    ll b1 = 1;
    ll b2 = 1;
    for(long i=0; i<b; i++){
        b1 = b1*(n-i);
        b2 = b2*(b-i);
        b1 = b1 % MOD;
        b2 = b2 % MOD;
    }

    ll A = (a1*RepeatSquaring(a2, MOD-2, MOD)) % MOD;
    ll B = (b1*RepeatSquaring(b2, MOD-2, MOD)) % MOD;

    ll t = A + B;
    t = t%MOD;
    ll ans = x + MOD - t;

    if(ans <0 ) ans = 0;
    
    cout << ans%MOD;

    return 0;
}

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

#define N 100010
#define ff first
#define ss second
#define pb push_back
#define ll long long
#define pii pair <int, int>
#define PI 3.1415926535897932384626433832795

using namespace std;

int k;
string s;
set <string> S;

int main()
{
	cin >> s >> k, k--;
	
	for(int i = 0; i < s.length(); i++) {
		string t;
		
		for(int h = i; h < i+100 && h < s.length(); h++)
			t += s[h], S.insert(t);
	}
	
	while(k--)
		S.erase(*S.begin());
	
	cout << *S.begin();
}

Measured memory_bytes: 78592
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void){
    ll a, b, c;
    cin>>a>>b>>c;
    cout<<a+b+c-max({a, b, c})<<endl;
    return 0;
}


Measured memory_bytes: 3588
import math

N, D = map(int,input().split())
List = [list(map(int,input().split())) for i in range(N)]

count = 0

for i in range(N):
    
    for k in range(i+1,N):
        sum = 0
#        print("i: {}  k: {}".format(i, k))
        for j in range(D):
#            print("list: {}  list: {}".format(List[i][j], List[k][j]))
            sum += (List[i][j] - List[k][j]) ** 2
#            print(sum)
        result = math.sqrt(sum)
#        print(result)
        if result.is_integer() == True:
            count += 1

print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
int h[110];
int n;
inline ll quickpow(ll base,int ind)
{
	ll ans=1;
	while(ind>0)
	{
		if(ind&1)ans=ans*base%MOD;
		ind>>=1;
		base=base*base%MOD;
	}
	return ans;
}
pair<ll,ll> solve(int l,int r)
{
	int minval=inf;
	for(int i=l;i<=r;i++)
		minval=min(minval,h[i]);
//	cout<<l<<" "<<r<<" "<<minval<<endl;
	int st=l;
	ll cross=2,all=1;
	for(int i=l;i<=r+1;i++)
		if(i>r||h[i]==minval)
		{
			if(i>st)
			{
				for(int j=st;j<i;j++)
					h[j]-=minval;
				pair<ll,ll> tmp=solve(st,i-1);
				cross=cross*tmp.first%MOD;
				all=all*(tmp.first+tmp.second)%MOD;
			}
			st=i+1;
			if(i<=r)all=all*2%MOD;
		}
	all=(all-cross+MOD)%MOD;
	cross=cross*quickpow(2,minval-1)%MOD;
	all=(all+cross)%MOD;
//	cout<<cross<<" "<<all<<endl;
	return make_pair(cross,all);
}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&h[i]);
	}
	printf("%lld\n",solve(0,n-1).second);
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			long a = in.nextLong(), b = in.nextLong(), h = in.nextLong();
			out.println((a + b) * h / 2);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

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

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

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

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

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

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

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////


void solve() {
	string S; cin >> S;
	S[3] = '8';
	cout << S << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

#define arr_print_d0dn(a, n) for(int i=0;i<(n);++i)printf(i==(n)-1?"%d\n":"%d ",(a)[i])

int selection_sort(int *a, const int N) {
    int cnt = 0;
    for(int i = 0; i < N; ++i) {
        int mini = i;
        for(int j = i + 1; j < N; ++j) {
            if(a[j] < a[mini]) mini = j;
        }
        if(i != mini) {
            int tmp = a[i];
            a[i] = a[mini];
            a[mini] = tmp;
            cnt++;
        }
    }
    return cnt;
}

int main() {
    int n;
    scanf("%d", &n);
    int a[n];
    for(int i = 0; i < n; ++i) scanf("%d", a + i);
    int cnt = selection_sort(a, n);
    arr_print_d0dn(a, n);
    printf("%d\n", cnt);
    return 0;
}



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

#define pi 2*acos(0)
#define INF 1e16
#define MIN 1e-9
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#define m_p make_pair
#define p_b push_back
#define n_p(a) next_permutation(all(a))
#define all(v) v.begin(),v.end()
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define rev(s) reverse(all(s))
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define mem(a,k) memset(a,k,sizeof a)
#define REP(i, a, b) for (int i = int(a); i <= int(b); i++)
#define u_b(X,V) upper_bound(X.begin(),X.end(),V)
#define l_b(X,V) lower_bound(X.begin(),X.end(),V)
#define cnt(s,c) count(all(s),c)

//bitwise helpers
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))

using namespace std;

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

    int n, k;

    cin >> n;

    int a[n], b[n], c[n];

    for(int i = 0; i < n; i++)
        cin >> a[i] >> b[i] >> c[i];

    int dp[n + 1][3];
    dp[0][0] = dp[0][1] = dp[0][2] = 0;
    dp[1][0] = a[0];
    dp[1][1] = b[0];
    dp[1][2] = c[0];

    for(int i = 2; i <= n; i++) {
        dp[i][0] = max(dp[i - 1][0], a[i - 1] + max(dp[i - 1][1], dp[i - 1][2]));
        dp[i][1] = max(dp[i - 1][1], b[i - 1] + max(dp[i - 1][0], dp[i - 1][2]));
        dp[i][2] = max(dp[i - 1][2], c[i - 1] + max(dp[i - 1][0], dp[i - 1][1]));
    }

    cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define MOD 1000000007

int main(void){
    string a,b;
    cin >> a >> b;
    int c,d;
    cin >> c >> d;
    string e;
    cin >> e;
    if(e==a) c--;
    else d--;
    cout << c << ' ' << d << endl;
}

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

int main(){
 cout << fixed<< setprecision(12);
 
 double r;
 cin>>r;

 double PI = acos(-1);
 double area = r * r * PI;
 double cir = (r + r) * PI;
 cout<<area<<" "<<cir<<endl;

 return 0;
}


Measured memory_bytes: 3260
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed;
// cout << setprecision(10) << val;

int n, m;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n >> m;
  vii p(m), k(m);
  int s[11][11];
  rep(i, 0, m) {
    cin >> k[i];
    rep(j, 0, k[i]) cin >> s[i][j];
  }
  cin >> p;
  int ans = 0;
  rep(bit, 0, (1 << n)) {
    int sum = 0;
    rep(j, 0, m) {
      int cnt = 0;
      rep(l, 0, k[j]) {
        rep(i, 0, n) {
          if ((bit >> i) & 1) {
            if (i + 1 == s[j][l]) cnt++;
          }
        }
      }
      if (cnt % 2 == p[j]) sum++;
    }
    if (sum == m) ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int n;
int x[100],y[100];
double solve() {

    double s = 0.0;
    rep(i,n) cin>>x[i]>>y[i];
    x[n]=x[0];
    y[n]=y[0];

    rep(i,n) {
        s+=x[i]*y[i+1]-x[i+1]*y[i];
    }

    return s/2.0;
}
int main() {
    int cnt=1;
    while(cin>>n) {
        if(n==0) break;
        double s = solve();
        printf("%d %.1f\n", cnt,-s);
        cnt++;
    }
    return 0;
}

Measured memory_bytes: 1192
package main

import "fmt"

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	s := make([]string, h)
	for i := 0; i < h; i++ {
		fmt.Scan(&s[i])
	}

	a := make([]string, h)
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if s[i][j] == '#' {
				a[i] += "#"
				continue
			}

			c := 0
			for y := -1; y <= 1; y++ {
				if i+y < 0 || i+y > h-1 {
					continue
				}
				for x := -1; x <= 1; x++ {
					if j+x < 0 || j+x > w-1 {
						continue
					}
					if s[i+y][j+x] == '#' {
						c++
					}
				}
			}

			a[i] += fmt.Sprintf("%d", c)
		}
	}

	for _, r := range a {
		fmt.Println(r)
	}
}


Measured memory_bytes: 640
h, w, k = map(int, input().split())
c = []
for _ in range(h):
    c.append(input())

ans = 0
for mask_h in range(2**h):
    for mask_w in range(2**w):
        ctr = 0
        for i in range(h):
            for j in range(w):
                if((mask_h >> i) &1) ==0 and ((mask_w >> j) &1) ==0 \
                    and c[i][j]=='#':
                    ctr +=1
        if ctr == k:
            ans+=1

print(ans)

Measured memory_bytes: 9140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=100010;
int A,B,n,C,l[10];
int solve(int idx,int a,int b,int c)
{
  if(idx==n)
  {
    if(!a || !b || !c) return 80000;
    return abs(a-A)+abs(b-B)+abs(c-C);
  }
  int res=solve(idx+1,a,b,c);
  res=min(res,solve(idx+1,a+l[idx],b,c)+(a?10:0));
  res=min(res,solve(idx+1,a,b+l[idx],c)+(b?10:0));
  res=min(res,solve(idx+1,a,b,c+l[idx])+(c?10:0));
  return res;
}
int main()
{
  cin>>n>>A>>B>>C;
  for(int i=0;i<n;i++) cin>>l[i];
  cout<<solve(0,0,0,0)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iomanip>
#include<cstdio>
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

typedef long double ll;
typedef pair<ll,ll> pll;
vector<pll> list;
pll operator-(pll a,pll b){
  return pll(a.first-b.first,a.second-b.second);
}

ll dist(pll a){
  return sqrt(a.first*a.first + a.second*a.second);
}

ll cal(pll a,pll b,pll c){
  ll ab = dist(a-b);
  ll bc = dist(b-c);
  ll ca = dist(c-a);
  ll z = (ab+bc+ca)/2;
  return sqrt(z*(z-ab)*(z-bc)*(z-ca));
}

ll solve(){
  ll ans=0;
  for(int i=2;i<list.size();i++){
    ans+=cal(list[0],list[i-1],list[i]);
  }
  return ans;
}
int main(){
  char c;
  ll x,y;
  while(cin>>x>>c>>y){
    list.push_back(pll(x,y));
  }
  cout<<solve()<<endl;
}

Measured memory_bytes: 1292
N, M = map(int, input().split())

AB = sorted(
  [ list(map(int, input().split())) for _ in range(N) ],
  key = lambda x : x[0]
)

ans = 0
for a, b in AB:
  if M <= b:
    ans += a * M
    break
  ans += a * b
  M -= b
print(ans)

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

using namespace std;
vector<vector<long long> >v(1002,vector<long long>(100006,-1));
/**long long sol(int idx=0,long long ttlw=0){
    if(idx==n)
        return 0;
    if(v[idx][ttlw]!=-1)
        return v[idx][ttlw];
    if(ttlw+wt[idx]>w)
        return v[idx][ttlw]=sol(idx+1,ttlw);
    return v[idx][ttlw]=max(vl[idx]+sol(idx+1,ttlw+wt[idx]),sol(idx+1,ttlw));
}
*/
int main()
{
    long long n,w;
    cin>>n>>w;
    long long wt[n+1],vl[n+1];
    for(int i=0;i<n;i++){
        cin>>wt[i]>>vl[i];
    }
    long long dp[n+1][w+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=w;j++){
            if(i==0||j==0)
                dp[i][j]=0;
            else if(wt[i-1]<=j)
                dp[i][j]=max(dp[i-1][j],vl[i-1]+dp[i-1][j-wt[i-1]]);
            else
                dp[i][j]=(dp[i-1][j]);
        }
    }

    cout << dp[n][w] << endl;
    return 0;
}


Measured memory_bytes: 864752
#include<bits/stdc++.h>
using namespace std;
int main()
{
 double a,b,c,d;
 long long aa,bb;
 cin>>aa;
 bb=aa;
 if(aa%2==1)
 {bb=aa/2+1;
 cout<<fixed<<setprecision(10)<<(double)bb/(double)aa;

 }
else
 {bb=aa/2;
 cout<<(double)bb/(double)aa;

 }


}


Measured memory_bytes: 256
s = list(input())
t = list(input())
 
ans = float('inf')
for i in range(0,len(s)-len(t)+1):
    count = 0
    for j in range(len(t)):
        if s[i+j] != t[j]:
            count += 1
    ans = min(ans,count)
print(ans)

Measured memory_bytes: 80924
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 1000000007
using namespace std;

int main(){
    FASTIO
    int n;
    cin >> n;
    int a[n], b[n];
    rep(i, 0, n){
    	cin >> a[i];
    	b[i] = a[i];
    }
    sort(b, b + n);
    int c = 0;
    rep(i, 0, n){
    	if(a[i] != b[i])
    	c++;
    }
    if(c > 2)
    cout << "NO";
    else
    cout << "YES";
    return 0;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

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

    char now;
    ll ans = 0;
    ll cnt = 0;

    // 頭から
    now = s.at(0);
    REP(i, s.size()) {
        if (s.at(i) != now) {
            now = s.at(i);
            cnt++;
        }
    }
    ans = cnt;

    // 尾から
    now = s.at(s.size() - 1);
    cnt = 0;
    for (int i = s.size() - 1; i >= 0; --i) {
        if (s.at(i) != now) {
            now = s.at(i);
            cnt++;
        }
    }

    ans = min(ans, cnt);
    MSG(ans)

    return 0;
}


Measured memory_bytes: 512
a,b,c,d=map(int,input('').split(' '))
k=[]
k.append(a*c)
k.append(a*d)
k.append(b*c)
k.append(b*d)

ma=-10000000000000000000000000000000
for i in range(4):
    if ma<k[i]:
        ma=k[i]

print(ma)

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

int main(){
  int a[4];
  for(int i=0;i<4;i++)cin>>a[i];
  sort(a,a+4);
  if(a[0]==a[1]&&a[2]==a[3])cout<<"yes"<<endl;
  else cout<<"no"<<endl;
  return 0;
}

Measured memory_bytes: 3140
n = int(input())
s = input()

# total number of pairs fullfilling first condition 
r = s.count('R')
g = s.count('G')
b = len(s) - r - g
total = r*g*b

# j-i = k-j
for p in range(1, (n-1)//2 + 1):
    for i in range(0, n-(2*p)):
        si, sj, sk = s[i], s[i+p], s[i+2*p]
        if si != sj and sj != sk and sk != si:
            total -=  1
print(total)

Measured memory_bytes: 9244
N,Y = map(int, input().split())
S=[Y//10000,(Y%10000)//5000,((Y%10000)%5000)//1000]
flag=0

for x in range(Y//10000+(Y%10000)//5000+1):
	if sum(S) == N:
		flag = 1
		break
	elif sum(S)+9<=N and S[0]>0:
		S[0] -=1
		S[2] +=10
	elif sum(S)+4<=N and S[1]>0:
		S[1] -=1
		S[2] +=5
	elif sum(S)+1<=N and S[0]>0:
		S[0] -=1
		S[1] +=2
		
if flag ==1:
	print(S[0],S[1],S[2])
else:
	print(-1,-1,-1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool srt( pair < int , int > a, pair < int , int > b){
    return a.first != b.first ? a.first>b.first : a.second<b.second;
}
const ll oo=1e18;
int dx[8]={1,-1,0,0,1,-1,-1,1};
int dy[8]={0,0,1,-1,1,-1,1,-1};
const int N = 100050;

int main(){
    
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b>=c){
        puts("Yes");
    }
    else puts("No");
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int n,m,l,r;
    cin >> n >> m;
    cin >> l >> r;
    int xl = l,xr = r;
    for(int i = 1;i < m;i++){
        cin >> l >> r;
        if(xl < l){ xl = l; }
        if(xr > r){ xr = r; }
    }
    if(xl > xr){
        cout << 0 << endl;
    }else{
        cout << (xr - xl + 1) << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair < int , int > pii;
#define mpr make_pair
#define FS first
#define SC second
#define PB push_back
template < typename T > T MAX(T a,T b){return (a>b)?a:b;}
template < typename T > T MIN(T a,T b){return (a<b)?a:b;}
template < typename T > void UMAX(T &a,T b){a=(a>b?a:b);}
template < typename T > void UMIN(T &a,T b){a=(a<b?a:b);}
LL readint(){
	char c=getchar();
	LL ret=0ll;
	while(!(c>='0' && c<='9')) c=getchar();
	while(c>='0' && c<='9'){
		ret=ret*10ll+(LL)(c-'0');
		c=getchar();
	}
	return ret;
}
void putint(LL v){
	if(!v){
		putchar('0');
		return;
	}
	if(v>=10ll) putint(v/10ll);
	putchar('0'+(v%10ll));
}
const int inf=(int)1e9;
int n,dist[505][505];
bool dead[505][505];
const int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
void bfs(vector < pii > ss,vector < int > idis){
	int i,j,k;
	deque < pii > Q;
	for(i=0;i<(int)ss.size();++i){
//		if(idis[i]<dist[ss[i].FS][ss[i].SC]){
			dist[ss[i].FS][ss[i].SC]=idis[i];
			Q.push_back(ss[i]);
//		}
	}
	while(!Q.empty()){
		int x=Q.front().FS,y=Q.front().SC,d=dist[x][y]+!dead[x][y];
		Q.pop_front();
		for(i=0;i<4;++i){
			int nx=x+dx[i],ny=y+dy[i];
			if(nx>=0 && nx<n && ny>=0 && ny<n && d<dist[nx][ny]){
				dist[nx][ny]=d;
				if(dead[x][y])
					Q.push_front(mpr(nx,ny));
				else
					Q.push_back(mpr(nx,ny));
			}
		}
	}
}
int main(){
	int i,j,k;
	n=readint();
	for(i=0;i<n;++i)
		fill(dist[i],dist[i]+n,inf);
	vector < pii > iniss;
	vector < int > inids;
	for(i=0;i<n;++i){
		for(j=0;j<n;++j){
			if(!i || i==n-1 || !j || j==n-1)
				iniss.push_back(mpr(i,j)),inids.push_back(0);
		}
	}
	bfs(iniss,inids);
	LL res=0;
	for(i=0;i<n*n;++i){
		int v=readint()-1,x=v/n,y=v%n;
		res+=dist[x][y];
//		printf("(%d,%d) %d\n",x,y,dist[x][y]);
		iniss.assign(1,mpr(x,y));
		inids.assign(1,dist[x][y]);
		dead[x][y]=1;
		bfs(iniss,inids);
	}
	printf("%lld\n",res);
	return 0;
}


Measured memory_bytes: 5820