akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree < int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update >
#define smallk order_of_key
#define kth find_by_order
*/

#define nl '\n'
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pb push_back

typedef long long ll;

const int N = (int)1e5 + 123;
const int M = 1e9 + 7;
const int K = 500;

int n, m;
long long dp[111][N], sum[111][N];
int main(){

    //ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

    #ifdef LOCAL
        freopen("B.txt", "r", stdin);
    #endif // LOCAL

    cin >> n >> m;
    dp[0][0] = 1;
    for(int i = 1; i <= n; ++i){
        int x; cin >> x;
        sum[i - 1][0] = dp[i - 1][0];
        for(int j = 1; j <= m; ++j){
            sum[i - 1][j] = (sum[i - 1][j - 1] + dp[i - 1][j]) % M;
        }
        for(int j = 0; j <= m; ++j){
            dp[i][j] = sum[i - 1][j];
            if(j - x > 0){
                dp[i][j] = (dp[i][j] - sum[i - 1][j - x - 1] + M) % M;
              	dp[i][j] %= M;
            }
        }
    }
    cout << dp[n][m] % M;
    return 0;
}



Measured memory_bytes: 160000
N = int(input())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))


A_list = A_list[::-1]
B_list = B_list[::-1]

count = 0
tmp = 0
for i, a in enumerate(A_list):
  
  if i < len(B_list):  
    if a <= B_list[i] + tmp:
      count += a
      if tmp > a:
        tmp = B_list[i]
      else:
        tmp = B_list[i] + tmp - a      
    else:
      count += B_list[i] + tmp
      tmp = 0            
  else:
    if a <= tmp:
      count += a
    else:
      count += tmp
    
print(count)

Measured memory_bytes: 18624
#include <bits/stdc++.h>
#define ll long long
#define w(t) while(t--)
#include <iostream>
using namespace std;

int main()
{
    ll t=1;
    //cin>>t;
    w(t)
    {
        string s;
        cin>>s;
        if(s.length()>=6 && s[2]==s[3] && s[4]==s[5])
            cout<<"Yes";
        else cout<< "No";
    }
}

Measured memory_bytes: 256
#include <stdio.h>

void Merge(int, int, int);
void Merge_Sort(int, int);
    
int A[500000],count=0;

main()
{
  int n,i;
  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }
  
  
  Merge_Sort(0,n);
  
  for(i = 0; i < n; i++){
    printf("%d",A[i]);
    if(i != n-1){
      printf(" ");
    }
  }
  
  printf("\n%d\n",count);
  return 0;
  
}


void Merge(int left, int mid, int right)
{


  int  n1 = mid - left,
    n2 = right - mid;
  
  int L[n1+1],R[n2+1];
  int i,j,k;

  for(i = 0; i < n1; i++){

    L[i] = A[left + i];
  }
  for(i = 0; i < n2; i++){
   
    R[i] = A[mid + i];
  }
  
  L[n1] = 1000000000+1;
  R[n2] = 1000000000+1;

i = 0;
  j = 0;
  for(k = left; k < right; k++){

    if(L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }
    else {
      A[k] = R[j];
      j = j + 1;
    }
    count++;
  }
}

void Merge_Sort(int left, int right){
  int mid; 
  
  if(left+1 < right){
    mid = (left + right)/2;
    Merge_Sort(left, mid);
    Merge_Sort(mid, right);
    Merge(left, mid, right);
  }
}

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

#define INF 1e9;
//#define mod 1e9+7

//#define max(x,y) (x>y)?x:y
//#define min(x,y) (x<y)?x:y
#define rep(i,j,k) for(int i=j;i<k;i++)
#define repp(i,j,k) for(int i=j;i>=k;i--)


using namespace std;
int mod=1000000007;

int main(){
   int w,a,b;
   cin>>w>>a>>b;
   
   if(a+w<b) cout<<b-(a+w)<<endl;
   else if(b+w<a) cout<<a-(b+w)<<endl;
   else cout<<0<<endl;
   
   
   

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int main() {
    int n;
    cin >> n;
    int dp[45];
    dp[0] = 1;
    dp[1] = 1;
    for(int i = 2;i<=n;i++) {
        dp[i] = dp[i-2] + dp[i-1];
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 3092
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const int maxn=100000+10;
int d[maxn],a[maxn];
int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	int n;
	cin>>n;
	int sum=0;
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		d[i]=abs(a[i-1]-a[i]);
		sum+=d[i];
	}
	d[n+1]=abs(a[n]);
	sum+=d[n+1];
	for(int i=1;i<=n;++i){
		int ans=sum-d[i]-d[i+1]+abs(a[i-1]-a[i+1]);
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 2048
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;
using P = std::pair<ll, ll>;

const ll di[4] = { 0, 1, 0, -1 }, dj[4] = { 1, 0, -1, 0 };
const ll INF = 1ll<<60;

ll H, W, K;
std::string A[1000];
std::queue<P> que;
ll dist[1000][1000];
ll ans = INF;
ll gi, gj;

void bfs( bool all )
{
  while( !que.empty() )
  {
    P st = que.front();
    ll i = st.first, j = st.second;

    que.pop();

    if( !i || !j || i == H-1 || j == W-1 )
    {
      gi = i;
      gj = j;

      break;
    }

    if( !all && dist[i][j] == K )
      continue;

    rep( d, 4 )
    {
      ll ni = i+di[d], nj = j+dj[d];

      if( ni >= 0 && ni < H && nj >= 0 && nj < W && (all || A[ni][nj] != '#') && dist[ni][nj] > dist[i][j]+1 )
      {
        dist[ni][nj] = dist[i][j]+1;
        que.push( P( ni, nj ) );
      }
    }
  }

  return;
}

ll si, sj;

int main()
{
  std::cin >> H >> W >> K;

  rep( i, H )
  {
    std::cin >> A[i];

    rep( j, W ) if( A[i][j] == 'S' )
      si = i, sj = j;
  }

  que.push( P( si, sj ) );

  rep( i, H ) rep( j, W )
    dist[i][j] = INF;

  dist[si][sj] = 0;

  bfs( false );

  rep( i, H ) rep( j, W )
  {
    if( dist[i][j] != INF )
    {
      dist[i][j] = K;

      que.push( P( i, j ) );
    }
  }

  bfs( true );

  std::cout << (dist[gi][gj]+K-1)/K << std::endl;

  return 0;
}

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

typedef long long LL;
typedef unsigned long long ULL;

#define debug printf("fuck %d\n", __LINE__);

inline LL read() {
	LL res = 0, bo = 1; char ch = getchar();
	while(ch < '0' || ch > '9') { if (ch == '-') bo = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9') { res = (res << 1) + (res << 3) + ch - '0'; ch = getchar(); }
	return bo * res;
}

template<typename T> void read(T &x) { x = read(); }
template<typename T, typename ...Argv> void read(T &a, Argv &...argv) { read(a); read(argv...); }

const int N = 6e5 + 10, p = 998244353;
int fac[N], inv[N];

int ksm(int x, int y) {
	int res = 1; 
	for (; y; y >>= 1, x = 1LL * x * x % p) if (y & 1) res = 1LL * res * x % p;
	return res;
}

void init(int n) {
	fac[0] = 1;
	for (int i = 1; i <= n; ++ i) fac[i] = 1LL * fac[i - 1] * i % p;
	inv[n] = ksm(fac[n], p - 2);
	for (int i = n - 1; ~i; -- i) inv[i] = 1LL * inv[i + 1] * (i + 1) % p;
}

int C(int n, int m) { return m > n ? 0 : 1LL * fac[n] * inv[m] % p * inv[n - m] % p; }

int main() {
	int n = read(), k = read(); init(N - 1);
	int ans = 0;
	for (int i = n; i <= k; ++ i) {
		(ans += C(k - 1, i - 1)) %= p;
	}
	std::cout << ans << std::endl;
	return 0;
}

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

int main(){
	int N;
	cin >> N;
	int Max = N/4;
	
	int ans=0, i, j, sum;
		for(i=0; i<=Max; i++){
			for(j=0; j<=Max; j++){
				sum = 4*i + 7*j;
				if(sum == N)	ans=1;
			}
		}
	
	if(ans == 0)	cout << "No" << endl;
	else		cout << "Yes" << endl;
	
	return 0;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  map<string, map< int, int > > mp;

  int n;cin>>n;
  for(int i=0;i<n;i++){
    string s;int p;cin>>s>>p;
    mp[s][p] = i+1;
  }

  for (auto& kv : mp) {
    auto mp2 = kv.second;
    for (auto iter = mp2.rbegin(); iter != mp2.rend(); ++iter) {
      cout<< (iter->second) <<endl;
    }
  }

  return 0;
}


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

using namespace std;

const int Nmax = 1e5+5;

int x, y, n, m, i;
vector<int> v[Nmax], vv, ans;
bool used[Nmax];

void connect(int node)
{
    used[node] = 1;
    vv.push_back(node);

    for(auto it : v[node])
        if(!used[it])
        {
            connect(it);
            return;
        }
}

int main()
{
  //  freopen("input", "r", stdin);
  //  freopen("output", "w", stdout);

    cin.sync_with_stdio(false);

    cin >> n >> m;
    for(i=1; i<=m; ++i)
    {
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }

    used[x] = used[y] = 1;
    connect(x);
    reverse(vv.begin(), vv.end());
    for(auto it : vv) ans.push_back(it);
    vv.clear();

    connect(y);
    for(auto it : vv) ans.push_back(it);

    cout << ans.size() << '\n';
    for(auto it : ans) cout << it << ' ';

    return 0;
}


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

using namespace std;

int main() {
	int x; cin >> x;
	for (int a = -200; a <= 200; a++)
		for (int b = -200; b <= 200; b++)
			if ((long long) a * a * a * a * a - (long long) b * b * b * b * b == x) {
				cout << a << ' ' << b << '\n';
				return 0;
			}
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,mx=0;
	scanf("%i",&n);
	vector<int> dp(n,0),a(n,0);
	for(i=0;i<n;i++)
	{
		scanf("%i",&a[i]);
		a[i]--;
		if(a[i]>0) dp[a[i]]=dp[a[i]-1]+1;
		else dp[a[i]]=1;
		mx=max(mx,dp[a[i]]);
	}
	printf("%i\n",n-mx);
	return 0;
}

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

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



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

    vector<ll> a(n);

    ll co=0,sum=0,mi=99999999999;
    rep(i,n){
        cin>>a.at(i);
        if(a.at(i)<0){
            co++;
        }
        a.at(i) = abs(a.at(i));
        mi = min(mi,a.at(i));
        sum += a.at(i);
    }
    if(co%2==1)sum-=2*mi;
    cout<<sum<<endl;

}

Measured memory_bytes: 1024
n = int(input())
abc = [[0 for i in range(3)] for j in range(n)]
dp = [[0 for i in range(3)] for j in range(n+1)]

for i in range(n):
  a,b,c = map(int, input().split() ) 
  abc[i][0] = a
  abc[i][1] = b
  abc[i][2] = c

for i in range(1,n+1):
  for j in range(3):
    for k in range(3):
      if j == k:
        continue
      
      dp[i][j] = max(dp[i][j], abc[i-1][j]+dp[i-1][k])

  
  
#print(abc)
#print(dp)
ret = 0
for i in range(3):
  ret = max(ret, dp[n][i])
 
print(ret)


Measured memory_bytes: 72796
fun main(args: Array<String>) {
    val s = readString()
    if (
        s.isPalindrome() &&
        s.substring(0 until (s.length - 1) / 2).isPalindrome() &&
        s.substring((s.length + 3) / 2 - 1 until s.length).isPalindrome()
    ) {
        println("Yes")
    } else {
        println("No")
    }
}

fun String.isPalindrome(): Boolean =
    if (length % 2 == 0) {
        substring(0 until length / 2) == substring(length / 2 until length).reversed()
    } else {
        substring(0 until (length - 1) / 2) == substring((length + 3) / 2 - 1 until length).reversed()
    }

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)


Measured memory_bytes: 33280
#include<stdio.h>

int main(){
int A,B,C;
char kigou;
 scanf("%d %c %d",&A,&kigou,&B);
 switch(kigou){
      case '+':
            C=A+B;
             printf("%d",C);
              break;
       default:
       C=A-B;
       printf("%d",C);
        break;
}
return 0;
}

Measured memory_bytes: 128
import heapq
n = int(input())
copy = n


def factorization(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


f = factorization(n)
l = []
for i in f:
    for j in range(1, i[1]+1):
        l.append(i[0]**j)

heapq.heapify(l)

cnt = 0
while l:
    tmp = heapq.heappop(l)
    if n % tmp == 0:
        n = n // tmp
        cnt += 1
print(cnt if copy != 1 else 0)

Measured memory_bytes: 63940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("abc165/abc165_a.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int K, A, B;
  cin >> K >> A >> B;

  bool ok = false;
  repi(i, A, B + 1) { 
    if (i % K == 0) {
      ok = true;
      break;
    }
  }

  cout << (ok ? "OK" : "NG") << endl;
}

Measured memory_bytes: 3640
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()

A = [0]
for i in range(1,2*10**5):
    a = 0
    r = i
    for j in range(18):
        a += (i>>j)&1
    r %= a
    if r == 0:
        A.append(1)
    else:
        A.append(1+A[r])

X = LS2()

b = 0
for i in range(N):
    if X[i] == '1':
        b += 1
if b >= 2:
    c = b-1
    d = b+1

    r1 = 0
    r2 = 0

    amari1 = [1]
    amari2 = [1]
    for i in range(1,N):
        amari1.append((amari1[-1]*2) % c)
        amari2.append((amari2[-1]*2) % d)
    amari1.reverse()
    amari2.reverse()
    for i in range(N):
        if X[i] == '1':
            r1 += amari1[i]
            r1 %= c
            r2 += amari2[i]
            r2 %= d
    ANS = []
    for i in range(N):
        if X[i] == '1':
            e = r1
            e -= amari1[i]
            e %= c
            ANS.append(A[e]+1)
        else:
            f = r2
            f += amari2[i]
            f %= d
            ANS.append(A[f]+1)
else:
    d = b + 1
    r2 = 0


    amari2 = [1]
    for i in range(1, N):
        amari2.append((amari2[-1] * 2) % d)
    amari2.reverse()

    for i in range(N):
        if X[i] == '1':

            r2 += amari2[i]
            r2 %= d
    ANS = []
    for i in range(N):
        if X[i] == '1':

            ANS.append(0)
        else:
            f = r2
            f += amari2[i]
            f %= d
            ANS.append(A[f] + 1)


print(*ANS,sep='\n')

Measured memory_bytes: 130040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define reverse(s) reverse(s.begin(),s.end())

int main(){
    int n;  cin >> n;
    vector<int> A(n),a(n);

    rep(i,n){
        cin >> A[i];
        a[i] = A[i];
    }
    sort(a.begin(),a.end(),greater<int>());

    rep(i,n){
        if(A[i]==a[0]){
            cout << a[1] << endl;
        }else{
            cout << a[0] << endl;
        }
    }

    return 0;
}

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

int N;
string S[10010];
int main(){
    cin >> N;
    int ans = 0;
    int a = 0,b = 0,ab = 0;
    for(int i=1;i<=N;i++){
        cin >> S[i];
        int n = S[i].size();
        for(int j=0;j<n-1;j++) if(S[i][j]=='A' && S[i][j+1]=='B') ans++;
        if(S[i][0]=='B' && S[i][n-1]=='A') ab++;
        else if(S[i][0]=='B') b++;
        else if(S[i][n-1]=='A') a++;
    }
    if(ab==0){
        cout << ans+min(a,b) << endl;        
    }else{
        if(a+b>0){
            cout << ans+ab+min(a,b) << endl;           
        }else{
            cout << ans+ab-1 << endl;       
        }
    }
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll MAX=100004;
const ll MOD=998244353;
ll n;
vector<ll> a,p;
main(){
    scanf("%lld",&n);
    for(ll i=0;i<n;i++){
        ll tmp;
        scanf("%lld",&tmp);
        a.push_back(tmp);
    }
    sort(a.begin(),a.end());
    for(ll i=n;i>=1;i--){
        if(a[i-1]==a[i]) p.push_back(a[i]),i--;
        if(p.size()==2){
            printf("%lld\n",p[0]*p[1]);
            return 0;
        }
    }
    printf("%lld\n",0ll);
    return 0;
}


Measured memory_bytes: 1400
function Main(input){
  input = input.split("\n");
  inputStr = input[0].split(" ");
  var N = Number.parseInt(inputStr[0]);
  var X = Number.parseInt(inputStr[1]);
  //入力値Lを数値化して配列に放り込む
  inputStr = input[1].split(" ");
  var L_arr = inputStr.map( inputStr => parseInt(inputStr));
  
  //計算処理
  var ov_cnt = 0; //回答
  var c_val = 0;  //Xと比較する計算値格納変数
  for( i=0 ; i<N+1 ; i++ ){
    if(c_val > X) { break; }
    //console.log(c_val);
    ov_cnt += 1;
    c_val = c_val + L_arr[i]
  }
  console.log(ov_cnt);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	ll ten=10;
	while(cin>>N) {
		VVI F(N, VI(ten)), P(N, VI(ten+1));
		REP(i, N) REP(j, ten) cin>>F[i][j];
		REP(i, N) REP(j, ten+1) cin>>P[i][j];
		ll ans = -INF;
		REP(bi, 1<<ten) if(bi!=0) {
			ll lans=0;
			REP(i, N) {
				ll c=0;
				REP(j, ten) if(bi>>j&1) c+=F[i][j];
				lans+=P[i][c];
			}
			maxUpdate(ans, lans);
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
S = input()
mx = 0
for i in range(len(S)):
    for j in range(i, len(S) + 1):
        s = S[i:j]
        flag = True
        for si in s:
            if si not in ["A", "C", "G", "T"]:
                flag = False
        if flag:
            mx = max(mx, len(s))

print(mx)


Measured memory_bytes: 3060
V,E=map(int,input().split())
EDGE=[list(map(int,input().split())) for i in range(E)]

#Tarjanのアルゴリズム

from collections import deque
QUE = deque(list(range(V)))
EDGEOUTLIST=[[] for i in range(V)]

for x,y in EDGE:
    EDGEOUTLIST[x].append(y)

check=[0]*V
TOP_SORT=[]

def dfs(x):
    if check[x]==1:
        return
    
    for to in EDGEOUTLIST[x]:
        if check[to]==0:
            dfs(to)

    TOP_SORT.append(x)
    check[x]=1

while QUE:
    x=QUE.pop()
    dfs(x)

TOP_SORT.reverse()
for v in TOP_SORT:
    print(v)


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


unsigned long long lcmm(unsigned long long a, unsigned long long b) {

	unsigned long long x, tmp, r;
	x = a * b;

	if (a == b) {
		return a;
	}

	/* 自然数 a > b を確認・入替 */
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return x / b;
}

unsigned long long div(unsigned long long a, unsigned long long b) {
	return a / b;
}

int main() {

	unsigned long long A, B, C, D, e, x, y;

	cin >> A >> B >> C >> D;
	e = lcmm(C, D);


	x = div((A - 1) , C) + div((A - 1) ,D) - div((A - 1) , e);
	y = div(B , C) + div(B , D) - div(B , e);

	cout << (B - A + 1) - (y - x);

	return 0;
}


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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,n)      for(int i=0; i < (n); ++i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define sz(x)         (x).size()
#define M             1e9+7;
#define MM            998244353
#define PI            3.14159265358979

typedef long double ld;
typedef pair <int,int> pii;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,ans; string str;

int solve(){
    cin>>n;
    int d[n];
    rep(i,n) cin>>d[i];
    for (int i = 0; i < n; ++i)
    {
        for (int j = i+1; j < n; ++j)
        {
            ans+=d[i]*d[j];
        }
    }
    cout<<ans;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

prev = -10
result = 0

for i in range(N):
    n = A[i]
    result += B[n-1]
    if n == (prev + 1):
        result += C[n-2]
        
    prev = n

print(result)

Measured memory_bytes: 38384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc157/tasks/abc157_a>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    res = (N+1)/2;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<double>v(N);
  for(int i=0;i<N;i++){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  double ans=v[0];
  for(int i=1;i<N;i++){
    ans = (ans+v[i])/2;
  }
  cout << ans << endl;
}
      
    
      


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC169B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var As = Console.ReadLine().Split().Select(ulong.Parse).OrderBy(x => x).ToArray();

            if (As[0] == 0ul)
            {
                Console.WriteLine(0);
                return;
            }

            ulong ans = 1ul;

            for (var i = 0; i < N; i++)
            {
                var A = As[i];

                try
                {
                    ans = checked(ans * A);
                }
                catch (Exception)
                {
                    Console.WriteLine(-1);
                    return;
                }

                if (ans > 1000000000000000000ul)
                {
                    Console.WriteLine(-1);
                    return;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 39320
# -*- coding: utf-8 -*-
import math

N, D = map(int, str(input()).split())
X = list()
for i in range(N):
    x = list(map(int, str(input()).split()))
    X.append(x)

count = 0

for i in range(N):
    for j in range(N):
        d = math.sqrt(sum(map(lambda x,y : abs(x-y) * abs(x-y) , X[i],X[j])))
        if d - int(d) == 0 and d != 0.0:
            count += 1
count = count /2

print(int(count))
    

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

int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin >> vec.at(i);
    }
    int ans=0;
    int tmp=0;
    for(int i=0;i<n-1;i++){
        if(vec.at(i) >= vec.at(i+1)){
            tmp++;
        }else{
            tmp=0;
        }
        if(ans<tmp)ans=tmp;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
X, Y, A, B, C = map(int, input().split())

red_apple = list(map(int, input().split()))
green_apple = list(map(int, input().split()))
all_apple = list(map(int, input().split()))

red_apple = sorted(red_apple, reverse=True)
green_apple = sorted(green_apple, reverse=True)

all_apple += red_apple[:X]
all_apple += green_apple[:Y]
ans = sum(sorted(all_apple)[::-1][:X+Y])
print(ans)
    

Measured memory_bytes: 24364
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

const int MAX_V = 1e5 + 1;
vector<vector<P>>G;
int N;
ll prim() {
    vector<int> mincost(N, INF);
    vector<int> used(N, false);
    mincost[0] = 0;
    priority_queue<P, vector<P>, greater<>> pque;
    pque.emplace(0, 0);
    ll res = 0;
    while(!pque.empty()) {
        P p = pque.top();
        pque.pop();
        if(used[p.second])continue;
        used[p.second] = true;
        res += p.first;
        for(P child : G[p.second]) {
            if(!used[child.first])
                pque.push(mp(child.second, child.first));
        }
    }
    return res;
}


int main() {
    cin >> N;
    P posX[N], posY[N];
    rep(i, N) {
        int x, y; cin >> x >> y;
        posX[i] = mp(x, i);
        posY[i] = mp(y, i);
    }
    sort(posX, posX + N);
    sort(posY, posY + N);
    G.resize(N);
    rep(i, N - 1) {
        G[posX[i].second].pb(mp(posX[i + 1].second, posX[i + 1].first - posX[i].first));
        G[posX[i + 1].second].pb(mp(posX[i].second, posX[i + 1].first - posX[i].first));
        G[posY[i].second].pb(mp(posY[i + 1].second, posY[i + 1].first - posY[i].first));
        G[posY[i + 1].second].pb(mp(posY[i].second, posY[i + 1].first - posY[i].first));
    }
    cout << prim() << endl;
}


Measured memory_bytes: 11384
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define mod 1000000007
vector<vector<int>> graph(200000);
 int n;

ll power(ll n,ll m)
{
    ll ans=1;
    for (int r=0;m>>r>0;r++)
    {
        if ((m>>r)&1) ans=ans*n%mod;
        n=n*n%mod;
    }
    return ans;
}

ll inv(ll n)
{
    return power(n,mod-2);
}

ll ans=0;

ll dfs(int s,int w)
{
    ll sz,acu=1;
    ll now=power(2,n-1)-1;
    for (int i=0;i<graph[s].size();i++)
    {
        int u=graph[s][i];
        if (u==w) continue;
        sz=dfs(u,s);
        acu+=sz;
        now=(now-(power(2,sz)-1)+mod)%mod;
    }
    if (w!=-1) now=(now-(power(2,n-acu)-1)+mod)%mod;
    ans=(ans+now)%mod;
    return acu;
}

int main()
{
    cin >> n;
    int a,b;
    for (int i=0;i<n-1;i++)
    {
        cin >> a >>b;
        a--;b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    dfs(0,-1);
    ll ans1=inv(power(2,n));
    cout << ans*ans1%mod << endl;
    return 0;
}

Measured memory_bytes: 22272
#include <stdio.h>

int main(void){
int H,W,c,d=0;
while(1){
scanf("%d",&H);
scanf("%d",&W);

if(H==0&&W==0){break;}

else{
for(c=1;c<=H;c++){
		for(d=1;d<=W;d++){
			printf("#");
		}
	printf("\n");
}
printf("\n");
}
}
return 0;
}

Measured memory_bytes: 572
from collections import defaultdict
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


class UnionFind:
    """
    sizeによる実装
    """

    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.size = [1 for _ in range(N)]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            return self.find(self.parent[x])

    def union(self, x, y):
        px = self.find(x)
        py = self.find(y)
        if px == py:
            return
        if self.size[px] < self.size[py]:
            self.parent[px] = py
            self.size[py] += self.size[px]
        else:
            self.parent[py] = px
            self.size[px] += self.size[py]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def connectedNum(self, x):
        return self.size[self.find(x)]


N, M = map(int, input().split())
Un = UnionFind(N)  # 会話できる人をつなげる
D = defaultdict(lambda: [])
for i in range(N):
    _, *L = map(lambda x: int(x)-1, input().split())
    for l in L:
        D[l].append(i)
for i in range(M):
    if len(D[i]) > 1:
        t = D[i]
        for d in t[1:]:
            Un.union(t[0], d)
if Un.size[Un.find(0)] == N:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 27404
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve(){
	int l,r,d,c;
	cin>>l>>r>>d;
	cout<<(r/d)-((l-1)/d)<<endl;
}

int main() {
	ios_base::sync_with_stdio(0);
	int t, i, j, k, p, q, r, x, y, u, v, n, m;
	solve();
	return 0;
}

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = ((ll)result * base) % mod;
		base = ((ll)base * base) % mod;
		exp >>= 1;
	}
	return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}




Measured memory_bytes: 10644
from collections import defaultdict

n = int(input())
ans = 0

a_lis = list(map(int,input().split()))
A_dict = [0]*(10**5+1)

for i in a_lis:
  A_dict[i] += 1

for j in range(1,10**5):
  tmp = A_dict[j-1]+A_dict[j]+A_dict[j+1]
  if tmp > ans:
    ans = tmp
print(ans)

Measured memory_bytes: 14336
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long A = Integer.parseInt(sc.next());
        long B = Integer.parseInt(sc.next());
        long i = 1;
        if(A<B){
            long temp = A;
            A = B;
            B = temp;
        }
        while(true){
            if((A*i)%B == 0){
                System.out.println(A*i);
                return;
            }
            i++;
        }
    }
}

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

int main ()
{
    int n;
    cin >> n;
    double a[5] = {165.0, 170.0, 175.0, 180.0, 185.0};
    string res[6];

    for (int i = 0; i < n; i++) {
        double num;
        cin >> num;
        for (int j = 0; j < 6; j++) {
            if (j < 5 && a[j] > num) {
                res[j] += '*';
                break;
            }  else if(j == 5) {
                res[5] += '*';
            }
        }
    }

    for (int i = 0; i < 6; i++) {
        cout << i+1 <<':' << res[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 1240
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    def bfs(u):
        dist = [inf] * n
        cur = [u]
        pre = [-1] * n
        dist[u] = 0
        d = 0
        while cur:
            d += 1
            nxt = []
            for v in cur:
                for kv in to[v]:
                    if dist[kv] != inf: continue
                    dist[kv] = d
                    pre[kv] = v
                    nxt.append(kv)
            cur = nxt
        mn = [inf, -1]
        for v in range(n):
            if v == u: continue
            if u in to[v]:
                mn = min(mn, [dist[v], v])

        # print(dist)
        # print(mn)
        # print(pre)
        res = []
        v = mn[1]
        if mn[0] == inf:
            return [0] * (n + 1)
        for _ in range(mn[0] + 1):
            res.append(v)
            v = pre[v]
        return res

    inf = 10 ** 9
    n, m = map(int, input().split())
    to = defaultdict(set)
    for _ in range(m):
        u, v = map(int, input().split())
        to[u - 1].add(v - 1)
    ans = [0] * (n + 1)
    for u in range(n):
        res = bfs(u)
        if len(res) < len(ans):
            ans = res
    if len(ans) == n + 1:
        print(-1)
    else:
        print(len(ans))
        for u in ans:
            print(u + 1)

main()


Measured memory_bytes: 3828
def CountingSort(A,B,k):
    C = []
    for i in range(0,k+1):
        C.append(0)
    for j in A:
        C[j] += 1
    for i in range(0,k+1):
        while(C[i] != 0):
            B.append(i)
            C[i] -= 1
B = []
n = int(input())
st = input()
A = list(map(int,st.split()))
max = 0
for x in A:
    if x > max:
        max = x
CountingSort(A,B,max)
for i in range(0,n-1):
    print(B[i],end=" ")
print(B[n-1])

Measured memory_bytes: 243156
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const ll  MOD = 1000000007LL;
/*メモ 
*/
itn main(){
    int a,b;
    std::cin >> a>>b;
    std::cout << (a-1)*(b-1) << std::endl;
}

Measured memory_bytes: 256
a,b,c,x,y = map(int, input().split())

plan_a = c * (2*x) + max(0, y-x) * b
plan_b = c * (2*y) + max(0, x-y) * a
plan_c = a * x + b * y

print(min(plan_a, plan_b, plan_c))

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

int main() {
  int N;
  cin >> N;
  vector<int> a;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    tmp--;
    a.emplace_back(tmp);
  }
  /* for (int i = 0; i < a.size(); i++) { */
  /*   cout << a[i] << endl; */
  /* } */
  int now = 0, cnt = 0;
  while (true) {
    if (now == 1) {
      cout << cnt << endl;
      return 0;
    } else if(cnt >= N) {
      cout << -1 << endl;
      return 0;
    }
    cnt++;
    now = a[now];
  }
}


Measured memory_bytes: 892
def solve():
    N = int(input())
    dict = {}

    for _ in range(N):
        S = input()
        if S in dict:
            dict[S] += 1
        else:
            dict[S] = 1
    sorted_dict = list(sorted(dict.items(), key=lambda x:x[1], reverse=True))
    mx = sorted_dict[0][1]
    cand = []
    for d in sorted_dict:
        if d[1] == mx:
            cand.append(d[0])
        else:
            break
    print(*sorted(cand), sep='\n')
    
if __name__ == '__main__':
    solve()

Measured memory_bytes: 121132
/*
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
ordered_set -> less -> less_equal
ordered_set find_by_order() -> возвращает k-ый элемент(отсчёт с нуля)
ordered_set order_of_key() -> возвращает количество элементов в множестве,строго меньших,чем наш элемент
*/
#include <bits/stdc++.h>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;
using namespace __gnu_pbds;

template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());


typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vector<int> > matrix;

inline void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll maxn=2e5+123;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=(1ll<<61)-1;
const double eps=1e-9;
const double pi=acos(-1);
int dx[8]={0,1,-1,0,1,-1,1,-1};
int dy[8]={1,0,0,-1,1,1,-1,-1};
ll a[maxn],b[maxn],c[maxn];
vector<pll>v;
int main(){
    boost();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll x,y,n,m,k;
    cin>>x>>y>>n>>m>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=m;i++){
        cin>>b[i];
    }
    for(int i=1;i<=k;i++){
        cin>>c[i];
    }
    sort(a+1,a+1+n);
    sort(b+1,b+1+m);
    sort(c+1,c+1+k);
    for(int i=max(1ll,n-x+1);i<=n;i++){
        v.pb({a[i],1});
    }
    for(int j=max(1ll,m-y+1);j<=m;j++){
        v.pb({b[j],2});
    }
    sort(all(v));
    reverse(c+1,c+1+k);
    for(int i=1;i<=k;i++){
        if(v.size()<i){
            break;
        }
        if(v[i-1].F<c[i]){
            v[i-1].F=c[i];
        }
        else{
            break;
        }
    }
    ll cntr=0;
    for(int i=0;i<v.size();i++){
        cntr+=v[i].F;
    }
    cout<<cntr;
	exit(0);
}


Measured memory_bytes: 9840
#include <iostream>

using namespace std;

template <size_t N>
struct Solver
{
    bool is_prime[N + 1];
    int ans[N + 1];
    constexpr Solver() : is_prime(), ans()
    {
        is_prime[0] = false;
        is_prime[1] = false;
        for (size_t i = 2; i <= N; i++)
        {
            is_prime[i] = true;
        }
        for (size_t prime = 2; prime <= N; prime++)
        {
            if (is_prime[prime])
            {
                for (size_t q = prime * 2; q <= N; q += prime)
                {
                    is_prime[q] = false;
                }
            }
        }
        for (size_t i = 1; i <= N; i++)
        {
            ans[i] += ans[i - 1];
            if (is_prime[i] && is_prime[(i + 1) / 2])
            {
                ans[i] += 1;
            }
        }
    }
};

int main()
{
    constexpr auto M = 100000;
    constexpr auto solver = Solver<M>();
    int Q;
    cin >> Q;
    for (size_t i = 0; i < Q; i++)
    {
        int l, r;
        cin >> l >> r;
        cout << (solver.ans[r] - solver.ans[l - 1]) << endl;
    }
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
ll dfs(ll src,vector<ll> adj[],ll *dp)
{
	if(dp[src]!=-1)
		return dp[src];
	ll temp=0;
	for(auto child:adj[src])
	{
			temp=max(temp,1+dfs(child,adj,dp));
	}

	return dp[src]=temp;
}
void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}
void input()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
}
int main()
{
	fast();
	
	ll n,m;
	cin>>n>>m;
	vector<ll> adj[n+1];
	for(ll i=1;i<=m;i++)
	{
		ll a,b;
		cin>>a>>b;
		adj[a].pb(b);
	}
	bool vis[n+1];
	ll res=INT_MIN;
	ll dp[n+1];
	memset(dp,-1,sizeof(dp));
	for(ll i=1;i<=n;i++)
	{
			res=max(res,dfs(i,adj,dp));
	}
	cout<<res<<endl;
}

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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int n,k;
    cin>>n>>k;
    vector <int> a(n);
    loop(i,0,n) cin>>a[i];
    sort(all(a));
    int s=0;
    loop(i,0,k) s+=a[i];
    cout<<s;


    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
ll gyaku(ll n){
  ll u=mod-2;
  ll ret=1;
  ll now=n;
  while(u>0){
    if(u%2==1){
      ret*=now;
      ret%=mod;
    }
    now*=now;
    now%=mod;
    u/=2;
  }
  return ret;
}
int main(){
  ll b,w;cin>>b>>w;
  ll p[b+w+1];
  ll now=1;
  ll kai=1;
  for(ll i=0;i<w;i++){
    kai*=gyaku(2);
    kai%=mod;
  }
  ll sum=0;
  for(ll i=w;i<b+w;i++){
    p[i]=now*kai;
    p[i]%=mod;
    now*=i;
    now%=mod;
    now*=gyaku(i-w+1);
    kai*=gyaku(2);
    now%=mod;
    kai%=mod;
    sum+=p[i];
    sum%=mod;
    //cout<<now<<" "<<kai<<endl;
  }
  p[b+w]=(1-sum+mod)%mod;
  //for(ll i=1;i<=b+w;i++)cout<<p[i]<<endl;
  //cout<<(3*gyaku(16))%mod;
  //return 0;
  ll imos[b+w+2];
  fill(imos,imos+b+w+2,0);
  for(ll i=w;i<b+w;i++){
    ll r=i-w;
    r*=gyaku(i-1);
    r%=mod;
    r*=p[i];
    r%=mod;
    imos[1]+=r;
    imos[1]%=mod;
    imos[i]+=(-r+mod)%mod;
    imos[i]%=mod;
    imos[i+1]+=p[i];
    imos[i+1]%=mod;
    imos[b+w+1]+=(-p[i]+mod)%mod;
    imos[b+w+1]%=mod;
  }
 // for(ll i=1;i<=b+w;i++)cout<<imos[i]<<endl;
 // return 0;
  ll q[b+w+1];
  now=1;
  kai=1;
  for(ll i=0;i<b;i++){
    kai*=gyaku(2);
    kai%=mod;
  }
  for(ll i=b;i<b+w;i++){
    q[i]=now*kai;
    q[i]%=mod;
    now*=i;
    now%=mod;
    now*=gyaku(i-b+1);
    kai*=gyaku(2);
    now%=mod;
    kai%=mod;
    //cout<<now<<" "<<kai<<endl;
  }
  for(ll i=b;i<b+w;i++){
    ll r=b-1;
    r*=gyaku(i-1);
    r%=mod;
    r*=q[i];
    r%=mod;
    imos[1]+=r;
    imos[1]%=mod;
    imos[i]+=(-r+mod)%mod;
    imos[i]%=mod;
    imos[i]+=q[i];
    imos[i+1]+=(-q[i]+mod)%mod;
  }
  ll ans[b+w+1];
  fill(ans,ans+b+w+1,0);
  for(ll i=1;i<=b+w;i++){
    ans[i]=ans[i-1]+imos[i];
    ans[i]%=mod;
  }
  for(ll i=1;i<=b+w;i++){
    cout<<ans[i]<<endl;
  }
}
    
  
  
  

Measured memory_bytes: 6912
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;
  cin >> s;
  int x = s.size();
  if(s[x-1] != 's'){
    cout << s << 's' << endl;
  }
  else if(s[x-1] == 's'){
    cout << s << "es" << endl;
  }
  return 0;
}

Measured memory_bytes: 3600
n = int(input())
a_list = list(map(int, input().split()))

s = 0
for a in a_list:
  s += a

hoge = 0
for i in range(n-1):
  if i%2 == 0:
    continue
  hoge += a_list[i]
  
x1 = s - (2 * hoge)

result = []
# result.append(x1)
print(x1)
xi = x1
for i in range(n-1):
    hoge = (a_list[i] * 2) - xi
    # result.append(hoge)
    print(hoge)
    xi = hoge
# print(result)


Measured memory_bytes: 14028