akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

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

  deque<char> d;
  for (auto c : S) {
    d.pb(c);
  }

  bool rev = false;
  while (Q-- > 0) {
    int q;
    cin >> q;
    if (q == 1) {
      rev = (!rev);
    } else {
      int F;
      char C;
      cin >> F >> C;

      F--;

      if (rev ^ F) {
        d.pb(C);
      } else {
        d.push_front(C);
      }
    }
  }

  if (!rev) {
    while (!d.empty()) {
      cout << d.front();
      d.pop_front();
    }
    cout << '\n';

  } else {
    while (!d.empty()) {
      cout << d.back();
      d.pop_back();
    }
    cout << '\n';
  }
}

Measured memory_bytes: 976
#include<bits/stdc++.h>
using namespace std;
bitset<4000010>b;
int main(){
	int n,s=0;
	b[0]=1;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		s+=x;
		b|=(b<<x);
	}
	int mid=s+1>>1;
	while(!b[mid]) mid++;
	printf("%d\n",mid);
	return 0;
}


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


using namespace std;


#define uniq(x)  x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
#define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Upper value search  >
#define lower(arr,n,fixed) lower_bound(arr,arr+n,fixed)-arr  //Lower value search  >=
#define FOR(i,a,n) for(int i=a; i<(int)n; i++)
#define FORI(i,a,n) for(int i=a; i>=(int)n; i--)
#define pii pair<int,int>
#define vpii vector<pii>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(a) int((a).size())
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0)
#define endl "\n"
#define all(a) a.begin(), a.end()
#define MEMSET(p,i) memset(p,i,sizeof(p))


int n, m;

bool isSafe(int i, int j){
	return (i >= 0 && i < n && j >= 0 && j < m);
}


int main(void)
{
	fastIO();

	
	cin >> n >> m;
	char M[n][m];

	FOR(i,0,n)
		FOR(j,0,m)
			cin >> M[i][j];

	FOR(i,0,n)
		FOR(j,0,m){
			if(M[i][j] == 'B' || M[i][j] == '#'){
				if(isSafe(i,j+1) && (M[i][j+1] == '#' || M[i][j+1] == 'B'))
					M[i][j] = M[i][j+1] = 'B';
				if(isSafe(i+1,j) && (M[i+1][j] == '#' || M[i+1][j] == 'B'))
					M[i][j] = M[i+1][j] = 'B';
			}
		}
	FOR(i,0,n)
	{
		FOR(j,0,m)
			if(M[i][j] == '#'){
				cout << "No\n";
				return 0;
			}
	}
	cout << "Yes\n";


	

	return 0;
}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
class Team {
public:
	string name;
	int score;
	bool operator <(const Team &other) {
		return this->score > other.score;
	}
	bool operator >(const Team &other) {
		return other.score < this->score;
	}
	Team(string s, int x) {
		this->name = s;
		this->score = x;
	}
};
signed main() {
	int n, cnt(0);
	while (cin >> n, n) {
		vector<Team>team;
		rep(i, 0, n) {
			string s; int w, l, d;
			cin >> s >> w >> l >> d;
			Team a(s, w * 3 + d);
			team.push_back(a);
		}
		sort(team.begin(), team.end());
		if (cnt++)cout << endl;
		each(it, team)cout << it->name << "," << it->score << endl;
	}
	return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int i,n,ans=0;
    cin>>n;
    
    int a[n],b[n],c[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        cin>>b[i];
        cin>>c[i];
    }
    for(i=1;i<n;i++)
    {
        a[i]=a[i]+max(b[i-1],c[i-1]);
        b[i]=b[i]+max(a[i-1],c[i-1]);
        c[i]=c[i]+max(b[i-1],a[i-1]);
    }
    ans=max(a[n-1],b[n-1]);
    ans=max(ans,c[n-1]);
    cout<<ans;

}

Measured memory_bytes: 1408
import math

n, d = map(int, input().split())
a = []
for i in range(n):
    a.append(list(map(int, input().split())))
cnt = 0

for i in range(n):
    for j in range(n):

        if i != j:
            countwa = 0
            for k in range(d):
                countwa += abs(a[i][k] - a[j][k]) ** 2
            if float(math.sqrt(countwa)).is_integer():
                cnt += 1
print(cnt//2)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long long ll;

template <typename T> void max_self(T& a, T b){
	a = max(a,b);
}

#define MAXN 200001
 pi par[MAXN];

void find(int u){
  //cout<<u<<endl;
  par[u].S++;
  if(par[u].F != u){
    find(par[u].F);
  }
}

void solve(){	
  int n;cin>>n;
  for(int i=0;i<=n;i++){
    par[i].F = i;
    par[i].S = 0;
  }
  vi a(n);
  for(int i=1;i<n;i++){
    cin>>a[i];
    a[i]--;
    find(a[i]);
  }
  for(int i=0;i<n;i++)
    cout<<par[i].S<<endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //int t; cin >> t;
  //while(t--) solve();
  //
  solve();
  return 0;
}

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

struct box {
    ll item[3];
};

int main() {
    ll n, m, i, j, k;
    cin >> n;
    vector<ll> A(n);
    for(auto &x : A) {
        cin >> x;
    }
    if(n % 2 == 0) {
        if(n == 2) {
            cout << max(A[0], A[1]) << endl;
            return 0;
        }
        ll odd[n / 2 + 10] = {}, even[n / 2 + 10] = {};
        for(i = 1; i <= n; i++) {
            if(i % 2 == 0)
                even[i / 2] = A[i - 1];
            else
                odd[i / 2 + 1] = A[i - 1];
        }
        for(i = 0; i < n / 2 + 1; i++) {
            even[i + 1] += even[i];
            odd[i + 1] += odd[i];
        }
        ll ret = -INF;
        for(i = 0; i <= n / 2; i++) {
            ret = max(odd[i] + even[n / 2 + 1] - even[i], ret);
        }
        cout << ret << endl;
    } else {
        vector<box> v(n / 2 + 1);
        for(i = 1; i < n; i += 2) {
            v[i / 2] = {A[i - 1], A[i], A[i + 1]};
            //cout << i/2 << endl;
        }
        vector<vector<ll>> dp(n / 2 + 1, vector<ll>(3, -INF));
        function<ll(int, int)> dfs = [&](const int now, const int cnt) {
            if(now == n / 2 - 1) {
                return v[now].item[cnt];
            }
            if(dp[now][cnt] != -INF)
                return dp[now][cnt];
            else {
                ll tmp = -INF;
                for(int x = cnt; x <= 2; x++) {
                    tmp = max({v[now].item[cnt] + dfs(now + 1, x), tmp});
                }
                return dp[now][cnt] = tmp;
            }
        };

        ll ret = max({dfs(0, 0), dfs(0, 1), dfs(0, 2)});
        cout << ret << endl;
        //cout << v[n/2-1].item[2] << endl;
    }
    return 0;
}

Measured memory_bytes: 22008
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())

w = str(input())

import collections
c = collections.Counter(w)
for key in c.keys():
    if c[key] % 2 == 0:
        pass
    else:
        break
else:
    print("Yes")
    exit()
print("No")


Measured memory_bytes: 5460
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  string S, ans;
  cin >> S;
  if (S.size() == 26) {
    ans = S;
    if (!next_permutation(begin(ans), end(ans)))
      ans = "-1";
    else
      for (int i = 0; i != 26; ++i) {
        if (S[i] != ans[i]) {
          ans.resize(i + 1);
          break;
        }
      }
  } else {
    int d[26]{};
    for (char c : S) ++d[c - 'a'];
    ans = S + char('a' + find(d, d + 26, 0) - d);
  }
  cout << ans << endl;
}


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

int main(){
    ll N, K, Q;
    cin >> N >> K >> Q;
    vector<ll>A(N, 0);
    for(ll i=0; i<Q; ++i){
        ll a;
        cin >> a;
        A[a-1]++;
    }
    for(ll i=0; i<N; ++i){
        if(K-Q+A[i]>0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>

int n,a[2000001];

void maxheap(int x){
  
  int y,l,r,max;
  l = 2 * x;
  r = 2 * x+1;

  if(l<=n && a[l] > a[x]) max = l;
  else max = x;

  if(r<=n && a[r] > a[max]) max = r;

  if(max != x){
    y = a[x];
    a[x] = a[max];
    a[max] = y;
    maxheap(max);
  }
}

int extr(){
  int max;
  if(n<1) return -1;
  max = a[1];
  a[1] = a[n--];
  maxheap(1);
  return max;
}

void inckey(int x,int key){

  int b;
  if(key<a[x]) return;
  a[x] = key;
  while(x>1 && a[x/2] < a[x]){
    b = a[x];
    a[x] = a[x/2];
    a[x/2] = b;
    x = x/2;
  }
}

void insert(int key){
  n++;
  a[n] = -1;
  inckey(n,key);
}

int main(){
  int key;
  char com[10];
  while(1) {
    scanf("%s",com);
    if(com[0] == 'e' && com[1] == 'n') break;
    else if(com[0] == 'i'){
      scanf("%d",&key);
      insert(key);
    }
    else printf("%d\n",extr());
  }
  return 0;
}



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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        _i64 H, W; bool sharp;
        while(cin >> H >> W && !(H == 0 && W == 0)){
            _rep(i, H) {
                _rep(j, W) {
                    sharp = i == 0 || i == H - 1 || j == 0 || j == W - 1;
                    cout << (sharp ? "#" : ".");
                }
                cout << endl;
            }
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
int main(){
    Int N; cin >> N;
    Int ans = 0;
    for(Int i = 1; i <= N; ++i){
        Int div = N / i;
        ans += (div) * (div + 1) / 2 * i;
    }
    cout << ans << endl;
}




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

using namespace std;
using ll = long long;
using ld = long double;

vector<int> g[100500];
vector<int> used(100500);

void dfs(int x) {
    used[x] = 1;
    for (int i : g[x]) {
        if (!used[i]) {
            dfs(i);
        }
        used[x] = max(used[x], used[i] + 1);
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cout.tie(0); cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
    }
    for (int i = 1; i <= n; i++) {
        if (!used[i]) dfs(i);
    }
    cout << *max_element(used.begin(), used.end()) - 1;
}


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

int main() {
  
  string s, t;
  cin >> s >> t;
  
  bool answer = true;
  for(int i = 0; i < s.size(); i++) {
    if(s.at(i) != t.at(i)) {
      answer = false;
      break;
    }
  }
  
  if(answer)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

}

Measured memory_bytes: 3628
#include <iostream>
#include<time.h>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
#include<cctype>
#include<iterator>
#include<unordered_map>
#include <cassert>
#include <bit>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
using Edge=pair<int,ll>;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// g++ -o a a.cpp -Wall -lm -std=c++17
int n;
map<string,vector<VI>>m;
int main(){
    cin>>n;
    string s;
    int p;
    rep(i,n){
        cin>>s>>p;
        p*=-1;
        VI a={p,i+1};
        m[s].push_back(a);
    }
    for(auto v:m){
        sort(ALL(v.second));
        for(auto t:v.second){cout<<t[1]<<endl;}
    }
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    for (int i = 0; i < n; ++i) cin >> x[i];

    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        ans += 2 * (std::min)(x[i], k - x[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
// using System.Collections.Generic;
// using System.Linq;

class Program
{
    static void Main()
    {
        String S = Console.ReadLine();
        String T = Console.ReadLine();
        Console.WriteLine(S == T.Substring(0, T.Length - 1) ? "Yes" : "No");
        return;
    }
}

Measured memory_bytes: 25868
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int A[n + 1];
    int ans = 0;
    for(int i = 0; i < n; i++) cin >> A[i];
    for(int i = 0; i < n; i++)
    {
        if(i > 0 && A[i] == A[i - 1])
        {
            A[i] = 0;
            ans++;
        }
    }
    cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
def gcd(a,b):
  if a<b:
    a,b=b,a
  while b>0:
    a,b=b,a%b
  return int(a)
N=int(input())
T=1
for i in range(N):
  ti=int(input())
  T=T*ti//gcd(T,ti)
print(T)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;


void solve(long long A, long long B){
  cout << myCeil(B-1, A-1) << endl;
}

signed main(){
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  solve(A, B);
}


Measured memory_bytes: 256
n = int(input())
c = []#料理Nに対する高橋くんと青木さんの幸福度の和？
bs = 0#全ての料理を青木さんが食べたと仮定した時の青木さんの幸福度
for i in range(n):
    a,b = map(int,input().split())
    bs += b
    c.append(a+b)

c.sort()#Cを昇順ソート
c.reverse()#降順に直す

ans = -bs
for i in range(n):
    if i%2==0: ans += c[i]#高橋くんが食べる時、引いた青木さんの幸福度(食べてないのでいらない)と高橋くんの幸福度を足す
print(ans)

Measured memory_bytes: 7508
N = int(input())
H = list(map(int, input().split()))
c_max = 0
c = 0

for i in range(N - 1):
    if H[i] >= H[i + 1]:
        c += 1
    else:
        if c > c_max:
            c_max = c
        c = 0

if c > c_max:
    c_max = c

print(c_max)


Measured memory_bytes: 14252
//難しかった

#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

int maxtime(int x){
  return (x + 9) / 10 * 10;
}
int remtime(int x){
  return maxtime(x) - x;
}
int main(void){
  vector <int> A(5);
  rep(i,5) cin >> A[i];

  int sum = 0;
  rep(i,5) sum += maxtime(A[i]);
  sum -= max({remtime(A[0]), remtime(A[1]), remtime(A[2]), remtime(A[3]), remtime(A[4]) });
  cout << sum << endl;

}


Measured memory_bytes: 3624
from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
import math
from fractions import gcd
def sosuu(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


N=int(input())
A=list(map(int,input().split()))
mod=10**9+7
M=1
dic={}
for a in A:
    arr=sosuu(a)
    for b,c in arr:#b,c:素数、指数
        if b in dic:
            if c>dic[b]:
                M=M*pow(b,c-dic[b],mod)%mod
                dic[b]=c
        else:
            dic.update({b:c})
            M=M*pow(b,c,mod)%mod
M%=mod
print(sum([M*pow(a,mod-2,mod)%mod for a in A])%mod)


Measured memory_bytes: 71640
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll l,r,d;
    cin>>l>>r>>d;
    if(l%d==0)
    cout<<r/d-l/d+1;
    else
    cout<<r/d-l/d;}

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

int main(){
    int n;
    cin >> n;
    int *a = new int[n];

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


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, x;
	cin >> n >> x;
	vector<int> l(n);
	for(int i = 0; i < n; i++)
		cin >> l.at(i);
	int ans = 1, pos = 0;
	for(int i = 0; i < n; i++){
		pos += l.at(i);
		if(pos <= x){
			ans++;
		}
		else
			break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
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; }


int main(){
    ll H, W, M, mh = 0, mw = 0;
    cin >> H >> W >> M;
    vector<ll> h(H), w(W);
    map<pair<ll, ll> , bool > mp;
    vector<ll> my, mx;
    rep(i, M){
        ll a, b;
        cin >>a >> b;
        a--; b--;
        h.at(a)++;
        if(h.at(a) > mh){
            mh = h.at(a);
        }
        w.at(b)++;
        if(w.at(b) > mw){
            mw = w.at(b);
        }
        mp[make_pair(a, b)] = true;
    }
    rep(i, H){
        if(h.at(i) == mh){
            my.push_back(i);
        }
    }
    rep(i, W){
        if(w.at(i) == mw){
            mx.push_back(i);
        }
    }
    bool check = false;
    rep(i, my.size()){
        rep(j, mx.size()){
            ll x = mx.at(j);
            ll y = my.at(i);
            if(mp.count({y, x}) == 0){
                
                check = true;
                break;
            }
        }
        if(check == true) break;
    }
    if(check){
        cout << mw + mh << endl;
    }
    else {
        cout << mw + mh - 1 << endl;
    }
}

Measured memory_bytes: 34932
#include <bits/stdc++.h>
using namespace std;
#define arep(i, x, n) for (int i = int(x); i < (int)(n); i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9 + 7
using ll = long long;

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

    ll total = n * (n - 1) / 2;

    cout << total << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector< pair<int, int> > vpii;
#define MOD 1000000007
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define FOR(i, n) for (int i = 0; i < n; i++)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define input_arr(a, n)         \
    for (int i = 0; i < n; i++) \
        cin >> a[i];
#define print_arr(a, n)         \
    for (int i = 0; i < n; i++) \
        cout << a[i] << " ";
#define deb(n) cerr << #n << "=" << n << "\n";

void fst() {
    ios::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

void solve() {
    string s;
    cin >> s;
    int ans = 0;
    int cnt = 0;
    FOR(i, s.length())
    {
        if(s[i] == 'R')
            cnt++;
        else
        {
            cnt = 0;
        }
        ans = max(ans, cnt);
    }

    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
const char S = 'S';
const char T = 'T';

int main() {
    string s;
    cin >> s;
    stack<char> sta;
    
    for (auto c : s) {
        if (c == S) sta.emplace(c);
        else if (sta.empty() || sta.top() == T) sta.emplace(c);
        else sta.pop();
    }
    
    cout << sta.size() << endl;
    return 0;
}

Measured memory_bytes: 644
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

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

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string s;cin>>s;
    if(s.length()==2)
        cout<<s<<Endl;
    else{
        reverse(all(s));
        cout<<s<<Endl;
    }
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------









Measured memory_bytes: 256
import java.util.*;
public class Main {

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int [] point = new int[2];
		double x = 0;
		double y = 0;
		int deg = 0;
		while(true){
			String str = sc.next();
			if(str.equals("0,0"))
				break;

			String [] input = str.split(",");
			for(int i=0; i < 2; i++){
				point[i] = Integer.parseInt(input[i]);
			}
			x += Math.sin(Math.PI * deg / 180) * point[0];
			y += Math.cos(Math.PI * deg / 180) * point[0];
			deg = deg + point[1];
		}
		System.out.printf("%d\n%d\n",(int)x,(int)y);
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

int main(){
    string s; cin >> s;
    char t = s[0];
    ll ans = 0;
    rep(i, s.length()){
        if(s[i] != t){
            t = s[i];
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int f(int n){
    if (n % 2 == 0){
        return n / 2;
    } else {
        return 3 * n + 1;
    }
}

bool in(vector<int> A, int key){
    for (int a : A) if (a == key) return true;
    return false;
}

int main(){
    int s;
    vector<int> A;
    cin >> s;
    rep(i,1000000) {
        if (in(A,s)) {
            cout << (i + 1) << endl;
            return 0;
        }

        A.push_back(s);
        s = f(s);
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    string S;
    cin >> S;
    sort(S.begin(),S.end());
    if(S.at(0)==S.at(1)&&S.at(2)==S.at(3)&&S.at(0)!=S.at(3))cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

deque<int> dll;

void printList( )
{
	deque<int>::iterator itr = dll.begin( );
	deque<int>::iterator itrE = dll.end( );
	for( ; itr!=itrE; itr++ ) {
		cout<<*itr;
		if( itr != itrE-1 ) cout<<' ';
	}
	cout<<endl;
}
	
int main()
{
	int n;
	ios::sync_with_stdio( false );
	cin>>n;
	
	string cmd;
	int key;
	for( int i=0; i<n; i++ ) {
		cin>>cmd;
		if( "insert" == cmd ) {
			cin>>key;
			dll.push_front( key );
		} else if( "deleteFirst" == cmd ) {
			dll.pop_front( );
		} else if( "deleteLast" == cmd ) {
			dll.pop_back( );
		} else if( "delete" == cmd ) {
			cin>>key;
			deque<int>::iterator itr = dll.begin( );
			deque<int>::iterator itrE = dll.end( );
			for( ; itr!=itrE; itr++ ) {
				if( key == *itr ) {
					dll.erase( itr );
					break;
				}
			}
		}
	}
	printList( );

    return 0;
}

Measured memory_bytes: 5316
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

pub fn prime_factor(n: u64) -> std::collections::HashMap<u64, u64> {
    if n < 2 {
        return std::collections::HashMap::new();
    }
    let mut res = std::collections::HashMap::new();
    let mut n = n;
    let mut i = 2;
    while i * i <= n {
        while n % i == 0 {
            let c = res.entry(i).or_insert(0);
            *c += 1;
            n /= i;
        }
        i += 1;
    }
    if n != 1 {
        res.insert(n, 1);
    }
    res
}

fn solve() {
    input! {
        a: u64, b: u64
    };

    let aset = prime_factor(a).keys().copied().collect::<HashSet<_>>();
    let bset = prime_factor(b).keys().copied().collect::<HashSet<_>>();
    let res = aset.intersection(&bset).count() + 1;
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  while (A > 0 && C > 0){
    C -= B;
    if (C <= 0){
      cout << "Yes" << endl;
      return 0;
    }
    A -= D;
    if (A <= 0){
      cout << "No" << endl;
      return 0;
    }   
  }
}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 3e5+5;

bitset <sz> bst;

int main()
{
    int n, k;
    cin >> n >> k;
    while(k--) {
        int d;
        cin >> d;
        while(d--) {
            int x;
            cin >> x;
            bst[x] = 1;
        }
    }

    int ans = 0;
    for(int i=1; i<=n; i++) if(!bst[i]) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3548
#include <stdio.h>
#include <stdlib.h>
int func(const void *a,const void *b){//昇順
	if(*((long long int *)a) > *((long long int *)b)){
		return 1;
	}else if(*((long long int *)a) == (*(long long int *)b)){
		return 0;
	}else{
		return -1;
	}
}

int main(){
	long long int ans=0,N;
	scanf("%lld",&N);
	long long int A[N],B[N],C[N];
	for(int i=0;i<N;i++){
		scanf("%lld",&A[i]);
	}
	for(int i=0;i<N;i++){
		scanf("%lld",&B[i]);
	}
	for(int i=0;i<N;i++){
		scanf("%lld",&C[i]);
	}
	qsort((void *)A,N,sizeof(long long int),func);
	qsort((void*)C,N,sizeof(long long int ),func);
	for(int i=0;i<N;i++){
		long long int left=-1,right=N;
		//printf("i:%d\n",i);
		while(right-left>1){
			long long int harf=left+(right-left)/2;
			if(A[harf]>=B[i])right=harf;
			else left=harf;
			//printf("right:%d\nleft:%d\n",right,left);
		}
		//printf("A終了\n");
		long long int aleft=left+1;
		//printf("aleft:%d\n",aleft);
		left=-1;
		right=N;
		while(right-left>1){
			long long int harf=left+(right-left)/2;
			if(C[harf]>B[i])right=harf;
			else left=harf;
			//printf("right:%d\nleft:%d\n",right,left);
		}
		long long int bright=N-right;
		//printf("bright:%d\n",bright);
		ans+=(aleft*bright);
		//printf("ans:%d\n",ans);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3324
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;

int main() {
	char d;
	int rect = 0, rhom = 0;
	for (int a, b, c; cin >> a >> d >> b >> d >> c; ) {
		if(c * c == a * a + b * b) rect++;
		if(a == b) rhom++;
	}
	cout << rect << endl << rhom << endl;
	
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

void Do(int K, int A, int B){
  int i, y, p1, p2;
  long long c;
  c = 1;
  y = 0;
  for(i = 0;i < K;i++){
    if(y == 1){
      y--;
      c += B;
      continue;
    }
    if(y == 0 && c < A){
      c++;
      continue;
    }else{
      if(i < K - 1 && c >= A && B - A > 2){
	c -= A;
	y++;
      }else c++;
    }
  }
  printf("%lld\n", c);
}

int main(void){
  int K, A, B;
  scanf("%d %d %d", &K, &A, &B);
  Do(K, A, B);
  return 0;
}


Measured memory_bytes: 128
#include<vector>
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main()
{
	int n,sum;
	int i;
	sum=0;
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		sum += i;
	}
	cout << sum << endl;
	return 0;
}

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

using namespace std;


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


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int H,A; cin>>H>>A;
    if(H<A) cout<<1<<endl;
    else if(H%A==0) cout<<H/A<<endl;
    else cout<<(H/A)+1<<endl;
}

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

int main() {
    int r, c, i, j, z;
    cin >> r >> c;
    int poi[r + 1][c + 1];
    
    for(i = 0; i < r; i++){
    	for(j = 0; j < c; j++){
    		cin >> poi[i][j];
    	}
    }
    
    for(i = 0; i < r; i++){
    	z = 0;
  	   for(j = 0; j < c; j++){
    	  z += poi[i][j];
    	  
       }
       
       poi[i][c] = z;
    }
    
    for(i = 0; i < c + 1; i++){
       z = 0;	
       for(j = 0; j < r; j++){
    		z += poi[j][i];
    	}
    	poi[r][i] = z;
    }
    
    for(i = 0; i < r + 1; i++){
    	for(j = 0; j < c + 1; j++){
    		cout << poi[i][j];
    		if(j < c)
    		  cout << " ";
    		else
    		  cout << endl;
    	}
    }
    
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N;cin>>N;
  vector<pair<string,int>>V(N);for (int i=0;i<N;i++)cin>>V[i].first>>V[i].second;
  string X;cin>>X;
  int T;
  for(int i=0;i<N;i++){
    if(V[i].first==X)T=i;
  }
  int sum=0;
  for(int i=T+1;i<N;i++){
    sum+=V[i].second;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a;
  cin >> n;
  vector<int> v(n);
  for(int i = 1;i <= n;i++) {
    cin >> a;
    v[a-1] = i;
  }
  for(auto x : v) cout << x << " ";
}

Measured memory_bytes: 3692
n = int(input())
a = list(map(int, input().split()))
flag = [False for _ in range(8)]
flex = 0
for x in a:
    if x >= 3200:
        flex += 1
    else:
        flag[int(x/400)] = True
les = flag.count(True)
if les == 0 and flex > 0:
    print("1 {}".format(flex))
else:
    print("{} {}".format(les, les+flex))

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <string.h>
#include <set>
#include <algorithm>
#include <cmath>
#include <deque>
#include <string>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LL MOD = 1000000007;
const int INF = 1e9;
const LL LINF = 1LL * INF * INF;
const int MAXN = 200007;
const LD EPS = 1e-7;

string S;
int n, T[MAXN], L[MAXN];
vector <int> P[30];

void upd(int pos)
{
	for (int i = pos; i < n; i |= i + 1)
		++T[i];
}

int query(int pos)
{
	int s = 0;
	for (int i = pos; i >= 0; i = (i & (i + 1)) - 1)
		s += T[i];
	return s;
}

int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("In.txt", "r", stdin);
	LL ans = 0;
	cin >> S;
	n = SZ(S);
	REP(i, n)
		P[S[i] - 'a'].push_back(i);
	int cntodd = 0, podd;
	bool odd = (n & 1);
	REP(i, 26)
	{
		if (SZ(P[i]) & 1)
		{
			++cntodd;
			podd = i;
		}
	}
	if (cntodd > 1)
	{
		cout << -1;
		return 0;
	}
	int sk = 0;
	REP(i, n)
	{
		if (P[S[i] - 'a'][L[S[i] - 'a']] != i || L[S[i] - 'a'] >= SZ(P[S[i] - 'a']) / 2)
		{
			if (odd && i == P[podd][SZ(P[podd]) / 2])
				sk = 2;
			continue;
		}
		int l = i - query(i), r = P[S[i] - 'a'][SZ(P[S[i] - 'a']) - 1 - L[S[i] - 'a']];
		r -= query(r);
		ans += n - 1 - l - r + sk;
		upd(P[S[i] - 'a'][SZ(P[S[i] - 'a']) - 1 - L[S[i] - 'a']]);
		++L[S[i] - 'a'];
	}
	cout << ans;
	//cout << endl; system("pause");
	return 0;
}

Measured memory_bytes: 1936
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<algorithm>

using namespace std;

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




// a^n mod を計算する
long int modpow(long int a, long int n, long int mod) {
    long int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = (a * a) % mod;
        n >>= 1;
    }
    return res;
}

long int modcomb(long int a, long int b, long int mod){
    
    long int res = 1;
    for(long int i = a; i > a - b; i--){
        res *= i % mod;
        res %= mod;
    }
    res %= mod;
    for(long int i = 1; i <= b; i++){
        long int i_inv = modpow(i, mod - 2, mod);
        res *= i_inv % mod;
        res %= mod;
    }
    res %= mod;
    // cout << res << endl;
    return res;
}


int main(){
    long int const mod = 1000000007;
    long int x, y;
    cin >> x >> y;
    long int a, b;
    if ((2 * x - y) % 3 == 0 && (2 * y - x) % 3 == 0 && 2 * x - y >= 0 && 2 * y - x >= 0){
        a = (2 * y - x) / 3;
        b = (2 * x - y) / 3;
    }else{
        cout << 0 << endl;
        return 0;
    }
    long int ans = modcomb(a + b, b, mod);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
const int N = 2e5+5;
const dd eps = 1e-8;
const int mod = 1e9+7;

int n;
ll a[N],all;

int main(){
  ios::sync_with_stdio(false);
  // freopen("input.txt","r",stdin);
  cin>>n;
  for(int i = 1;i <= n;i++){
    cin>>a[i];
    all ^= a[i];
  }
  for(int i = 1;i <= n;i++){
    cout<<(all^a[i])<<" ";
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
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;
}
signed main() {
    int D;cin>>D;
    rep(i,26){
        int C;
        cin>>C;
    }
    rep(i,D){
        vector<int>S(26);
        rep(j,26)cin>>S[j];
        int ma=0;
        rep(j,26)chmax(ma,S[j]);
        rep(j,26){
            if(S[j]==ma){
                cout<<j+1<<endl;
                break;
            }
        }
        
    }
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n = 1e6;
int unip[max_n],unir[max_n];
void init(int n){
  for(int i=0 ; i<n ; i++){
    unip[i] = i;
    unir[i] = 0;
  }
}
int find(int x){
  if(unip[x] == x){
    return x;
  }else{
    return unip[x] = find(unip[x]);
  }
}
void unite(int x, int y){
  x = find(x);  y = find(y);
  if(unip[x] == unip[y]){
    return;
  }
  if(unir[x] < unir[y]){
    unip[x] = y;
  }else{
    unip[y] = x;
    if(unir[x] == unir[y]){
      unir[x]++;
    }
  }
}
bool same(int x, int y){
  return find(x) == find(y);
}
void solve();
vector<pair<int, int> > v;
vector<ll> ans;//i番目の不便さ
ll cnt[max_n] = {0};//v-iの移動できる島の数
ll n,m;
int main(){
  cin >> n >> m;
  for(int i=0 ; i<m ; i++){
    int a,b;
    cin >> a >> b;
    --a;  --b;
    v.push_back(make_pair(a,b));
  }
  reverse(v.begin(), v.end());
  ans.assign(m,0);
  solve();
  for(int i=m-1 ; i>=0 ; i--){
    cout << ans[i] << endl;
  }
  return 0;
}

void solve(){
  ans[0] = (n*(n-1))/2;
  init(n+1);
  for(int i=0 ; i<n ; i++){
    cnt[i] = 1;
  }
  for(int i=0 ; i<m-1 ; i++){
    ll now = 0, sum = 0;
    if(same(v[i].first, v[i].second)){
      ans[i+1] = ans[i];
      continue;
    }
    now = sum = cnt[find(v[i].first)];
    cnt[find(v[i].first)] = 0;
    now *= cnt[find(v[i].second)];
    sum += cnt[find(v[i].second)];
    cnt[find(v[i].second)] = 0;
    unite(v[i].first, v[i].second);
    cnt[find(v[i].first)] = sum;
    ans[i+1] = ans[i] - now;
  }
}


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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define SORT(v, n) sort(v, v+n)
#define VREV(v) reverse(v.begin(),v.end())
#define REV(v,n) reverse(v,v+n)
#define vi vector<int>
#define pf push_front
#define pb push_back

template<class T, size_t N> size_t countof(const T (&array)[N]) { return N; }
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }

void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}

void mprint(auto *matrix,auto N){
	REP(i,N) cout<<matrix<<(i!=N-1?' ':'\n');
	return;
}

const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const ll MOD =1000000007;
#define PI 3.14159265258979

#define P pair<int,int>
#define Pll pair<ll,ll>
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

inline int in(){int x; cin>>x; return x;}

struct UnionFind{
	vector<int> par; //データiが属する親の番号
	vector<int> sizes; //根ノードiの木に含まれるデータの数

	// 最初は全てのデータiがグループiに存在するものとして初期化
	UnionFind(int n):par(n),sizes(n, 1){
		REP(i,n) par[i] = i;
	}

	// 根を張り替えながら再帰的に根ノードを探す
	int find(int x){
		if(x==par[x]) return x;
		return par[x]=find(par[x]);
	}

	// 2つのデータx, yが属する木をマージする
	void unite(int x, int y) {
		// データの根ノードを得る
		x = find(x);
		y = find(y);

		// 既に同じ木に属しているならマージしない
		if (x == y) return;

		// xの木がyの木より大きくなるようにする
		if (sizes[x] < sizes[y]) swap(x, y);

		// xがyの親になるように連結する
		par[y] = x;
		sizes[x] += sizes[y];
		sizes[y] = 0;  // sizes[y]は無意味な値となるため
	}

	// 2つのデータx, yが属する木が同じならtrueを返す
	bool same(int x, int y) {
		return find(x) == find(y);
	}

	// データxが含まれる木の大きさを返す
	int size(int x) {
		return sizes[find(x)];
	}
};
int gcd(int n,int m){
	if(m>n) return gcd(m,n);
	if(m==0) return n;
	else return gcd(m,n%m);
}

int main(void){
	int N,M,a;
	priority_queue<int> A;

	cin>>N>>M;
	REP(i,N){
		cin>>a;
		A.push(a);
	}

	REP(i,M){
		a=A.top();
		A.pop();
		A.push(a/2);
	}

	ll sum=0;
	REP(i,N){
		sum+=A.top();
		A.pop();
	}
	print(sum);
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int h,w;
  cin >> h >> w;
  rep(i,h){
    string s;
    cin >> s;
    cout << s << endl << s << endl;
  }
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int N; cin >> N;
  vector<int> A(N); REP(i, N) cin >> A[i];
  vector<int> B(N); REP(i, N) cin >> B[i];
  vector<int> C(N - 1); REP(i, N - 1) cin >> C[i];

  int ans = 0;
  REP(i, N) {
    ans += B[A[i] - 1];
    if(i != N - 1 && A[i + 1] == A[i] + 1) ans += C[A[i] - 1];
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
n, k, *a = map(int, open(0).read().split())

mn = 1e18
ans, got = 1, 0
for i in range(n):
    if(mn>a[i]): mn = a[i]
    elif got==a[i]-mn: ans += 1
    elif got<a[i]-mn:
        got = a[i]-mn
        ans = 1
print(ans)

Measured memory_bytes: 14052