akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<cassert>
#include<algorithm>
#include<iostream>
#include<map>

using namespace std;

#define Whats(x) cout<<#x<<" is "<<x<<endl
#define Oops() cout<<"!!!!!!!!!"<<endl
#define Divhim() cout<<">>>>>>>>>"<<endl
#define Divher() cout<<"<<<<<<<<<"<<endl

template<typename T> bool GetMin(T &a,T b)
{
	return a<=b?false:(a=b,true);
}

template<typename T> bool GetMax(T &a,T b)
{
	return a>=b?false:(a=b,true);
}

/*
	 -<Unlimited Blade Works>-
 */

const int N=100000+10;

int n,a[N],b[N],tot,fa[N],ans;
map<int,int> A,B,id;
bool vis[N];

int Find(int x)
{
	return fa[x]?(fa[x]=Find(fa[x])):x;
}

void GG()
{
	puts("-1");
	exit(0);
}

void Merge(int x,int y)
{
	if(x!=y)
		++ans;
	if((x=Find(x))!=(y=Find(y)))
	{
		fa[x]=y;
		vis[y]=true;
		vis[x]=true;
	}
}

int main()
{
	scanf("%d",&n);
	int sm=0;
	for(int i=1;i<=n;++i)
	{
		scanf("%d",a+i);
		sm^=a[i];
	}
	bool fl=true;
	for(int i=1;i<=n;++i)
	{
		scanf("%d",b+i);
		fl&=(a[i]==b[i]);
	}
	if(fl)
	{
		puts("0");
		return 0;
	}
	for(int i=1;i<=n;++i)
	{
		++A[a[i]];
		++B[b[i]];
	}
	++A[sm];
	int diff=0,x,y,w=-1;
	for(map<int,int>::iterator it=A.begin();it!=A.end();++it)
	{
		x=it->second;
		id[it->first]=++tot;
		y=B[it->first];
		if(x>y)
		{
			diff+=x-y;
			w=it->first;
		}
		else if(x<y)
			GG();
	}
	if(diff!=1)
		GG();
	a[++n]=sm;
	b[n]=w;
	for(int i=1;i<n;++i)
		Merge(id[a[i]],id[b[i]]);
	for(int i=1;i<=tot;++i)if(vis[i]&&!fa[i])
		++ans;
	if(vis[id[sm]])
		--ans;
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

#define Fast  ios::sync_with_stdio(false); cin.tie(0)
#define pb push_back
#define pf push_front
#define pp pop
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define S second
#define F first
typedef long long ll;
const ll mod = 1e9 + 7;
const ll N = 1e6 + 5;
ll inf = 1e18;

int main(){

    Fast;

    long double a , b , c;
    cin >> a >> b >> c;
    long double tmp = a / c;

    if( tmp <= b)cout << "Yes" ;
    else cout << "No";


    return 0;
}


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

using namespace std;

constexpr int MAXN = 1e6 + 6, MOD = 1e9 + 7;

int n, a, b, c, ans;
string s;
int divisor[MAXN];

int main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
        for (int j = i; j <= n; j += i)
            divisor[j]++;
    for (c = 1; c <= n - 1; c++) {
        int ab = n - c;
        ans += divisor[ab];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7556
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    rep(i, N) {
        int L = C * i - D * (N - i - 1);
        int R = D * i - C * (N - i - 1);
        if (L <= (B - A) && (B - A) <= R) {
            cout << "YES" << endl;
            //cout << i << " " << N - i - 1 << endl;
            //cout << L << " " << (B - A) << " " << R << endl;
            return 0;
        }
    }
    cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int calc(int y, int m, int d) {
	int res = 0;
	res += (2*(5*19+5*20)+(10*20))*((y-1) / 3) + (5*19+5*20)*((y-1) % 3);
	res += (y%3)?(((m-1)/2)*(20+19)+((m-1)%2)*(20)):((m-1)*20);
	res += (d-1);

	return res;
}

int main() {
	int n; cin >> n;
	while(n--) {
		int y, m, d; cin >> y >> m >> d;
		cout << calc(1000, 1, 1) - calc(y, m, d) << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb push_back
#define mp std::make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
//const ll MOD=1e9+7;
const ll MOD=998244353;
//const ll MOD=100000;
const ll MAX=1e7;
const ll INF=(1ll<<60);
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
struct Binary_indexed_tree{
    int N;
    vi bit;
    Binary_indexed_tree(int n):N(n){
        bit.resize(N+1,0);
    }
    void add(int x,int a){
        for(x;x<=N;x+=(x&-x)) bit[x]+=a;
    }
    ll sum(int x){
        ll ret=0;
        for(x;x>0;x-=(x&-x)) ret+=bit[x];
        return ret;
    }
};
struct Union_Find{
    ll N;
    vi par;
    vi siz;
    Union_Find(int n):N(n){
        par.resize(N);
        siz.resize(N,1);
        rep(i,0,N) par[i]=i;
    }
    ll root(ll X){
        if(par[X]==X) return X;
        return par[X]=root(par[X]);
    }
    bool same(ll X,ll Y){
        return root(X)==root(Y);
    }
    void unite(ll X,ll Y){
        X=root(X);
        Y=root(Y);
        if(X==Y) return;
        par[X]=Y;
        siz[Y]+=siz[X];
        siz[X]=0;
    }
    ll size(ll X){
        return siz[root(X)];
    }
};
ll modpow(ll X,ll Y){
    ll sum=X,cnt=1;
    vi A;
    while(cnt<=Y){
        A.pb(sum);
        sum*=sum;
        sum%=MOD;
        cnt*=2;
    }
    int M=A.size();
    ll ret=1;
    REP(i,1,M){
        if(Y>=(1ll<<M-i)){
            Y-=(1ll<<M-i);
            ret*=A[M-i];
            ret%=MOD;
        }
    }
    return ret;
}
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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 COM(ll n,ll r){
    if(n<r||n<0||r<0) return 0;
    return fac[n]*finv[r]%MOD*finv[n-r]%MOD;
}
signed main(){
    ll N,M,K; cin>>N>>M>>K;
    ll ans=0;
    COMinit();
    REP(i,N-K,N){
        ans+=modpow(M-1,i-1)*M%MOD*COM(N-1,i-1)%MOD;
        ans%=MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 238004
import collections


def solve():

    n = int(input())
    v = list(map(int, input().split()))
    v0 = v[::2]
    v0_counter = collections.Counter(v0).most_common()
    v1 = v[1::2]
    v1_counter = collections.Counter(v1).most_common()

    if v0_counter[0][0] != v1_counter[0][0]:
        print(n - v0_counter[0][1] - v1_counter[0][1])
        exit()
    else:
        if len(v0_counter) == 1 or len(v1_counter) == 1:
            print(n // 2)
            exit()
        else:
            print(n - max(v0_counter[0][1] + v1_counter[1][1], v0_counter[1][1] + v1_counter[0][1]))


if __name__ == '__main__':
    solve()


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif


void Main() {
    ll N; cin >> N; cout << N * N << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

int main() {
    // your code goes here
    ll n,k,i,h[200005],sum=0;
    cin >> n >> k;
    for(i=0;i<n;i++){
        cin >> h[i];
    }
    sort(h,h+n);
    for(i=0;i<n-k;i++){
        sum+=h[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1792
N,W = map(int, input().split())
v = []
w = []
for i in range(N):
    a,b = map(int,input().split())
    w.append(a)
    v.append(b)

dp = [[0 for i in range(W+1)] for j in range(N+1)]

for j in range(N):
    for i in range(W):
        dp[j+1][i] = max(dp[j][i],dp[j+1][i])
        if i+w[j] <= W:
            dp[j+1][i+w[j]] = max(dp[j+1][i+w[j]],dp[j][i]+v[j])
        
print(max([max(item) for item in dp]))

Measured memory_bytes: 171912
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
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 ll INF = 1e18+1;



int main() {
    ll N, C;
    cin >> N >> C;
    vector<ll> x(N), v(N);

    for (int i = 0; i < N; i++) cin >> x[i] >> v[i];
    
    ll res = 0;

    vector<ll> o1(N+1,0), o2(N+1,0);
    for (int i = 0; i < N; i++) {
        o1[i+1] = o1[i] + v[i] - x[i];
        if (i > 0) o1[i+1] += x[i-1];
    }
    for (int i = N-1; i >= 0; i--) {
        o2[i] = o2[i+1] + v[i] -(C- x[i]);
        if (i < N-1) o2[i] += (C-x[i+1]);
    }
    
    vector<ll> f(N+1,0), g(N+1,0);
    for (int i = 0; i < N; i++) {
        f[i+1] = f[i] + v[i] - 2*x[i];
        if (i > 0) f[i+1] += 2 * x[i-1];
    }
    for (int i = 0; i < N; i++) {
        g[i+1] = max(g[i],f[i+1]);
    }

    vector<ll> h(N+1,0), u(N+1,0);
    for (int i = N-1; i >= 0; i--) {
        h[i] = h[i+1] + v[i] -2*(C- x[i]);
        if (i < N-1) h[i] += 2*(C-x[i+1]);
    }
    for (int i = N-1; i >= 0; i--) {
        u[i] = max(u[i+1],h[i]);
    }

    for (int b = 0; b <= N; b++) {
        chmax(res, g[b]+o2[b]);
    }
    for (int a = 0; a <= N; a++) {
        chmax(res, o1[a]+u[a]);
    }
    cout << res << endl;




}



Measured memory_bytes: 6528
#include<iostream>
#include<cstdio>
#include<algorithm>
#define N 1000000
using namespace std;
int a[N],b[N];
int n;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		while (!(x&1))x/=2,a[i]++;
	}
	sort(a+1,a+n+1);
	for (int i=1;i<=n/2+(n&1);i++)
		b[i*2-1]=a[i],b[i*2]=a[n-i+1];
	for (int i=1;i<n;i++)
		if (b[i]+b[i+1]<2){
			printf("No");
			return 0;
		}
	printf("Yes");
	return 0;
}

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

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

  int ans = 0;
  
  rep(i,1000){
    string pass = to_string(i);
    while(pass.size() < 3) pass = '0' + pass;
      
    int p = 0;
    rep(j,n){
      if(pass[p] == s[j]){
        p++;
      }
    }
    if(p == 3) ans++;
  }
  cout << ans << endl;
}



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

int main()
{
    string s;
    cin>>s;
    if(s[0]=='Y') {
        if(s[1]=='A'){
           if(s[2]=='K'){
                if(s[3]=='I'){
                    cout << "Yes" << endl;
                }
                else { cout << "No" << endl;}
            }
            else { cout << "No" << endl;}
        }
        else { cout << "No" << endl;}
    }
    else { cout << "No" << endl;}
    return 0;
}


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

#define Ni 3

int pl[Ni][Ni],tmp[Ni][Ni];
int Dx[4]={0,1,0,-1},Dy[4]={1,0,-1,0};

void em(int *a,int *b){
  int i,j;
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      if(!pl[i][j]){
	*a = j;
	*b=i;
      }
    }
  }
}

void SW(int *a,int *b){
  int tmp;
  tmp =*a;
  *a = *b;
  *b = tmp;
}

int cal(){
  int i,A,S=0;
  for(i=0;i<9;i++){
    A = pl[i/3][i%3];
    if(A){
      A--;
      S += abs(i/3-A/3) + abs(i%3 - A%3);
    }
  }
  return S;
}

int df(int a,int b,int P,int D,const int shin){
  int i,hi,A,B,result;
  hi = cal();
  if(hi==0){
    return D;
  }
  if(D+hi>shin){
    return -1;
  }

  for(i=0;i<4;i++){
    A = a+Dx[i];
    B = b+Dy[i];
    if(~P && i==(P+2)%4) {
      continue;
    }
    if(!(0<=A && A<3 && 0<=B && B<3)){
      continue;
    }
    SW(&pl[b][a],&pl[B][A]);
    result = df(A,B,i,D+1,shin);
    if(~result){
      return result;
    }
    SW(&pl[b][a],&pl[B][A]);
  }
  return -1;
}

int main(){
  int i,j,li,TA,a,b;

  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      scanf("%d",&pl[i][j]);
    }
  }

    em(&a,&b);
    for(li=0;li<100;li++){
      for(i=0;i<3;i++){
	for(j=0;j<3;j++){
	  tmp[i][j]=pl[i][j];
	}
      }
	TA = df(a,b,-1,0,li);
	if(TA!=-1){
	  printf("%d\n",TA);
	  break;
	}

	for(i=0;i<3;i++){
	  for(j=0;j<3;j++){
	    pl[i][j]=tmp[i][j];
	  }
	}

	TA = -1;
	if(li==99){
	      printf("%d\n",TA);
	    }
      }

    return 0;
	    }

  
  



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

int n,m,p;
int co[10005];
int ans[105][105];

int main()
{
    //freopen("in.txt","r",stdin);
    scanf("%d%d%d",&n,&m,&p);
    for(int i=0;i<p;i++)scanf("%d",&co[i]);
    int di=1,j=0,now_co=0,now_cnt=0;
    for(int i=0;i<n;i++)
    {
        int ed;
        if(j==0)ed=m-1;
        if(j==m-1)ed=0;
        while(1)
        {
            ans[i][j]=now_co;
            now_cnt++;
            if(now_cnt==co[now_co])
            {
                now_cnt=0;
                now_co++;
            }
            if(j==ed)break;
            j+=di;
        }
        di=-di;
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            printf("%d",ans[i][j]+1);
            if(j!=m-1)printf(" ");
        }
        if(i!=n-1)printf("\n");
    }
    return 0;
}


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

using namespace std;
const int MAXN = 60;

int a[MAXN];

void print (int x) {
	if (x) printf("YES\n");
	else printf("NO\n");
	exit(0);
}

int main () {

	int n;
	scanf("%d", &n);

	for (int i = 1; i <= n; ++i) 
		scanf("%d", &a[i]);

	int cnt = 0, p = 0;
	for (int i = 1; i <= n; ++i) {
		if (a[i] != i) {
			++cnt;
			p = i;
		}
	}

	if (cnt == 0)
		print(1);
	else if (cnt & 1 || cnt > 2) print(0);
	else {
		int x = a[p];
		swap(a[p], a[x]);
		for (int i = 1; i <= n; ++i) {
			if (i != a[i]) print(0);
		}
		print(1);
	}



	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;


int main(){
	string tmp;
	string key[] = {"the","this","that"};
	int alfabet;
	bool clearFlag;
	while(getline(cin,tmp)){
		clearFlag = false;
		alfabet = 26;
		while(alfabet--){

			for(string::iterator it = tmp.begin(); it != tmp.end(); it++){
				if(*it == '\n'){
					it = tmp.erase(it);
				}
				if(*it >= 'a' && *it <= 'z'){
					(*it)++;
					if(*it > 'z'){
						*it = 'a';
					}
				}
			}
			for(int j = 0; j < 3; j++){
				if(tmp.find(key[j]) != string::npos){
					cout << tmp << endl;
					clearFlag = true;
					break;
				}
			}

			if(clearFlag == true){
				break;
			}

		}
	}
	return 0;
}

Measured memory_bytes: 1188
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    string s; cin >> s;
    if(s.back() == 's') s += "es";
    else s += "s";
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3564
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int N = sc.nextInt();
		long[] A = new long[N];
		for(int i = 0; i < N; i ++){
			A[i] = sc.nextLong();
		}
		long sum = 1L;
		long max = (long)Math.pow(10, 18);
		for(int i = 0; i < N; i ++){
			if(A[i] == 0){
				sum = 0;
				break;
			}else if(A[i] > max / sum){
				sum = -1;
			}else{
			sum *= A[i];
			}
		}
		System.out.println(sum);
    }
}


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

using namespace std;

int main(){
    int N;
    while(cin >> N){
        vector<int> A(N);
        vector<long long> num(N+1, 0);
        for(int i=0;i<N;i++){
            cin >> A[i];
            num[A[i]]++;
        }
        long long res = 0;
        for(auto& t : num) res += t*(t-1)/2;
        for(auto& t : A){
            auto v = num[t];
            if(v <= 1){
                cout << res << endl;
            } else {
                cout << res - v*(v-1)/2 + (v-1)*(v-2)/2 << endl;
            }
        }
    }
}

Measured memory_bytes: 4992
import math

A, B, H, M = map(int, input().split())

radi = abs((30 * H + 0.5 * M) - 6 * M)

a2 = A ** 2 + B ** 2 - 2 * A * B * (math.cos(math.radians(radi)))
ans = math.sqrt(a2)

print(ans)

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

// 型定義
typedef unsigned long long int ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);

    ll N;
    cin >> N;

    vector<ll> A(N);
    REP(i, N){
        cin >> A[i];
        if(A[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = 1;
    REP(i, N){
        if(LINF/A[i] >= ans){
            ans = ans * A[i];
        }
        else{
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3996
#include "bits/stdc++.h"
using namespace std;

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


int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;

    if (n % 2 == 0) { cout << (ll) (n / 2) - 1 << endl; }
    else { cout << (ll) n / 2 << endl; }



    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	string s = "RYGB";
	int h, w, d; cin >> h >> w >> d;
	vector<string> res(h, string(w, '.'));
	rep(i, h) rep(j, w){
		int a = (i + j) % (2 * d) / d;
		int b = (i - j % (2 * d) + 2 * d) % (2 * d) / d;
		res[i][j] = s[2 * a + b];
	}
	rep(i, h) cout << res[i] << endl;
	
	return 0;
}

Measured memory_bytes: 768
#import queue
from collections import deque
INF=-1

N,M=[int(e) for e in input().split(' ')]

to=[[] for _ in range(N)]

for i in range(M):
    u,v=[int(e) for e in input().split(' ')]
    to[u-1].append(v-1)
S,T=[int(e)-1 for e in input().split(' ')]

dist=[[INF for i in range(3)] for j in range(N)]

q=deque([])
q.append([S,0])

dist[S][0]=0

while(q):
    v,l=q.popleft()
    for v_to in to[v]:
        nl=(l+1)%3
        if dist[v_to][nl] != INF:
            continue
        dist[v_to][nl]=dist[v][l]+1
        q.append([v_to,nl])
ans=dist[T][0]
if ans == INF:
    ans = -1
else:
    ans=ans//3

print(ans)


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


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)		idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)	for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)		idp p2((x).F, (x).S)
#define dump(x,n)	idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)	idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)	idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)	idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)	rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)	rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li a[2020];
li res[2020];
li table[2020][2020];

int main() {
	li n, x;
	cin >> n >> x;
	rin{cin >> a[i];}

	rin{
		table[i][0] = a[i];
		repp(j, 1, n) {
			li from = (i - j + n) % n;
			table[i][j] = min(table[i][j - 1], a[from]);
		}
	}

	li res = INF;
	rep(i, n) {
		li tres = 0;
		rep(j, n) {
			tres += table[j][i];
		}
		res = min(res, tres + x * i);
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 31872
#include <bits/stdc++.h>
using namespace std;
 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#define rep(i, a, b) for(lli i = a; i < (b); ++i)
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) lli((x).size())
#define wis cout<<endl<<"I already speak english, bitch"<<endl<<endl;
 
typedef long long int lli;
typedef vector<lli> vi;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef pair<ii,lli> iii;
 
#define trace(args...) { string  _s =#args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
void err(istream_iterator<string> it){}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args){
    cout <<  *it  << " : " << a << endl;
    err(++it, args...);
}

int main(){
	int n; cin>>n;
	int odd=0,eve=0;
	rep(i,1,n+1){
		if(i%2==1) odd++;
		else eve++;
	}

	cout<<double((odd+0.0)/(n+0.0))<<endl;

	return 0;
}

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

#define INF 0x3f3f3f3f

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

string s;

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

	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0) cout << s[i];
	}

	cout << endl;

	return 0;
}


Measured memory_bytes: 592
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    const [a,b,c,d] = lines[0].split(" ").map(v=>v-0);
    const x = c-a, y = d-b;
    console.log([c-y, d+x, a-y, b+x].join(" "));
    
});


Measured memory_bytes: 30144
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;

string S;

int main() {
    cin >> S;

    ll res = 0;
    for (int i = 0; i < (1 << (S.size() - 1)); i++) {
        ll tmp = S[0] - '0';
        ll sum = 0;
        for (int j = 0; j < S.size() - 1; j++) {
            if ((i >> j) & 1) {
                sum += tmp;
                tmp = S[j+1] - '0';
            } else {
                tmp = 10 * tmp + S[j + 1] - '0';
            }
        }
        sum += tmp;
        res += sum;
    }
    cout << res << endl;

    return 0;
}


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

long long fnc(long long b, long long n){
  if(n < b)
    return n;
  else
    return fnc(b,n/b)+n%b;
}

int main(){
  long long n, s;
  cin >> n >> s;
  long long ans = -1ll;
  
  for(long long b = 2; b <= sqrt(n); b++){
    if(fnc(b,n) == s){
      ans = b;
      break;
    }
  }
  
  if(ans == -1ll){
    for(long long x = sqrt(n); x > 0; x--){
      if((n-s)%x == 0 && (n-s)/x+1 > x && (n-s)/x+1 > s-x && s-x >= 0){
        ans = (n-s)/x+1;
        break;
      }
    }
  }
  
  if(ans == -1ll){
    if(n == s)
      ans = n+1;
  }
    
  cout << ans << endl;
}

Measured memory_bytes: 384
/* ex 9_2
   KitamoriFumiya */

#include <stdio.h>
#include <stdlib.h>
#define SIZE 100001
// リストのノード（スタック内の各データ）の定義
typedef struct node{
	char elem;
	struct node *next;
} node;

void push(node **first, char elem);
char pop(node **first);

int main(void){
	node *first = NULL; // リストの先頭
	char cube[SIZE], *ptr; 
	int count = 0;
	ptr = cube;
	scanf("%s", cube); // キューブの色を入力
	while(*ptr){
		// 空または色が先頭の要素と同じならノードを追加
		if(first == NULL || first->elem == *ptr){
			push(&first, *ptr);
		}
		// 色が異なればスタックから先頭のノードを取り出す
		else{
			pop(&first);
			count += 2; // キューブを2個取り出したことになるから取り出した個数を2増やす
		}
		ptr++;
	}
	printf("%d\n", count); // 取り出したキューブの個数を出力
	return 0;
}

//スタックにデータを追加
void push(node **first, char elem){
	// 追加する分の領域を確保
	node *new = calloc(1, sizeof(node));
	if(new == NULL) exit(1);
	new->elem = elem;
	new->next = *first;
	*first = new;
}
//スタックからデータを取り出す
char pop(node **head){
	char elem;
	node *tmp = *head;
	if(tmp == NULL){
		exit(1);
	}
	elem = tmp->elem;
	*head = tmp->next;
	// 取り出したノードのメモリを開放
	free(tmp);
	return elem;
}

Measured memory_bytes: 4880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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(){
    ll n; cin>>n;
    vector<ll> div;
    for(ll i=1; i*i<=n; i++){
        if(n%i==0){
            div.push_back(i);
            if(i!=n/i) div.push_back(n/i);
        }
    }
    sort(div.begin(), div.end());
    ll res=0;
    for(ll x:div){
        ll m=n;
        if(x==1) continue;
        while(m%x==0) m=m/x;
        if(m%x==1) res++;
    }

    for(ll i=1; i*i<=(n-1); i++){
        if((n-1)%i==0){
            res++;
            if(i!=(n-1)/i) res++;
        }
    }
    cout<<res-1<<endl;
    return 0;
}

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

int p[10000];

int root( int n ) {
	if ( p[n] != n )
		p[n] = root( p[n] );
	return p[n];
}

void unit( int x, int y ) {
	p[root( y )] = p[root( x )];
}

void same( int x, int y ) {
	if ( root( x ) == root( y ) )
		cout << 1 << endl;
	else
		cout << 0 << endl;
}

int main() {
	int n, q, com, x, y;
	cin >> n >> q;
	for ( int i = 0; i < n; i++ )
		p[i] = i;
	for ( int i = 0; i < q; i++ ) {
		cin >> com >> x >> y;
		if ( com == 0 )
			unit( x, y );
		else
			same( x, y );
	}
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <algorithm> 
#include <cmath> //pow

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

using namespace std;

void shortest(vector<vector<char>>& field, vector<vector<int>>& path, int len, int h, int w, int i , int j) {
  if (i >= h || j >= w || i < 0 || j < 0) return;
  if (field[i][j] == '#' || path[i][j] <= len) return;
	
	path[i][j] = len;
  shortest(field, path, len+1, h, w, i+1, j);
	shortest(field, path, len+1, h, w, i-1, j);
	shortest(field, path, len+1, h, w, i, j+1);
	shortest(field, path, len+1, h, w, i, j-1);
}

int main(void) {
	int h, w;
	cin >> h >> w;

	vector<vector<char>> field(h, vector<char>(w));
	rep(i,h) rep(j, w) {
	  char c;
		cin >> field[i][j];
	}

	int s = 0;
	rep(i, h) rep(j, w) {
		if (field[i][j] == '.') s++;
	}

	vector<vector<int>> path(h, vector<int>(w, h*w+1));

	shortest(field, path, 1, h, w, 0, 0);

	int des = path[h - 1][w - 1];
	if (des > h*w) cout << -1 << endl;
	else cout << s-des << endl;

}


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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

int cnt = 0;


void solve()
{
	ll n, a, b; cin >> n >> a >> b;
	if (abs(a - b) % 2 == 0LL)
	{
		cout << abs(a - b) / 2LL;
	}
	else
	{
		cout << min(a - 1, n - b) + 1 + (b - a - 1) / 2;
	}
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
}


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

bool check(int base, int limit) {
	int num = 0;
	int n3=0,n5=0,n7=0;
	while(base>0) {
		num *= 10;
		if(base%4==0) return false;
		if(base%4==1) {num+=3;n3++;}
		if(base%4==2) {num+=5;n5++;}
		if(base%4==3) {num+=7;n7++;}
		base /= 4;
	}
	//cout << num << endl;
	if(n3*n5*n7>0&&num<=limit) {
		//cout << num << endl;
		return true;
	}
	return false;
}

int main() {
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 0; i < 262144; i++) {
		ans += (check(i,n))?1:0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import numpy as np
N,X=map(int, input().split())

A=np.array(list(map(int, input().split())))
B=A-X
if N==1:
  print(abs(B[0]))
  exit()

from fractions import gcd
GCD=gcd(abs(B[0]),abs(B[1]))
#print(B)
if N>2:
  for i in range(2,N):
    GCD=gcd(GCD, abs(B[i]))
    
  
print(GCD)



Measured memory_bytes: 23120
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
#define int long long

int n, k, ta = 0;
pair<int, int> a[100000];

signed main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a, a + n);
	for (int i = 0; i < n; i++) {
		ta += a[i].second;
		if (k <= ta) {
			cout << a[i].first << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

bool check(ll a, ll b, ll x) {
    ll A = a*a*a*a*a;
    ll B = b*b*b*b*b;
    if (x == A-B) return true;
    else return false;
}

int main(int argc, char const *argv[]) {
    ll x; cin>>x;
    for (ll i = -3000; i <= 3000; ++i) {
        for (ll j = -3000; j <= 3000; ++j) {
            if (check(i,j,x)) {
                cout << i << ' ' << j << '\n';
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

typedef long long int64;

using namespace std;

int64 mod = 1000000007;

int64 powmod(int64 a, int64 n) {
    if (n == 0) return 1;
    if (n % 2 == 1) return a * powmod(a, n - 1) % mod;
    int64 x = powmod(a, n / 2);
    return x * x % mod;
}

int64 inv(int64 a) {
    return powmod(a, mod - 2);
}

vector<int64> f;

int64 c(int n, int k) {
    int64 ans = f[n];
	ans *= inv(f[k]);
	ans %= mod;
    ans *= inv(f[n - k]);
	ans %= mod;
	return ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	
	int n;
	cin >> n;
	int k;
	cin >> k;
	vector<int64> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	
	sort(all(a));
	f.resize(n + 1);
	f[0] = 1;
	for (int i = 1; i <= n; ++i) f[i] = (i * f[i - 1]) % mod;

    int64 ans = 0;
	for (int i = k - 1; i < n; ++i) {
	    ans = (ans + c(i, k - 1) * a[i] % mod) % mod;
	}
	for (int i = 0; i + k <= n; ++i) {
	    ans = (ans - c(n - i - 1, k - 1) * a[i] % mod) % mod;
	}
	ans %= mod;
	ans += mod;
	ans %= mod;
	
	cout << ans << endl;
    return 0;
}


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int p[1000];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, k;
    cin >> n >> k;
    for (int i=0; i<n; i++)
        cin >> p[i];

    sort(p, p + n);
    int ret = 0;
    for (int i=0; i<k; i++)
        ret += p[i];

    cout << ret << "\n";

    return 0;
}


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

int main(){
  int x;
  cin>>x;
  if(x<1200){
    cout<<"ABC"<<endl;
  }
   else if(x<2800){
    cout<<"ARC"<<endl;
  }
   else if(x<=4208){
  cout<<"AGC"<<endl;
   }
}

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

#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
string s,t;
signed main(){
    cin>>s>>t;
    int ls=s.size(),ts=t.size();
    for(int i=ls-ts+1;i>=0;i--){
        bool b=true;
        for(int j=i;j<i+ts;j++){
            if(s[j]!='?'&&s[j]!=t[j-i]){
                b=false;
            }
        }
        if(b){
            rep(j,ls){
                if(j==i){
                    cout<<t;
                    j+=ts-1;
                }
                else if(s[j]=='?'){
                    cout<<"a";
                }
                else{
                    cout<<s[j];
                }
            }
            cout<<endl;
            return 0;
        }
    }
    puts("UNRESTORABLE");
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const double PI = acos(-1);

vector<int> divisor(int n)
{
	vector<int> res;
	for (int i = 1; i * i <= n; i++) 
	{
		if (n % i == 0)
		{
			res.push_back(i);
			if (i != n / i)
			{
				res.push_back(n / i);
			}
		}
	}
	return res;
}

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

	int n, m;
	cin >> n >> m;

	vector<int> d(divisor(m));

	int ma = 0;
	for (auto di : d) 
	{
		if (di <= m / n)
		{
			chmax(ma, di);
		}
	}

	out(ma);

	return 0;
}

Measured memory_bytes: 256
from collections import deque
H, W = map(int, input().split())


if __name__ == '__main__':

    # make graph
    maze = []
    dx = [0, 1, 0, -1]
    dy = [1, 0, -1, 0]

    for i in range(H):
        line = input()
        maze.append(line)

    max_path = 0
    for i in range(H):
        for j in range(W):
            if maze[i][j] != '#':
                que = deque([[i, j]])
                dist = [[-1 for k in range(W)] for l in range(H)]
                dist[i][j] = 0
                while len(que) != 0:
                    h, w = que[0][0], que[0][1]
                    que.popleft()
                    for k in range(4):
                        if h + dy[k] < 0 or w + dx[k] < 0 or h + dy[k] >= H or w + dx[k] >= W:
                            continue
                        if maze[h + dy[k]][w + dx[k]] == '#':
                            continue
                        if dist[h + dy[k]][w + dx[k]] == -1:
                            dist[h + dy[k]][w + dx[k]] = dist[h][w] + 1
                            que.append([h + dy[k], w + dx[k]])

                max_dist = max(max(li) for li in dist)
                if max_dist > max_path:
                    max_path = max_dist

    print(max_path)



Measured memory_bytes: 47708
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int W, H;
int x, y;
int main()
{
    cin >> W >> H;
    cin >> x >> y;
    double result = (double)W * H / 2;
    int ans = 0;
    if (2 * x == W && 2 * y == H)
    {
        ans = 1;
    }
    printf("%.12f %d", result, ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;

int num[10];
int main(int argc, const char * argv[])
{
    int i;
    while (scanf("%d",&num[0])!=EOF)
    {
        for (i=1; i<=9; ++i)
        {
            scanf("%d",&num[i]);
        }
        sort(num, num+10);
        printf("%d\n%d\n%d\n",num[9],num[8],num[7]);
    }
    return 0;
}

Measured memory_bytes: 1208
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int n, m; cin >> n >> m;
	map<int, pair<bool, bool>> ma;
	rep(i, m) {
		int a, b; cin >> a >> b;
		if (a == 1)ma[b].first = true;
		if (b == n)ma[a].second = true;
	}

	bool ans = false;
	for (auto aa : ma) {
		if (aa.second.first&&aa.second.second)ans = true;
	}
	puts(ans ? "POSSIBLE" : "IMPOSSIBLE");
}

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

int main() {
	int k,ans=0;
	string s;
	cin >> s;
	k=s.size();
	for(int i=0; i<k; i++){
		if(s[i]=='x') ans++;
	}
	if(ans>7){
		cout << "NO";
	}else{
		cout << "YES";
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
typedef long long int ll;
using namespace std;
int main(){
	io;
	char s[3];
	cin >> s;
	bool fa = 0,fb = 0;
	for(int i = 0;i < 3;++i){
		if(s[i] == 'A'){
			fa = 1;
		}
		else{
			fb = 1;
		}
	}
	if(fa && fb){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int n, m;
priority_queue<ll> arr;
priority_queue<pair<ll, int>> pq;

int main() {
    scanf("%d%d", &n, &m);
    rep(i, n) {
        ll a;
        scanf("%lld", &a);
        arr.push(a);
    }
    rep(i, m) {
        int b, c;
        scanf("%d%d", &b, &c);
        pq.push(make_pair(c, b));
    }
    ll ans = 0;
    int cnt = 0;
    while (cnt < n) {
        ll a = arr.top();
        auto b = pq.top();
        if (!pq.empty() && b.first > a) {
            pq.pop();
            if (cnt + b.second >= n) {
                ans += b.first * (n - cnt);
                break;
            } else {
                cnt += b.second;
                ans += b.first * b.second;
            }
        } else {
            ans += a;
            arr.pop();
            cnt++;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3188
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <set>
#include <queue>
#include <cstdio>
#include <stack>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define lrep(i, n) for(long long i=0;i<n;i++)
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;
template <class T> T gcd(T n, T m){return m ? gcd(m, n%m):n;}

const int N = 200000;
const int MOD = 1000000000+7;

ll com[2001][2001];

void combination(){
    for(int i=0;i<=2000;++i){
        com[i][i]=1;
        com[i][0]=1;
        com[0][i]=1;
    }
    for(int i=2;i<=2000;i++){
        for(int j=1;j<=i;j++){
            com[i][j]=com[i-1][j-1]%MOD+com[i-1][j]%MOD;
        }
    }
}

int main(){
    int n,k;cin>>n>>k;
    int white=n-k;
    combination();
    for(int i=1;i<=k;i++){
        cout << (com[n-k+1][i]*com[k-1][i-1])%MOD << endl;
    }
    return 0;
}


Measured memory_bytes: 30080