akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

	string s;
	cin >> s;
	int p=0,m=0;
	rep(i,s.size()){
		if(s[i]=='+')p++;
		else m++;
	}
	cout << p - m << endl;

	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(x)-1 for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

total = 0
prev = -2
for a in A:
    total += B[a]
    if prev + 1  == a:
        total += C[a-1]
    prev = a
print(total)





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

int n, a[Maxn][Maxn];
int main()
{
    scanf("%d", &n);
    if (n==1) { puts("Yes"); puts("1"); return 0; }
    if (n&1) { puts("No"); return 0; }
    puts("Yes");
    for (int i=1; i<=n; i++)
        for (int j=i; j<=n; j++)
            a[i][j]=(i+j-2)%n+1;
    for (int i=2; i<=n; i++)
        for (int j=1; j<i; j++)
        {
            a[i][j]=(i+j-2)%(n-1)+n;
            if (a[i][j]==n) a[i][j]=(n<<1)-1;
        }
    for (int i=2; i<n; i++)
        if (a[n][i-1] + 2 > (n<<1) - 1) a[n][i]=a[n][i-1]-(n-3);
        else a[n][i]=a[n][i-1] + 2;
    for (int i=1; i<=n; i++)
    {
        for (int j=1; j<n; j++)
            printf("%d ", a[i][j]);
        printf("%d\n", a[i][n]);
    }
}



Measured memory_bytes: 4200
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a / g * b;
}

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

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll ans = b - a + 1;

    // cで割り切れる
    ans -= (b / c - (a - 1) / c);

    // dで
    ans -= (b / d - (a - 1) / d);

    // lcmで
    ll e = lcm(c, d);
    ans += (b / e - (a - 1) / e);

    cout << ans << "\n";
    return 0;
}

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

#define read(a) cin >> a
#define out(a)  cout << a
#define ull unsigned long long
#define ll long long
#define FOR(i, l, r) for (ll i = l; i <= r; i++)
#define FOD(i, l, r) for (ll i = l; i >= r; i--)
#define fast ios_base::sync_with_stdio(0);
#define mod 1000000007
#define ll long long

int main()
{
    ll a, b, c, d, t1 = 0, t2 = 0, t3 = 0, t4 = 0, kq = 0;
    cin >> a >> b >> c >> d;
    t1 = a * c;
    t2 = a * d;
    t3 = b * c;
    t4 = b * d;

    cout << max(max(t1, t2), max(t3, t4));

}


Measured memory_bytes: 3540
#include <iostream>

using namespace std;

char s[51][51];

int vx[] = { 0,  1, 1, 1, 0, -1, -1, -1};
int vy[] = {-1, -1, 0, 1, 1,  1,  0, -1};

// 周囲にMineがいくつあるかカウントする
int countMine(int h, int w, int x, int y) {
    int cnt = 0;

    for (int i = 0; i < 8; i++) {
        if (((x + vx[i] < w && x + vx[i] >= 0) || (y + vy[i] < h && y + vy[i] >= 0)) && (s[x + vx[i]][y + vy[i]] == '#')) cnt++;
    }

    return cnt;

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

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

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '.') s[i][j] += 2 + countMine(h, w, i, j);

            if (j != w - 1) cout << s[i][j];
            else cout << s[i][j] << endl;
        }
    }

    // for (int i = 0; i < h; i++) {
    //     for (int j = 0; j < w; j++) {
    //         if (j != w - 1) cout << s[i][j];
    //         else cout << s[i][j] << endl;
    //     }
    // }

    return 0;
}


Measured memory_bytes: 760
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define INF 9876543219876
#define PI 3.14159265358979323846264
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
ll MOD = 1000000009;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,-1,1,0 }, dy[] = { 1,0,0,-1 };
int ddx[] = { 0,0,1,1,1,-1,-1,-1 }, ddy[] = { 1,-1,1,0,-1,1,0,-1 };


int main() {
	int a, b, c, x, y;
	scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);
	int xy = 2 * c;
	int ans = a*x + b*y;
	fup(i, 1, 100000, 1)
	{
		int temp = xy*i;
		if (x > i)temp += (x - i)*a;
		if (y > i)temp += (y - i)*b;
		ans = min(ans, temp);
	}
	printf("%d", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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 long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int a, b, k; cin >> a >> b >> k;
    int p = max(a, b), q = min(a, b);
    int ans = 0;
    RRep(i, q, 0)
    {
        if (a % i == 0 && b % i == 0) k--;
        if (0 == k)
        {
            ans = i; break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n,m;
  cin>>n>>m;
  vector<int> a(m);
  rep(i,m) cin>>a[i];
  sort(rall(a));
  a[0]-=(n+1)/2;
  if(a[0]<=0){
    cout<<0<<endl;
    return 0;
  }
  vector<int> v(n);
  rep(i,n) if(i%2==0 || (n-i-1)/2<a[0]) v[i]=1;
  int re=0;
  reps(i,1,n) if(v[i-1]&&v[i]) ++re;
  //cout<<v;
  cout<<re<<endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
 
#define X first
#define Y second
 
//#include <boost/unordered_map.hpp>
//using namespace boost;
 
/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/
 
using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
//using i128 = i64;
//using u128 = u64;
 
ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}
 
ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

ll gcd(ll a, ll b)
{
	return b ? gcd(b, a%b) : a;
}
 
template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}
 
template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

template<class T>
void print(const T &a)
{
	for (auto x : a) printf("%d ", x); puts("");
}

const int MAXN = 500010;
//const int MAXM = 100010;
const int MAXK = 30;
//const i64 INF = 1000000000000000000LL;
const int INF = 1000000000;
//const int MOD = 998244353;
const int B = 31;
const int MOD = 998244353;
//const int INV2 = (MOD+1)/2;
const ld pi = 3.1415926535897932384626433;

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

#define rep(i,a,b) for (int i = (a), I = (b); i <= I; ++ i)

int days[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

bool leap(int y)
{
	return y%4 == 0 && y%100 != 0 || y%400 == 0;
}

int n, m;
int a[MAXN];
vector<int> v[MAXN];

void solve()
{
	int a, b;
	cin >> a >> b;
	cout << max(a-b-b, 0) << endl;
}

int main()
{
	
	int T;
	T = 1;
	//scanf("%d", &T);
	while (T --)
	solve();
	
	return 0;
}


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

void print2DArray(vector<vector<long long int>> A)
{
    for(auto x : A)
    {
        for(auto y : x) cout<< y <<" ";
        cout<<endl;
    }
    cout<<endl;
}

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

    vector<int> wt(n);
    vector<int> val(n);

    for(int i = 0; i < n; i++)
    {
        cin>>wt[i]>>val[i];
    }

    vector<vector<long long int>> dp(n+1, vector<long long int> (max_wt+1, 0));
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= max_wt; j++)
        {
            long long int x = (j >= wt[i-1]) ? val[i-1] + dp[i-1][j-wt[i-1]] : 0;
            long long int y = dp[i-1][j];

            dp[i][j] = max(x, y);
        }
        // print2DArray(dp);
    }

    cout<<dp[n][max_wt]<<endl;

    return 0;
}


Measured memory_bytes: 80256
/*
Created by Rishu Sahu
*/
/*
*****************************************************************
*/

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

#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define pai pair<int,int>
#define f first
#define s second
#define sz(x) (int)x.size()
#define vi vector<nt>

const int mod = 1e9+7;
const int INF = INT_MAX;



void solve(){
   ll x,k,d;
   cin>>x>>k>>d;
  if(x<0)
    x=-x;
   ll req=x/d;
   if(req>=k){
        cout<<(x-d*k)<<endl;
   }

   else{
        k=k-req;
        //x=abs(x)-req*abs(d);
        if(k%2==0){
            cout<<""<<abs(x%d)<<endl;
        }
        else{
            cout<<""<<abs(d-x%d)<<endl;
        }
   }


}


int main(){
    /*int t;
    cin>>t;
    while(t--){*/
        solve();
    //}
}
/*
1000000000000000
1000000000000000
1000000000000000
*/


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int INF = 1e9;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int H,W,N;
    cin >> H >> W >> N;
    cout << min((N + H - 1) / H,(N + W - 1) / W) << endl;
}

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	int n, m;
	cin >> n >> m;

	VI connected(n + 1, 0);
	REP(i, 0, m)
	{
		int u, v;
		cin >> u >> v;
		++connected[u];
		++connected[v];
	}

	for(int i = 1; i <= n; ++i)
		cout << connected[i] << endl;

	return 0;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

class UnionFind {
public:
   vector<int> parent, rank;

   UnionFind(){}

   UnionFind(int size) {
      parent.resize(size, 0);
      rank.resize(size, 0);
      for (int i = 0; i < size; i++) {
         parent[i] = i;
      }
   }

   void init(int size) {
      parent.resize(size, 0);
      rank.resize(size, 0);
      for (int i = 0; i < size; i++) {
         parent[i] = i;
      }
   }

   int find(int x) {
      if(parent[x] == x) {
         return x;
      } else {
         return parent[x] = find(parent[x]);
      }
   }

   void unite(int x, int y) {
      x = find(x);
      y = find(y);
      if (x == y) return;

      if (rank[x] < rank[y]) {
         parent[x] = y;
      } else {
         parent[y] = x;
         if (rank[x] == rank[y]) rank[x]++;
      }
   }

   bool same(int x, int y) {
      return find(x) == find(y);
   }
};

int N, M;
int p[111111];

signed main() {
   cin >> N >> M;
   UnionFind uf(N);
   rep (i, N) {
      cin >> p[i];
      p[i]--;
   }
   rep (i, M) {
      int x, y;
      cin >> x >> y;
      x--, y--;
      uf.unite(x, y);
   }

   int cnt = 0;
   rep (i, N) {
      if (uf.same(i, p[i])) {
         cnt++;
      }
   }

   cout << cnt << endl;

   return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N,K;
    cin>>N>>K;
    vector <ll> H(N);
    loop(i,0,N) {
        cin >>H[i];
    }
    sort(H.begin(), H.end());
    ll sum=0;
    loop(i,0,N-K) {
        sum+=H[i];
    }
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 1792
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    a,b,k = map(int, input().split())
    turn = 0
    while k > 0:
        k -= 1
        if turn == 0:
            if a%2 == 1:
                a -= 1
            a //= 2
            b += a
        else:
            if b%2 == 1:
                b -= 1
            b //= 2
            a += b
        turn ^= 1
    print(a, b)

if __name__ == '__main__':
    main()

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

int main(){
  	int N;
  	cin >> N;
  	int ans = 0;
  	for(int i = 0; i < N; i++){
    	int l, r;
      	cin >> l >> r;
      	ans += r - l + 1;
    }
  	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<vector>
#include<cmath>
#include<set>
#define int long long int
const int maxn=21;
int32_t main()
{
    int n;
    cin>>n;
    set<int> s;
    int j;
    for(j=0;j<n;j++)
    {
		int x;
		cin>>x;
		s.insert(x);
	}
	int val=s.size();
	int cut=n-val;
	if(cut%2!=0)
	  val--;
	cout<<val<<endl;
}


Measured memory_bytes: 4992
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

const int MAX = 100;

int main(){
    int N;
    int W[MAX];
    int l = 0;
    int r = 0;
    int ans = 1 << 30;

    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> W[i];
        r += W[i];
    }

    for(int i = 0;i < N;i++){
        l += W[i];
        r -= W[i];
        ans = min(ans,abs(l - r));
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if ((a == 1 && b == 2) || (a == 2 && b == 1)) cout << 3 << endl;
  else if ((a == 2 && b == 3) || (a == 3 && b == 2)) cout << 1 << endl;
  else cout << 2 << endl;
}

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

int main(){
  int64_t N,T;
  cin>>N>>T;
  vector<int64_t> A(N),B(N);
  for(int i=0;i<N;++i) cin>>A[i]>>B[i];


  //i番目以降からj以下なるように選ぶdp[i][j]
  //dp[i][j][0]はi番目以降から最後の注文を選ばない場合
  //dp[i][j][1]は選ぶ場合

  int64_t dp[N+1][T][2];
  
  for(int i=0;i<=N;++i){
    for(int j=0;j<T;++j){
      dp[i][j][0]=0;
      dp[i][j][1]=0;
    }
  }

  for(int i=N-1;i>=0;--i){
    for(int j=0;j<T;++j){
      if(j<A[i]){
        dp[i][j][0]=dp[i+1][j][0];
        dp[i][j][1]=max(dp[i+1][j][1],dp[i+1][j][0]+B[i]);
      }
      else{
        dp[i][j][0]=max(dp[i+1][j][0],dp[i+1][j-A[i]][0]+B[i]);
        dp[i][j][1]=max(dp[i+1][j][1],max(dp[i+1][j-A[i]][1]+B[i],dp[i+1][j][0]+B[i]));
      }
    }
  }

  cout<<dp[0][T-1][1]<<endl;
}


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

int main(){
    long long n ,a, b;
    cin >> n >> a >> b;
    if(a==0){
        cout << 0 << endl;
        return 0;
    }
    if(b==0){
        cout << n << endl;
        return 0;
    }
    if(a >= n){
        cout << n << endl;
        return 0;
    }
    cout << (long long)(n/(a+b)) * a + min(a,n - (long long)(n/(a+b)) * (a+b))  << endl; 
    return 0;
}

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

ll pow5(ll x){
    return 1ll*x*x*x*x*x;
}

int main(){
    ll x, a=0, b=0;

    cin >> x;
    for(ll i=0;i<4000;i++){
        for(ll j=i+1;j<4000;j++){
            if(x==pow5(j)-pow5(i)){
                a = j; b = i;
                break;
            }
            else if(x==pow5(j)-pow5(-i)){
                a = j; b = -i;
                break;
            }
            else if(x==pow5(-j)-pow5(i)){
                a = -j; b = i;
                break;
            }
        }
    }

    cout << a << " " << b <<'\n';   
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#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;
typedef long long ll;

const ll MOD = 1000000007;

ll mod_add(ll a, ll b){
    return ((a % MOD) + (b % MOD)) % MOD;
}
 
ll mod_mul(ll a, ll b){
    return ((a % MOD) * (b % MOD)) % MOD;
}

ll mod_pow(ll x, ll r){
    if (r == 0) return 1;

    else if (r == 1) return x % MOD;

    else if (r % 2 == 0){
        ll t = mod_pow(x, r/2) % MOD;
        return mod_mul(t, t);
    }

    else{
        ll t = mod_pow(x, r/2) % MOD;
        ll k = mod_mul(t, t);
        return ((k % MOD) * (x % MOD)) % MOD;
    }
}

ll mod_div(ll a, ll b){
    return mod_mul(a, mod_pow(b, MOD - 2));
}

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

    ll x, y;
    cin >> x >> y;

    if((x+y)%3 != 0 || min(x, y)*2 < max(x, y)){
        cout << 0 << endl;
        return 0;
    }

    // coordinate transformation
    ll n = (x+y) / 3;
    x %= n;
    y %= n;

    // calc nCx
    ll numerator = 1;
    rep(i, x){
        numerator = mod_mul(numerator, (n-i));
    }

    ll denominator = 1;
    rep1(i, x+1){
        denominator = mod_mul(denominator, i);
    }
    
    ll res = mod_div(numerator, denominator);

    cout << res << endl;

    return 0;
}

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

int main() {
  double a;
  while(cin >> a) {
    double sum=a;
    for(int i=1; i<10; i++) {
      if(i%2==1) a*=2;
      else a/=3;
      sum+=a;
    }
    printf("%.8f\n",sum);
  }
  return 0;
}


Measured memory_bytes: 1236
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int x = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();

        out.println(Math.abs(x - a) > Math.abs(x -b) ? "B" : "A");
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

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

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

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

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 20948
#include<bits/stdc++.h>
using namespace std;
map<int, int> M1;
map<int, int> M2;
int main()
{
  int N; scanf("%d", &N);
  M1[0] = 0; M2[0] = 0;
  for(int i=0; i<N/2; ++i)
  {
  
    int a;
    scanf("%d", &a); M1[a] = M1[a] + 1;
    scanf("%d", &a);  M2[a] = M2[a] + 1;
  }
  vector<pair<int, int> > V1, V2;
  for(auto x: M1)
  {
    int a, b; tie(a, b) = x; V1.emplace_back(b, a);
  }
  for(auto x: M2)
  {
    int a, b; tie(a, b) = x; V2.emplace_back(b, a);
  }
  sort(V1.rbegin(), V1.rend());
  sort(V2.rbegin(), V2.rend());
  int ans;
  if(V1[0].second == V2[0].second)
    ans = max(V1[1].first+V2[0].first, V1[0].first+V2[1].first);
  else
    ans = V1[0].first + V2[0].first;
  printf("%d\n", N-ans);
  return 0;
}

Measured memory_bytes: 6136
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,c,k;
    cin>>a>>b>>c>>k;
    long long sum=0;
    if(k<=a){
        sum=k;
    }
    else{
        sum=a;
        k=k-a;
        if(k>b){
            k=k-b;
            sum=sum-k;
        }
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define len(x) (int) x.size()
using namespace std;

const int MAX {200005};
vector<int> adj[MAX];
int total[MAX];

void dfs(int u, int p=-1) {
    for(int v : adj[u]) {
        if (v == p) continue;
        total[v] += total[u];
        dfs(v, u);
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    memset(total, 0, sizeof(total));

    int u, v;
    for(int i = 0; i < n-1; i++) {
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    int xx, value;
    for(int i = 0; i < q; i++) {
        cin >> xx >> value;
        total[xx] += value; 
    }
    dfs(1);

    for(int i = 1; i <= n; i++) {
        cout << total[i] << (i == n? '\n' : ' ');
    }

    return 0;
}

Measured memory_bytes: 23424
#include<iostream>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int r = 0, b = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'R'){
            r++;
        }else{
            b++;
        }
    }
    if(r > b){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<map>
#define ll long long int
#define ld long double
#define pb push_back
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 100009
#define endl '\n'
#define mp make_pair
#define INF 100000000
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ff first
#define ss second
#define ps(x,y) fixed<<setprecision(y)<<x
#define pii pair<long long int,long int>
#define mii map<long long int,long long int>
#define w(t) 	int t; cin>>t; while(t--)

using namespace std;

//ll c[MAX];




int main() {
	int n,m;
	cin>>n>>m;
	ll h[n];
	forn(i,n)	cin>>h[i];
	ll a[m],b[m];
	forn(i,m)	cin>>a[i]>>b[i];
	vector<pair<ll,ll> > v1,v2;
	forn(i,m){
		v1.pb(mp(a[i],b[i]));
		v2.pb(mp(b[i],a[i]));
	}
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	vector<ll> v[n];
	int flag[n];
	forn(i,n)	flag[i]=1;
	forn(i,m){
		if(h[v1[i].ss-1]>=h[v1[i].ff-1]){
			flag[v1[i].ff-1]=0;
		}
		if(h[v2[i].ss-1]>=h[v2[i].ff-1]){
			flag[v2[i].ff-1]=0;
		}
	}
	ll cnt=0;
	forn(i,n){
		if(flag[i]==1)		cnt++;
	}
	cout<<cnt;
}


Measured memory_bytes: 11692
ary=gets.chomp.split(" ")
stack=[]
c=[]
ary.each {|x|
	if x =~ /\d+/ 
		x=x.to_i
		stack.unshift(x)
		
	c=nil
	elsif x== "+" || x=="-" || x=="*" || x=="/"
		b=stack.shift
		a=stack.shift
		case x
			when "+"
				stack=stack.unshift(a+b)
			when "-"
				stack=stack.unshift(a-b)
			when "*"
				stack=stack.unshift(a*b)
			when "/"
				stack=stack.unshift(a/b)
		end
	end
}
puts stack

Measured memory_bytes: 8516
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include<vector>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<pair<int,int>>a(n);
    for(int i=1;i<=n;++i){
        int s;
        cin>>s;
        a[i-1]={s,i};
    }
    sort(a.begin(),a.end());
    for(auto x:a){
        cout<<x.second<<endl;
    }
}


// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;	cin>>n;
	string s;	cin>>s;
	int d;	cin>>d;
	string t=s;
	for(int i=0;i<n&&d>0;i++){
		if(s[i]=='0'){
			d--;
			s[i]='1';
		}
	}
	for(int i=n-1;i>=0&&d>0;i--){
		if(t[i]=='1'){
			d--;
			s[i]='0';
		}
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
#include <time.h>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[1000][1000];
    bool graph[1000][1000];
    clock_t st = clock();
    memset(graph,false,sizeof(graph));
    for (int i = 0; i < N; i++){
        for (int j = 0; j < N-1; j++){
            cin >> a[i][j];
            a[i][j]--;
        }
    }
    int in[1000]; fill(in,in+1000,0);

    int day = 0;
    int time = 0;
    while (true){
        bool game = false; //試合を行ったか
        day++;
        bool used[1000]; fill(used,used+1000,false);
        for (int i = 0; i < N; i++){
            int dest = a[i][in[i]];
            if (in[i] >= N-1) continue;
            if (graph[i][dest] == true || graph[dest][i] == true){
                //cout << "i : " << i << ", day = " << day << ", ";
                //cout << "dest = " << dest << endl;
                cout << -1 << endl;
                return 0;
            }
            if (used[i] || used[dest]) continue;
            //graph[i][a[i][in[i]]] = true;
            //graph[a[i][in[i]]][i] = true;
            
             //目的地の目的地
            int dest_of_dest = a[dest][in[dest]];
            if (in[dest] >= N-1) continue;
            if (dest_of_dest == i && used[i] == false && used[dest] == false){
                //cout << "day = " << day << ", i = " << i << ", dest = " << dest << endl;
                //cout << "";
                used[i] = true;
                used[dest] = true;
                graph[i][dest] = true;
                graph[dest][i] = true;
                
                in[dest]++;
                in[i]++;
                game = true;
            }
            if ((double)(clock()-st)/CLOCKS_PER_SEC >= 1.99){
                cout << N*(N-1)/2 << endl;
                return 0;
            }
        }

        bool flg = true;
        for (int i = 0; i < N; i++){
            if (in[i] < N-1) flg = false;
        }
        if (flg) break;
        if (day >= 499500){
            cout << -1 << endl;
            return 0;
        }
        if (!game){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << day << endl;
}


Measured memory_bytes: 5120
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";


    void Solve()
    {
        int N = cin.Nextint;
        int M = cin.Nextint;
        var G = new int[N];
        for (int i = 0; i < M; i++)
        {
            int a = cin.Nextint - 1;
            int b = cin.Nextint - 1;
            G[a]++;
            G[b]++;
        }
        for (int i = 0; i < N; i++)
        {
            WriteLine(G[i]);
        }
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

Measured memory_bytes: 11216
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  string s; readV(s);
  writeln(s[0], s.length-2, s[$-1]);
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-8
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long i=0; i<n; ++i) { cout<<a[i]; if(i!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> vl;
typedef vector<vector<long long> > vll;
typedef vector<P> vp;
typedef vector<vector<P> > vpp;
class RMQ {
#define RMQ_MAX ((1ll<<31)-1)
public:
	RMQ(int n) {
		_n=1;
		while(_n<n) _n*=2;
		_dat.resize(2*_n-1);
		for(int i=0;i<2*_n-1;++i) _dat[i]=(RMQ_MAX);
	}
	int size() {
		return _n;
	}
	void update(int k,long long a) {
		k+=_n-1;
		_dat[k]=a;
		while(k>0) {
			k=(k-1)/2;
			_dat[k]=min(_dat[k*2+1],_dat[k*2+2]);
		}
	}
	// return the minimum number in [a,b)
	// external call should be written like query(a,b,0,0,_n)
	ll query(int a,int b,int k=0,int l=0,int r=-1) {
		if(r==-1) r=_n;
		if(r<=a||b<=l) return RMQ_MAX;
		if(a<=l&&r<=b) return _dat[k];
		else {
			ll vl=query(a,b,k*2+1,l,(l+r)/2);
			ll vr=query(a,b,k*2+2,(l+r)/2,r);
			return min(vl,vr);
		}
	}
private:
	int _n;
	vector<ll> _dat;
};
int main() {
	ios::sync_with_stdio(false);
	int n,q;
	cin>>n>>q;
	RMQ rmq(n);
	REP(i,q) {
		int c,x,y;
		cin>>c>>x>>y;
		if(c==0) {
			rmq.update(x,y);
		}
		if(c==1) {
			cout<<rmq.query(x,y+1)<<endl;
		}
	}
}

Measured memory_bytes: 4952
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> nums(n, 0);

    for (int i = 0; i < k; i++)
    {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            int a;
            cin >> a;
            nums[a - 1]++;
        }
    }
    int count = 0;
    for (auto v : nums)
    {
        if (v == 0)
        {
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3196
L, R = map(int, input().split())
l = L % 2019
r = R % 2019
w = R - L
if l + w >= 2019:
  print(0)
else:
  ans = 2019
  for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
      ans = min(ans, (i * j) % 2019)
  print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

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

    if (S == "SUN") cout << 7;
    else if (S == "MON") cout << 6;
    else if (S == "TUE") cout << 5;
    else if (S == "WED") cout << 4;
    else if (S == "THU") cout << 3;
    else if (S == "FRI") cout << 2;
    else if (S == "SAT") cout << 1;
    cout << endl;
}

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

int main(){
	int A,B;
  cin >>  A >> B;
  int i;
   for(i=0;i<1100;i++){
   	  if(i*8/100==A&&i/10==B){
      	break;
      }	
   }
  if(i>1050){
  	i=-1;
  }
  
	cout << i << endl;

	return 0;
}

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

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

    long long a[n];

    long long maxv = 0;
    long long index_max;
    for(long long i = 0; i < n; i++){
        cin >> a[i];
        if(maxv < a[i]){
            maxv = a[i];
            index_max = i;
        }
    }

    long long comb_standard = maxv/2;
    long long comb_min = comb_standard*comb_standard;
    long long r = 0;
    for(long long i = 0; i < n; i++){
        if(i == index_max){
            continue;
        }

        if(comb_min > (comb_standard - a[i])*(comb_standard - a[i])){
            comb_min = (comb_standard - a[i])*(comb_standard - a[i]);
            r = a[i];
        }
    }

    printf("%lld\n", maxv);

    printf("%lld\n", r);

    return 0;
}

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

int main(void){
  int n,i;
  double b;
  cin >> n;
  vector<double> a(n);
  for(i=0;i<n;i++){
    cin >> a[i];
    a[i] = 1/a[i];
  }

  for(i=0;i<n;i++){
    b += a[i];
  }

  printf("%.10lf",1/b);
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    int a;
    long long s = 0;
    vector<int> an(100001, 0);
    for (int i = 0; i < n; i++) {
        cin >> a;
        s += a;
        an[a]++;
    }

    int q;
    cin >> q;
    int b, c;
    for (int i = 0; i < q; i++) {
        cin >> b >> c;

        s += an[b] * (c - b);
        an[c] += an[b];
        an[b] = 0;

        cout << s << endl;
    }
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#define pb push_back
#define mkp make_pair
#define maxx 1000000005
#define MOD 1000003
#define sf(n) scanf("%lld", &n);
#define sff(n,m) scanf("%lld %lld", &n, &m)
#define pf(n) printf("%lld\n", n)
#define pff(n,m) printf("%lld %lld\n", n, m)
#define mem(a) memset(a, 0, sizeof(a))
#define mem(a,b) memset(a, (b), sizeof(a))
#define fr(i,n) for(ll i=0; i<n; i++)
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type))
#define pi 2*acos(0.0)
#define F first
#define S second
#define EPS 1e-9

using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll a[100005];
ll dp[100005];

ll fun(ll n)
{
    for(ll i=2; i<=n; i++)
    {
        if(i==2) dp[2]=abs(a[1]-a[2]);
        else if(i==3) dp[3]=abs(a[1]-a[3]);
        else
        {
            dp[i]=min((dp[i-1]+abs(a[i]-a[i-1])), (dp[i-2]+abs(a[i]-a[i-2])));
        }
    }
    return dp[n];
}

int main()
{
    //freopen("testcases.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll n;
    while(cin>>n)
    {
        mem(dp, -1);
        for(ll i=1; i<=n; i++)
            cin>>a[i];
        cout << fun(n) << endl;
    }

    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}

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

int main(){
  int N, X;
  cin >> N >> X;
  int sum=0, tmp, i;
  for(i=0; i<N; i++){
    cin >> tmp;
    sum += tmp;
    if (sum > X) break;
  }
  
  cout << i+1;
  
  return 0;
}

Measured memory_bytes: 256
fun main (args:Array<String>){
    val badid : String = (readLine()!!)
    val newid : String = (readLine()!!)
    val nidlen : Int = newid.length
    val aaa : String = newid.substring(0,nidlen-1)
    if(badid == aaa){
        print("Yes")
    }
    else{
        print("No")
    }
}


Measured memory_bytes: 34360
import kotlin.math.abs

fun main() {
    val n = readLine()!!.toInt()
    val k = readLine()!!.toInt()
    val xn = readLine()!!.split(" ").map { it.toInt() }
    val ans = solve(n, k, xn)
    println(ans)
}


fun solve(n: Int, k: Int, xn: List<Int>): Int {
    return xn.map {xi ->
        val absK = abs(xi - k)
        val small = if (absK > xi) xi else absK
        2 * small
    }.sum()
}


Measured memory_bytes: 36548
n = int(input())
a = list(map(int, input().split()))
a = [a[0]] + a
hoge = 0
ans = 1
for i in range(n):
    prev = a[i]
    now = a[i+1]
    # どちらにも行ける
    if hoge == 0:
        if now > prev:
            hoge = 1
        elif now < prev:
            hoge = -1
    # 増加中
    elif hoge == 1:
        if now < prev:
            hoge = 0
            ans += 1
    # 減少中
    else:
        if now > prev:
            hoge = 0
            ans += 1
print(ans)


Measured memory_bytes: 14252
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<list>
#include<algorithm>
#include <ctype.h>
#include<deque>
using namespace std;
using ll = long long int;

int h, w;
vector<string> field;
vector<bool> row(100, true), column(100, true);
int main(void) {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		string s;
		cin >> s;
		field.push_back(s);
		for (int j = 0; j < w; j++) {
			if (s[j] == '#') {
				row[i] = false;
				column[j] = false;
			}
		}
		if (row[i])
			field.pop_back();
	}

	for (int i = w - 1; i >= 0; i--) {
		if (column[i]) {
			for (int j = 0; j < field.size(); j++) {
				field[j].erase(field[j].begin() + i);
			}
		}
	}

	for (int i = 0; i < field.size(); i++) {
		cout << field[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,x;
	while(cin>>a>>b>>c>>x){
		int ans=0;
		for(int i=0;i<=a;i++){
			for(int j=0;j<=b;j++){
				for(int k=0;k<=c;k++){
					if(i*500+j*100+k*50==x) ans++;
				}
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, f, n) for (ll i = (f); i < (ll)(n); i++)
#define repe(i, f, n) for (ll i = (f); i <= (ll)(n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pint = pair<int, int>;

int main() {
  ull a, b, x;
  cin >> a >> b >> x;
  if (a == 0)
    cout << (b / x + 1) << endl;
  else
    cout << (b / x - (a - 1) / x) << endl;
  return 0;
}


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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for(auto &z: v)
#define sp << ' ' << 
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353

int main()
{
    boost;
    ll tt = 1, n, m, k = 0, i, j;
    ll q, l = 0, r = 0, x, y, z, h, a, b, c, d;

    bool poss = true;
    string s;
    // cin >> tt;
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        cin >> s;
        s[1] = 'R' + 'B' - s[1];
        cout << s << nl; 
    }   
    return 0;
}

Measured memory_bytes: 3668
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#include<complex>
#define EPS 1e-10
using namespace std;
typedef long long llong;
vector<int>ans;
vector<int>a, b;
int m;
void dandc(int x, int i) {
	if (x > 1009)return;
	if (i == m) {
		ans[x]++;
		//cout << "ans[" << x << "] = " << ans[x] << endl;
		return;
	}
	//cout << "i" << " = " << i << endl;
	for (int j = 0; j <= b[i]; j++) {
		dandc(x + j*a[i], i + 1);
	}
}
int main() {
	while (cin >> m&&m) {
		ans = vector<int>(1010, 0);
		a = b = vector<int>(m,0);
		for (int i = 0; i < m; i++) {
			cin >> a[i] >> b[i];
		}
		dandc(0, 0);
		//for (int i = 0; i < 1010; i++) {
		//	cout << i << " : " << ans[i] << endl;
		//}
		int g, n;
		cin >> g;
		while (g--) {
			cin >> n;
			cout << ans[n] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3160