akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <regex>
#include <climits>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#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, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define forin(i, a) for(auto i: (a))
#define p(...) printf(__VA_ARGS__); cout << endl;
#define in(...) __VA_ARGS__; input__(__VA_ARGS__);
#define input(...) in(__VA_ARGS__)
#define out(...) output__(__VA_ARGS__);
#define output(...) out(__VA_ARGS__)
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](auto const &a, auto const &b){ return c ;}
#define key(t, x, compare) [](const t &a, const t &b){ return a x compare b x ;}
#define unless(a) if(!(a))

using namespace std;

using pii = pair<int, int>;

template <class... T>
void input__(T &...a) {
  for(auto v: {&a...}) {
    cin >> *v;
  }
}

void output__(){
  cout << endl;
}

template <class Head, class... T>
void output__(Head const &v, T const &...a) {
  if(sizeof...(a) == 0) {
    cout << v;
  } else {
    cout << v << " ";
  }
  output__(a...);
}

int main(){
  long in(x);

  long a = x % 11;
  if (1 <= a and a <= 6) {
    out((x + 10) / 11L * 2 - 1);
  } else {
    out((x + 10) / 11L * 2);
  }
}


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

#define FOR(i,a,b) for(int i = (a); i< (b); i++)
#define REP(i,n) FOR(i,0,n)
#define endl '\n'
#define ll long long
using namespace std;
deque <int> q;
int flag = 0;
int main(){
    int n;
    cin>>n;
    REP(i,n){
        int x;
        cin>>x;
        if(flag)
            q.push_front(x);
        else
            q.push_back(x);
        flag++;
        flag%=2;
    }
    if(flag==0)
    for(auto it:q)
        cout<<it<<" ";
    else
    for(auto it = q.rbegin();it!=q.rend();it++){
        cout<<*it<<" ";
    }
    return 0;
}


Measured memory_bytes: 2944
#include<iostream>
using namespace std;
int main() {
    int n, m; cin >> n >> m;
    if (n == 1 && m == 1) {
        cout << 1 << endl;
    } else if (n == 1 || m == 1) {
        cout << max(n, m) - 2 << endl;
    } else if (n == 2 || m == 2) {
        cout << 0 << endl;
    } else {
        cout << (long long)n * m - 2 * n - (2 * m - 4) << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64
#define n_max 100000

int n;

void judge(llong B[],llong C[],llong D[]){
    int c=0;
    REP(i,n){
        while(c < n){
            if(C[c] < B[i]) c+=1;
            else break;
        }
        D[i]=c;
    }
}

llong judge2(llong A[],llong B[], llong D[]){
    llong ans=0;
    llong tmp=0;
    int b=0;
    REP(i,n){
        while(b < n){
            if(B[b] < A[i]){
                tmp+=D[b];
                b+=1;
            }
            else break;
        }
        ans+=tmp;
    }
    return ans;
}

int main(){
    cin >> n;
    llong A[n_max+5],B[n_max+5],C[n_max+5];
    REP(i,n) scanf("%ld",&C[i]);
    REP(i,n) scanf("%ld",&B[i]);
    REP(i,n) scanf("%ld",&A[i]);
    sort(&A[0],&A[n]);
    sort(&B[0],&B[n]);
    sort(&C[0],&C[n]);

    
    llong D[n_max+5];
    judge(B,C,D);
    cout << judge2(A,B,D) << endl;
    
}

Measured memory_bytes: 3328
#include<stdio.h>

int main()
{
  int N,Y;
  int x,y,z;
  int i,j;
  int a;
  scanf("%d%d",&N,&Y);
  for(i=0;i<=N;i++){
    for(j=0;j<=N-i;j++){
      a=Y-10000*i-5000*j;
      if(a==1000*(N-i-j)){
        x=i;
        y=j;
        z=N-i-j;
        printf("%d ",x);
        printf("%d ",y);
        printf("%d ",z);
        return 0;
      }
    }
  }
  printf("%d ",-1);
  printf("%d ",-1);
  printf("%d ",-1);
  return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char X;
  cin >> X;
  if(X=='A'){
    cout << 'T' << endl;
  }
  if(X=='T'){
    cout << 'A' << endl;
  }
    if(X=='G'){
    cout << 'C' << endl;
  }
    if(X=='C'){
    cout << 'G' << endl;
  }
}


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

# dp = np.zeros(shape=(len(s), len(t)), dtype=np.int64)
dp = [[0] * (len(t)+1) for i in range(len(s)+1)]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1)
        else:
            dp[i+1][j+1] = max(dp[i+1][j+1], max(dp[i][j+1], dp[i+1][j]))

# print(dp[len(s)][len(t)])


i = len(s)
j = len(t)
# print(type(i))
# print(type(j))
ans = ""
while (i > 0) and (j > 0):
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans += s[i-1]
        i -= 1
        j -= 1

print(ans[::-1])


Measured memory_bytes: 112732
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];


int main(){
    long long a;
    cin>>a;
    vector <tuple<string,int,int>> p;
    rep(i,a){
        string s;
        int t;
        cin>>s>>t;
        p.push_back(make_tuple(s,-t,i+1));
    } 

    sort(p.begin(),p.end());
    rep(i,a){
        cout<<get<2>(p[i])<<endl;
    }
}



Measured memory_bytes: 256
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))
ans = [0] * 21

for i in range(N):
  ans[P[i]] += 1

print(min(sum(ans[0:A + 1]), sum(ans[A + 1:B + 1]), sum(ans[B + 1:])))

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

int main(void){
    long long h,ans=0,amount=1 ;
    cin >> h ;
    while(1){
        if (h>1){
            ans+=amount ; 
            amount*=2 ;
            h/=2 ;
        } else {
            ans+= amount ;
            break ;
        }
    }
    cout << ans << endl ;
}

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

mi = []
pl = []

for i in range(N):
    s = A[i] - B[i]
    if s < 0:
        mi.append(s)
    elif s > 0:
        pl.append(s)

            
pl.sort(reverse=True)
p = np.sum(mi)



if (len(pl)>0)and(len(mi)>0):
    count = 0
    for i in pl:
        if p + i < 0:
            p += i
            count += 1
            continue
        else:
            count += 1
            break
    else:
        print('-1')
        exit()

    print(count + len(mi))
    
        
elif len(mi) == 0:
    print('0')
    exit()
else:
    print('-1')
    exit()


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> pii;

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

	int h, w, d;
	cin >> h >> w >> d;

	int max_a = 1e5;
	pii INF = (pii){-1, -1};

	pii s[max_a];
	rep(i, max_a) s[i] = INF;

	rep(i, h) rep(j, w){
		int a;
		cin >> a;

		s[a] = (pii){i, j};
	}

	int t[max_a];
	rep(i, max_a) t[i] = 0;

	rep(i, max_a){
		if(s[i] != INF){
			if(i - d >= 0 && s[i-d] != INF) t[i] = t[i-d] + abs(s[i].first - s[i-d].first) + abs(s[i].second - s[i-d].second);
		}
	}

	int q;
	cin >> q;

	rep(i, q){
		int l, r;
		cin >> l >> r;

		cout << t[r] - t[l] << endl;
	}
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
*/

ll modpow(__int128_t a, ll n,ll mo) {
	__int128_t r=1;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

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

long long gcd(long long a,long long b){
	if(b==0)return a;
	return gcd(b,a%b);
}
long long lcm(long long a,long long b){
	return a*b/gcd(b,a%b);
}

ll n,l=1,ans=1e18;

int main(void){
	cin>>n;
	if(n==2){
		cout<<1<<endl;
		return 0;
	}
	for(ll i=2;i*i<=n;i++){  // 同じ素因数2個あったらアウト
		if(n%(i*i)==0){
			cout<<-1<<endl;
			return 0;
		}
	}
	ll n2=n;
	for(ll i=2;i*i<=n;i++){
		if(n2%i==0){
			l = lcm(l,i-1);
			n2 /= i;
		}
	}
	if(n2>1)l = lcm(l,n2-1);
	if(gcd(n,l)!=1){
		cout<<-1<<endl;
		return 0;
	}
	if(gcd(n,l)!=1){
		cout<<-1<<endl;
		return 0;
	}
	ll phi_l = euler(l);
	for(ll i=1;i*i<=phi_l;i++){
		if(phi_l%i==0){
			if(modpow(n,i,l)==1)ans=min(ans,i);
			if(modpow(n,phi_l/i,l)==1)ans=min(ans,phi_l/i);
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int j = 1;
    int cnt = 0;

    rep(i,n){
        if(a[i] == j){
            j++;
        }else{
            cnt++;
        }
    }

    if(cnt == n){
        cout << -1 << endl;
    }else{
        cout << cnt << endl;
    }
}

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

int main(){
    int N, Q;
    cin >> N >> Q;
    vector<pair<int, pair<int, int>>> event;
    for (int i = 0; i < N; i++) {
        int s, t, x;
        scanf("%d", &s);
        scanf("%d", &t);
        scanf("%d", &x);
        event.push_back({s-x, {1, x}});
        event.push_back({t-x, {-1, x}});
    }
    sort(event.begin(), event.end());
    set<int> stop;
    auto it = event.begin();
    for (int i = 0; i < Q; i++) {
        int d;
        scanf("%d", &d);
        while (it != event.end() && (*it).first <= d) {
            int p = (*it).second.first;
            int q = (*it).second.second;
            if (p == 1) stop.insert(q);
            else stop.erase(q);
            it++;
        }
        if (!stop.empty()) cout << *stop.begin() << endl;
        else cout << -1 << endl;
    }
    return 0;
}

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

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

  vector<int> X(N, 0);
  vector<int> Y(N, 0);  
  for (int i = 0; i < N; i++) {
    cin >> X.at(i);
    Y.at(i) = X.at(i);
  }

  sort(Y.begin(), Y.end());

  int left = Y.at(N / 2 - 1);
  int right = Y.at(N / 2);    
  for (int i = 0; i < N; i++) {
    if (X.at(i) <= left) {
      cout << right << endl;
    } else {
      cout << left << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3712
import time

n = int(input())
listA=[]
index=0
while index < n:
    a = int(input())
    listA.append(a)
    index+=1

startT = time.time()
buttonLighted=0
pushCounter=0
index=0
while 1:
    pushCounter+=1
    if listA[buttonLighted] == 2:
        print(pushCounter)
        break
    else:
        buttonLighted = listA[buttonLighted]-1
    if time.time()-startT > 0.9:
        print(-1)
        break

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

bool used[2510][2510];
int roomL[51][51], roomR[51][51];

inline int s_to_i(char c) {
  switch (c) {
  case '#':
    return -1;
  case '.':
    return 0;
  case 'L':
  case 'R':
    return 1;
  case '%':
    return 2;
  }
}

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  while (true) {
    int R, C;
    cin >> C >> R;
    if (R == 0 && C == 0) break;
    REP(i, R) {
      string rowL, rowR;
      cin >> rowL >> rowR;
      REP(j, C) {
	roomL[i][j] = s_to_i(rowL[j]);
	roomR[i][j] = s_to_i(rowR[j]);
      }
    }	  

    int sl = 0, el = 0, sr = 0, er = 0;
    REP(r, R) REP(c, C) {
      if (roomL[r][c] == 1) sl = r * C + c;
      else if (roomL[r][c] == 2) el = r * C + c;
      if (roomR[r][c] == 1) sr = r * C + c;
      else if (roomR[r][c] == 2) er = r * C + c;
    }
    //cout << slr << ' ' << slc << ' ' << elr << ' ' << elc << ' ' << srr << ' ' << src << ' ' << err << ' ' << erc << endl;
    REP(i, R*C) REP(j, R*C) used[i][j] = false;
    
    queue<P> que;
    que.push(P(sl, sr));

    bool flag = false;
    while (!que.empty()) {
      P p = que.front(); que.pop();
      int l = p.first, r = p.second, lr = p.first / C, lc = p.first % C, rr = p.second / C, rc = p.second % C;
      //cout << lr << ' ' << lc << ' ' << rr << ' ' << rc << endl;
      if (l == el && r == er) {
	flag = true;
	break;
      } else if (used[l][r] || l == el || r == er) {
	continue;
      }

      used[l][r] = true;
      REP(i, 4) {
	int nlr = lr + dr[i], nlc = lc + dc[i], nrr = rr + dr[(i+2*(i&1))%4], nrc = rc + dc[(i+2*(i&1))%4];
	if (nlr < 0 || nlr >= R || nlc < 0 || nlc >= C || roomL[nlr][nlc] == -1) nlr = lr, nlc = lc;
	if (nrr < 0 || nrr >= R || nrc < 0 || nrc >= C || roomR[nrr][nrc] == -1) nrr = rr, nrc = rc;
	if (!used[nlr * C + nlc][nrr * C + nrc]) que.push(P(nlr * C + nlc, nrr * C + nrc));
      }
    }
    cout << (flag ? "Yes" : "No") << endl;    
  }
  return 0;
}

Measured memory_bytes: 9960
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e18
#define ret return

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll a[111111][3];
ll dp[111111][3];

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 3; j++)cin >> a[i][j];
		if(i==0)for(int j = 0; j < 3; j++)dp[0][j]=a[0][j];
		else for(int j = 0; j < 3; j++)dp[i][j]=a[i][j]+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]); 
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	
	
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k, s = 0, ct1 = 0, ct2=0;
  cin >> n >> m >> k;
  int a[n], b[m];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 0; i < m; i++)
    cin >> b[i];

  for (int i = 0; i < n; i++) {
    if (s + a[i] <= k) {
      s += a[i];
      ct1++;
    } else
      break;
  }

  for (int i = 0; i < m; i++) {
    if (s + b[i] <= k) {
      s += b[i];
      ct2++;
    } else
      break;
  }
  int ct = ct1 + ct2;
  for (int i = ct1 - 1; i >= 0; i--) {
    s -= a[i];
    int tmp = s;
    for (int j = ct2; j < m; j++) {
      if (tmp + b[j] <= k) {
        tmp += b[j];
        s+=b[j];
        ct2++;
      } else
        break;
    }
    if (i + ct2 > ct)
      ct = i + ct2;
  }
  cout << ct;
  return 0;
}

Measured memory_bytes: 5072
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int len=s.size();
    /*
    for(int i=0;i<len;i++)
    {
        cout<<"i is equal to : "<<s[i]<<" "<<endl;;
    }
    */
    if(s[2]==s[3]&&s[4]==s[5])
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<bitset>
using namespace std;
int n,tot,x;
bitset<2000090>k;
int main(){
    scanf("%d",&n);
	k[0]=1;
	for(int i=1;i<=n;i++){
	    scanf("%d",&x);
	    k|=k<<x;
		tot+=x;
	}
	for(int i=(tot+1)/2;i<=tot;i++){
	    if(k[i]){
		cout<<i;
		break;
		}
	}
    return 0;
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
ll LCM(int a, int b){
    return a*b/gcd(a,b);
}

int main(void)
{
    int a,b;
    cin>>a>>b;
    cout<<((a*b)%2?"Odd":"Even")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a1,a2,b1,b2,c1,c2,d1,d2;
	float l,r;
	a1=0,a2=0,b1=0,b2=0,c1=0,c2=0,d1=0,d2=0;
	while(scanf("%f %f",&l,&r)!=EOF){
		if(l<0.2) d1++;
		else if(l>=0.2&&0.6>l) c1++;
		else if(l>=0.6&&1.1>l) b1++;
		else a1++;
		if(r<0.2) d2++;
		else if(r>=0.2&&0.6>r) c2++;
		else if(r>=0.6&&1.1>r) b2++;
		else a2++;
	}
	printf("%d %d\n%d %d\n%d %d\n%d %d\n",a1,a2,b1,b2,c1,c2,d1,d2);
	return 0;
}

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

using namespace std;

int main(){
    char s[14]; scanf("%s", s);
    int cnt = 0, ans = 0;
    for(int i=0;i<strlen(s);++i){
        if(s[i]!='A'&&s[i]!='T'&&s[i]!='G'&&s[i]!='C'){
            cnt = 0;
        }
        else cnt++, ans = max(ans, cnt);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <math.h>
#include <climits>
#include <stack>
#include <iomanip>
#include <sstream>

using namespace std;

template <typename T>
inline bool sign(T A) {
    return (A>0)-(A<0);
}

#define REP(i,s,n) for(int i=s; (n-i)*sign(n-s)>0; i+=sign(n-s))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool _less(pair<int, int> a, pair<int, int> b) {
    return a.second < b.second;
}

template <template<class,class,class...> class C, typename K, typename V, typename... Args>
V map_get(const C<K,V,Args...>& m, K const& key, const V & defval)
{
    typename C<K,V,Args...>::const_iterator it = m.find( key );
    if (it == m.end())
        return defval;
    return it->second;
}

#define MOD (1'000'000'000+7)

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> A(N), b(N), c(N), d(N);
    int sum = 0;
    REP(i, 0, N) {
        cin >> A[i];
        sum += A[i];
    }
    
    int mgcd = 1;
    
    auto f = [&](int i) {
        int diff = 0;
        REP(j, 0, N) {
            int d = A[j]%i;
            diff += d;
            b[j] = d;
        }
        if (diff%i == 0) {
            sort(all(b));
            c[N-1] = (b[N-1]>0?b[N-1]-i:0);
            d[0] = b[0];
            REP(j, 1, N) {
                d[j] = d[j-1] + b[j];
                c[N-j-1] = c[N-j] + (b[N-j-1]>0?b[N-j-1] - i:0);
            }
            ll k = LONG_MAX;;
            REP(j, 0, N-1) {
                k = min(k, max(d[j], -c[j+1]));
            }
            if (k <= K)
                mgcd = max(mgcd, i);
        }
    };
    
    REP(i, 1, sqrt(sum)+1) {
        if (sum%i == 0) {
            f(i);
            f(sum/i);
        }
    }
    cout << mgcd << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize "-O3"
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define LSOne(S) (S & (-S))
#define ll long long
#define two pair<int,int>
#define twol pair<ll,ll>
#define four pair<two,two>
#define pb push_back
#define mk make_pair
#define INF 1000000000000000000
#define P 1000000007
#define lmax 1000000000
#define nn 1000003
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define vi vector<int>
#define vll vector<ll>
#define vtwo vector<two>
#define ALL(container) (container).begin(), (container).end()
#define sz(container) (int)(container.size())
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define mid(a,b) (a+b>>1)
#define minN 0
#define maxN 10000000
#define na(x) ((x)<P?(x):(x)-P)
#define ab(a) (-(a)<(a)?(a):-(a))
#define FAST std::ios::sync_with_stdio(false)
#define xRand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define rnd rng
#define IT iterator
typedef
tree<
  int,// aq pair<int,int> shegidzlia
  null_type,
  less/*_equal*/<int>,// aqac
  rb_tree_tag,
  tree_order_statistics_node_update>
ordered_set;
// '_equal' mashin ginda roca multiset gchirdeba
template<class key, class value,class cmp = std::less<key>>
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;
ordered_map<int, int> my_map;
inline int in(){
	int x=0,w=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if (ch=='-') w=0,ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
ll n,k;
int main(){FAST;xRand;
cin>>n>>k;
cout<<n-k+1<<endl;

}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
                 *   *   * *   *
                  *   *   *   *
                   *   * *   *
                     *  *   *
					   *  *


*/






Measured memory_bytes: 256
import sys

n, k, *p = map(int, sys.stdin.read().split())

def main():
    ex = [(1 + i) * i // 2  / i for i in p]
    l = 0; r = k

    res = []
    s = sum(ex[l:r])
    res.append(s)
    while r < n:
        s -= ex[l]
        s += ex[r]
        l += 1
        r += 1
        res.append(s)
    return max(res)
    
if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 25036
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long int n,b,k;
	cin>>n;
	long int i,a[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		
	}
	
	sort(a,a+n);
	b=n/2;
	k=a[b]-a[b-1];
	
	cout<<k;
}

Measured memory_bytes: 4312
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

VI adj[112345];
int color[112345] = {};

bool dfs(int v, int c){
    color[v] = c;
    for(int p : adj[v]){
        if(color[p] == color[v]) return false;

        if(color[p] == 0 && !dfs(p,-c)) return false;
    }

    return true;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL N,M; cin >> N >> M;
    REP(i,M){
        int a,b; cin >> a >> b;
        a--; b--;
        adj[a].eb(b);
        adj[b].eb(a);
    }

    bool bip = dfs(0,1);

    if(bip){
        LL bcnt = 0, wcnt = 0;
        REP(i,N){
            if(color[i] == 1) bcnt++;
            else wcnt++;
        }
        cout << bcnt * wcnt - M << endl;
    }
    else{
        cout << N * (N-1) / 2 - M << endl;
    }

}

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

#define ll long long
#define ld long double

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k, ans = 0;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        int h;
        cin >> h;
        if (h >= k) {
            ans++;
        }
    }
    cout << ans;
    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  
  int total = 0;
  
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    
    if (K > x * 2) total += x;
    else total += K - x;
  }
  
  cout << total * 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int a, b, sum;

   cin >> a >> b;

   sum = a + b;

   if(sum < a * b){
      sum = a * b;
   }
   
   if(sum < a - b){
      sum = a - b;
   }

   cout << sum;

   return 0;
}

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

//map<long long , int> pa;

int main()
{
  long long H,N,i,first,second;
  cin>>H>>N;
  first=second=0;
  
  long long A;
  
  for(i=0;i<N;i++)
  {
    cin>>A;
    first+=A;
  }
  
  if(first>=H) cout<<"Yes";
  else cout<<"No";
  
}

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

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	vector < vector < int >>path(N + 1);
	for (int i = 1; i <= M; i++) {
		int a, b;
		cin >> a >> b;
		path[a].push_back(b);
		path[b].push_back(a);
	}

	vector < int >dist(N + 1, INT_MAX);
	vector < int >prev(N + 1, INT_MAX);
	dist[1] = 0;

	queue < int >que;
	que.push(1);

	while (!que.empty()) {
		int n = que.front();
		que.pop();
		for (size_t i = 0; i < path[n].size(); i++) {
			if (dist[path[n][i]] != INT_MAX) {
				continue;
			}
			dist[path[n][i]] = dist[n] + 1;
			prev[path[n][i]] = n;
			que.push(path[n][i]);
		}
	}

	cout << "Yes" << endl;
	for (int i = 2; i <= N; i++) {
		cout << prev[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 10748
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>

#define INT unsigned long long int
#define FOR1(n) for(int i=0;i<n;i++)
#define FOR2(j, n) for(int j=0;j<n;j++)
#define FOR3(i, m, n) for(int i=m;i<=n;i++)
#define PINT(d) printf("%d", d);
#define PDOUBLE(lf) printf("%lf", lf);
#define PSTR(s) printf("%s", s);
#define ALL(c) c.begin(), c.end()
#define MOD 1000000007
#define MAX_N 100000

using namespace std;

main(){
	int n, k, x, y;
	scanf("%d\n%d\n%d\n%d", &n, &k, &x, &y);
	if(n <= k){
		PINT(n * x);
	}else{
		PINT(k * x + (n-k) * y);
	}
	
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int n;
    float a, total = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        total += pow(a, -1.0);
    }
    total = pow(total, -1.0);
    cout << total;
    return (0);
}

Measured memory_bytes: 256
($N,$M)=glob<>;
$N++;
@C=0;$#C=$N;$C[1]=1;
@L=("1")x($N);

for(1..$M){
    ($x,$y)=glob<>;
    $L[$x]--;
    $L[$y]++;
    $C[$y]++ if($C[$x]>0);
    $C[$x]=0 if($L[$x]<1);
}
print scalar (grep{$_>0}@C)

Measured memory_bytes: 14976
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		StringBuilder stc_out = new StringBuilder();
		
		for(int i=1;i<=n;i++){
			if(i%3==0){ 
				stc_out.append(" "+i);
			} else {
				int num=i;
				
				while(num!=0){
					if(num%10==3){
						stc_out.append(" "+i);
						break;
					}else{
						num=num/10;
					}//if
				}//while
			}//if	
		}//for
		System.out.println(stc_out);
	}
}

Measured memory_bytes: 24852
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 20;
const double PI = acos(-1.0);
const double DINF = 1e20;

/* typedef */

/* global variables */

int n;
double r , th;
double xs[MAX_N], ys[MAX_N], mat[MAX_N][MAX_N], dists[2][MAX_N][MAX_N];

/* subroutines */

/* main */

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

  double cth = cos(th * PI / 180);
  
  for (int i = 0; i < n; i++) cin >> xs[i] >> ys[i];

  for (int i = 0; i < n; i++) {
    mat[i][i] = DINF;
    for (int j = i + 1; j < n; j++) {
      double dx = xs[j] - xs[i], dy = ys[j] - ys[i];
      mat[i][j] = mat[j][i] = sqrt(dx * dx + dy * dy);
    }
  }

  int cur = 0, nxt = 1;
  bool ok = false;

  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) dists[cur][i][j] = DINF;
  
  for (int i = 1; i < n; i++)
    if (mat[0][i] <= r) dists[cur][0][i] = mat[0][i], ok = true;

  if (! ok) {
    cout << 0 << endl;
    return 0;
  }

  int k = 1;

  for (;;) {
    ok = false;
    
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) dists[nxt][i][j] = DINF;
    
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) {
	if (dists[cur][i][j] >= DINF) continue;
	double vx0 = xs[j] - xs[i], vy0 = ys[j] - ys[i];
	double d0 = mat[i][j];
	for (int k = 0; k < n; k++) {
	  if (j == k) continue;
	  double vx1 = xs[k] - xs[j], vy1 = ys[k] - ys[j];
	  double d1 = mat[j][k];
	  double c = (vx0 * vx1 + vy0 * vy1) / (d0 * d1);
	  if (c >= cth) {
	    double nd = dists[cur][i][j] + d1;
	    if (nd <= r && dists[nxt][j][k] > nd)
	      dists[nxt][j][k] = nd, ok = true;
	  }
	}
      }

    if (ok) k++;
    else break;

    cur ^= 1;
    nxt ^= 1;
  }

  cout << k << endl;
  
  return 0;
}

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

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

  int ans[N];
  memset(ans, 0, sizeof(ans));
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      int dist = min(min(abs(j - i), abs(X - i) + 1 + abs(j - Y)), abs(Y - i) + 1 + abs(j - X));
      ans[dist]++;
    }
  }
  for (int i = 1; i < N; i++) {
    cout << ans[i] / 2 << endl;
  }
}

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



Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	unsigned int	iNumber;
	char			cCondition = 0;
	//正の整数を入力
	scanf("%d", &iNumber);
	//入力された数に応じた"本"の読み方を出力
	switch (iNumber % 10)
	{
	case 0:
		printf("pon\n");
		break;
	case 1:
		printf("pon\n");
		break;
	case 2:
		printf("hon\n");
		break;
	case 3:
		printf("bon\n");
		break;
	case 4:
		printf("hon\n");
		break;
	case 5:
		printf("hon\n");
		break;
	case 6:
		printf("pon\n");
		break;
	case 7:
		printf("hon\n");
		break;
	case 8:
		printf("pon\n");
		break;
	case 9:
		printf("hon\n");
		break;
	default:
		break;
	}
	return 0;
}

Measured memory_bytes: 1656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
//		String[] tmpArray = br.readLine().split(" ");
		int n = Integer.parseInt(br.readLine());
//		int b = Integer.parseInt(tmpArray[1]);
//		int c = Integer.parseInt(tmpArray[2]);
//		int y = Integer.parseInt(tmpArray[3]);
//		int r = Integer.parseInt(tmpArray[4]);

		//HashMap<String, Boolean> cards = new HashMap<String, Boolean>();
		String[] mark = {"S","H","C","D"};
		boolean[][] exist = new boolean[4][13+1];
		for(int i = 0;i < 4; i++){
			Arrays.fill(exist[i], false);
		}

		//String[] tmpArray = br.readLine().split(" ");
		//int[] input = new int[n];
		for(int i = 0; i < n; i++){
			String[] tmpArray = br.readLine().split(" ");
			String tmpmark = tmpArray[0];
			int number = Integer.parseInt(tmpArray[1]);
			int markIndex;
			if(tmpmark.equals("S")){
				markIndex = 0;
			}
			else if(tmpmark.equals("H")){
				markIndex = 1;
			}
			else if(tmpmark.equals("C")){
				markIndex = 2;
			}
			else{
				markIndex = 3;
			}
			exist[markIndex][number] = true;
		}
		
		for(int i = 0; i < 4; i++){
			for(int j = 1; j <= 13; j++){
				if(!exist[i][j]){
					System.out.println(mark[i] + " " + j);
				}
			}
		}
//		
//		System.out.print(input[0]);
//		for(int i = 1 ; i < n; i++){
//			System.out.print(" "+ input[i]);
//		}
//		System.out.println();
////		
//		Arrays.sort(input);
//		System.out.printf("%d %d %d\n", input[0], input[input.length - 1], sum);
//		
//		while(true){
//			String[] tmpArray = br.readLine().split(" ");
//			int a = Integer.parseInt(tmpArray[0]);
//			int b = Integer.parseInt(tmpArray[1]);
//			if(a == 0 && b == 0){
//				break;
//			}
//			
//			for(int i = 0; i < a; i++){
//				for(int j = 0; j < b; j++){
//					if((i + j)%2 == 1){
//						System.out.print(".");
//					}
//					else{
//						System.out.print("#");
//					}
//				}
//				System.out.println();
//			}
//			System.out.println();
//		}

		//		int[] array = new int[3];
//		array[0] = a; array[1] = b; array[2] = c;
//
//		Arrays.sort(array);
//		System.out.printf("%d %d %d\n", array[0], array[1], array[2]);
		/*
		if(a < b && b < c){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}*/
	}

}

Measured memory_bytes: 24312
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N,C = LI()
D = [[0]*(C+1)] + [[0]+LI() for _ in range(C)]
c = [[0]*(N+1)] + [[0]+LI() for _ in range(N)]

from collections import defaultdict

d0,d1,d2 = defaultdict(int),defaultdict(int),defaultdict(int)
# dk = ((i+j)%3==k たる (i,j) に対して各色が何個ずつあるか)
for i in range(1,N+1):
    for j in range(1,N+1):
        if (i + j) % 3 == 0:
            d0[c[i][j]] += 1
        elif (i + j) % 3 == 1:
            d1[c[i][j]] += 1
        elif (i + j) % 3 == 2:
            d2[c[i][j]] += 1

ans = 10**18
# 変化後の色で全探索
for i in range(1,C+1):
    for j in range(1,C+1):
        for k in range(1,C+1):
            if i == j or j == k or k == i:
                continue
            else:
                a = 0
                for color in d0.keys():
                    a += D[color][i]*d0[color]
                for color in d1.keys():
                    a += D[color][j]*d1[color]
                for color in d2.keys():
                    a += D[color][k]*d2[color]
                ans = min(ans,a)

print(ans)

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

//using namespace boost::multiprecision;
using namespace std;
//typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
//const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;
#define ret() return 0;

bool contain(set<char> &s, char a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

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

    vector<int> r(s.size());
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'R') r[i] = i;
        else {
            r[i] = r[i - 1];
        }
    }
    vector<int> l(s.size());
    for (int i = s.size() - 1; i >= 0; i--) {
        if (s[i] == 'L') l[i] = i;
        else l[i] = l[i + 1];
    }

    vector<int> ans(s.size(), 0);

    rep(i, s.size()) {
        if (s[i] == 'L') {
            int nr = r[i];
            if ((i - nr) % 2 == 0) {
                ans[nr]++;
            } else {
                ans[nr + 1]++;
            }
        } else {
            int nl = l[i];
            if ((nl - i) % 2 == 0) {
                ans[nl]++;
            } else {
                ans[nl - 1]++;
            }
        }
    }
    for (int i : ans) printf("%d ", i);
}



Measured memory_bytes: 1792
#include <cstdio>
int main(){
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);
    int ans = 0;
    while(C > 0 && B >= A){
        ans++;
        C--;
        B -= A;
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
typedef double D;
typedef complex<D> P;
const D EPS = 1e-8;

int n,r,q,r2;
P p[30];
int cur;
D min_s[30],SIN[30],COS[30],x,y;

inline P rotate(const P &v, const D &s){
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}

inline D arg(const P &a,const P &b,const P &c){return real(conj(b-a)*(c-a))/(abs(b-a)*abs(c-a));}

inline D rot_seta(const int &end){
  D seta = acos( 1 - norm(p[end]-p[cur])/r2 );
  P nxt = rotate(p[cur],-seta);
  return arg(p[cur],p[end],nxt);
}

int main(){
  while(scanf("%d%d%d",&n,&r,&q), n){
    r2 = 2*r*r;
    rep(i,n){
      scanf("%lf%lf",&x,&y);
      p[i] = P(x,y);
      if(abs(abs(p[i])-r)<EPS)cur = i;
    }
    
    vector<int> nxt(n,-1);
    bool f = false;

    rep(i,q){
      if(nxt[cur]>=0)f = true;

      if(!f){
	min_s[cur] = 5;
	rep(j,n){
	  if(cur==j)continue;
	  D s = rot_seta(j);
	  if(nxt[cur]<0 || s > min_s[cur]+EPS)nxt[cur] = j, min_s[cur] = s;
	}
	min_s[cur] = acos(min_s[cur]);
	SIN[cur] = sin(min_s[cur]); COS[cur] = cos(min_s[cur]);
      }

      rep(j,n){
	if(j==cur || (f&&nxt[cur]<0))continue;
	x = p[j].real()-p[cur].real(); y = p[j].imag()-p[cur].imag();
	p[j] = P(x*COS[cur] - y*SIN[cur], x*SIN[cur] + y*COS[cur]) + p[cur];
      }
      printf("%.9lf %.9lf\n",p[nxt[cur]].real(), p[nxt[cur]].imag());

      if(!i){
	int tmp = nxt[cur];
	nxt[cur] = -1;
	cur = tmp;
      }else{
	cur = nxt[cur];
      }
    }
  }
}

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

//mod逆元を使ったnCkの計算(速)
const int64_t MAX = 3000000;
const int64_t MOD = 1000000007;

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

// 二項係数計算
int64_t COM(int64_t n, int64_t k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int64_t calc(int64_t x, int64_t y1, int64_t y2){
  int64_t A = COM(x+y2+1, y2); //0からc2まで
  int64_t B = COM(x+y1, y1-1); //0からc1-1まで
  A -= B;
  if(A < 0){
    A += MOD;
  }
  return A % MOD;
}
  


int main(){
  int64_t r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;
  int64_t sum = 0;
  COMinit();
  for(int i=r1; i<=r2; i++){
    sum += calc(i,c1,c2);
    sum %= MOD;
  }
  cout << sum << endl;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define ff first 
#define ss second  
typedef pair<int,int> pp;
bool com(pp x,pp y){
    return x.ff<y.ff;
} 
int N=1e5+9;
void solve(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i]; 
    sort(a,a+n);
    ll ans=a[n-1]; 
    if(n==3) ans+=a[n-2];
    else{ 
        int k=n-2;
        for(int i=n-2;i>=0&&k>0;i-=1){
            //cout<<k<<endl;
            if(k>1) ans+=a[i]*2,k-=2;
            else ans+=a[i],k-=1;
        }
    }
    cout<<ans;
}
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--) 
	    solve();
	return 0; 
	
}


Measured memory_bytes: 4396
a = []
for _ in range(3):
    a.append(list(map(int, input().split())))

n = int(input())
b = [int(input()) for _ in range(n)]

for x in b:
    for i in range(3):
        for j in range(3):
            if a[i][j] == x:
                a[i][j] = -1

for i in range(3):
    ok = True
    for j in range(3):
        if a[i][j] != -1:
            ok = False

    if ok:
        print("Yes")
        exit(0)

for j in range(3):
    ok = True
    for i in range(3):
        if a[i][j] != -1:
            ok = False
    if ok:
        print("Yes")
        exit(0)

if a[0][0] == -1 and a[1][1] == -1 and a[2][2]:
    print("Yes")
    exit(0)
if a[2][0] == -1 and a[1][1] == -1 and a[0][2]:
    print("Yes")
    exit(0)

print("No")


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    bool approved = true;
    for(int a : A) {
        if(a % 2 == 0) {
            if(a % 3 != 0 && a % 5 != 0) {
                approved = false;
                break;
            }
        }
    }

    if(approved) {
        cout << "APPROVED" << endl;
    } else {
        cout << "DENIED" << endl;
    }
    return 0;
}

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

int main() {
	string str;
	cin >> str;
	for(int pos = 0; pos < str.size(); pos++)
		if(str[pos] == '1')
			cout << '9';
		else if(str[pos] == '9')
			cout << '1';
		else 
			cout << str[pos];
}


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

int main(){
    int N,count=0;
  	string S;
  	cin>>N>>S;
    	for(int i=0;i<N-2;i++){
          if((S[i]=='A')&&(S[i+1]=='B')&&(S[i+2]=='C')){
            count++;
          }
        }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x,y;
  function<int(int,int)> gcd;
  cin >> x >> y;
  cout << x + y + 1 - (gcd = [&gcd](int a,int b){return b == 0 ? a : gcd(b,a % b);})(x,y) << endl;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
  int n; cin >> n;
  vector<ll> t(n),a(n),fixed(n);
  ll M= 0;
  for(int i = 0; i < n; ++i){
    cin >> t[i];
    if(M<t[i]){
      M=t[i];
      fixed[i]=1;
    }
  }
  for(int i = 0; i < n; ++i){
    cin >> a[i];
  }
  M=0;
  bool f = true;
  for(int i = n-1; i >= 0; --i){
    if(fixed[i] && a[i] < t[i]){
      f = false;
    }
    if(M<a[i]){
      M=a[i];
      fixed[i]= 1;
    }
  }
  ll ans = 0;
  if(f)ans = 1;
  ll now = 0;
  for(int i = 0; i < n; ++i){
    if(fixed[i]){
      ;
    }
    else{
      ans *= min(a[i],t[i]);
      ans %= MOD;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
/**
*@author: Ritchie Zhang
*@date:2020-4-26
**/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include <set>
typedef long long ll;
using namespace std;
int a[100010];

int main()
{
	set<string>s;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		string a;
		cin >> a;
		s.insert(a);
	} 
	cout << s.size() << endl;
	return 0;
}

Measured memory_bytes: 15516
from sys import stdin

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

point = 0
mi = 10**10
total = 0

for i in li:
    if i < 0:
        point += 1
    mi = min(mi,abs(i))
    total += abs(i)
if point % 2 == 0:
    print(total)
else:
    print(total-mi*2)

Measured memory_bytes: 14284
#include<stdio.h>
int main (void){
  int A[100];
  int n, a, d, i, j, minj;
  a = 0;
  scanf("%d", &n);
  for (i = 0;i < n;i++)
    scanf ("%d", &A[i]);
  for (i = 0;i < n - 1;i++){
    minj = i;
    for (j = i;j < n;j++){
      if (A[j] < A[minj])
        minj = j;
    }
    d = A[i];
    A[i] = A[minj];
    A[minj] = d;
    if (i != minj)
      a++;
  }
  for (i = 0;i < n;i++){
    if (i > 0)
      printf (" ");
    printf ("%d",A[i]);
  }
  printf ("\n");
  printf ("%d\n", a);
  return 0;
 }

Measured memory_bytes: 604
N, M = map(int, input().split())
A = list(map(int, input().split()))

Nd = {}

for i in range(M):
  B, C = map(int, input().split())
  if C in Nd.keys():
    Nd[C] = Nd[C] + B
  else:
    Nd[C] = B
  
for a in A:
  if a in Nd.keys():
    Nd[a] = Nd[a] + 1
  else:
    Nd[a] = 1
    
Nd = sorted(Nd.items(), key=lambda x: -x[0]) # type=list
sum = 0

for key, val in Nd:
  if N >= val:
    sum = sum + key*val
    N = N-val
  else:
    sum = sum + key*N
    break;
  
print(sum)

Measured memory_bytes: 49440
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/**
*   author: j o s e m a g o
*   user: m a m i s a k i
**/
using namespace std;

/***PLANTILLA***/

using namespace __gnu_pbds; //*st.find_by_order(1);  st.order_of_key(p);
#pragma GCC optimize ("Ofast")
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mset(a,v) memset(a,v,sizeof(a))
#define pb push_back
#define sz(x) ((int)(x).size())
#define rsz resize
#define ln "\n"
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef double dbl;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const ld PI = 2*acos(0.0);
const int MOD = 1000000007;

string tostring(auto a){
    stringstream ss;ss<<a;string s = ss.str();
    return s;
}

/**Mi Debug**/
#define var(x) cout<<#x<<" = ";
#define db(x) cout<<#x<<" = "<<x<<"\n";
void dbvector(vector<auto>&v){
    int c = -1;
    for(auto i: v){
        c++;cout<<"["<<c<<":"<<i<<"] ";
    }cout<<"\n";
}
void dbmapa(map<auto,auto>mp){
   for(auto x : mp) cout<<"{"<<x.first<<":"<<x.second<<"} ";cout<<"\n";
}
void dbstring(string v){
    int c = -1;
    for(auto i: v){
        c++;cout<<"["<<c<<":"<<i<<"] ";
    }cout<<"\n";
}

/***********Code***************/

const int JJJ = 100100;










int main(){

  //freopen("input.in","r",stdin);
  //freopen("input.out","w",stdout);

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


    ll a;
    ld b;
    cin >> a >> b;
    ll c = a*b;
    cout<<c;







    return 0;
}


Measured memory_bytes: 3744
fun main(args: Array<String>) {
    agc029a()
}

fun agc029a() {
    val s = readLine()!!.map { it == 'W' }.toBooleanArray()

    val wPos = mutableListOf<Long>()
    for (i in s.indices) if (s[i]) wPos.add(i.toLong())

    if (wPos.size == 0 || wPos.size == s.size) return println(0)

    val answer = wPos.sum() - (wPos.size - 1).toLong() * wPos.size / 2

    println(answer)
}


Measured memory_bytes: 40368