akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using ll = unsigned long long int;
using namespace std;

int harshad(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {
    fastIO;
    int x;
    cin >> x;
    if (x % harshad(x) == 0)
        cout << "Yes";
    else
        cout << "No";
}

Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const int INF = INT_MAX / 4;
string color = "RGB";
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};

int w, h;

map<vector<string>, int> memo;

int solve(const vector<string>& s, int prevNum, int d)
{
    if(d > 20)
        return INF;
    if(memo.find(s) != memo.end())
        return memo[s];

    int ret = INF;
    for(int i=0; i<3; ++i){
        if(s[0][0] == color[i])
            continue;

        char c = s[0][0];
        vector<string> t = s;
        t[0][0] = color[i];
        queue<pair<int, int> > q;
        q.push(make_pair(0, 0));
        int n = 0;
        while(!q.empty()){
            int y = q.front().first;
            int x = q.front().second;
            q.pop();
            ++ n;

            for(int j=0; j<4; ++j){
                int y2 = y + dy[j];
                int x2 = x + dx[j];
                if(y2 < 0 || y2 >= h || x2 < 0 || x2 >= w)
                    continue;
                if(t[y2][x2] == c){
                    t[y2][x2] = color[i];
                    q.push(make_pair(y2, x2));
                }
            }
        }

        if(n == prevNum)
            return memo[s] = INF;
        if(n == h * w)
            return memo[s] = 0;
        ret = min(ret, solve(t, n, d+1) + 1);
    }

    return memo[s] = ret;
}

int main()
{
    for(;;){
        cin >> w >> h;
        if(w == 0)
            return 0;

        vector<string> s(h, string(w, ' '));
        for(int i=0; i<h; ++i){
            for(int j=0; j<w; ++j){
                cin >> s[i][j];
            }
        }

        memo.clear();
        cout << solve(s, -1, 0) << endl;
    }
}

Measured memory_bytes: 4032
import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int min = Integer.MAX_VALUE;
 
		String[] x = new String[S.length()];
		for(int i=0; i<S.length(); i++){
			String str = String.valueOf(S.charAt(i));
			x[i] = str;
			if(i>1){
				int X = Integer.parseInt(x[i-2]+x[i-1]+x[i]);
				//System.out.println(X);
				int d = Math.abs(753-X);
				if(d<min){
					min = d;
				}
			}
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 26920
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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; }

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;



int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << ketasitei;

	string s, t;
	cin >> s >> t;

	rep(i, s.size())
	{
		if (s[i] == t[i])
			continue;
		else
		{
			cout << "No" << endl;
			ret;
		}
	}
	if (s.size() + 1 == t.size())
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,c,d=0,e=0,f=2,g=0,h[300001],i,j,k=0,l=0,r=0,p[300001],n[101],m,q,u,v,w,y,z;
    string s,t,x;
    cin>>a;
    if(a%2==1){
        cout<<a/2+1;
    }
    else{
        cout<<a/2;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<iostream>

using namespace std;

int m,n;

int fie[1002][1002];
int flag[3][3];
int ok[1002][1002];

bool check(int x,int y){
	if(fie[x][y]!=flag[0][0])return false;
	if(fie[x+1][y]!=flag[1][0])return false;
	if(fie[x][y+1]!=flag[0][1])return false;
	if(fie[x+1][y+1]!=flag[1][1])return false;
	return true;
}

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		string s;
		cin >> s;
		for(int j=0;j<m;j++){
			if(s[j]=='J')fie[j][i]=0;
			if(s[j]=='O')fie[j][i]=1;
			if(s[j]=='I')fie[j][i]=2;
		}
	}
	for(int i=0;i<2;i++){
		string s;
		cin >> s;
		for(int j=0;j<2;j++){
			if(s[j]=='J')flag[j][i]=0;
			if(s[j]=='O')flag[j][i]=1;
			if(s[j]=='I')flag[j][i]=2;
		}
	}
	int cnt=0;
	for(int i=0;i<n-1;i++){
		for(int j=0;j<m-1;j++){
			if(check(j,i))cnt++,ok[j][i]=1;
		}
	}
	
	int res=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			int prev=fie[j][i];
			for(int k=0;k<=2;k++){
				int plus=0;
				fie[j][i]=k;
				for(int y=-1;y<=1;y++){
					for(int x=-1;x<=1;x++){
						if(j+x>=0 && j+x<m-1 && y+i>=0 && y+i<n-1){
							plus-=ok[j+x][i+y];
							if(check(j+x,i+y))plus++;
						}
					}
				}
				res=max(res,plus);
			}
			fie[j][i]=prev;
		}
	}
	printf("%d\n",res+cnt);
	return 0;
}

Measured memory_bytes: 9068
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
using namespace std;

int a,b,k;
int main()
{
    cin>>a>>b>>k;
    for (int i=0; i<k; ++i)
    {
        if (i%2==0)
        {
        if (a%2==1) a-=1;
        b+=a/2;
        a/=2;
        continue;
        }
        if (b%2==1) b-=1;
        a+=b/2;
        b/=2;
    }
    cout<<a<<' '<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;
	vector<lint> data(N + 2);
	lint sum = 0;

	data[0] = 0;
	data[N + 1] = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> data[i + 1];
		sum += abs(data[i + 1] - data[i]);
	}
	sum += abs(data[N]);

	for (int i = 1; i <= N; i++)
	{
		int out = sum;
		out -= abs(data[i] - data[i - 1]);
		out -= abs(data[i] - data[i + 1]);
		out += abs(data[i + 1] - data[i - 1]);
		cout << out << endl;
	}

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef unsigned long long lu;
typedef pair<int, int> pi;
typedef long long ll;
typedef long double lf;
const ll mod = 1e9 + 7;
int32_t main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    lf now = 0;
    cin >> n >> k;
    vector<lf> a(n), b;
    fr(i, 0, n)
    {
        int u;
        cin >> u;
        a[i] = log(u);
        if (i < k)
        {
            now += a[i];
        }
    }
    b.pb(now);
    int idx = 0;
    for (int i = k; i < n; i++, idx++)
    {
        now += a[i];
        now -= a[idx];
        b.pb(now);
    }
    fr(i, 1, sz(b))
    {
        if (b[i] > b[i - 1])
        {
            cout << "Yes\n";
        }
        else
        {
            cout << "No\n";
        }
    }
    return 0;
}

Measured memory_bytes: 10936
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int w, h, n;
    cin >> w >> h >> n;
    int north = h, south = 0, west = 0, east = w;
    int x, y, a;
    while(n--) {
        cin >> x >> y >> a;
        if (a == 1)
            chmax(west, x);
        else if (a == 2)
            chmin(east, x);
        else if (a == 3)
            chmax(south, y);
        else
            chmin(north, y);
    }
    if ((north - south) >0 && (east - west) > 0)
        cout << (north - south) * (east - west) << endl;
    else
        cout << 0 << endl;
}

Measured memory_bytes: 3580
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

int main() {
	int n;
	scanf("%d",&n);
	if ((n&-n)==n||n==1) {puts("No");return 0;}
	puts("Yes"); 
	printf("1 2\n2 3\n3 %d\n%d %d\n%d %d\n",n+1,n+1,n+2,n+2,n+3);
	for(int i=4;i<n;i+=2) printf("%d %d\n%d %d\n%d %d\n%d %d\n",i,i+1,i+1,n+1,n+1,i+n,i+n,i+n+1);
	if (!(n&1)) {
		fo(x,2,n-1) {
			if (x&1) continue;
			int y=x^1^n;
			if (y>0&&y<n) {
				printf("%d %d\n%d %d\n",x+n,n,y,n<<1);
				break;
			}
		}	
	}
	return 0;
}

Measured memory_bytes: 2688
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
void solve()
{
    int a,b;
    cin>>a>>b;
    if(a>b)swap(a,b);
    int lo=0;
    int hi=b-a;
    while(hi-lo>=2)
    {
        int x=(lo+hi)>>1;
        int val=(a+(x/2))*(a+x-(x/2));
        if(val<(a*b))
        {
            lo=x;
        }
        else
        {
            hi=x;
        }
    }
    cout<<2*(a-1)+lo<<endl;

}
 main()

{
    fast
    int q;
    cin>>q;
    f(i,1,q)
    {
        solve();
    }
    return 0;

}





































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

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] p = new int[N];
		for(int i = 0; i < N; i++) {
			p[i] = sc.nextInt();
		}
		sc.close();
		Arrays.sort(p);
		int sum = 0;
		for(int i = 0; i < N; i++) {
			sum += p[i];
			if(i == K - 1) break;
		}
		prtln(sum);
	}

	public static <T> void prtln(T t) { System.out.println(t); }
}


Measured memory_bytes: 30384
s = input()
t = input()

res = 'UNRESTORABLE'

def check(s,t):
	if len(s) != len(t):
		return False
	else:
		for i in range(len(s)):
			if s[i] != '?' and s[i] != t[i]:
				return False
		return True

flg = False

for i in range(len(s)-len(t), -1, -1):
	L = len(t)
	sub = s[i:L+i]
	if check(sub,t):
		new = s[:i] + t + s[L+i:]
		flg = True
		break


if flg:
	print(new.replace('?', 'a'))
else:
	print(res)

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

int main(){
    int N, K;
    string S;
    cin >> N >> K >> S;
    map <int, int> mp; 
    int a = 0;
    int b = 0;
    rep(i, N - 1){
        if(S[i] == '1' & S[i+1] == '0'){
            a++;
            mp[a] = i + 1;
        }
        if(S[i] == '0' & S[i+1] == '1'){
            b--;
            mp[b] = i + 1;
        }
    }
    if(S[N-1] == '0'){
        b--;
        mp[b] = N;
    }
    else if(S[N-1] == '1'){
        a++;
        mp[a] = N;
    }
    mp[0] = 0;
    int ans = 0;
    if(b >= -K){
        ans = N;
    }
    else if(S[0] == '0'){
        rep(i, a - K + 1){
            ans = max(ans, mp[i+K] - mp[-i]);
        }
        if(S[N-1] == '0'){
            ans = max(ans, mp[b] - mp[b+K]);
        }
    }
    else if(S[0] == '1'){
        rep(i, a - K){
            ans = max(ans, mp[i+K+1] - mp[-i]);
        }
        if(S[N-1] == '0'){
            ans = max(ans, mp[b] - mp[b+K]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
n = int(input())

a = list(map(int, input().split()))
     #a = [].append(input())
count = 0

while(True):
    odd = False
    for i in range(0,n):
        if a[i]%2==1:
            odd = True
    if(odd):
        break
    for i in range(0,n):
        a[i] /= 2 
    count += 1


print(count)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e5+1;
const int m=1e9+7;
int n;
vector<int>adj[N];
vector<vector<int>>dp(2, vector<int>(N,1));

void dfs(int x, int p)
{
    for(auto y: adj[x])
    {
        if(y!=p)
        {
            dfs(y, x);
            dp[1][x]=(dp[1][x]*dp[0][y])%m;
            dp[0][x]=(dp[0][x]*(dp[0][y]+dp[1][y]))%m;
        }
    }
}

int32_t main()
{
    cin>>n;
    for(int i=0; i<n-1; ++i)
    {
        int u, v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(1,0);
    cout<<(dp[1][1]+dp[0][1])%m;
}

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

int main() {
  string o, e;
  cin >> o >> e;

  for (int i=0; i<o.size(); i++) {
    cout << o[i];
    if (i<e.size()) {
      cout << e[i];
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#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 <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	LL ans = (n - 1)*n;

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

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

using int64 = long long;

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};

#define int long long

signed main() {
  int N, M, A[100000], B[100000];
  cin >> N >> M;
  UnionFind uf(N);

  for(int i = 0; i < M; i++) {
    cin >> A[i] >> B[i];
    --A[i], --B[i];
  }
  int ret = 0;

  vector< int > ans(M);
  for(int i = M - 1; i >= 0; i--) {
    ans[i] = 1LL * N * (N - 1) / 2 - ret;
    if(uf.find(A[i]) != uf.find(B[i])) {
      ret += 1LL * uf.size(A[i]) * uf.size(B[i]);
      uf.unite(A[i], B[i]);
    }
  }
  for(auto &p : ans) cout << p << endl;
}






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


namespace Sample
{
  class Sample
  {
    static void Main()
    {
      var p = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
      var q = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
      Console.Write((p[0]-q[0])*(p[1]-q[1]));
      
		}
	}
}

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

using i64 = int64_t;

int main() {
    string o;
    string e;    
    cin >> o >> e;
    for(int i=0;i < (int)o.size();++i){
        cout << o[i];
        if (i < (int)e.size()) {cout << e[i];}

    }
    cout << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int x1,y1,x2,y2,x3,y3,x4,y4;
	int a,b;
	
	scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
	
	a = x1-x2;
	b = y1-y2;
	
	x3 = x2+b;
	y3 = y2-a;
	x4 = x3+a;
	y4 = y3+b;
	
	printf("%d %d %d %d\n", x3, y3, x4, y4);
	
	return 0;
}

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

int main(){
	int A, B;
	cin >> A >> B;
	cout << (A + B - 3) / (A - 1)  << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <string>
using namespace std;
int main()
{
    int a,b,x,n;
    cin>>a;
    cin>>b;
    n= b-a;
    x = n*(n-1)/2 - a;
    cout<<x;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll N,M,K;
ll extgcd(ll a, ll b, ll& x, ll&y){
    ll d=a;
    if(b!=0){
        d=extgcd(b, a%b, y, x);
        y-=(a/b)*x;
    }
    else {
        x=1; y=0;
    }
    return d;
}
ll mod_inverse(ll a, ll m=MOD){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}
const int MAX_N=300000;
ll fact[MAX_N], invfact[MAX_N];
ll comb(ll a, ll b){
    return fact[a]*invfact[b]%MOD*invfact[a-b]%MOD;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>M>>K;
    ll res=0;
    rep(i,0,M-1){
        ll t=N*(i+1), u=N*(M-i-1);
        res+=t*(t-1)+u*(u-1);
        res%=MOD;
    }
    rep(i,0,N-1){
        ll t=M*(i+1), u=M*(N-i-1);
        res+=t*(t-1)+u*(u-1);
        res%=MOD;
    }
    fact[0]=1;
    invfact[0]=1;
    rep(i,1,MAX_N){
        fact[i]=fact[i-1]*i%MOD;
        invfact[i]=mod_inverse(fact[i]);
    }
    res=N+M-2-res*mod_inverse(N*M*(N*M-1))%MOD;
    res=(res%MOD+MOD)%MOD;
    ll x=comb(N*M,K);
    res*=comb(N*M, K)*comb(K,2)%MOD;
    cout <<(res+MOD)%MOD<<"\n";
}

Measured memory_bytes: 4992
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
template<typename T>
T minch(T& l, T r) {
    return l = min(l, r);
}
template<typename T>
T maxch(T& l, T r) {
    return l = max(l, r);
}
template<typename T>
void output(const T& val) {
    cout << val << endl;
}
template<typename T>
void output(const vector<T>& vec, const bool newline = false) {
    for (const T& val : vec)cout << val << (newline ? '\n' : ' '); cout << endl;
}
template<typename T>
void output(const vector<vector<T>>& mat) {
    for (const auto& row : mat)output(row);
}
// ============ template finished ============

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N)cin >> A[i];

    vector<int> B(N);
    rep(j, N)B[j] = A[j] - j;

    ll res = 0;
    map<int, int> mp;
    mp[B.back()]++;
    for (int l = N - 2; l >= 0; l--) {
        ll tgt = -A[l] - l;
        if (mp.find(tgt) != mp.end()) {
            res += mp[tgt];
        }
        mp[B[l]]++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 13400
n = int(raw_input())
a = map(int,raw_input().split(' '))
b = [0 for i in range(int(round(n/2.)))]
b_r = [0 for i in range(n//2)]
for i in range(n):
    if i%2 == 0:
        b[i/2] = a[i]
    else:
        b_r[i/2] = a[i]

n2 = int(round(n/2.))
if n%2 == 0:
    s = str(b_r[n2-1])
    for i in range(1,n):
        if i < n2:
            s += ' ' + str(b_r[n2-1-i])
        else:
            s += ' ' + str(b[i-n2])
    print s
else:
    s = str(b[n2-1])
    for i in range(1,n):
        if i < n2:
            s += ' ' + str(b[n2-1-i])
        else:
            s += ' ' + str(b_r[i-n2])
    print s


Measured memory_bytes: 20820
n = int(input())
a=list(map(int, input().split()))

_minus=0
for i in range(n):
    if a[i]<0:
        _minus+=1
abs_a = [abs(g) for g in a]

if _minus%2==0:
    print(sum(abs_a))
else:
    print(sum(abs_a) - 2*min(abs_a))

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

int main() {
  int a[100],n;
  cin >> n;
  for (int i = 0;i < n;++i) {
  cin >> a[i];
  }


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

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

//素数判定
bool is_prime(ll n) {
    if (n <= 1) return false;
    if (n == 2) return true;

    for (ll i = 2; i * i <= n; ++i) {
        if (n % i == 0) return false;
    }

    return true;
}

int main() {

    int n; cin >> n;

    int cnt = 0;
    for (int i = 31; i <= 55555; ++i) {
        if (is_prime(i) && i % 5 == 1) {
            cout << i << ' ';
            cnt++;
        }

        if (cnt == n) break;
    }

    cout << endl;
}

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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> x(N);
  for (int i = 0; i < N; ++i) cin >> x[i];
  int ans = 1 << 30;
  for (int i = 0; i < N - K + 1; ++i)
    if (x[i] > 0 ^ x[i + K - 1] > 0)
      ans = min(ans, abs(x[i]) + abs(x[i + K - 1]) +
                         min(abs(x[i]), abs(x[i + K - 1])));
    else
      ans = min(ans, max(abs(x[i]), abs(x[i + K - 1])));
  cout << ans << endl;
  return 0;
}

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


/*
int solve(int i){
	if(i == 0) return 0;
	if(i == 1) return 0;
	if(memo[i] != -1) return memo[i];
	int m = INT_MAX;
	for(int d = 1; d <= k; d++){
		if(i - d < 0) break;
		m = min(solve(i-d, k)+abs(h[i]-h[i-d]), m);
	}
	return memo[i] = m;
}*/


int n, m;

int dp[100000];
vector<vector<int>> con;
vector<int> len;

int culclen(int p){
	if(len[p] != -1) return len[p];
	if(con[p].size() == 0) return len[p] = 0;
	int ret = 0;
	for(int i = 0; i < con[p].size(); i++)
		ret = max(ret, culclen(con[p][i]));
	ret++;
	return len[p] = ret;
}

int main(){

	cin >> n >> m;
	con = vector<vector<int>>(n);
	len = vector<int>(n);

	for(int i = 0; i < n; i++){
		len[i] = -1;
	}
	for(int i = 0; i < m; i++){
		int x, y;
		cin >> x >> y;
		con[x-1].push_back(y-1);
	}

	int ans = 0;
	for(int i = 0; i < n; i++){
		ans = max(ans, culclen(i));
	}

	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8192
#include<iostream> 
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath> 
#include<algorithm>
#define ll long long 
using namespace std;
const int maxn=500010, inf=1e9;
int n, K;

template<typename T>
inline void read(T &k)
{
	int f=1; k=0; char c=getchar();
	while(c<'0' || c>'9') c=='-'&&(f=-1), c=getchar();
	while(c<='9' && c>='0') k=k*10+c-'0', c=getchar();
	k*=f;
}

int main()
{
	read(n); read(K); int ans=0;
	while(ans*(K-1)+1<n) ans++;
	printf("%d\n", ans);
} 

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 1e9 + 7;
const string YES = "Yes";
const string NO = "No";

int main()
{
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  long long Q;
  scanf("%lld", &Q);
  std::vector<long long> A(Q);
  for (int i = 0; i < Q; i++)
  {
    scanf("%lld", &A[i]);
  }
  vector<int> v(N, 0);
  for (int i = 0; i < Q; ++i)
  {
    v[A[i] - 1]++;
  }
  for (int i = 0; i < N; ++i)
  {
    if (K - (Q - v[i]) > 0)
      printf("%s\n", YES.c_str());
    else
      printf("%s\n", NO.c_str());
  }

  return 0;
}


Measured memory_bytes: 1792
S = input()
cnt = 0
for i in range(0, len(S)):
    if ((i+1) % 2 == 1 and S[i] in ["R", "U", "D"]) or ((i+1) % 2 == 0 and S[i] in ["L", "U", "D"]):
        cnt += 1

if len(S) == cnt:
    print("Yes")
else:
    print("No")

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

int main(){

  int a=0, b=0, c=0;

  cin >> a >> b >> c;

  int count=0;

  for(int x=a; x<=b; x++) {

    if(c%x==0) {

      count++;
      
    }
    
  }
  cout << count << endl;
}


Measured memory_bytes: 3080
n = STDIN.gets.to_i
array = STDIN.gets.split.map(&:to_i)

array.each_with_index do |num, index|
  printf("node %d: key = %d,", index + 1, num)
  printf(" parent key = %d,", array[(index - 1) / 2]) if index != 0
  printf(" left key = %d,", array[index * 2 + 1]) if index * 2 + 1 < array.size
  printf(" right key = %d,", array[(index + 1) * 2]) if (index + 1) * 2 < array.size
  printf(" \n")
end

Measured memory_bytes: 8672
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int c = sc.nextInt();
        int[] b = new int[m];
        for (int i = 0; i < b.length; i++) {
            b[i] = sc.nextInt();
        }
        int[][] a = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int sum = 0;
            for (int j = 0; j < m; j++) {
                sum += b[j] * a[i][j];
            }
            sum += c;
            if(sum > 0)ans++;
        }
        System.out.println(ans);
    }
}

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

// dp[i][j] : i番目まで見た時、余分な × をj個挿入しているときの数の和 
ll dp[2*100005][3];

const ll INF = ll(1e18)+1;

int main() 
{
    int n;
    cin >> n;
    ll a[n];
    rep(i,n) cin >> a[i];

    int k = n%2 + 1; // 挿入する × の数

    rep(i,n+1)rep(j,k+1) dp[i][j] = -INF;
    dp[0][0] = 0;
    rep(i,n) {
        rep(j,k+1) {
            // i番目に × を挿入する場合
            if (j+1 <= k) chmax(dp[i+1][j+1], dp[i][j]);

            // i番目に挿入しない場合
            if ((i+j)%2 == 0) chmax(dp[i+1][j], dp[i][j] + a[i]);
            else chmax(dp[i+1][j], dp[i][j]);
        }
    }

    ll ans = dp[n][k];
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 9876
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest._300Problems_remain_
{
    class APC001_B
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            var aArray = ReadInts();
            var bArray = ReadInts();
            long cnt = 0;
            for(int i = 0; i < n; i++)
            {
                if (aArray[i] > bArray[i]) cnt += aArray[i] - bArray[i];
            }
            if (cnt == 0)
            {
                Console.WriteLine("Yes");
                return;
            }
            for(int i = 0; i < n; i++)
            {
                if (aArray[i] >= bArray[i]) continue;

                int addCnt = (bArray[i] - aArray[i]) / 2;
                cnt -= addCnt;
                if (cnt <= 0)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            Console.WriteLine("No");
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

int main(){
  int a,b,i,r;
  r=0;
  scanf("%d%d",&a,&b);
  for(i=0;i<2;i++){
    if(a>b){
      r=r+a;
      a--;
    }
    else{
      r=r+b;
      b--;
    }
  }
  printf("%d",r);
  return 0;
}

Measured memory_bytes: 128
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]

min_diff = 10**9
max_diff = -10**9
min_sum = 2 * 10**9
max_sum = 2

for x,y in XY:
    min_diff = min(x-y, min_diff)
    max_diff = max(x-y, max_diff)
    min_sum = min(x+y, min_sum)
    max_sum = max(x+y, max_sum)

print(max(max_sum-min_sum, max_diff-min_diff))

Measured memory_bytes: 107012
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

//#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 3e3 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
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; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, s, a[N], dp[N][N], ans;
void add(int &a, int b) {
  a += b;
  if (a < mod2) a += mod2;
  a %= mod2;
}
main() {
  file("threesum");
  ios;
  cin >> n >> s;
  fo(i, 1, n, 1) cin >> a[i];
  dp[0][0] = 1;
  fo(i, 1, n, 1) {
    foo(j, s - a[i], 0, 1) add(dp[i][j + a[i]], dp[i - 1][j]);
    add(dp[i][0], 1);
    add(ans, ((n - i + 1) * 1ll * dp[i][s] % mod2));
    fo(j, 0, s, 1) add(dp[i][j], dp[i - 1][j]);
  }
  cout << ans;
  return 0;
}
/**

*/


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

#define reps(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) reps(v, 0, n)
#define lep(v, n) reps(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }
template<typename T> void show(T& a, char del='\n', char last='\n'){ rep(i, a.size() - 1) cout << a[i] << del; cout << a[a.size() - 1] << last; }

vector<string> split(const string& S)
{
  istringstream stream(S);
  string field;
  vector<string> result;
  while (getline(stream, field, ' ')){
    result.push_back(field);
  }
  return result;
}

int main()
{
  string str;
  while (getline(cin, str), str != "END OF INPUT"){
    vector<string> ss = split(str);
    rep(i, ss.size()){
      printf("%d", ss[i].size());
    }
    puts("");
  }

  return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define P pair<int,int>
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int main() {
	int n, m, ans = 0;
	cin >> n >> m;
	int a[m], b[m];
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
	}
	for (int l = 0; l < m; l++) {
		int g[n][n] = {};
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i != j) {
					g[i][j] = INF;
				}
			}
		}
		for (int i = 0; i < m; i++) {
			if (i != l) {
				g[a[i]][b[i]] = 1;
				g[b[i]][a[i]] = 1;
			}
		}
		for (int k = 0; k < n; k++) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
				}
			}
		}
		bool flag = false;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (g[i][j] == INF) {
					flag = true;
					break;
				}
			}
			if (flag) {
				break;
			}
		}
		if (flag) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/* ***************************************
Author        :Scau.ion
Created Time  :2016/10/29 20:41:01 UTC+8
File Name     :ion.cpp
*************************************** */

#include <bits/stdc++.h>

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

using namespace std;

int ans[300000];

int main()
{
    IOS;
	int n,x;
    cin>>n>>x;
    if (x==1||x==2*n-1) cout<<"No\n";
    else
    {
        cout<<"Yes\n";
        ans[n]=x;
        int l=1,r=2*n-1;
        for (int j=1;j<n;++j)
        {
            ans[n-j]=l;
            ans[n+j]=r;
            if (j&1) swap(ans[n-j],ans[n+j]);
            ++l;
            --r;
            if (l==x) ++l;
            if (r==x) --r;
        }
        for (int j=1;j<=2*n-1;++j)
            cout<<ans[j]<<"\n";
        cout<<flush;
    }
	return 0;
}


Measured memory_bytes: 2304
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
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; }
typedef pair <ll,ll> P;
 
int main()
{
    ll N, X;
    cin >> N >> X;
    vector<ll> x(N);
    rep(i, N) {
        cin >> x[i];
        x[i] = abs(x[i] - X);
    }
    ll ans = x[0];
    rep(i, N-1) {
        ans = gcd(ans, x[i+1]);
    }
    print(ans);
    return 0;
}

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

int n,W;
int weight[111],value[111];

int dp[111][11111];

int main(){
	cin>>n>>W;
	for(int i=0;i<n;++i)cin>>value[i]>>weight[i];
	for(int w=0;w<=W;++w)dp[0][w]=0;
	for(int i=0;i<n;i++){
		for(int w=0;w<=W;++w){
			if(weight[i]<=w)dp[i+1][w]=max(dp[i][w-weight[i]]+value[i],dp[i][w]);
			else dp[i+1][w]=dp[i][w];
		}
	}
	cout<<dp[n][W]<<endl;
} 



Measured memory_bytes: 7420
while line = gets
  h, w = line.split.map(&:to_i)

  break if h.zero? && w.zero?

  puts '#' * w
  (h - 2).times do
    print '#'
    (w - 2).times do
      print '.'
    end
    puts '#'
  end
  print "#{'#' * w}\n\n"
end

Measured memory_bytes: 8728
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<iomanip>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using vvii = vector<vector<int> >;
using vvll =  vector<vector<ll> >;

const ll inf = 1LL << 60;

//bool check()

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(0);
    int N,K;cin>>N>>K;
    vector<int> A(N);
    REP(i,N){
        cin>>A[i];
    }

    int ng = 0, ok = INF+1;
    while(ok - ng > 1){
        int mid = (ng+ok)/2;
        int goukei = 0;
        REP(i,N){
            goukei += ((A[i]+mid-1)/mid)-1;
        }
        if(goukei <= K)ok = mid;
        else ng = mid;
    }
    cout << ceil(ok)<<endl;
}

Measured memory_bytes: 3972
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
int main(void){
    int n;
    cin >> n;
    int p[n]; rep(i, n){cin >> p[i];}
    int b[3]={};
    int cnt = 0;
    rep(i, n-2){
        b[0] = p[i];
        b[1] = p[i+1];
        b[2] = p[i+2];
        sort(b, b+3);
        if(b[1] == p[i+1]){++cnt;}
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3636
from collections import defaultdict
from itertools import product
 
H, W, K = map(int, input().split())
S = [input() for _ in range(H)]
 
i = 0
while i < len(S):
  if '1' in S[i]:
    i += 1
  else:
    del S[i]
H = len(S)
 
C = [[int(s[i]) for s in S] for i in range(W)]#列を一括りにする
 
total = sum(sum(c) for c in C)#すべての値の合計を算出
 
if total <= K:
  answer = 0
else:
  answer = H * W
  for X in product([False, True], repeat=H-1):#Hは行数
    #あるXについて一回目のfor文が回る
    ans = sum(X)#Trueの数を換算
    if ans > answer:
      continue
    M = [[0]]
    for i, x in enumerate(X):
      if x:#Trueなら実行
        M.append([])#Trueの数の配列が作成される
      M[-1].append(i+1)#一番最後にその番目をappendする
    D = [0] * len(M)#初期値を設定
    for c in C:
      for k, m in enumerate(M):
        D[k] += sum(c[i] for i in m)#k番目の要素に足していく
        #Dにどんどん代入することによってどの列まで足すことができるか算出することができる
      if any(d > K for d in D):#一つでもKを超えていたら
        ans += 1
        if ans > answer:
          break
        D = [sum(c[i] for i in m) for m in M]#Dの更新(1番最初のDに戻る)
        if any(d > K for d in D):#一つでもKを超えていたら
          ans = answer + 1#ansの更新
          break
    answer = min(answer, ans)

print(answer)

Measured memory_bytes: 3564
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> grid(h);
    for (int i = 0; i < h; ++i) {
        cin >> grid[i];
    }
    int ans = 0;
    for (int i = 0; i < (1 << h); ++i) {
        bitset<6> bsh(i);
        for (int j = 0; j < (1 << w); ++j) {
            bitset<6> bsw(j);
            int cnt = 0;
            for (int a = 0; a < h; ++a) {
                for (int b = 0; b < w; ++b) {
                    if (grid[a][b] == '#' and !(bsh.test(a)) and !(bsw.test(b))) {
                        cnt++;
                    }
                }
            }
            if (cnt == k) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int N, M, K;
	cin >> N >> M >> K;

	vector <ll> SA(N+1, 0);
	for (int ii = 0; ii < N; ++ii){
		ll tmp;
		cin >> tmp;
		SA[ii+1] = SA[ii] + tmp;
	}

	vector <ll> SB(M+1, 0);
	for (int ii = 0; ii < M; ++ii){
		ll tmp;
		cin >> tmp;
		SB[ii+1] = SB[ii] + tmp;
	}

	ll ans = 0;
	for (int ii = 0; ii <= N; ++ii){
		if (SA[ii] <= K){
			ll l = -1;
			ll r = M+1;
			while(l + 1 < r) {
				ll mid = (l + r) / 2;
				ll time = SA[ii] + SB[mid];
				if (time > K){
					r = mid;
				} else {
					l = mid;
				}
			}
			ans = max(ans, ii + l);
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 6344
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

int main(){
	ll N;
	cin >> N;
	vector<ll> A(N);

	rep(i, N) cin >> A[i];

	ll maxi = -1;
	ll maxi2 = -1;

	rep(i, N) {
		if(maxi < A[i]) {
			maxi2 = maxi;
			maxi = A[i];
		} else if (maxi2 < A[i]) {
			maxi2 = A[i];
		}
	}

	rep(i, N) {
		if(A[i] == maxi) {
			cout << maxi2 << endl;
		} else {
			cout << maxi << endl;
		}
	}
}


Measured memory_bytes: 4828
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

// 素因数分解
// facotr[i].first  : 基数
// factor[i].second : 指数
void integerFactorization(long long n, vector<pair<long long, int> >& factor)
{
    factor.clear();
    long long a = 2;
    while(a * a <= n){
        int b = 0;
        while(n % a == 0){
            ++ b;
            n /= a;
        }
        if(b > 0)
            factor.push_back(make_pair(a, b));
        ++ a;
    }
    if(n > 1)
        factor.push_back(make_pair(n, 1));
}

int main()
{
    long long n, p;
    cin >> n >> p;

    vector<pair<long long, int> > factor;
    integerFactorization(p, factor);

    long long ans = 1;
    for(const auto& f : factor){
        long long i = f.second / n;
        while(--i >= 0)
            ans *= f.first;
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
  int h, w;
  cin >> h >> w;
  
  rep(i,h){
    rep(j,w){
      string s;
      cin >> s;
      if(s == "snuke"){
        cout <<(char)('A'+j)<<i+1<<endl;
        return 0;
      }
    }
  }
  
}

Measured memory_bytes: 256
a=-1,A=65,d;char*N="GKSOCNWLDFVTBRXHAJUPEMQI",*E="PHLTIDOXQAGWECSUMBKVJFNR",s[9];main(c){for(;c-48&&scanf("%s",s);a+=d/4+1)(c=*s)<A?~a&&printf("%d\n",a),a=d=0:0,d=(c==78?d=N[d]:c==69?d=E[d]:c==83?d=N[N[N[d]-A]-A]:c==87?d=E[E[E[d]-A]-A]:d+A)-A,c==82?d=d&28|d%4+1&3:d,c==76?d=d&28|d%4+3&3:d;}

Measured memory_bytes: 0
X, K, D = list(map(int, input().split()))
X = abs(X)
syo = X // D
#print(syo, amari)
if X <= K * D:
    K -= syo
    X -= D * syo
    if K % 2 == 0:
        print(X)
    else:
        print(abs(X - D))
else:
    print(X - K * D)
    
    

Measured memory_bytes: 9024
#include <algorithm>
#include <cmath>
#include <cstdio>

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

using namespace std;

int main(){
	int n,a[200000];
	scanf("%d",&n);
	rep(i,n) scanf("%d",a+i), a[i]-=i+1;

	sort(a,a+n);

	long long ans=0;
	rep(i,n) ans+=abs(a[i]-a[n/2]);
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 896
//Author: Abitnav
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
int M=1e9+7;
int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M

signed main(){
#ifndef ONLINE_JUDGE 
freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//string s;
	int n,m,c=0,t=1,i,j,k,sum=0,ans,f=0,x,y;
	//cin>>t;
	while(t--){
		//vector<int> v;map<int,int> mp;set<int> st;
		cin>>n;
		double pi=3.1415926535;
		double ans=2*(pi*n);
		printf("%0.15lf",ans);
		//int a[n];rep(i,n) cin>>a[i];

	}
	return 0;
}













Measured memory_bytes: 3748
#include <stdio.h>

int main(){
 int x,y;
 scanf("%d %d", &x, &y);

 for(int i = 0; i <= x; i++){
  if((i*2 + (x-i)*4) == y){
   printf("Yes\n");
   return 0;
  }
 }

 printf("No");

 return 0;
}


Measured memory_bytes: 3228