akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
int a[1000000];
struct data
{
    int b,c;
};
bool cmp(data q,data w)
{
    return q.c>w.c;
};
data op[1000000];
main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    for(int i=1; i<=m; i++)
    {
        cin>>op[i].b>>op[i].c;
    }
    sort(op+1,op+m+1,cmp);
    int i=1;
    for(int j=1; j<=m; j++)
    {
        while(i<=n && op[j].b>0 && op[j].c>a[i])
        {
            a[i]=op[j].c;
            op[j].b--;
            i++;
        }
    }
    int sum=0;
    for(int i=1; i<=n; i++)
    {
        sum+=a[i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 5888
if __name__ == '__main__':
    while 1:
        n = int(input())
        if n ==0 :break
        line = list(map(int,input().strip().split()))
        diff = max(line)
        for i in range(n-1):
            for j in range(i+1,n):
                if diff > abs(line[i] - line[j]):diff = abs(line[i]-line[j])
        print(diff)

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

constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;

vector<long> fact, finv, inve;

void init(long n) {
  fact.resize(n), finv.resize(n), inve.resize(n);
  fact.at(0) = fact.at(1) = 1;
  finv.at(0) = finv.at(1) = 1;
  inve.at(1) = 1;
  for (int i = 2; i < n; i++) {
    fact.at(i) = fact.at(i - 1) * i % MOD;
    inve.at(i) = MOD - inve.at(MOD % i) * (MOD / i) % MOD;
    finv.at(i) = finv.at(i - 1) * inve.at(i) % MOD;
  }
}

long com(long n, long r) {
  if (n < r || n < 0 || r < 0) return 0;
  return fact.at(n) * (finv.at(r) * finv.at(n - r) % MOD) % MOD;
}

long mpow(long a, long b) {
  long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}

long com2(long n, long r) {
  if (n < r || n < 0 || r < 0) return 0;
  long x = 1, y = 1;
  for (int i = 1; i <= r; i++) {
    x = x * (n - i + 1) % MOD;
    y = y * i % MOD;
  }
  return x * mpow(y, MOD - 2) % MOD;
}

long inv(long a) {
  long b = MOD, u = 1, v = 0;
  while (b) {
    long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= MOD;
  if (u < 0) u += MOD;
  return u;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int K;
  string S;
  cin >> K >> S;
  int N = S.size();
  K += N;
  init(K);
  long ans = 0;
  for (int i = N; i <= K; i++) {
    long tmp = com(i - 1, N - 1);
    tmp *= mpow(25, i - N);
    tmp %= MOD;
    tmp *= mpow(26, K - i);
    tmp %= MOD;
    ans += tmp;
    ans %= MOD;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 51252
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    long long t , n,count= 0;
    string s;
    cin>>n>>s;
    //n =  s.size();
    for(int i = 0;i<n-2;i++)
    {
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
        {
            count++;
            i= i + 2;
        }
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){ 
   int n;
   cin>>n;  
   string s;
   cin>>s;
   rep(i,s.size()){
      int a=s[i]-'A'+n;
      if(a>=26){
         a-=26;
      }
      cout<<char(a+'A');
   }
   
   
   

   return 0;
}

Measured memory_bytes: 256
// Author : Mohamed Sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;
string x ;
int k,n;
ll dp[101][4][2];
ll solve (int cur = 0 , bool ex = 0 , int d =0 )
{
    if (cur == n )return d == k ;
    if (d > k )return 0;
    ll &ret = dp[cur][d][ex];
    if (~ret)return ret ;
    ret =0 ;
    int mx = x[cur] - '0';
    if (ex)mx = 9;
    for (int i =0 ; i <= mx ;i++)
    {
        ret += solve(cur + 1 , (ex | (i < mx )) , d + (i > 0) );
    }
    return ret ;
}
int main()
{
    memset(dp , -1 ,sizeof dp);
    cin >> x >> k ;
    n = SZ(x)  ;
    cout << solve() ;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
}

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

int main() {
	vector<pair<pair<string, int>, int>> res;
	int n,bpoint;
	string bname;
	pair<string, int> bp;
	pair<pair<string, int>, int> bv;
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		cin >> bname >> bpoint;
		bp = make_pair(bname, -bpoint);
		bv = make_pair(bp, i + 1);
		//cout << "(" << bv.first.first << "," << bv.first.second << "," << bv.second << ")\n";
		res.emplace_back(bv);
	}
	
	sort(res.begin(), res.end());

	for (int i = 0; i < n; i++) {
		cout <<res[i].second << endl;
	}
	return 0;
}


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

typedef long long ll;
const int maxn = 3000+5;
ll a[maxn];
ll dp[maxn][maxn], sum[maxn];

ll dfs(int l,int r) {
    if(dp[l][r] || l == r) return dp[l][r];
    return dp[l][r] = max(a[l] - dfs(l + 1, r), a[r] - dfs(l, r - 1));
}

int main()
{
        int n;
        cin >> n;
        for (int i = 1; i <= n; ++i) {
	  cin >> a[i];
	  dp[i][i] = a[i];
	}
        cout << dfs(1, n) << endl;
    return 0;
}


Measured memory_bytes: 70144
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

const ll INF = 1LL << 40;

int main() {
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> S(A), T(B), X(Q);
    for (int i = 0; i < A; i++) cin >> S[i];
    for (int i = 0; i < B; i++) cin >> T[i];
    for (int i = 0; i < Q; i++) cin >> X[i];
    S.push_back(INF);
    T.push_back(INF);
    sort(S.begin(), S.end());
    sort(T.begin(), T.end());
    for (int i = 0; i < Q; i++) {
        int s_idx = lower_bound(S.begin(), S.end(), X[i]) - S.begin(), t_idx = lower_bound(T.begin(), T.end(), X[i]) - T.begin();
        ll ans = INF;
        if (S[s_idx] == INF) {
            s_idx--;
        }
        if (T[t_idx] == INF) {
            t_idx--;
        }
        for (int j = s_idx; j >= max(0, s_idx - 1); j--) {
            for (int k = t_idx; k >= max(0, t_idx - 1); k--) {
                ans = min(ans, abs(S[j] - X[i]) + abs(S[j] - T[k]));
                ans = min(ans, abs(T[k] - X[i]) + abs(T[k] - S[j]));
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main(){
  ll n,k,q;
  cin >> n >> k >> q;
  vector<ll> vec(n,k-q);
  ll tmp;
  for(int i=0; i<q; i++){
    cin >> tmp;
    vec.at(tmp-1)++;
  }
  for(int i=0; i<n; i++){
    if(vec.at(i)>0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 1408
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<utility>
#include<bitset>
#include<complex>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>

using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=a; i<=b; ++i)
#define FOR(i,a,b) for(int i=a; i<b; ++i)
#define MP make_pair
#define PB push_back
#define fi first
#define se second
typedef long long LL;
typedef pair<int,int> pii;

const int md = 1e9 + 7;

inline int Get(int x) {
    if(x < 10) return 1;
    if(x < 100) return 2;
    if(x < 1000) return 3;
    if(x < 10000) return 4;
    if(x < 100000) return 5;
    if(x < 1000000) return 6;
    if(x < 10000000) return 7;
    return 8;
}

LL PowMod(LL a, LL b) { LL r=1; while(b) { if(b&1) r=r*a%md; a=a*a%md, b>>=1; } return r; }

int main() {
    int S;
    LL ans = 0;
    scanf("%d", &S);
    for(int l = 1, r = 1, sum = 0; l < int(1e7); ++r) {
        sum += Get(r);
        while(sum > S) sum -= Get(l++);
        if(l < int(1e7) && sum == S) ++ans;
    }
    for(int i = S/8; i >= 1; --i) {
        if(S%i == 0) {
            LL tmp = PowMod(10, S/i - 1);
            ans = (ans + tmp*10 - tmp - (i - 1) + md) % md;
        }
        else
            ans = (ans + 1) % md;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
long n,m,ans;
scanf("%ld%ld",&n,&m);
if (n==1&&m==1){
ans=1;
}else if (n==1||m==1){
ans=n*m-2;
}else{
ans=(n-2)*(m-2);
}
printf("%ld\n",ans);
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <stack>
#include <cmath>
using namespace std;

int n, a[500000], cnt = 0;

void func(int l, int r){
  if(l + 1 >= r) return;
  int m = (l + r) / 2;
  func(l, m);
  int t1[m - l + 1], t2[r - m + 1];
  for(int i = l; i < m; i++){
    t1[i - l] = a[i];
  }
  t1[m - l] = 1000000001;
  func(m, r);
  for(int i = m; i < r; i++){
    t2[i - m] = a[i];
  }
  t2[r - m] = 1000000001;
  int t1i = 0, t2i = 0;
  for(int i = l; i < r; i++){
    if(t1[t1i] <= t2[t2i]) a[i] = t1[t1i++];
    else a[i] = t2[t2i++];
    cnt++;
  }
  /*for(int i = l; i < r; i++){
    cout << a[i]
  }*/
  return;
}

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

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



Measured memory_bytes: 8888
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define yawn ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}
const int N = 751;
int sz[N] , p[N];
#define READ(filename)  freopen(filename, "r", stdin);
void initialize(){
    iota(p , p + N , 0); // 0 1 2 3 .. N
    fill(sz , sz + N , 1);
}
double dis(int x1,int y1, int x2, int y2)
{
    return (double)sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
}
int FindParent(int u){
    return p[u] = (p[u] == u ? u : FindParent(p[u]));
}

void Union(int u , int v){
    u = FindParent(u);
    v = FindParent(v);

    if(u == v)return;

    if(sz[v] < sz[u])swap(u , v);

    p[u] = v;
    sz[v] += sz[u];
}
int main()
{
    yawn;
    int a,b; cin>>a>>b;
    cout<< (a<b? 0 : 10);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int low = n / 105;
        int high = n / 100;
        for(int i = low; i <= high; i++){
            int tmp = n;
            tmp -= (i*100);
            if(0 <= tmp && tmp <= 5*i){
                System.out.println(1);
                return;
            }
        }
        System.out.println(0);
    }
}


Measured memory_bytes: 21716
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		double[] relese = new double[N];
		for(int i = 0; i<N; i++) {
			relese[i] = sc.nextDouble();
		}
		Arrays.sort(relese);
			double anser = relese[0];
			for(int i = 1 ; i<N;i++) {
				anser = (anser+relese[i])/2;
			}
			System.out.println(anser);

	}

}


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

int main() {
    ll N,K;
    cin >> N >> K;
    vector<ll> H(N);
    rep(i,N)cin >> H[i];
    sort(H.begin(),H.end(),greater<ll>());
    rep(i,K)if(i<N)H[i]=0;
    ll ans = 0;
    rep(i,N){
        if(H[i]>0){
            ans += H[i];
            H[i] = 0;
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
    int n, k, value = 0;
    cin >> n >> k;
    for (int i=0; i<n; i++) {
        if (i == 0)
            value = k;
        else
            value *= (k - 1);
    }
    cout << value;
    return 0;
}


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

int main() {
	string s;
	int a[26]={};
	for(;cin>>s;)
	for(int i=0;i<s.length();i++)
	{
		if(s[i]>='a'&&s[i]<='z')a[s[i]-'a']++;
		else if(s[i]>='A'&&s[i]<='Z')a[s[i]-'A']++;
	}
	for(int i=0;i<26;i++)
	{
		cout<<(char)('a'+i)<<" : "<<a[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3172
#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<sstream>
using namespace std;
 
#define sf scanf
#define pf printf
#define pfn printf("\n");
#define pfk printf(" ");
#define pf0 printf("0");
#define pf1 printf("1");
#define ll long long
#define sfd(n) scanf("%d",&n);
#define sfdd(n,m) scanf("%d%d",&n,&m);
#define sfld(n) scanf("%lld",&n);
#define sfldd(n,m) scanf("%lld%lld",&n,&m);
#define sflf(n) scanf("%lf",&n);
#define sflff(n,m) scanf("%lf%lf",&n,&m);
#define sfc(n) scanf("%c",n);
#define sfcc(n,m) scanf("%c%c",n,m);
#define sfs(n) scanf("%s",n);
#define sfss(n,m) scanf("%s%s",n,m);
#define pfd(n) printf("%d",n);
#define pfld(n) printf("%lld",n);
#define pflf(n) printf("%lf",n);
#define pfc(n) printf("%c",n);
#define pfs(n) printf("%s",n);
 
#define csh(a,n) memset(a,n,sizeof(a));
int arr[1000000];
int main(){
	int n;
	cin>>n;
	int sum=0;
	int p=0;
	arr[0]=0;
	arr[n+1]=0;
	for(int i=1;i<=n;i++){
		cin>>arr[i];
		sum+=abs(arr[i-1]-arr[i]);
		p=arr[i];
	}
	sum+=abs(arr[n+1]-arr[n]);
	for(int i=1;i<=n;i++){
		cout<<sum-abs(arr[i-1]-arr[i])-abs(arr[i+1]-arr[i])+abs(arr[i+1]-arr[i-1])<<endl;
	}
	
}

Measured memory_bytes: 1664
import math

while True:
    N = int(input())
    if N == 0:
        break
    point = list(map(int,input().split())) 
    sum = 0
    for i in range(N):
        sum += point[i]

    heikin = sum / N
    s = 0
    for i in range(N):
        s += (point[i]-heikin)**2

    a2 = s / N
    a =math.sqrt(a2)

    print(round(a,8))


Measured memory_bytes: 5708
input_line = input().split(' ')
numA = int(input_line[0])
numB = int(input_line[1])

def gcd(a, b):
  if b > a:
    tmp = b
    b = a
    a = tmp
  while True:
    rem = a % b
    if rem == 0:
      break
    else:
      a = b
      b = rem
  return b

gcd = gcd(numA, numB)
divA = numA // gcd
divB = numB // gcd

print(gcd * divA * divB)

Measured memory_bytes: 3064
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if 500 * a + 100 * b + 50 * c == X:
                count += 1
print(count)


Measured memory_bytes: 3060
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

class AtCoder
{
    const int MOD = 1000000007;
    
    public void Slove()
    {
        var inputs = Console.ReadLine().Split();
        int n = int.Parse(inputs[0]);
        int a = int.Parse(inputs[1]);
        int b = int.Parse(inputs[2]);
        Console.WriteLine(Math.Min(n * a, b));
    }
    static void Main()
    {
        var ac = new AtCoder();
        ac.Slove();
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] t = new int[n];
        int[] x = new int[n];
        int[] y = new int[n];
        for (int i = 0; i < n; i++) {
            t[i] = sc.nextInt();
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }
        int tt = 0;
        int xx = 0;
        int yy = 0;
        for (int i = 0; i < n; i++) {
            int tmpT = t[i] - tt;
            int tmpX = Math.abs(x[i] - xx);
            int tmpY = Math.abs(y[i] - yy);
            if(tmpX + tmpY > tmpT) {
                System.out.println("No");
                return;
            }
            if(tmpT % 2 != (tmpX + tmpY) % 2) {
                System.out.println("No");
                return;
            }
            tt = t[i];
            xx = x[i];
            yy = y[i];
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 59664
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=3007;
const ll mod=1000*1000*1000+7;

int n, q;

ll tab[nax];

int ost[nax][nax];
ll dp[nax][nax];

ll wyn;

pii zm[nax];

void dod(ll &a, ll b)
{
	a=(a+b)%mod;
}

int czas;
ll pot[nax];

void rel(int a, int b)
{
	dp[a][b]=(dp[a][b]*pot[czas-ost[a][b]])%mod;
	ost[a][b]=czas;
}

int main()
{
	scanf("%d%d", &n, &q);
	for (int i=1; i<=n; i++)
		scanf("%lld", &tab[i]);
	for (int h=1; h<=q; h++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		if (a>b)
			swap(a, b);
		zm[h]={a, b};
	}
	pot[0]=1;
	for (int i=1; i<=q; i++)
		pot[i]=(pot[i-1]*2)%mod;
	reverse(zm+1, zm+1+q);
	for (int i=1; i<=n; i++)
		for (int j=1; j<i; j++)
			dp[i][j]=1;
	for (int i=1; i<=q; i++)
	{
		int a=zm[i].first;
		int b=zm[i].second;
		for (int j=1; j<=n; j++)
		{
			if (j==a || j==b)
				continue;
			czas=i-1;
			rel(j, a);
			rel(j, b);
			rel(a, j);
			rel(b, j);
			ll x=dp[j][a];
			ll y=dp[j][b];
			dp[j][a]=dp[j][b]=(x+y)%mod;
			x=dp[a][j];
			y=dp[b][j];
			dp[a][j]=dp[b][j]=(x+y)%mod;
			ost[a][j]=ost[b][j]=ost[j][a]=ost[j][b]=i;
		}
		czas=i-1;
		rel(a, b);
		rel(b, a);
		dp[a][b]=dp[b][a]=(dp[a][b]+dp[b][a])%mod;
		ost[a][b]=ost[b][a]=i;
	}
	czas=q;
	for (int i=1; i<=n; i++)
	{
		for (int j=i+1; j<=n; j++)
		{
			rel(i, j);
			rel(j, i);
			//~ debug() << i << " " << j << "   " << dp[i][j] << " " << dp[j][i];
			if (tab[i]<tab[j])
				dod(wyn, dp[i][j]);
			if (tab[i]>tab[j])
				dod(wyn, dp[j][i]);
		}
	}
	
	printf("%lld\n", wyn);
	return 0;
}


Measured memory_bytes: 106240
import java.util.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String str;
      String[] arr;
      int height;
      int width;
      
      while(true){
         str = sc.nextLine();
         arr = str.split(" ");
         height = Integer.parseInt(arr[0]);
         width = Integer.parseInt(arr[1]);
      
         if(height == 0){
            break;
         }
      
         edge(width);
         System.out.println();
         middle(height - 2, width);
         edge(width);
         System.out.println("\n");
      
      }
      
         
   }//main method 
   
   
   public static void edge(int width){
      for(int i = 0; i < width; i++){
         System.out.print("#");
      }
   }
   
   public static void middle(int n,int  width){
      for(int i = 0; i < n; i ++){
         System.out.print("#");
         for(int j = 0; j < width - 2; j++){
            System.out.print(".");
         }
         System.out.print("#\n");
      }
   }
}//class

Measured memory_bytes: 33476
//what is this solution even doing
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int MN = 402;
const int MM = 100100;
bitset<MN> bs[MN];
ii eg[MM];
ii sad[MM];
bool po[MN][MN];
inline bool get(int u, int v) {
	return po[min(u,v)][max(u,v)];
}
void reset(int u, int v) {
	po[min(u,v)][max(u,v)] = false;
}
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n,m;
	cin >> n >> m;
	for(int i=0;i<m;i++) {
		int a,b;
		cin >> a >> b;
		a--;b--;
		eg[i] = {a,b};
	}
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			po[i][j] = true;
		}
	}
	for(int i=0;i<m;i++) {
		int a = eg[i].first;
		int b = eg[i].second;
		int idx = 0;
		for(int j=0;j<n;j++) {
			if(!(get(a,j) && get(b,j) && get(a,b))) {
				sad[idx] = {a,j};idx++;
				sad[idx] = {b,j};idx++;
			}
		}
		reset(a,b);
		for(int j=0;j<idx;j++) {
			ii it = sad[j];
			reset(it.first,it.second);
		}
	}
	int ctr = 0;
	for(int i=0;i<n;i++) {
		for(int j=i+1;j<n;j++) {
			if(get(i,j)) {
				ctr++;
			}
		}
	}
	cout << ctr << '\n';
}


Measured memory_bytes: 4448
h,w = map(int,input().split())
masu = []
for i in range(h):
    tmp = list(str(input()))
    masu.append(tmp)
count = 0
for i in range(len(masu)):
    if '#' not in masu[i - count]:
        del masu[i - count]
        count += 1

count = 0
x = int(len(masu[0]))
for i in range(x):
    tmp = []
    for j in range(len(masu)):
        tmp.append(masu[j][i - count])
    if '#' not in tmp:
        for k in range(len(masu)):
            del masu[k][i - count]
        count += 1

for i in masu:
    print(''.join(i))
     

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int a,ans,maxx=0;
int main(){
	for(int i=1;i<=5;i++){
		cin>>a;int k=(ceil(a*1.0/10))*10;ans+=k;
		if(k-a>maxx)maxx=k-a;
	}
	cout<<ans-maxx;
}

Measured memory_bytes: 256
import re
s = input()
ans = []

def sum_p(res, i):
    if i == 3:
        res += s[i]
        a = sum(list(map(int, re.split('[+, *]', res))))
        if a == 7:
            res = res.replace("*", "")
            ans.append(res+"=7")
    elif i == 0:
        res1 = res+s[i]+"+"
        sum_p(res1, i+1)
        res2 = res+s[i]+"*"+"-"
        sum_p(res2, i+1)
    else:
        sum_p(res+s[i]+"+", i+1)
        sum_p(res+s[i]+"*"+"-", i+1)

sum_p("", 0)
print(ans[0])

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

int main() {
    int n, m; cin >> n >> m;
    int maxL = 1, minR = n;
    while (m--) {
        int l, r; cin >> l >> r;
        maxL = max(maxL, l);
        minR = min(minR, r);
    }
    cout << max(0, minR - maxL + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cassert>

#include <unordered_set>
#include <unordered_map>
#include <random>
#include <thread>
#include <chrono>

using namespace std;

#define val const auto
#define var auto

#define all(c) c.begin(), c.end()
#define repeat(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x) 
#endif

typedef complex<double> point;

template<typename T,std::size_t N>
struct _v_traits {using type = std::vector<typename _v_traits<T,N-1>::type>;};
template<typename T>
struct _v_traits<T,1> {using type = std::vector<T>;};
template<typename T,std::size_t N=1>
using vec = typename _v_traits<T,N>::type;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    for(auto it = v.begin(); it != v.end(); ++it){
        if(it != v.begin()){
            os << ",";
        }
        os << *it;
    }
    return os << "}";
}

template <typename T>
T read_next(){
    T ret; cin >> ret;
    return ret;
}


template<typename T>
void isort(std::vector<T>& v, std::function<bool(T,T)> comp=less<T>()){
    sort(v.begin(), v.end(), comp);
}
template<typename T>
std::vector<T> sort(std::vector<T> v, std::function<bool(T,T)> comp=less<T>()){
    isort(v);
    return v;
}
template<typename T1, typename T2>
std::vector<T2> rmap(const std::vector<T1>& v, std::function<T2(T1)> f){
    std::vector<T2> t; t.reserve(v.size());
    for(const auto& i: v) t.push_back(f(i));
    return t;
}
std::vector<std::string> split(std::string str, char delim){
    std::vector<std::string> res;
    size_t current = 0, found;
    while((found = str.find_first_of(delim, current)) != std::string::npos){
        res.push_back(std::string(str, current, found - current));
        current = found + 1;
    }
    res.push_back(std::string(str, current, str.size() - current));
    return res;
}
string join(const std::vector<string>& v, string delim){
    string ret = "";
    for(auto it = v.begin(); it != v.end(); ++it){
        if(it != v.begin()){
            ret += delim;
        }
        ret += *it;
    }
    return ret;
}


using i64 = int64_t;
using i32 = int32_t;

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

    int a, b;
    cin >> a >> b;

    int ret = a;
    if (a > b)
        ret--;
    cout << ret << endl;
    return 0;
}


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

int main(){

    int n;
    cin >> n;

    string s;
    cin >> s;

    int rr=0,ww=0;

    for(int i=0;i<s.size();i++){
        if(s[i]=='R') rr++;
        else ww++;
    }

    string tar = "";
    for(int i=0;i<rr;i++) tar += 'R';
    for(int i=0;i<ww;i++) tar += 'W';

    int diff = 0;
    for(int i=0;i<n;i++){
        if(s[i] != tar[i]) diff++;
    }

    cout << diff / 2 << endl;

    return 0;
}

Measured memory_bytes: 3824
n =int(input())
a =list(map(int, input().split()))

flg = True

for x in a:
    if x % 2 != 0:
        continue
    if x % 3 != 0 and x % 5 != 0:
        flg = False

if flg:
    print("APPROVED")
else:
    print("DENIED")

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*{

}*/

int main()
{
  string s;
  cin >> s;
  int n = s.size();
  
  vector<pair<char, int>> t;
  rep(i, n){
    if(s[i] != 'x') t.pb(mp(s[i], i));
  }
  int m = t.size();

  if(m == 0){
    cout << 0 << endl;
    return 0;
  }

  bool flag = true;
  rep(i, m/2){
    if(t[i].first != t[m-1-i].first) flag = false; 
  }

  if(!flag){
    cout << -1 << endl;
    return 0;
  }

  map<int, int> left, right;
  int cnt = 0;
  rep(i, t[(m-1)/2].second){
    if(s[i] == 'x'){
      left[cnt]++;
    }else{
      cnt++;
    }
  }

  cnt = 0;
  for(int i = n-1; i >= t[m/2].second; i--){
    if(s[i] == 'x'){
      right[cnt]++;
    }else{
      cnt++;
    }
  }

  int ans = 0;
  rep(i, m/2+1){
    if(left.count(i) == 0) left[i] = 0;
    if(right.count(i) == 0) right[i] = 0;
    ans += abs(left[i] - right[i]);
//    cout << i << " : " << left[i] << " : " << right[i] << endl;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5876
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
struct Dinic{
  const int INF=1<<28;
  struct edge {
    int to,cap,rev;
    edge(){}
    edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
  };

  int n;
  vector<vector<edge> > G;
  vector<map<int,int> > M;
  vector<int> level,iter;

  Dinic(){}
  Dinic(int sz):n(sz),G(n),M(n),level(n),iter(n){}
  
  void add_edge(int from,int to,int cap){
    M[from][to]=G[from].size();
    M[to][from]=G[to].size();
    G[from].push_back(edge(to,cap,G[to].size()));
    G[to].push_back(edge(from,0,G[from].size()-1));
  }
  
  void bfs(int s){
    fill(level.begin(),level.end(),-1);
    queue<int> que;
    level[s]=0;
    que.push(s);
    while(!que.empty()){
      int v=que.front();que.pop();
      for(int i=0;i<(int)G[v].size();i++){
        edge &e = G[v][i];
        if(e.cap>0&&level[e.to]<0){
          level[e.to]=level[v]+1;
          que.push(e.to);
        }
      }
    }
  }
  int dfs(int v,int t,int f){
    if(v==t) return f;
    for(int &i=iter[v];i<(int)G[v].size();i++){
      edge &e=G[v][i];
      if(e.cap>0&&level[v]<level[e.to]){
        int d = dfs(e.to,t,min(f,e.cap));
       if(d>0){
         e.cap-=d;
         G[e.to][e.rev].cap+=d;
         return d;
       }
      }
    }
    return 0;
  }
  int flow(int s,int t,int lim){
    int fl=0;
    for(;;){
      bfs(s);
      if(level[t]<0||lim==0) return fl;
      fill(iter.begin(),iter.end(),0);
      int f;
      while((f=dfs(s,t,lim))>0){
       fl+=f;
       lim-=f;
      }
    }
  }
};

int N,A,B,ans,a,b;
vector<P>C1,C2;

bool check(int a,int b){
  int X=abs(a-b);
  return X<=A||(B<=X&&X<=2*A);
}

int main(){

  cin>>N>>A>>B;

  for(int i=0;i<N;i++){
    cin>>a>>b;
    if(check(a,b))ans++;
    else{
      if(a==b)continue;
      if(a>b)C1.push_back(P(a,b));
      else C2.push_back(P(a,b));
    }
  }

  int c1=C1.size(),c2=C2.size();

  Dinic D(c1+c2+2);

  for(int i=0;i<C1.size();i++){
    for(int j=0;j<C2.size();j++){
      int a=C1[i].first+C2[j].first;
      int b=C1[i].second+C2[j].second;
      if(check(a,b)){
        D.add_edge(i,C1.size()+j,1);
      }
    }
  }

  for(int i=0;i<C1.size();i++)D.add_edge(c1+c2,i,1);
  for(int i=0;i<C2.size();i++)D.add_edge(c1+i,c1+c2+1,1);

  cout<<ans+D.flow(c1+c2,c1+c2+1,1e8)<<endl;
}


Measured memory_bytes: 7744
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

int main() {
	string s;
	cin >> s;
	rep(i, s.size()) {
		cout << "x";
	}
	cout << endl;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int cnt = 0;
        sc.close();
        for(int i=1;i<=n;i++){
            if(digit(i)%2==1){
                cnt++;
            }
        }
        System.out.println(cnt);
    }

    static int digit(int x){
        int res = 0;
        while(x > 0){
            x/=10;
            res++;
        }
        return res;

    }

}

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

int main(){
  long long int N,A,B,C,D,E;
  cin >> N >> A >> B >> C >> D >> E;

  long long MinMove = min({A,B,C,D,E});

  long long ans = (N + MinMove - 1)/MinMove + 4;

  cout << ans << endl;
}


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

    string s;
    map<string,string>m;
    m["Sunny"]="Cloudy";
    m["Cloudy"]="Rainy";
    m["Rainy"]="Sunny";
    cin>>s;
    cout<<m[s]<<endl;
    return 0;
}


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

int main(){

	int dp[50001];
	int n,m;
	cin >> n >> m;
	int c[m+1];
	for(int i=1;i<=m;i++) cin >> c[i];
	dp[0] = 0;
	for (int i = 1; i <=n ; ++i) 
	{
		dp[i] = -1;
	}
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= m; j++){
			if(i-c[j] < 0) continue;
			if(dp[i-c[j]] != -1){
				if(dp[i] == -1)	dp[i] = dp[i-c[j]] + 1;
				else	dp[i] = min(dp[i],dp[i-c[j]]+1);
			}
		}
	}
	cout << dp[n] << endl;
	return 0;
}

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

int main()
{
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N,vector<int>(D));

    for(int i = 0; i < N; i++)
        for(int j = 0; j < D; j++)
            cin >> X[i][j];

    int cnt = 0;
    for(int i = 0; i < N; i++)
    {
        for(int j = i+1; j < N; j++)
        {
            int tmp = 0;
            for(int k = 0; k < D; k++)
                tmp += pow(X[i][k]-X[j][k],2);
            for(int k = 1; k*k <= tmp; k++)
                if(k*k == tmp) cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

//字符转换为数字 
int getChar(char ch)
{
	if(ch == 'A') return 1;
	else if(ch == 'C') return 2;
	else if(ch == 'G') return 3;
	else if(ch == 'T') return 4;
	else return 0;
}

//字符串转换为数字并生成key
long long getKey(char str[])
{
	long long sum = 0, p = 1, i;
	for(i=0; i<strlen(str); i++)
	{
		sum += p*(getChar(str[i]));
		p *= 5;
	}
	
	return sum;
} 

int h1(int key)
{
	return key % M;
}

int h2(int key)
{
	return 1 + (key % (M-1));
}

int find(char str[])
{
	long long key, i, h;
	key = getKey(str);//字符串转换为数值‘
	for(i=0; ; i++)
	{
		h = (h1(key) + i*h2(key)) % M;
		if (strcmp(H[h],str) == 0)return 1;
		else if (strlen(H[h] )== 0)return 0;
	} 
	
	return 0;
}

int insert(char str[])
{
	long long key, i, h;
	key = getKey(str);
	for(i=0; ; i++)
	{
		h = (h1(key) + i*h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0)
		{
			strcpy(H[h], str);
			return 0;	
		} 
	}
	return 0; 
}

int main()
{
	int i, n, h;
	char str[L], com[9];
	for(i=0; i<M; i++) H[i][0] = '\0';
	scanf("%d",&n);
	for (i=0; i<n; i++)
	{
		scanf("%s %s",com,str);
		
		if (com[0] == 'i')
		{
			insert(str);
		}
		else 
		{
			if (find(str))
			{
				printf("yes\n");
			}
			else
			{
				printf("no\n");
			}
			
		}
	}
	return 0;
}


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

int main()
{
    int h,w,x,y;
    string str;
    cin>>h>>w;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            cin>>str;
            if(str=="snuke"){
                x=i;
                y=j;
            }
        }
    }
    printf("%c%d\n",y+'A',x+1);
    return 0;
}


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

using namespace std;

int N, M;

int L[100005], R[100005];

int main(void) {

	int left = 0, right = 100005;

	cin >> N >> M;

	for (int i = 1; i <= M; i++) {
		cin >> L[i] >> R[i];
	}

	for (int i = 1; i <= M; i++) {
		left = max(left, L[i]);
		right = min(right, R[i]);
	}

	
	cout << max(0,right - left + 1) << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main()
{
  string s,t;
  cin>>s>>t;
  bool b=true;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i])b=false;
  }
  if(b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3628
n = int(input())

if n < 10:
    print(n)
    exit()

memo = dict()
 
def func(s,f):
    ans = 0
    for i in range(1,n+1):
        if str(i)[0] == f and str(i)[-1] == s:
            ans += 1
    memo[s+" "+f] = ans
 
res = 0

for i in range(1,n+1):
    s = str(i)[0]
    f = str(i)[-1]

    if s + " " + f in memo:
        res += memo[s + " " + f]
    else:
        func(s,f)
        res += memo[s + " " + f]

print(res)

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

#define after (5 * pow(10, 12))
int main()
{
	string s;
	long long k;
	int flag = 1;
	char ans;
	cin >> s;
	cin >> k;

	for (int i = 0; flag; i++){
		if (s[i] == '1' && i + 1 == k){
			flag = 0;
			ans = '1';
		}
		else if (s[i] != '1'){
			flag = 0;
			ans = s[i];
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

int main() {
	ll N;
	cin >> N;
	vll A(N + 1);
	repn(i, N) cin >> A[i];
	sort(++A.begin(), A.end(), greater<ll>());
	ll ans = 0;
	
	repn(i, N-1) {
		ll x = i / 2 + 1;
		ans += A[x];
	}
	cout << ans << endl;

}

Measured memory_bytes: 4836
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M): 
    b.append(b[i] + B[i])
ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47472
#include<iostream>
#include<cstdio>

#include<vector>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
const int INF = 1e9+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;}

//正解確率(1/2)^M の無限級数
//A = 1900*M+100+(N-M)
//A*(1/2)^M + 2A*(1/2)^2M + 3A*(1/2)^3M

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());
    ll res = 0;
    for (int i = 0; i < N; i++) {
        res += (lower_bound(A.begin(),A.end(),B[i]) - A.begin()) *
               (C.end() - upper_bound(C.begin(),C.end(),B[i]));
    }
    cout << res << endl;






}

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

#define ll long long int

using namespace std;

int main() {
    ll a, b, v, w, t;
    cin >> a >> v >> b >> w >> t;
    if (w > v) {
        cout << "NO" << endl;
        return 0;
    }
    ll c = abs(a-b);
    ll d = abs(v-w);
    if (d == 0) {
        cout << "NO" << endl;
        return 0;
    }

    if (c <=     t * d) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


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

using namespace std;

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

    vector<string> W(N);

    for(int i=0;i<W.size();i++)
        cin >> W[i];
    
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            if(W[i] == W[j]){
                cout << "No" << endl;
                exit(0);
            }
        }
        if(W[i].back() != W[i+1].front()){
            cout << "No" << endl;
            exit(0);
        }
    }

    cout << "Yes" << endl;

    
}

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

typedef long long ll;
const int inf = 1000000000; // 10^9

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll h,w;
  cin>>h>>w;

  // The bishop can not move digonally when the board is a line. 
  if(h == 1 || w == 1) {
    cout << 1 << '\n';    
    return 0;
  }
  
  // The bishop starts on a valid square (i.e. a specific colored square). 
  // Every other square is then also valid.
  // No. of valid squares is half the squares when h*w is even.
  // No. of valid squares is rounded up (i.e. h*w+1) when h*w is odd.
  cout <<  (h*w+1)/2 << '\n';

  return 0;
}


Measured memory_bytes: 3652
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(d)]

import math
ans = float('inf')
for i in range(1 << d):
    point = 0
    solved = 0

    for j in range(d):
        if (i >> j) & 1:
            point += pc[j][1] + pc[j][0] * 100 * (j + 1)
            solved += pc[j][0]

    if point >= g:
        f = True
    else:
        f = False
        for j in reversed(range(d)):
            if not ((i >> j) & 1):
                if point + (j + 1) * 100 * (pc[j][0] - 1) >= g:
                    _solved = math.ceil((g - point) / ((j + 1) * 100))
                    solved += _solved
                    point += _solved * 100 * (j + 1)
                    f = True
                    break
                else:
                    _solved = pc[j][0] - 1
                    solved += _solved
                    point += _solved * 100 * (j + 1)

    if f:
        ans = min(ans, solved)

print(ans)


Measured memory_bytes: 41456
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

bool check357(ll x){
    bool c3 = false, c5 = false, c7 = false;
    while(x != 0){
        if(x%10 == 3) c3 = true;
        else if(x%10 == 5) c5 = true;
        else if(x%10 == 7) c7 = true;
        x /= 10;
    }
    return c3 & c5 & c7;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n; cin >> n;
    vi semi357;
    queue<ll> que; que.push(0);

    while(!que.empty()){
        ll f = que.front(); que.pop();
        if(f > 1000000000 || f > n) break;
        semi357.push_back(f);
        que.push(f*10+3);
        que.push(f*10+5);
        que.push(f*10+7);
    }
    ll ans = 0;
    for(auto p: semi357) if(check357(p)) ans++;
    cout << ans << endl;
}

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

int main(){
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  cout << x2+(y1-y2) << ' ' << y2+(x2-x1) << ' ' << x1+(y1-y2) << ' ' <<  y1+(x2-x1);
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n;
  cin >> n;
  int a[200001] = {};
  rep(i, 0, n) cin >> a[i];
  int k = 0;
  rep(i, 0, n) {
    if(a[i] < a[i + 1] - 1) {
      cout << -1 << endl;
      return 0;
    }
  }
  if(a[0] > 0) {
    cout << -1 << endl;
    return 0;
  }
  int ans = 0;
  rep(i, 0, n) {
    if(a[i] + 1 == a[i + 1]) ans++;
    else ans += a[i + 1];
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
abcde = []
for i in range(5):
    abcde.append(int(input()))
ans = sum([-(-abcde[i] // 10)*10 for i in range(5)])
amari = [abcde[i]%10 for i in range(5) if abcde[i]%10 != 0]
if len(amari) == 0:
    ans = sum([-(-abcde[i] // 10)*10 for i in range(5)])
else:
    ans = sum([-(-abcde[i] // 10)*10 for i in range(5)])-10+min(amari)
    
print(ans)

Measured memory_bytes: 3064
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 5;

vector <int> g[N];
int sz[N], parent[N] = {0};

void dfs(int cur, int par);

int main()
{
	int n;
	cin >> n;
	for (int i = 1; i < n; ++i)
	{
		int u, v;
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}

	dfs(1, -1);
	vector <int> path;
	int cur = parent[n];
	while (cur != 1)
	{
		path.pb(cur);
		cur = parent[cur];
	}

	int m = path.size();
	int y = sz[n] - 1, x = n - 1;
	if (!m)
		x -= sz[n];
	else
		x -= sz[path[m - 1]];

	int move = 0;
	for (int i = m - 1, j = 0; i >= j; --i, ++j)
	{
		x += sz[path[i]] - 1;
		if (!i)
			x -= sz[n];
		else
			x -= sz[path[i - 1]];

		if (i == j)
		{
			move = 1;
			break;
		}

		y += sz[path[j]] - 1;
		if (!j)
			y -= sz[n];
		else
			y -= sz[path[j - 1]];
	}

	while (true)
	{
		if (!move)
		{
			if (!x)
				break;

			--x;
			move = 1;
		}

		else
		{
			if (!y)
				break;
			
			--y;
			move = 0;
		}
	}

	if (!move)
		cout << "Snuke" << endl;
	else
		cout << "Fennec" << endl;
}

void dfs(int cur, int par)
{
	parent[cur] = par;
	sz[cur] = 1;
	for (auto &i : g[cur])
	{
		if (!parent[i])
		{
			dfs(i, cur);
			sz[cur] += sz[i];
		}
	}
}

Measured memory_bytes: 11772
fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val xs = readLine()!!.split(" ").map { it.toInt() }
  val ys = mutableListOf<Int>()
  var currentColor = -1
  var currentCount = 0
  for (i in 0 until n) {
    if (xs[i] != currentColor) {
      if (currentCount > 0) {
        ys.add(currentCount)
      }
      currentColor = xs[i]
      currentCount = 1
    } else {
      currentCount++
    }
  }
  if (currentCount > 0) {
    ys.add(currentCount)
  }
  println(ys.map { it / 2 }.sum())
}

Measured memory_bytes: 37780