akhauriyash/Code-Regression huggingface dataset:
// Last Change: 05/06/2019 19:45:38.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

class UnionFind {
private:
  vector<long long> vec;

private:
  long long FindRoot(long long ipt) {
    if (vec[ipt] == ipt) {
      return ipt;
    } else {
      vec[ipt] = FindRoot(vec[ipt]);
      return vec[ipt];
    }
  }

public:
  UnionFind() = delete;
  UnionFind(const UnionFind &another) = delete;
  UnionFind(long long size) {
    vec.resize(size);
    for (long long i = 0; i < size; ++i) {
      vec[i] = i;
    }
  }

  bool Same(long long a, long long b) {
    return FindRoot(a) == FindRoot(b);
  }

  void Union(long long a, long long b) {
    long long x = FindRoot(a);
    long long y = FindRoot(b);
    vec[y] = x;
  }
};

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

  vector<ll> p(N);
  for (auto &&e : p) {
    cin >> e;
    --e;
  }

  UnionFind unf(N);
  for (ll i = 0; i < M; ++i) {
    ll x, y;
    cin >> x >> y;
    --x;
    --y;
    unf.Union(x, y);
  }

  ll cnt = 0;
  for (ll i = 0; i < N; ++i) {
    if (unf.Same(i, p[i])) {
      ++cnt;
    }
  }

  cout << cnt << endl;

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 1792
#include<algorithm>//sort(all(変数),greater<型名>())で降順に、*max_element(all(変数))で最大値を獲得
#include<bits/stdc++.h>
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric>
//xとyのgcdは__gcd(x,y),xとyのlcmは(x*y)/__gcd、accumulate(all(変数),0)で要素の全加算
#include<queue>//priority_queue<型名> 変数
#include<set>
#include<stack>
#include<string>
#include<vector>
#define rep(i,n)  for(ll i=0; i<n; i++)
#define rrep(i,n) for(ll i=n-1; 0<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e18
using ll = long long;
using namespace std;
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; }

int main(){
  int n,m;  cin >> n >> m;
  vector<vi> to(n);
  rep(i,m){
    int a,b;  cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  queue<int> q;
  vi dist(n,1e5);
  vi node(n, -1);
  dist[0] = 0;
  q.push(0);
  while (!q.empty()) {
    int now = q.front(); q.pop();
    for(int next : to[now]){
      if(dist[next] != 1e5) continue;
      dist[next] = dist[now]+1;
      node[next] = now;
      q.push(next);
    }
  }
  rep(i,n){
    if(i == 0) cout << "Yes\n";
    else cout << node[i]+1 << "\n";
  }
}


Measured memory_bytes: 10624
#include<bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define A first
#define B second
#define make_pair MP
#define MOD 1000000007
#define MAXM 100005
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int mulmd(ll a, ll b){
    ll ret = (a * b) % MOD;
    return (int)ret;

}

inline int power(ll x, ll y, int p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = mulmd(res,x);
        y = y>>1;
        x = mulmd(x,x);
    }
    return (int)res;
}

int submd(ll a, ll b){
    ll ret = a-b;
    if(ret<0){
        ret+=MOD;
    }
    return (int)ret;
}

int addmd(ll a, ll b){
    ll ret = (a + b) % MOD;
    return (int)ret;
}

int phi(int n){
    int result = n;
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            while(n%i==0){
                n=n/i;
            }
            result-=result/i;
        }
    }
    if(n>1) result-=result/n;
    return result;
}

int gcd(int a, int b, int& x, int& y){
    if(a==0){
        x=0;
        y=1;
        return b;
    }
    int x1,y1;
    int d = gcd(b%a, a, x1, y1);
    x = y1 - (b/a)*x1;
    y = x1;
    return d;
}

int arr[100005];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string g;
    cin>>g;
    if(g=="Sunny")
        cout<<"Cloudy";
    else if(g=="Cloudy")
        cout<<"Rainy";
    else
        cout<<"Sunny";
}


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

const int64_t MOD = 1000 * 1000 * 1000 + 7;

template <uint8_t max_value, uint8_t mod_value>
struct index_mod {
  uint8_t mod[max_value];
  constexpr index_mod() : mod() {
    for (size_t i = 0; i < max_value; ++i) {
      mod[i] = i % mod_value;
    }
  }
};

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

  // i番目の文字を見た時に13との剰余がnになる個数を数え上げる
  std::vector<int64_t> dp(2 * 13);

  constexpr index_mod<13 * 10, 13> imod;

  {
    int val = -1;
    if (s[0] != '?') val = s[0] - '0';
    if (val == -1) {
      for (size_t i = 0; i < 10; ++i) {
        dp[i % 13] = 1;
      }
    } else {
      dp[val % 13] = 1;
    }
    // % 13は不要だけど定義に帰るため
  }

  for (size_t i = 1, e = s.length(); i < e; ++i) {
    int val = -1;
    if (s[i] != '?') val = s[i] - '0';
    if (val == -1) {
      for (size_t here = 0; here < 10; ++here) {
        for (size_t pre = 0; pre < 13; ++pre) {
          auto &here_dp = dp[13 + imod.mod[pre * 10 + here]];
          const auto &pre_dp = dp[pre];
          here_dp = here_dp + pre_dp;
        }
      }
    } else {
      for (size_t pre = 0; pre < 13; ++pre) {
        auto &here_dp = dp[13 + imod.mod[pre * 10 + val]];
        const auto &pre_dp = dp[pre];
        here_dp = here_dp + pre_dp;
      }
    }

    for (size_t i = 0; i < 13; ++i) {
      dp[i] = dp[13 + i] % MOD;
      dp[13 + i] = 0;
    }
  }

  std::cout << dp[5] << std::endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
   int a,b,c,d,sec,x,y;
   cin>>a>>b>>c>>d;
   sec=a+b+c+d;
   x=sec/60;
   y=sec%60;
   cout<<x<<endl;
   cout<<y<<endl;
    return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define ll long long
#define rep(i, a) for(ll i=0; i<a; i++)
#define rep1(i, a, b) for(ll i=a; i<b; i++)
using namespace std;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll fun(vi &v, ll s, ll e, vvi &dp){
    if(s==e)
        return (dp[s][e] = v[s]);
    if(s==e-1)
        return (dp[s][e] = max(v[s], v[e]));
    if(dp[s][e]==-1)
        dp[s][e] =  max(v[s] + min(fun(v, s+2, e, dp), fun(v, s+1, e-1, dp)), v[e] + min( fun(v, s+1, e-1, dp), fun(v, s, e-2, dp) ));
    return dp[s][e];
}

int main(){
    ll n, s=0;
    cin>>n;
    vi v(n);
    vvi dp(n+1, vi(n+1, -1));
    rep(i, n)
        cin>>v[i], s+=v[i];
    cout<<2*fun(v, 0, n-1, dp)-s;
}

/*

10 80 90 30

0, 3 -> 10 + min((2, 3), (1, 2))
     -> 30 + min((0, 1), (1, 2))







*/

Measured memory_bytes: 70912
#include <stdio.h>
int main(int argc, char const *argv[])
{
	int N,A,B;
	scanf("%d %d %d",&N,&A,&B);
	if(N*A<B){
		printf("%d\n",N*A);
	}
	else{
		printf("%d\n",B);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 998244353;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
ll dp[3005][3005];
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	repl(i, a, c + 1) {
		repl(j, b, d + 1) {
			if (i == a and j == b)
				dp[i][j] = 1;
			else
				dp[i][j] = (dp[i - 1][j] * j % MOD + dp[i][j - 1] * i % MOD) % MOD + MOD
				           - dp[i - 1][j - 1] * (i - 1) % MOD * (j - 1) % MOD;
			dp[i][j] = (dp[i][j] + MOD) % MOD;
		}
	}
	cout << dp[c][d] << endl;
	return 0;
}

Measured memory_bytes: 73992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;

int main() {
    char num[4]={0};
    for (int i = 0; i < 4; i++) cin >> num[i];

    for (int bit = 0; bit < (1 << 4); bit++) {
      ll sum = num[0]-'0';
      vector<char> hugou;
      for (int i = 1; i < 4; i++) {
        if (bit & (1 << i)) {
          sum += num[i] - '0';
          hugou.push_back('+');
        } else {
          sum -= num[i] - '0';
          hugou.push_back('-');
        }
      }
        if (sum == 7) {
          cout << num[0] << hugou[0] << num[1] << hugou[1] << num[2] << hugou[2]
               << num[3] << "=7" << endl;
          break;
        }
    }
    return 0;
}

Measured memory_bytes: 3580
N = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
ans = 0
for i in range(1, N + 1):
  if len(make_divisors(i)) == 8 and i%2 == 1:
    ans += 1
print(ans)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9+7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;


void solve() {
	int N, K; cin >> N >> K;
	ll ans = 0;
	REP(i, N) {
		int x; cin >> x;
		ans += min(abs(x), abs(K - x)) * 2;
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[111111],b[111111],cnt,mx,nw;
pair<int,int> arr[111111];
long long sum,fuck,x,y,d,pp;
long long gcd(long long a,long long b)
{
	if (!b) return a;
	return gcd(b,a%b);
}
struct frac
{
	long long x,y;
	bool operator > (const frac &u) const
	{
		return ((double)x/(double)y>(double)u.x/(double)u.y);
	}
}cur,ass;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		sum+=a[i];
	}
	for (int i=1;i<=n;i++)
	{
		arr[i]=make_pair(max(a[i],b[i]),i);
	}
	sort(arr+1,arr+n+1);
	reverse(arr+1,arr+n+1);
	for (int i=1;i<=n;i++)
	{
		fuck+=arr[i].first;
		if (fuck>=sum)
		{
			cnt=i;
			break;
		}
	}
	x=n-cnt;y=n;
	d=gcd(x,y);x/=d;y/=d;
	cur.x=x;cur.y=y;
	for (int i=1;i<=n;i++)
	{
		nw=b[arr[i].second];
		if (i<cnt) pp=max(0ll,sum-fuck+arr[i].first);
		else pp=max(0ll,sum-fuck+arr[cnt].first);
		if (pp>=nw) continue;
		x=1ll*nw*(n-cnt)+nw-pp;y=1ll*nw*n;
		d=gcd(x,y);x/=d;y/=d;
		ass.x=x;ass.y=y;
		if (ass>cur) cur=ass;
	}
/*	x=n-cnt;y=n;
	d=gcd(x,y);x/=d;y/=d;
	cur.x=x;cur.y=y;
	mx=-1e9;
	for (int i=cnt+1;i<=n;i++) mx=max(mx,b[arr[i].second]);
	for (int i=1;i<=cnt;i++)
	{
		nw=max(mx,b[arr[i].second]);
		pp=max(0ll,sum-fuck+arr[i].first);
		if (pp>=nw) continue;
		x=1ll*nw*(n-cnt)+nw-pp;y=1ll*nw*n;
		d=gcd(x,y);x/=d;y/=d;
		ass.x=x;ass.y=y;
		if (ass>cur) cur=ass;
	}*/
	printf("%lld %lld\n",cur.x,cur.y);
	return 0;
}

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

int main(){
  string n; cin >> n;
  for (int i=0; i<3 ;i++){
    if(n.at(i)=='1'){n.at(i)='9';}
    else n.at(i)='1';
  }
  cout << n << endl;
}

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

int main()
{
  int N; cin >> N;
  vector<ll> cumsum(N+1, 0);
  for (int i = 0; i < N; ++i) {
    int a; cin >> a;
    cumsum[i+1] = cumsum[i]+a;
  }

  ll ans = 1e18;
  for (int i = 1; i < N; ++i) {
    ans = min(ans, abs(cumsum[N]-2*cumsum[i]));
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)

using namespace std;
using ii = pair<int,int>;
using ll = long long;

constexpr int MAXN = 5+1e5;
vector<int> g[MAXN];
int p[MAXN];

void bfs(int s) {
  memset(p, -1, sizeof p);
  p[s] = s;
  queue<int> q; q.push(s);
  while (!q.empty()) {
    int u = q.front(); q.pop();
    for (int v : g[u]) {
      if (p[v] == -1) {
        p[v] = u;
        q.push(v);
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  int n,m; cin >> n >> m;
  while (m--) {
    int a,b; cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  bfs(1);
  for (int i = 2; i <= n; ++i) {
    if (p[i] == -1) {
      cout << "No" << '\n';
      return 0;
    }
  }
  cout << "Yes" << '\n';
  for (int i = 2; i <= n; ++i) {
    cout << p[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 10516
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define REP(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define REPS(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define RREP(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define RREPS(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define BIT(n) ((int)(1) << (n))
#define ALL(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
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;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int k;
    cin >> k;
    int sum = 0;
    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k; j++) {
            for (int l = 1; l <= k; l++) {
                sum += gcd(gcd(i, j), l);
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n;
	cin >> n;
	vector<vector<char>> a(n, vector<char>(n));
	rep(i, n) rep(j, n) cin >> a[i][j];
	int m = 0;
	bool ok = false;
	rep(i, n) {
		int cnt = 0;
		bool flag = true;
		rep(j, n) {
			if (a[i][j] == '#') {
				cnt++;
				ok = true;
			}
			if (a[j][i] == '#') flag = false;
		}
		if (flag) cnt--;
		chmax(m, cnt);
	}
	int k = 0;
	rep(j, n) {
		bool flag = true;
		rep(i, n) if (a[i][j] == '.') flag = false;
		if (flag) k++;
	}
	cout << (ok ? 2 * n - m - k : -1) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	int mi = 1000000000, cnt = 0;
	ll ans = 0;
	rep(i,n){
		if(a.at(i) < 0) cnt++;
		mi = min(mi, abs(a.at(i)));
		ans += abs(a.at(i));
	}
	if(cnt % 2) ans -= mi * 2;
	cout << ans << endl;
}


Measured memory_bytes: 640
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if(a != b && a != c) {
      System.out.println(a);
    }
    else if(b != a && b != c) {
      System.out.println(b);
    } else {
      System.out.println(c);
    }
  }
}


Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;
ll N;

int main(){
    //ll P , Q , R;
    //cin >> P >> Q  >> R;

    ll N;
    cin >> N ;
    vector<pair<ll , ll>> A(N);
    //cout << 3 * pow(A,2) << endl;

    for(int i = 0; i < N; i++){
        ll a = 0;
        cin >> a;
        A[i] = make_pair(a, i);
    }
    sort(A.rbegin(), A.rend());
    
    for(int i = 0; i < N; i++){
        if(A[0].second == i){
            cout << A[1].first << endl;
        }else{
            cout << A[0].first << endl;
        }
        
    }


}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod = 1e9 + 7;
long long INF = 1e7;
double EPS = 1e-12;
typedef long long int lld;
long double tick(){static clock_t oldt; clock_t newt=clock();
    long double diff=1.0L*(newt-oldt)/CLOCKS_PER_SEC; oldt = newt; return diff; }
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
inline lld sc() { lld a; scanf("%lld", &a); return a; }
inline int scd() { int a; scanf("%d", &a); return a; }
inline double scf() { double a; scanf("%lf",&a); return a; }
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) (c).begin(), (c).end()
#define sz(a) ((int)a.size())
#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }
#define errorpair(a) cout<<#a<<" = ( "<<((a).first)<<" , "<<((a).second)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll

typedef pair<lld,lld> PA;

lld powP(lld x, lld y) {
    lld ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}
 
bool bitSet(lld n, lld bit){
    if((n & (1LL << bit)) != 0) return true;
    else return false;
}
 
lld findGcd(lld a, lld b){
    while(a != 0) { lld temp = b % a; b = a; a = temp; }
    return b;
}

#define lim 300010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> G[lim];
// string S[lim];
// lld A[lim];

int main(){
    string a, b;
    cin >> a >> b;
    if(a == b.substr(0, b.size() - 1)) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>

using namespace std;
typedef long long ll;

int main(){

  int N;
  cin >> N;

  vector<vector<pair<int,int> > > p(N);

  for(int i=0;i<N-1;i++){
    int u,v,w;
    cin >> u >> v >> w;
    u--;v--;
    p[u].push_back(make_pair(v,w));
    p[v].push_back(make_pair(u,w));
  }

  vector<int> r(N,0);
  r[0]=1;
  stack<int> q;
  q.push(0);

  while(!q.empty()){
    auto t=q.top();
    //    cout << "***" << t << endl;
    q.pop();
    for(auto to:p[t]){
      if(r[to.first]!=0) continue;
      if(to.second%2==0){
	r[to.first]=r[t];
      }else{
	r[to.first]=-r[t];
      }
      q.push(to.first);
    }
  }

  for(int i=0; i<N; i++){
    cout << max(r[i],0) << endl;
  }
    

    
  return 0;
  
}


Measured memory_bytes: 6784
#include<bits/stdc++.h> 
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Graph = vector<vector<int>>;

int main(){
  ull h,w;
  cin >> h >> w;
  if( h == 1 || w == 1 ){
    cout << 1 << endl;
  }else if(  (h*w)%2 == 0 ){
    cout << (h*w)/2 << endl;
  }else{
    cout << (h*w)/2 + 1 << endl;
  }
  return 0;
}


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


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

struct edge {int to; ll cost; };

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

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

ll LCM(ll a, ll b){
  if(a<b) swap(a,b);
  return a/GCD(a,b)*b;
}

int main(){
  int n, x, t;
  cin >> n >> x >> t;
  int ans = n/x;
  if(n%x>0) ans++;
  ans *= t;
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n;
	cin>>n;
	vector<int> a(n), b(n);
	for(auto &x : a){
		cin>>x;
	}
	for(auto &x : b){
		cin>>x;
	}
	vector<int> p(n);
	for(int i = 0; i < n; i++){
		p[i] = i + 1;
	}
	int inda, indb, ind = 0;
	while(true){
		if(p == a)inda = ind;
		if(p == b)indb = ind;
		if(!next_permutation(p.begin(), p.end()))break;
		ind++;
	}
	cout<<abs(inda - indb)<<endl;

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    N,M = map(int,input().split())
    s = list(map(int,input().split()))
    t = list(map(int,input().split()))
    MOD = 10**9+7
    
    num = [[0 for _ in range(M+1)] for _ in range(N+1)]
    dp = [[0 for _ in range(M+1)] for _ in range(N+1)]
    for i in range(N+1):
        dp[i][0] = 1
    for j in range(M+1):
        dp[0][j] = 1

    ans = 1
    for i in range(N):
        for j in range(M):
            if s[i] == t[j]:
                num[i+1][j+1] = (dp[i][j])%MOD
                ans += num[i+1][j+1]
            dp[i+1][j+1] = (dp[i][j+1]+dp[i+1][j]-dp[i][j]+num[i+1][j+1])%MOD
    
    print(ans%MOD)

if __name__ == "__main__":
    main()


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

int hantei(int i, int j, int k){
        if(i==j && j==k && i==k ){
                return 1;
        }
        if(i==j || i==k || j==k){
                return 2;
        }
        return 3;
}


int main (){
        int a, b, c;
        cin >> a >> b >> c;
        cout << hantei(a, b, c);
}

Measured memory_bytes: 256
x,K,D=map(int, input().split())

X=abs(x)
n=X//D

if K<=n:
	print(X-K*D)
elif K%2==n%2:
	print(X-n*D)
else:
	print(abs(X-n*D-D))


# 2darray [[0] * 4 for i in range(3)]
# import itertools

Measured memory_bytes: 9168
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def solve():
    n = int(input())
    a = list(map(int, input().split()))
    ans = a[0]
    for i in range(1, n):
        ans = math.gcd(ans, a[i])
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 22148
// Problem : A - Frog 1
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<long,long> pl;
typedef pair<ll,ll> pll;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;

#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define REV(i,a,b) for(long long i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define tc ll t;cin>>t;while(t--)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define coutv(v) for(auto it: (v))cout<<it<<" ";newl;
#define cout2d(v) for(auto it: (v)) {for(auto j:it) cout<<j<<" ";newl;}
#define cinv(v,n) vll (v)(n);FOR(i,0,(n)){cin>>v[i];}
#define cinvg(v,n) (v).resize(n);FOR(i,0,(n)){cin>>v[i];}
#define cin2d(v,n,m) vvll (v)(n,vll(m,0));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define cin2dg(v,n,m) (v).resize(n,vll(m));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define newl cout<<"\n"
#define mod 1000000007
#define INF 1e18

int main()
{
	io;
	ll n;
	cin>>n;
	cinv(h,n);
	vll dp(n,INF);
	dp[0]=0;
	FOR(i,0,n)
	{
		if(i+1<=n-1){dp[i+1]=min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));}
		if(i+2<=n-1){dp[i+2]=min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));}
	}
	cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n, k;
	cin >> n >> k;
	int ans = 0;
	while (n--) {
		int x;
		cin >> x;
		if (x >= k) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b;
  rep(i,n) cin >> a[i];
  
  rep(i,n){
    if(n%2){
      if(i%2){
        b.push_back(a[i]);        
      }else{
        b.insert(b.begin(),a[i]);
      }
    }else{
      if(i%2){
        b.insert(b.begin(),a[i]);        
      }else{
        b.push_back(a[i]);
      }
    }

  }
  
  for(auto c:b){
    printf("%d ",c);
  }
  return 0;
}

Measured memory_bytes: 3828
#include<stdio.h>
#include<bits/stdc++.h>
#include<iostream>
#define ll long long

using namespace std;
int main()
{
  ll n;
  cin>>n;
  ll dp[n][3],h[n][3];
  for(ll i=0;i<n;i++)
    cin>>h[i][0]>>h[i][1]>>h[i][2];
  dp[0][0]=h[0][0];
  dp[0][1]=h[0][1];
  dp[0][2]=h[0][2];	
  for(ll i=1;i<n;i++)
  {
	dp[i][0]=max(dp[i-1][1]+h[i][0],dp[i-1][2]+h[i][0]);
    dp[i][1]=max(dp[i-1][0]+h[i][1],dp[i-1][2]+h[i][1]);
    dp[i][2]=max(dp[i-1][0]+h[i][2],dp[i-1][1]+h[i][2]);
  }
  ll ans=max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
  cout<<ans;
  return 0;
}

Measured memory_bytes: 8280
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int d, w;
int e[10][10];

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

    while (cin >> d >> w, d) {
        REP (i, d) REP (j, w) cin >> e[i][j];
        int ans = 0;
        REP (i, d) REP (j, w) FOR (k, i + 2, d) FOR (l, j + 2, w) {
            int minh = 10;
            FOR (y, i, k + 1) minh = min({minh, e[y][j], e[y][l]});
            FOR (x, j, l + 1) minh = min({minh, e[i][x], e[k][x]});
            int sum = 0, ok = 1;
            FOR (y, i + 1, k) FOR (x, j + 1, l) {
                sum += minh - e[y][x];
                if (e[y][x] >= minh) ok = 0;
            }
            if (ok) ans = max(ans, sum);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;

int main(){
    int N, M, ai, bi, i, j, bridge_cnt=0, num_one_path=1;
    cin >> N >> M;
    list<int> g[N];
    for (i=0; i<M; i++) {
        cin >> ai >> bi;
        ai--;
        bi--;
        g[ai].push_back(bi);
        g[bi].push_back(ai);
    }

    while (num_one_path > 0) {
        num_one_path = 0;
        for (i=0; i<N; i++) {
            if (g[i].size() == 1) {
                num_one_path++;
                auto itr = g[i].begin();
                j = *itr;
                g[j].remove(i);
                g[i].pop_front();
            }
        }
        bridge_cnt += num_one_path;
   }

    cout << bridge_cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;//cost, v, ticket
struct edge{
  int to, cost;
};

int main(int argc, char *argv[]){
  int c, n, m, s, d;
  while(std::cin >> c >> n >> m >> s >> d, n){
    s--;d--;
    vector<vector<edge> > g(n);
    for (int i = 0; i < m; i++) {
      edge e;
      int from;
      std::cin >> from >> e.to >> e.cost;
      e.to--;from--;
      g[from].push_back(e);
      g[e.to].push_back((edge){from, e.cost});
    }
    vector<vector<int> > dp(c + 1, vector<int>(n, 1e9));
    dp[0][s] = 0;
    priority_queue<piii, vector<piii>, greater<piii> > que;
    que.push(piii(0, pii(s, 0)));
    while(!que.empty()){
      int cost   = que.top().first;
      int v      = que.top().second.first;
      int ticket = que.top().second.second;
      que.pop();
      for (int i = 0; i < g[v].size(); i++) {
        edge e = g[v][i];
        if(dp[ticket][e.to] > dp[ticket][v] + e.cost){
          dp[ticket][e.to] = dp[ticket][v] + e.cost;
          que.push(piii(dp[ticket][e.to], pii(e.to, ticket)));
        }
        if(ticket + 1 <= c &&
           dp[ticket + 1][e.to] > dp[ticket][v] + e.cost/2){
          dp[ticket + 1][e.to] = dp[ticket][v] + e.cost/2;
          que.push(piii(dp[ticket + 1][e.to],
                        pii(e.to, ticket + 1)));
        }
      }
    }
    int ans = 1e9;
    for (int i = 0; i <= c; i++) {
      ans = min(ans, dp[i][d]);
    }
    std::cout << ans << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1260
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
using namespace std;

string s[50];
int n;

int main(void)
{
	cin >> n;
	for (int i = 0; i < n; ++i)cin >> s[i];
	string ans;
	for (char c = 'a'; c <= 'z'; ++c)
	{
		int sml = INT_MAX;
		for (int i = 0; i < n; ++i)
		{
			int cnt = 0;
			for (char t : s[i])
			{
				if (c == t)++cnt;
			}
			sml = min(sml, cnt);
		}
		for (int j = 0; j < sml; ++j)ans.push_back(c);
	}
	cout << ans << endl;
	return 0;
}


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

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

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

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

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

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

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

int main(int argc, char const *argv[]) {
    ll n; cin>>n;
    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (i%3==0 || i%5==0) continue;
        ans += i;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
using namespace std;

int main(){
    long long N;
    long long c[10][10] = {};
    cin >> N;

    string s;
    long long i, j;
    for (int num = 1; num <= N; num++){
        s = to_string(num);
        i = s.front() - '0';
        j = s.back() - '0';
        c[i][j]++;
    }
    // for (size_t i = 0; i < 10; i++)
    // {
    //     for (size_t j = 0; j < 10; j++)
    //     {
    //         cout << c[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    long long count = 0;
    for (size_t i = 0; i < 10; i++)
    {
        for (size_t j = 0; j < 10; j++)
        {
            count += c[i][j] * c[j][i];
        }
    }
    cout << count;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_Training
{
    class Program
    {
        static void Main(string[] args)
        {
            var rdx = Console.ReadLine().Split(' ');
            var r = int.Parse(rdx[0]);
            var d = int.Parse(rdx[1]);
            var x = int.Parse(rdx[2]);
            for(int i = 0; i< 10; i++)
            {
                x = r * x - d;
                Console.WriteLine(x);
            }
        }
    }
}


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

int main(){
    using namespace std;

    constexpr unsigned long N{200000}, register_length{100}, reg{N - register_length + 1}, one_reg{reg - 1};

    unsigned long cnt{0};
    vector<unsigned long> sim(N), cntr(N);
    vector<tuple<bool, unsigned long, unsigned long, unsigned long>> qs;
    const auto& cmp = [&cnt, &sim, &qs, &cntr](unsigned long i, unsigned long j, unsigned long k) -> void {
        //cout << "< " << i << " " << j << " " << k << endl;
        qs.emplace_back(false, i, j, k);
        ++cntr[i];
        ++cntr[j];
        ++cntr[k];
        ++cnt;
        sim[k] = static_cast<unsigned long>(sim[i] < sim[j]);
    };
    const auto& add = [&cnt, &sim, &qs, &cntr](unsigned long i, unsigned long j, unsigned long k) -> void {
        //cout << "+ " << i << " " << j << " " << k << endl;
        qs.emplace_back(true, i, j, k);
        ++cntr[i];
        ++cntr[j];
        ++cntr[k];
        ++cnt;
        sim[k] = sim[i] + sim[j];
    };
    const auto& set_one = [&cmp, &add]() -> void {
        add(0, 1, one_reg);
        cmp(2, one_reg, one_reg);
    };
    const auto& bit_and_add = [&cmp, &add](unsigned long i, unsigned long j, unsigned long k) -> void {
        add(i, j, reg);
        cmp(one_reg, reg, reg + 1);
        add(k, reg + 1, k);
    };
    const auto& binary_mul = [&add, &bit_and_add](unsigned long i, unsigned long i_len, unsigned long j, unsigned long j_len, unsigned long k) -> void {
        for(unsigned long itr{0}; itr < i_len + j_len - 1; ++itr){
            if(itr)add(k, k, k);
            for(unsigned long jtr{0}; jtr <= itr; ++jtr)if(jtr < j_len && jtr + i_len > itr)bit_and_add(i + itr - jtr, j + jtr, k);
        }
    };
    const auto& int_to_bin = [&sim, &cmp, &add](unsigned long idx, unsigned long i, unsigned long len, unsigned long j) -> void {
        for(unsigned long itr{0}; itr < len; ++itr){
            if(itr)add(j + itr - 1, j + itr - 1, j + itr);
            add(j + itr, one_reg, j + itr);
            for(unsigned long jtr{itr}; jtr + 1 < len; ++jtr)add(j + jtr, j + jtr, j + jtr + 1);
            cmp(j + len - 1, idx, i + itr);
            add(j + itr - 1, j + itr - 1, j + itr);
            add(j + itr, i + itr, j + itr);
        }
    };

    cout << 3930 << endl;
    sim[0] = 100;
    sim[1] = 1987;
    set_one();
    add(0, one_reg, 3);
    add(1, one_reg, 4);
    int_to_bin(3, 100, 30, 130);
    int_to_bin(4, 130, 30, 230);
    binary_mul(100, 30, 130, 30, 2);
    vector<unsigned long> inv(N);
    iota(begin(inv), end(inv), 0UL);
    sort(begin(inv) + 3, end(inv), [&cntr](auto i, auto j){return cntr[i] > cntr[j];});
    vector<unsigned long> idx(N);
    for(unsigned long i{0}; i < N; ++i)idx[inv[i]] = i;
    for(const auto& [f, i, j, k] : qs)cout << (f ? "+ " : "< ") << idx[i] << " " << idx[j] << " " << idx[k] << endl;
    cerr << sim[2] << " : " << cnt << endl;
    return 0;
}


Measured memory_bytes: 9840
#include<cstdio>
#include<algorithm>
using namespace std;
int N, C, K;
int w[101000];
int main(){
    int i, j;
    scanf("%d%d%d",&N,&C,&K);
    for(i=1;i<=N;i++){
        scanf("%d",&w[i]);
    }
    sort(w+1,w+N+1);
    int res = 0;
    for(i=1;i<=N;i++){
        res++;
        for(j=i;j<i+C&&j<=N;j++){
            if(w[j]>w[i]+K)break;
        }
        i=j-1;
    }
    printf("%d\n",res);
}

Measured memory_bytes: 512
#include<stdio.h>
int a[100002], b[100002];
int main()
{
	int A, B, m, c, i, minv,temp, mina, minb,x,y;
	while(~scanf("%d %d %d", &A, &B, &m))
	{
		mina=minb=100003;
		for(i=1; i<=A; i++)
		{
			scanf("%d", a+i);
			if(a[i]<mina) mina = a[i];
		}
		for(i=1; i<=B; i++)
		{
			scanf("%d", b+i);
			if(b[i]<minb) minb = b[i];
		}
		minv = mina + minb;
		for(i=1; i<=m; i++)
		{
			scanf("%d %d %d", &x, &y, &c);
			if(minv>(a[x]+b[y]-c))
				minv=(a[x]+b[y]-c);
		}
		printf("%d\n", minv);
	}
	return 0;
}

Measured memory_bytes: 1024
n, m, k = map(int, input().split(' '))
ans = 0

a_ls = [0] + list(map(int, input().split(' ')))
b_ls = [0] + list(map(int, input().split(' ')))

for i in range(1, n+1):
    a_ls[i] += a_ls[i-1]
for i in range(1, m+1):
    b_ls[i] += b_ls[i-1]

b_cnt = m
for a_cnt in range(0, n+1):
    if a_ls[a_cnt] > k:
        continue
    while a_ls[a_cnt] + b_ls[b_cnt] > k:
        b_cnt -= 1
    ans = max(ans, a_cnt + b_cnt)

print(ans)

Measured memory_bytes: 39832
import sys
import copy
import string
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

li = input().split(",")
print(*li)









Measured memory_bytes: 3896
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int M = 1000000;
    vector<int> v, u;
    for (int i = 1; i*(i+1)*(i+2)/6 <= M; ++i) {
        v.emplace_back(i*(i+1)*(i+2)/6);
        if(v[i-1]&1) u.emplace_back(v[i-1]);
    }
    v.emplace_back(MOD);
    u.emplace_back(MOD);
    vector<int> dp(M, INF<int>);
    dp[0] = 0;
    for (int i = 0; i < M; ++i) {
        for (int j = 0; v[j] <= i; ++j) {
            chmin(dp[i], dp[i-v[j]]+1);
        }
    }
    vector<int> dq(M, INF<int>);
    dq[0] = 0;
    for (int i = 0; i < M; ++i) {
        for (int j = 0; u[j] <= i; ++j) {
            chmin(dq[i], dq[i-u[j]]+1);
        }
    }
    int p;
    while(cin >> p, p){
        cout << dp[p] << " " << dq[p] << "\n";
    }
    return 0;
}



Measured memory_bytes: 10604
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 16 18:45:04 2017

@author: syaga
"""

if __name__ == "__main__":
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input()))
    max = a[1] - a[0]
    mini = a[0]
    for i in range(1, len(a)):
        diff = a[i] - mini
        if diff > max:
            max = diff
        if mini > a[i]:
            mini = a[i]
    print(max)

Measured memory_bytes: 15564
#include <cstdio>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{

	char a[101];
	scanf("%s", a);
	int i=strlen(a);
	for(int h=1;h<=i;h++)
	{
		cout << "x";
	}



	return 0;
}


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

using namespace std;


int main() {
        ios::sync_with_stdio(false);
        cin.tie(0);
        string s;
        cin >> s;
        if (s == "AAA" || s == "BBB")
                cout << "No\n";
        else
                cout << "Yes\n";
        return 0;
}


Measured memory_bytes: 256
import sys

a, b, c, d = map(int, input().split())

i = 0
while 1:
    if i % 2 == 0:
        c -= b
        if c <= 0:
            print('Yes')
            sys.exit()
    else:
        a -= d
        if a <= 0:
            print('No')
            sys.exit()
    i += 1


Measured memory_bytes: 9176
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long  ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

void solve() {
	int n, m; cin >> n >> m;
	vector<ll> a(n);
	set<LP> st;
	rep(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	rep(i, n) {
		int le = i;
		while (i + 1 < n&&a[i] == a[i + 1])i++;
		st.insert({ a[i],i - le + 1 });
	}
	int rest = n;
	vector<LP> v(m);
	rep(i, m) {
		cin >> v[i].second >> v[i].first;
	}
	sort(v.begin(), v.end(), greater<LP>());
	ll ans = 0;
	int loc = 0, tmp = 0;
	rep(i, n) {
		if (loc == m) {
			ans += a[i];
		}
		else {
			if (v[loc].first <= a[i]) {
				ans += a[i];
			}
			else {
				ans += v[loc].first;
				tmp++;
				if (tmp >= v[loc].second) {
					tmp = 0; loc++;
				}
			}
		}
	}
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define re return
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
int n;
int a[100010];
ll ans;
int main() { 
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=n-1;i>=0;i--){
		ans+=a[i]/2;
		a[i]%=2;
		if(a[i] && a[i-1]>=1){
			ans++;
			a[i-1]--;
		}
	}
	cout<<ans<<endl;
    return 0; 
}

Measured memory_bytes: 768
S = input()
min_ = 0
max_ = 0
flag_min = True
for i in range(len(S)):
  if flag_min:
    if S[i] == "A":
      min_ = i
      flag_min = False
  else:
    if S[i] == "Z":
      max_ = i
      
print(max_ - min_ + 1)




Measured memory_bytes: 3516
#include<stdio.h>
#include<string.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define INF (int)1e9
#define MIN(a,b) (((a)<(b)) ? (a):(b))

int root[102][102];

void init() {
	long i, j;

	FOR(i,0,102){
		FOR(j,0,102){
			if(i == j) {
				root[i][j] = 0;
			} else {
				root[i][j] = INF;
			}
		}
	}
}


int main(){
	int n,m,a[1002],b[1002],c[1002];

//	memset(root,INF,sizeof(root));
//	FOR(i,0,102) root[i][i] = 0;

	init();

	scanf("%d %d",&n,&m);
	FOR(i,0,m){
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
		root[a[i]][b[i]] = MIN(root[a[i]][b[i]],c[i]);
		root[b[i]][a[i]] = MIN(root[b[i]][a[i]],c[i]);
	}

	FOR(k,1,n+1)	//中継点
		FOR(i,1,n+1)	//始点
			FOR(j,1,n+1)	//終点
				root[i][j] = MIN(root[i][j],root[i][k]+root[k][j]);

	int ans = m;

	FOR(k,0,m)//{	//判定する辺
		
		
//		FOR(i,1,n+1){	//始点
//			FOR(j,1,n+1){	//終点
//				if(root[i][j] == root[i][a[k]] + c[k] + root[b[k]][j] ||
//						root[i][j] == root[j][a[k]] + c[k] + root[b[k]][i]){
//					ans--;
//					goto NEXT;
//				}
//			}
//		}
//		NEXT:;
//	}



			FOR(i,1,n+1)	//始点
				if(root[i][a[k]] + c[k] == root[i][b[k]]){	//最短経路に使用済み
					ans--;
					break;
				}


	printf("%d\n",ans);
}


Measured memory_bytes: 256