akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.lang.*;
  
public class Main{
  public static void main(String[] args){
    Scanner stdIn=new Scanner(System.in);
    int i=0,count=0;
    int a=stdIn.nextInt();
    int b=stdIn.nextInt();
    int c=stdIn.nextInt();
    for(i=a;i<=b;i++){
	if (c%i==0){
	    count++;
	}
    }
    System.out.println(count);
  }
}



Measured memory_bytes: 26356
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
vector<pair<long,int>> vp;
void factorization(long n){// O(\sqrt{n})
	vp.clear();
	rep(i,2,(int)sqrt(n)+1){
		if(n % i == 0){
			int cnt = 0;
			while(n % i == 0){
				cnt++;
				n /= i;
			}
			vp.push_back({i,cnt});
		}
	}
	if(n > 1) vp.push_back({n,1});
	return;
}
int main(){
	long N,P;cin>>N>>P;
	factorization(P);
	long res = 1;
	for(pair<long,int> p:vp){
		res *= pow(p.first, p.second / N);
	}cout<<res<<endl;
}

Measured memory_bytes: 256
l=int(input())
# n<=20
# m<=60
# l<=10**6
n=l.bit_length()
abc=[]
v=1
now=0
while l>1:
    if l%2==1:
        abc.append((v,n,l-1))
    abc.append((v,v+1,0))
    abc.append((v,v+1,l//2))
    now+=1
    v+=1
    l//=2
print(n,len(abc))
for u,v,c in abc:
    print(u,v,c)


Measured memory_bytes: 9196
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int a,b,c;
        cin >> a >> b >> c;
        int ans = c / a * b;
        cout << ans << endl;

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n; i>=0; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e10
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<lli>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using lli = long long int;
template<typename T> bool chmax(T &a, T &b){ if(a<b) { a=b; return 1; }}
template<typename T> bool chmin(T &a, T &b){ if(b<a) { a=b; return 1; }}
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T arrdebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    lli n, k, buf;
    vector<lli> h;
    cin >> n >> k;
    rep(i, n){
        cin >> buf;
        h.push_back(buf);
    }

    vsort(h);
    lli dp[100001];

    lli l=0, r=k-1;
    lli i=0;
    while(r < n){
        dp[i] = h[r] - h[l];
        r++; l++;
        i++;
    }

    lli ans = inf;
    rep(i, n-k+1){
        ans = min(ans, dp[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1908
#include<iostream>
#include <cmath>
#include <string>
#include <iomanip>

#define loop(k) for(int i=0;i<k;i++)
#define looop(k) for(int j=0;j<k;j++)
#define swap(a,b) a^=b^=a^=b;

using namespace std;

int main(){
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    int pay=0;
    loop(n){
        if(i<k){
            pay+=x;
        }else{
            pay+=y;
        }
    }
    cout<<pay<<endl;
}

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

typedef long long ll;
#define ll int
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 100001
#define int ll
string S,T;

int numS[maxn][26];
int N,M;

int _min(int i,int j){
	if (i == -1) return j;
	if (j == -1) return i;
	return min(i,j);
}
int32_t main(){
	fast;
	
	cin>>S>>T;
	
	int N = S.size(), M = T.size();
	
	mem(numS,-1);
	DEC(i,N-1,0){
		numS[i][(int)S[i] - 97] = _min(numS[i][(int)S[i] - 97], i);
		if (i < N-1) FOR(j,0,25) numS[i][j] = _min(numS[i][j], numS[i+1][j]);
	}
	
	int curstr = 0, curidx = 0;
	
	aFOR(i,T){
		if (numS[curidx][(int)i - 97] == -1){
			if (numS[0][(int)i - 97] == -1){
				cout<<-1;
				return 0;
			}
			curstr++;
			curidx = 0;
		}
		
		curidx = numS[curidx][(int)i - 97] + 1;
		if (curidx == S.size()){
			curidx = 0; curstr++;
		}
	}
	
	cout<<curstr * (ll)S.size() + curidx;
	
	
	
	
}



Measured memory_bytes: 13940
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
 
}
void solve()
{
	int n, m;
	cin >> n >> m;
	vector<pii> p(m);
	int ans = 0;
	rep(i, m) cin >> p[i].F >> p[i].S;
	rep(i, m){
		vector<vector<int> > g(n + 1);
		rep(j, m){
			if(i == j) continue;
			g[p[j].F].pb(p[j].S);
			g[p[j].S].pb(p[j].F);
		}
		queue<int> q;
		int cnt = 0;
		q.push(1);
		vector<int> u(n + 1);
		u[1] = 1;
		while(!q.empty()){
			int x = q.front();
			q.pop();
			++cnt;
			for(int to : g[x]){
				if(!u[to]){
					q.push(to);
					u[to] = 1;
				}
			}
		}
		ans += (cnt != n);
	}
	cout << ans;
}	 

 
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}


Measured memory_bytes: 3632
import sys

def sumdigit(val):
  res = 0
  for v in str(val):
    res += int(v)
  return res

N = int(sys.stdin.readlines()[0].strip())
min_val = sys.maxsize
for a in range(1, N):
  b = N - a
  cur_val = sumdigit(a) + sumdigit(b)
  if min_val > cur_val:
    min_val = cur_val
print(min_val)

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"strconv"
)

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

const INF = 1000000000

func main() {
	//sc = bufio.NewScanner(os.Stdin)
	//sc.Split(bufio.ScanWords)
	//n := nextInt()
	var s string
	fmt.Scan(&s)
	switch {
	case s[0:1] == s[1:2]:
		fmt.Println("Bad")
	case s[1:2] == s[2:3]:
		fmt.Println("Bad")
	case s[2:3] == s[3:4]:
		fmt.Println("Bad")
	default:
		fmt.Println("Good")
	}
}


Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = decimal.Parse(Console.ReadLine());
        decimal[] a = Console.ReadLine().Split().Select(decimal.Parse).ToArray();

        decimal diff = decimal.MaxValue;
        decimal x = 0;
        decimal y = 0;
        Array.Sort(a);
        if (a.Length == 2)
        {
            x = Math.Max(a[0], a[1]);
            y = Math.Min(a[0], a[1]);
        }
        else
        {
            for (int i = 0; i < a.Length-1; i++)
            {
                var max = a[a.Length - 1];
                var tmp = Math.Abs(max / 2 -a[i]); 
                if (diff > tmp)
                {
                    diff = tmp;
                    x = max;
                    y = a[i];
                }
            }
        }

        // 出力
        Console.WriteLine("{0} {1}", x, y);
    }
}

Measured memory_bytes: 38920
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
using ll = long long;


int main(){
    string str;
    ll ans=0;
    cin >> str;
    for(int i=1;i<str.size();i++){
        if(str[i-1]!=str[i])    ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <list>
#include <string>
#include <math.h>

using namespace std;





int main() {
	int ans = 0;
	int n, m;
	int k[10];
	int s[10][10];

	int lump[10];

	cin >> n >> m;

	int checktype = pow(2, n);


	for (int i = 0; i < m; i++) {
		cin >> k[i];

		for (int j = 0; j < k[i]; j++) {
			cin >> s[i][j];
		}
	}

	int p[10];

	for (int i = 0; i < m; i++) {
		cin >> p[i];
	}



	bool unko;
	for (int lumptype = 0; lumptype < checktype; lumptype++) {
		unko = true;
		int wk = lumptype;

		for (int i = 0; i < n; i++) {
			lump[n - 1 - i] = wk % 2;
			wk /= 2;
		}

		for (int i = 0; i < m; i++) {
			int goukei = 0;

			for (int j = 0; j < k[i]; j++) {
				goukei += lump[s[i][j]-1];
			}

			if (goukei % 2 == p[i]) {
			
				//正常

			}
			else {
				unko = false;
				break;
				//次のランプタイプに行く。
			}

		}
		//全部正常だったらこれ
		if (unko) {
			ans++;
		}


	}

	cout << ans << endl;




	return 0;




}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>

#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>

// namespace
using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

// constant
static const ll MOD = 1000000007LL;
static const double PI = 3.14159265358979323846;

// conversion
inline ll toint(string s) { ll v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// print
#define RET(x) return cout << x << endl, 0;

// for loop
#define REP(i, a, b) for ((i) = (ll)(a);(i) < (ll)(b);(i)++)
#define REPD(i, a, b) for (ll i = (ll)(a);(i) < (ll)(b);(i)++)
#define REPI(v, vs) for (auto& v : vs)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __LINE__ << ")" << " " << __FILE__ << endl

#define MAX_VALUE 9223372036854775807

ll calc_dps(
	ll r, ll c, ll row_item_count,
	vector<vector<vector<ll>>>& dps,
	const vector<vector<ll>>& items)
{
	if (r < 0) return 0;
	if (c < 0) return 0;
	if (row_item_count < 0) return 0;
	if (dps[r][c][row_item_count] != -1) return dps[r][c][row_item_count];

	ll res = 0;
	if (items[r][c] == 0) {
		res = max(res, calc_dps(r - 1, c, 2, dps, items));
		res = max(res, calc_dps(r, c - 1, row_item_count, dps, items));
	}
	else
	{
		res = max(res, calc_dps(r - 1, c, 2, dps, items) + items[r][c]);
		res = max(res, calc_dps(r, c - 1, row_item_count, dps, items));
		if (row_item_count > 0) {
			res = max(res, calc_dps(r, c - 1, row_item_count - 1, dps, items) + items[r][c]);
		}
	}
	dps[r][c][row_item_count] = res;

	return dps[r][c][row_item_count];
}

int solve() {
	ll R, C, K;
	cin >> R >> C >> K;
	
	vector<vector<ll>> items(R, vector<ll>(C));
	ll r, c, v;
	REPD(i, 0, K) {
		cin >> r >> c >> v;
		--r, --c;
		items[r][c] = v;
	}

	vector<vector<vector<ll>>> dps(R, vector<vector<ll>>(C, vector<ll>(3, -1)));
	RET(calc_dps(R - 1LL, C - 1LL, 2LL, dps, items));

	return 0;
}

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

	solve();
	// ll t;
	// cin >> t;
	// REPD(i, 0, t) solve();

	return 0;
}


Measured memory_bytes: 566364
N,A,B = list(map(int,input().split()))
S = str(input())
count = 0
abcount = 0
for i in range(len(S)):
    if S[i] == "c":
        print("No")
    elif S[i] == "a":
        if count < A+B:
            count += 1
            print("Yes")
        else:
            print("No")
    else:
        if count < A + B and abcount < B:
            abcount += 1
            count += 1
            print("Yes")
        else:
            print("No")

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

const int N = 100010;
vector<int> G[N];
vector<int> D(N);
vector<int> B(N);

void dfs(int now){
    for(auto x: G[now]){
        int to = x;
        if(D[to] > D[now] + 1){
            D[to] = D[now] + 1;
            B[to] = now + 1;
            dfs(to);
        }
    }
}

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

    int n, m;
    cin >> n >> m;
    while(m--){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    for(int i = 0; i < N; i++){
        D[i] = 1e9;
    }
    D[0] = 0;
    B[0] = -1;

    queue<int> q;
    q.push(0);
    while(!q.empty()){
        int now = q.front();
        q.pop();
        for(auto x: G[now]){
            int to = x;
            if(D[to] > D[now] + 1){
                D[to] = D[now] + 1;
                B[to] = now + 1;
                q.push(to);
            }
        }
    }

    dfs(0);

    cout << "Yes" << endl;
    for(int i = 1; i < n; i++){
        cout << B[i] << endl;
    }


    return 0;
}

Measured memory_bytes: 10680
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include<iomanip>

using namespace std ;

const int N = 800 + 5;
const int inf = 1e9 + 20;
int n, m, k;
char a[N][N];

int sx, sy;
int ans = inf;
int d[N][N];
queue < pair<int, int> > q;

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

void bfs(int sx, int sy)
{
	d[sx][sy] = 0;
	q.push({sx, sy});
	while (q.size())
	{
		int vx = q.front().first;
		int vy = q.front().second;
		q.pop();
		if (vx == 0 || vx == n - 1 || vy == 0 || vy == m - 1)
		{
			cout << 1;
			exit(0);
		}
		int res = min({vx, n - 1 - vx, vy, m - 1 - vy});
		ans = min(ans, 1 + (res + k - 1) / k);
		if (d[vx][vy] == k) 
		{
			continue;
		}
		for (int i = 0; i < 4; i++)
		{
			int ux = vx + dx[i];
			int uy = vy + dy[i];
			if (a[ux][uy] != '#' && d[vx][vy] + 1 < d[ux][uy])
			{
				d[ux][uy] = d[vx][vy] + 1;
				q.push({ux, uy});
			}
		}
	}
}

int main()
{
	cin >> n >> m >> k;	
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			d[i][j] = 1000000000;
			cin >> a[i][j];
			if (a[i][j] == 'S')
			{
				sx = i;
				sy = j;
			}
		}
	}
	bfs(sx, sy);
	cout << ans << endl;
}


 


Measured memory_bytes: 3456
def main():
    n=int(input())
    s_list=[]
    for i in range(n):
        city,score=input().split(' ')
        s_list.append((score,city,i+1))
    s_list=sorted(s_list,key=lambda s_list: int(s_list[0]),reverse=True)
    s_list=sorted(s_list,key=lambda s_list: s_list[1])
    for i in s_list:
        print(i[2])

if __name__=='__main__':
    main()

Measured memory_bytes: 3060
N = int(input())
A = list((input().split(" ")))

values = []
for i in range(N):
    values.append(int(A[i]))


suffixSumArray = values.copy()



for i in range(N-2,-1,-1):
    suffixSumArray[i] = suffixSumArray[i+1] + suffixSumArray[i]



sum = 0
for i in range(N-1):
    sum += (values[i] * suffixSumArray[i+1])

print(sum % (10 ** 9 + 7))

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

int main(){
    int a[5], ans;
    for (int i = 0; i < 5; ++i){
        cin >> a[i];
        if (a[i] == 0) ans = i + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
#define int ll

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];
    vector<ll> sub(n), plus(n);
    ll ans = 0;
    map<ll,ll> mp;
    rep(i,n)sub[i] = i - h[i];   
    rep(i,n)plus[i] = i + h[i];
    rep(i,n){
        ans += mp[sub[i]];
        mp[plus[i]]++;
    }

    cout << ans << endl;
}

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

#[allow(unused_macros)]
macro_rules! chmin {
    ( $ x : expr , $ y : expr ) => {
        if $ x > $ y {
            $ x = $ y;
            true
        } else {
            false
        }
    };
}

fn main() {
    input! {
        p: u64, q: u64, r: u64
    }

    let mut ret = 1u64 << 60;
    chmin!(ret, p+q);
    chmin!(ret, q+r);
    chmin!(ret, p+r);
    println!("{}", ret);
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;
map<string, int> s;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    string tmp;
    cin >> tmp;
    if (s[tmp] == 0) {
      s[tmp] = 1;
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 18768
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())
#define maxIndex(v) max_element(v.begin(), v.end()) - v.begin()
#define maxElement(v) *max_element(v.begin(), v.end())
#define minIndex(v) min_element(v.begin(), v.end()) - v.begin()
#define minElement(v) *min_element(v.begin(), v.end())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
using namespace std;

int main()
{
  ll N; cin >> N;
  vector<pair<ll, ll>> X(N);
  vector<ll> med(N);
  rep(i, 0, N) {
  	ll a; cin >> a;
    X[i] = make_pair(a, i);
  }
  vsort(X);
  rep(i, 0, N) {
  	if (i < N / 2) {
    	med[X[i].second] = X[N / 2].first;
    } else {
    	med[X[i].second] = X[N / 2 - 1].first;
    }
  }
  rep(i, 0, N) {
  	cout << med[i] << endl;
  }
}

Measured memory_bytes: 6912
n, a, b = map(int, input().split())
if (a + b) % 2 == 0:
    print((b - a) // 2)
else:
    if a - 1 < n - b:
        x = a - 1 + 1
        b = b - (a - 1)
        a = 1
    else:
        x = n - b + 1
        a = a + n - b
        b = n
    print((b - a) // 2 + x)


Measured memory_bytes: 2940
import math

def hcfnaive(a, b):
    if (b == 0):
        return a
    else:
        return hcfnaive(b, a % b)

def gcd(a, b, c):
    return hcfnaive(a, hcfnaive(b, c))

##def gcd(a, b, c, cnt):
  ##  i = 0
    ####  i = i + 1
        ##if len(list(filter(is_prime, [a, b, c]))) == 0:
          ##  if (a % i == 0) and(b % i == 0) and (c % i == 0):
            ##    return gcd(a / i, b / i, c / i, cnt * i)
        ##else:
          ##  return cnt

def is_prime(n):
    if n % 2 == 0 and n > 2:
        return False
    return all(n % i for i in range(3, int(math.sqrt(n)) + 1, 2))

ans = 0
k = int(input())
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans = ans + gcd(a, b, c)

print(ans)

Measured memory_bytes: 81632
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
/*
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};
*/
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

//デバッグ
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}


//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; 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;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}


ll N, A, B, C;

void solve(){
  ll ans = 0;
  ll h = inverse(100);
  ll p = 100 * inverse(A + B) % MOD;
  //T-win
  for(ll M = 0; M < N; M++){
    ans += comb(N+M-1, N-1) * pow_mod(A * inverse(A + B) % MOD, N) % MOD * pow_mod(B * inverse(A + B) % MOD, M) % MOD * (p * (N+M) % MOD) % MOD;
    ans %= MOD;
  }

  swap(A, B);
  //A-win
  for(ll M = 0; M < N; M++){
    ans += comb(N+M-1, N-1) * pow_mod(A * inverse(A + B) % MOD, N) % MOD * pow_mod(B * inverse(A + B) % MOD, M) % MOD * (p * (N+M) % MOD) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}

int main(){
  COMinit();
  cin >> N >> A >> B >> C;
  solve();
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define Int long long
#define rep(i,n) for(int i=0; i<n; ++i)
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  int N,K,X,Y;
  cin >> N >> K >> X >> Y;
  int ans = 0;
  rep(i,N) {
    if(i<K) ans += X;
    else ans += Y;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	string o, e;
	cin >> o >> e;
	rep(i, e.size())cout << o[i] << e[i];
	if (o.size() > e.size())cout << o[o.size() - 1];
	cout << endl;

}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double ang1 = ((h + m / 60.0) / 12.0) * 2.0 * M_PI;
    double ang2 = (m / 60.0) * 2.0 * M_PI;
    if (ang1 < ang2) swap(ang1, ang2);
    double angdiff = ang1 - ang2;
    if (angdiff > M_PI) angdiff = 2 * M_PI - angdiff;

    double ans = sqrt(a * a + b * b - 2.0 * a * b * cos(angdiff));

    printf("%.15f\n", ans);

    return 0;
}


Measured memory_bytes: 4144
#include <stdio.h>

int main()
{
	int N,a;
	float b;
	scanf("%d", &N);	
	for (int i = 1; i <= 9; i++)
		{
			a = N % i;
			b = N / i;
			if (a == 0)
			{
				if (b <= 9)
				{
					printf("Yes");
					return 0;
				}
			}
		}
			printf("No");
			return 0;
}

Measured memory_bytes: 128
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
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 end

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll r, g, b;
    in >> r >> g >> b;
    ll num = r * 100 + g * 10 + b;
    if(num % 4 == 0){
        out << "YES" << endl;
    }else{
        out << "NO" << endl;
    }
}


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

int main(void) {
    string str;
    int m, h;

    while (true) {
        cin >> str;
        if (str == "-") break;

        cin >> m;
        for (int i = 0; i < m; i++) {
            cin >> h;
            str = str.substr(h, str.size() - h) + str.substr(0, h);
        }
        cout << str << endl;
    }

    return 0;
} 

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
const int MOD=1000000007;

int main() {
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  map<int,int>k;
  for(int i=0;i<N;i++){
    k[a[i]+1]++;
    k[a[i]]++;
    k[a[i]-1]++;
  }
  int m=0;
  for(auto c:k){
    if(c.second>m){m=c.second;}
  }
  cout<<m<<endl;
  return 0;
}

Measured memory_bytes: 7876
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int h, w, k;
const int BUBEN = 1e5 + 10;
int f(int x, int y) {
    return __gcd(x, y) + 1;
}
const int maxN = 1e5 + 10;
vector < int > f1[maxN], f2[maxN];
int pp[maxN];
ll solve(int h, int w, int k) {
    ll ans = 0;
    k *= 2;
    for (int i = 0; i < maxN; i++) {
        pp[i] = __gcd(i, h);
    }
    for (int a = 1; a < h; a++) {
        vector < int > d1;
        vector < int > d2;
        for (int b = 1; b < w; b++) {
            if ((h - a) * b > k + BUBEN) break;
            d1.emplace_back((h - a) * b - f(a, b));
        }
        int max_b = d1.size();
        for (int c = 1; c < w; c++) {
            if (c * a > k + BUBEN) break;
            d2.emplace_back(c * a - f(h - a, c));
        }
        int max_c = d2.size();
        int t = max(max_b, max_c);
        for (int i = 0; i <= t; i++) {
            f1[i % h].clear();
            f2[i % h].clear();
        }
        for (int i = 1; i <= max_b; i++) {
            f1[i % h].emplace_back(d1[i - 1]);
        }
        for (int i = 1; i <= max_c; i++) {
            f2[i % h].emplace_back(d2[i - 1]);
        }
        for (int i = 0; i <= min(h - 1, max_b); i++) {
            sort(f1[i].begin(), f1[i].end());
            if (f1[i].empty()) continue;
            for (int j = 0; j <= min(h - 1, max_c); j++) {
                if (f2[j].empty()) continue;
                if (i == 1) sort(f2[j].begin(), f2[j].end());
                int d = pp[abs(i - j)];
                int lim = k - 4 + d;
                int ptr = f2[j].size() - 1;
                for (int x = 0; x < f1[i].size(); x++) {
                    while (ptr >= 0 && f1[i][x] + f2[j][ptr] > lim) ptr--;
                    ans += (ptr + 1);
                }
            }
        }
    }
    return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> h >> w >> k;
    cout << 2 * solve(h, w, k) + 2 * solve(w, h, k);
    return 0;
}


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


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define lint long long
#define pb(a) push_back(a)

const int INF = 1e9;
const int MOD = 1e9+7;
const lint LINF = 1e18;

using namespace std;

int n,x;
lint ans;
int a[200000];

int main(){
  cin >> n >> x;
  FOR(i,n) cin >> a[i];
  lint now;

  FOR(i,n-1){
    if(a[i]+a[i+1]<=x) continue;
    if(a[i]<x){
      ans += a[i]+a[i+1]-x;
      a[i+1] -= a[i]+a[i+1]-x;
    }
    else{
      ans += a[i+1]+(a[i]-x);
      a[i+1] = 0;
      a[i] = x;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
ostream &operator<<(ostream &out, vector<T> const &v) {
    for (auto &&a : v) out << a << " ";
    out << endl;
    return out;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int N, M, X;
    cin >> N >> M >> X;

    vvi a(N, vi(M + 1));
    REP(i, N) {
        REP(j, M + 1) {
            cin >> a[i][j];
        }
    }

    int min = 1000000007;
    for (int i = 1; i < (1 << N); ++i) {
        vi b(M);
        int sum = 0;
        REP(j, N) {
            if (!(i & (1 << j))) {
                continue;
            }

            sum += a[j][0];
            debug(sum);

            REP(l, M) {
                b[l] += a[j][l + 1];
            }
        }
        bool isCompleted = true;
        REP(j, M) {
            if (b[j] < X) {
                isCompleted = false;
                break;
            }
        }
        if (!isCompleted) {
            continue;
        }

        debug("chmax", sum);
        chmin(min, sum);
    }
    if (1000000007 == min) {
        min = -1;
    }
    cout << min;
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 3664
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();

        int[][] cs = new int[h + 2][w + 2];
        for (int i = 0; i < h; i++) {
            Arrays.fill(cs[i + 1], 0);
            String s = sc.next();
            for (int j = 0; j < w; j++) {
                if (s.charAt(j) == '#') {
                    cs[i + 1][j + 1] = 1;
                } else {
                    cs[i + 1][j + 1] = 0;
                }
            }
        }

        for (int i = 1; i < h + 1; i++) {
            for (int j = 1; j < w + 1; j++) {
                if (cs[i][j] == 1) {
                    System.out.print('#');
                } else {
                    int total = cs[i - 1][j - 1] + cs[i - 1][j] + cs[i - 1][j + 1] + cs[i][j - 1] + 
                    cs[i][j + 1] + cs[i + 1][j - 1] + cs[i + 1][j] + cs[i + 1][j + 1];
                    System.out.print(total);
                }
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 24276
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
#include <bitset>
#include <string>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)


ll modpow(ll x, ll n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        ll h = modpow(x, n / 2);
        return h * h % MOD;
    } else {
        return x * modpow(x, n - 1) % MOD;
    }
}

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

int main() {
    int A, B; cin >> A >> B;
    string ans = ":(";
    if(max(A, B) <= 8) ans = "Yay!";
    cout << ans << endl;
    return 0;
}


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

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

    vector<int> x(n);
    for (int i=0; i<n; i++) {
        cin >> x.at(i);
    }

    int ans = 1000000000, tmpans=0;

    for (int i=1; i<101; i++) {
        tmpans = 0;
        for (int j=0; j<n; j++) {
            tmpans += (i-x.at(j))*(i-x.at(j));
        }
        if (ans > tmpans) ans = tmpans;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String srgs[]) {
		String str;
		String ans = "";
		int l, i;
		char c;
		Scanner sc = new Scanner(System.in);
		str = sc.nextLine();
		l = str.length();
		for (i = 0; i < l; ++i) {
			c = str.charAt(i);
			if (c >= 'a' && c <= 'z') {
				c = Character.toUpperCase(c);
			} else {
				c = Character.toLowerCase(c);
			}
			ans = ans + c;
		}
		System.out.println(ans);
		sc.close();
	}

}


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



// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    string a;
    cin >> a;
    std::smatch smatch;
    if (std::regex_search(a, smatch, std::regex("[A-Z]"))){
        cout << "A" << endl;
    }else{
        cout << "a" << endl;
    }
}


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

#define int long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vvi vector<vi>
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    int n;
    cin >> n;
    vi a(n);
    ffor(i,n){
        cin >> a[i];
        a[i] = a[i] - i;
    }
    sort(all(a));
    int ans = 0;
    int mid = n/2;
    ffor(i,n){
        ans += abs(a[mid] - a[i]);
    }
    cout << ans;
}

Measured memory_bytes: 1792
#include <iostream>
#include <assert.h>
#include <algorithm>
#include <cmath>
#include <vector>

bool isAchievable(int64_t score, const int64_t& N, const int64_t& K, const std::vector<int64_t>& digests, const std::vector<int64_t>& difficulties){
    int64_t sum = 0;
    for(int32_t i = 0; i < N; i++){
        int64_t target = score / difficulties[i];
        if(target < digests[i]){
            sum += digests[i] - target;
        }
        if(sum > K){
             return false;
        }
    }
    return true;
}

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

    int64_t N, K;
    std::cin >> N >> K;

    std::vector<int64_t> digests(N);
    int64_t sum = 0;
    for(auto& i : digests){
        std::cin >> i;
        sum += i;
    }
    if(sum <= K){
        std::cout << 0;
        return 0;
    }

    std::vector<int64_t> difficulties(N);
    for(auto& i : difficulties){
        std::cin >> i;
    }

    std::sort(digests.begin(), digests.end());
    std::sort(difficulties.begin(), difficulties.end(), std::greater<int64_t>() );

    int64_t right = 1LL << 60;
    int64_t left = 0;
    while(right - left > 1){
        int64_t mid = (right + left) / 2;
        if(isAchievable(mid, N, K, digests, difficulties)){
            right = mid;
        }
        else{
            left = mid;
        }
        //std::cout << right << "," << left <<  std::endl;
    }
    std::cout << right;


    return 0;
}

Measured memory_bytes: 3328
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

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

class Pair<A, B> {
	A first;
	B second;

	Pair(A first, B second) {
		this.first = first;
		this.second = second;
	}

}

class TaskB {
	static int MAX_N = (int) 1e5 + 5;
	boolean visited[];
	ArrayList<Integer> edges[];
	int in_degree[];
	int dp[];

	void dfs(int s) {
		visited[s] = true;
		for (int i : edges[s]) {
			in_degree[i]--;
			dp[i] = Math.max(dp[i], dp[s] + 1);
			if (in_degree[i] == 0) {
				dfs(i);
			}
		}
	}

	public void solve(int testNumber, InputReader in, PrintWriter pw) {
		int N = in.nextInt();
		int M = in.nextInt();
		dp = new int[MAX_N];
		Arrays.fill(dp, 0);
		edges = new ArrayList[MAX_N];
		Arrays.setAll(edges, i -> new ArrayList<Integer>());
		visited = new boolean[MAX_N];
		in_degree = new int[MAX_N];
		for (int i = 0; i < M; i++) {
			int a = in.nextInt();
			int b = in.nextInt();
			edges[a].add(b);
			in_degree[b]++;
		}
		for (int i = 1; i <= N; i++) {
			if (!visited[i] && in_degree[i] == 0) {
				dfs(i);
			}
		}
		int ans = -1;
		for (int i = 1; i <= N; i++) {
			ans = Math.max(dp[i], ans);
		}
		pw.println(ans);
	}

	boolean FirstRow_Col(Pair<Integer, Integer> pair) {
		return pair.first == 0 || pair.second == 0;
	}

	int __gcd(int a, int b) {
		if (b == 0)
			return a;
		return __gcd(b, a % b);

	}

	public int getInt(int num) {
		int ret = -1;
		switch (num) {
		case 0:
			ret = 6;
			break;
		case 1:
			ret = 2;
			break;
		case 2:
			ret = 5;
			break;
		case 3:
			ret = 5;
			break;
		case 4:
			ret = 4;
			break;
		case 5:
			ret = 5;
			break;
		case 6:
			ret = 6;
			break;
		case 7:
			ret = 3;
			break;
		case 8:
			ret = 7;
			break;
		case 9:
			ret = 6;
			break;
		}
		return ret;
	}

	public int isPow(long num) {
		int count = 0;
		while (num > 0) {
			num /= 2;
			count++;
		}
		return count;
	}
}

class InputReader {
	BufferedReader br;
	StringTokenizer st;

	public InputReader(InputStream in) {
		br = new BufferedReader(new InputStreamReader(in));
		st = null;
	}

	public String next() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

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

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

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


Measured memory_bytes: 65792
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;

typedef long long ll;
typedef pair < ll , ll > ii;

ll n, say, ans, top, ham[N], kac[N], x[N], y[N];

void bul(ll x){
	ll top = x;
	do{
		// say++;if(say>N)exit(0);
		top += x;
		kac[x]++;
		ham[x]++;
		if(top > 9){
			ham[x]++;
			top = top%10 + top/10;
		}
	}while(top != x);
}

void ekle(ll x){
	top += x;
	ans++;
	if(top > 9){
		ans++;
		top = top%10 + top/10;
	}
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%lld",&n);
	for(ll i = 1; i <= 9; i++){
		bul(i);
		// cout << i << " -> " << ham[i] << " " << kac[i] << endl;
	}
	for(ll i = 1; i <= n; i++){
		scanf("%lld %lld",x + i, y + i);
		// cout << x[i] << " " << y[i] << endl;
		if(x[i] == 0){
			ans += y[i];
			y[i] = 0;
			continue;
		}
		ll amk = max(0ll, y[i] - (20));
		y[i] -= amk;
		y[i] += amk%kac[x[i]];
		amk -= amk%kac[x[i]];
		ans += (amk/kac[x[i]])*ham[x[i]];
	}
	for(ll i = 1; i <= n; i++){
		// cout << x[i] << " " << y[i] << endl;
		for(ll j = 1; j <= y[i]; j++)
			ekle(x[i]);
	}
	printf("%lld\n", ans - 1);
	return 0;
}

Measured memory_bytes: 9984
/*input
1000000000 180707 0
*/
#include <bits/stdc++.h>
using namespace std;

int main(){
	long double m, n, d, x; cin >> m >> n >> d;
	x = (d == 0 ? 1 : 2) * (m - d) * (n - 1) / m / m;
	cout << fixed << setprecision(6) << x << endl;
}

Measured memory_bytes: 256