akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define int long long
#define pii pair<int, int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define jai_shree_ram  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, a, b, d) for (int i = a; i <= b; i += d)
#define brep(i, a, b, d) for (int i = a; i >= b; i -= d)
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl '\n'
int MOD = 998244353;
////////////////////////////////

int dp[3005][3005];

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

int32_t main(){
    jai_shree_ram
    int n, s;
    cin >> n >> s;
    int a[n+1];
    rep(i,1,n,1) cin >> a[i];

    dp[0][0] = binpow(2, n, MOD);

    map <int, int> inv;
    inv[1] = 1;
    int m = MOD;
    inv[2] = (m - (m/2) * inv[m%2] % m) % m;

    rep(i,1,n,1){
        rep(sum,0,s,1){
            dp[i][sum] += dp[i-1][sum];
            dp[i][sum] %= MOD;
            if(sum >= a[i]){

                dp[i][sum] += ((dp[i-1][sum-a[i]]%MOD  * inv[2]%MOD)%MOD);
                
                dp[i][sum] %= MOD;
            }
        }
    }

    cout << dp[n][s]%MOD << endl;
    return 0;    
}

Measured memory_bytes: 74044
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll T1, T2, A1, A2, B1, B2;

int main() {

	cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;

	if (T1 * A1 + T2 * A2 == T1 * B1 + T2 * B2) {
		cout << "infinity" << endl;
		return 0;
	}

	if (T1 * A1 > T1* B1) {
		swap(A1, B1);
		swap(A2, B2);
	}

	if (T1 * A1 + T2 * A2 < T1 * B1 + T2 * B2) {
		cout << 0 << endl;
		return 0;
	}

	if ((T1 * B1 - T1 * A1) % ((T1 * A1 + T2 * A2) - (T1 * B1 + T2 * B2)))
		cout << (T1 * B1 - T1 * A1) / ((T1 * A1 + T2 * A2) - (T1 * B1 + T2 * B2)) * 2 + 1 << endl;
	else
		cout << (T1 * B1 - T1 * A1) / ((T1 * A1 + T2 * A2) - (T1 * B1 + T2 * B2)) * 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x;
  cin>>x;
  vector<long long> beki;
  for(int i=1;i<=1000;i++){
    long long ans = 1;
    ans*=i*i;
    for(int j=1;j<=10;j++){
      if(ans<=x){
        beki.push_back(ans);
        ans*=i;
      }
      else{
        break;
      }
    }
  }
  sort(beki.begin(),beki.end());
  reverse(beki.begin(),beki.end());
  cout<<beki.at(0)<<endl;
  return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

struct Edge {
  const int id, from, to;
  Edge(int id, int from, int to) : id(id), from(from), to(to) {}
};

vector<vector<Edge>> ReadUndirectedGraph(
    int n, int m, bool is_one_indexed=false) {
  vector<vector<Edge>> graph(n);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    if (is_one_indexed) {
      v1--;
      v2--;
    }
    graph[v1].push_back(Edge(i, v1, v2));
    graph[v2].push_back(Edge(i, v2, v1));
  }
  return graph;
}

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

  int n;
  cin >> n;
  auto graph = ReadUndirectedGraph(n , n - 1, true);
  
  vector<int> colors(n - 1, -1);

  function<void(int, int, int)> dfs_fn = [&](int v, int p, int p_color) {
    int c = 1;
    for (const auto& e : graph[v]) {
      if (e.to == p) continue;
      if (c == p_color) c++;
      colors[e.id] = c;
      dfs_fn(e.to, v, c);
      c++;
    }
  };
  dfs_fn(0, -1, -1);

  int max_color = 0;
  for (int c : colors) max_color = max(c, max_color);
  cout << max_color << "\n";
  for (int i = 0; i < n - 1; i++) {
    cout << colors[i] << "\n";
  }
}

Measured memory_bytes: 9216
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>
#include <string.h>
#include <cctype>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

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

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll 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 { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

long long plusL[100000];
long long plusR[100000];
long long minusL[100000];
long long minusR[100000];
long long a[100000];

int main()
{
	int n;
	cin >> n;
	vector<int> d;
	for (int i = 0; i < n; i++)
	{
		int tmp;
		cin >> tmp;
		d.push_back(tmp);
	}
	sort(d.begin(), d.end());
	int min = d[n / 2 - 1] + 1;
	int max = d[n / 2];
	cout << (max - min + 1);
}



Measured memory_bytes: 32124
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
import bisect




def main():
    num = int(input())
    data = [int(input()) for i in range(num)]

    now_list = [-1 for i in range(num)]

    for i in range(num):
        ind = bisect.bisect_left(now_list, data[i])
        now_list[ind - 1] = data[i]

    count = 0
    for i in range(num):
        if now_list[i] >= 0 :
            count += 1

    print(count)




if __name__ == '__main__':
    main()

Measured memory_bytes: 49948
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string S;cin >> S;
  int N = S.length();
  int minimum = N;
  repp(i,1,N) if(S[i-1]!=S[i]) minimum = min(minimum, max(i,N-i));
  cout << minimum << endl;
  return 0;
}


Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
#define int ll

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a,b,n; cin >> a >> b >> n;
    auto f = [&](ll x){
        return (a * x / b) - a * (x / b);
    };

    // rep(i,100)cout << f(i) << " ";
    ll ans = 0;
    if(b <= n)ans = f(b-1);
    else ans = f(n);

    cout << ans << endl;
}

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

string si(int a) {
  string s;
  char temp[10] = {};
  int i = 0;
  
  while ( a != 0 ) {
    temp[i] = a%10 + '0';
    i++;
    a /= 10;
  }
  
  for( i = i - 1; i >= 0 ; i--) {
    s += temp[i];
  }

  return s;
}

int main()
{
  string s;
  int ans = 0;
  int a, b;
  int i, j, k;
  int f;

  cin >> a >> b;

  for ( i = a; i <= b; i++) {
    s = si(i);

    j = 0;
    k = s.size() - 1;
    f = 1;
    
    while(f == 1 && j < k) {
      if (s[j] != s[k]) {
        f = 0;
      }

      j++;
      k--;
    }

    ans += f;
  }

  cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int a = sc.nextInt();
	static int b = sc.nextInt();
	static int c = sc.nextInt();
	static int d = sc.nextInt();
	static int e = sc.nextInt();
	public static void main(String[] args) {
		microwave();
	}

	private static void microwave() {
		int t = 0;

			if (a < 0) {
				t += c * Math.abs(a) + d + e * b;
			} else {
				t += e * Math.abs(a - b);
			}
		System.out.println(t);
	}

}



Measured memory_bytes: 26292
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

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

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

    ll x; cin>>x;

    for(ll i=-1000; i<=1000; i++){
        for(ll j=-1000; j<=1000; j++){
            ll A5 = i * i * i * i * i;
            ll B5 = j * j * j * j * j;

            if(A5 - B5 == x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<ll, int> mp;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int sum = a + b + c + d;
	int s = sum % 60;
	sum /= 60;
	int m = sum % 60;
	sum /= 60;
	cout << m << endl;
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3176
#include <iostream>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
#pragma warning(disable: 4996)

int main()
{
	int N;
	int ret;

	ret = scanf("%d", &N);

	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		ret = scanf("%d", &v[i]);
	}

	int sum = accumulate(v.begin(),v.end(),0);
    double average = (double)sum/N;
    int average_int = round(average);

	int result = 0;
	for (int i = 0; i < N; i++) {
		result += pow((v[i] - average_int), 2);
	}

	printf("%d\n", result);
	return 0;
//	std::cout << "Hello World!\n"; 
}

Measured memory_bytes: 256
//
//  main.cpp
//  ervb
//
//  Created by Kanak Gautam on 21/04/20.
//  Copyright © 2020 Kanak Gautam. All rights reserved.
//
 
 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#define pb push_back
#define mk make_pair
#define endl "\n"
#define mod 1000000007
using namespace std;
typedef long long int lli;
typedef long double ld;
/*priority_queue <lli, vector<lli>, greater<lli> > ti;
vector <lli> p[500005],g,b(500005,0),a(500005,0),ans(500005,0);
lli f[5005];
map <pair<lli,lli>,lli> mp;
set<pair<lli, lli> > s;
set<lli> st;
map<lli,lli> np,v;
queue<lli> qy;
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
lli bpow(lli a, lli b) {
    lli res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res%mod;
}
lli fact(lli i)
{
    f[0]=1;
    for(lli k=1;k<=i;k++)
    {
        (f[k]=f[k-1]*k)%=mod;
    }
    return f[i];
}
lli isprime(lli n)
{
    if(n==1)
        return 0;
    for(lli i=2;i<=sqrt(n);i++)
        if(n%i==0)
            return 0;
    return 1;
}
bool cmp(lli i,lli j)
{
    return p[i].size()<p[j].size();
}
void sieve()
{
    for(lli i=2;i<=5000000;i++)
    {
        if(b[i]==0)
        {
        for(lli j=2;i*j<=5000000;j++)
        {
            b[i*j]=1;
        }
        }
    }
}*/
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    lli r,c,k;
    cin>>r>>c>>k;
    vector<vector<lli>> a(3005,vector<lli>(3005,0));
    vector<vector<vector<lli>>> dp(3005,vector<vector<lli>>(3005,vector<lli>(3,0)));
    lli x,y,z;
    for(lli i=1;i<=k;i++)
    {
        cin>>x>>y>>z;
        a[x][y]=z;
    }
    lli g,h;
    for(lli i=1;i<=r;i++)
    {
        for(lli j=1;j<=c;j++)
        {
            for(lli k=0;k<3;k++)
            {
                if(k==0)
                {
                    dp[i][j][k]=max(dp[i-1][j][0],max(dp[i-1][j][1],dp[i-1][j][2]))+a[i][j];
                    dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k]);
                }
                else
                {
                    dp[i][j][k]=dp[i][j-1][k-1]+a[i][j];
                    dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k]);
                }
            }
        }
    }
    cout<<max(dp[r][c][0],max(dp[r][c][1],dp[r][c][2]))<<endl;
}



Measured memory_bytes: 567904
#include<iostream>
#include<algorithm>
using namespace std;
int N,A,B,C,D;
int f(int x,int y)
{
	return(x<A?A-x:x>C?x-C:0)+(y<B?B-y:y>D?y-D:0);
}
main()
{
	while(cin>>N,N)
	{
		int px,py,ans=0;
		cin>>A>>B>>C>>D>>px>>py;
		for(int i=0;i<N;i++)
		{
			int x,y;cin>>x>>y;
			ans+=min(abs(px-x)+abs(py-y),max(f(px,py)-1,0)+f(x,y));
			px=x;
			py=y;
		}
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 3048
def main():
    N = int(input())
    S = input()
    dict = {'R':0, 'B':0, 'G':0}
    for i in range(N):
        dict[S[i]] += 1
    ans = dict['R']*dict['B']*dict['G']
    for i in range(N-2):
        if (N-i)%2 == 0:
            tmp = int((N-i)/2)-1
        else:
            tmp = (N-i)//2
        for j in range(1,tmp+1):
            if S[i]!=S[i+j] and S[i]!=S[i+2*j] and S[i+j]!=S[i+2*j]:
                ans = ans - 1

    return ans

print(main())  


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    const ll INF = (1ll<<60);

    ll N, K;
    cin >> N >> K;
    vector<ll> h(N);
    REP(i, N) cin >> h[i];

    vector<ll> dp(N, INF);
    dp[0] = 0;
    REP(i, N){
        REP(j, K){
            if(i+j+1<N) dp[i+j+1] = min(dp[i] + abs(h[i+j+1]-h[i]), dp[i+j+1]);
        }
    }
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================








int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================





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

	for (int i = 0; i < 10009; i++) {
		if (int((double)i * 0.08) == A && int((double)i * 0.1) == B) {
			cout << i;
			return 0;
		}
	}

	cout << -1;











}


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

int main(){
  int ans=0;
  string s;
  cin >> s;
  for(int k=s.size()-2;0<=k;k=k-2){
    int c = 0;
    for(int i=0;i<k/2;i++){
      if(s[i]==s[i+k/2])
        continue;
      else{
        c = 1;
        break;
      }
    }
    if(c==0){
      ans = k;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n;
    double sum = 0;
    scanf("%d", &n);
    double data[n];
    for(int i = 0; i < n; i++){
        scanf("%lf", &data[i]);
        sum += 1 / data[i];
    }
    printf("%lf\n", 1 / sum);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vl p(n);
    ll sum = 0;
    rep(i, n) {
        cin >> p[i];
        if(i < k) {
            sum += p[i];
        }
    }

    ll maxsum = sum;
    // p[R]を加えてp[L]を捨てる
    rep(L, n-k) {
        ll R = L + k;
        sum += p[R] - p[L];
        chmax(maxsum, sum);
    }

    double ans = (double)(maxsum + k)/2.0;
    exout(ans);
    re0;
}

Measured memory_bytes: 1792
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())

for l in range(len(N)):
    t1, t2 = [float(i) for i in N[l].split()]
    if t1 < 35.5 and t2 < 71.0:
        print("AAA")
    elif t1 < 37.5 and t2 < 77.0:
        print("AA")
    elif t1 < 40.0 and t2 < 83.0:
        print("A")
    elif t1 < 43.0 and t2 < 89.0:
        print("B")
    elif t1 < 50.0 and t2 < 105.0:
        print("C")
    elif t1 < 55.0 and t2 < 116.0:
        print("D")
    elif t1 < 70.0 and t2 < 148.0:
        print("E")
    else:
        print("NA")



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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long res = 0;
  for (int i = 1; i < n + 1; i++) {
    res += (i % 3 && i % 5) ? i : 0;
  }
  cout << res << '\n';
  return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll dp[3005][3005];//dp[i][j]: a[i]まで条件を満たすうち, a[i]より大きい未使用のvalがj個

int main() {
    //cout.precision(10);
    ll n;
    string s;
    cin >> n >> s;
    s = "##" + s;
    for(int i = 0; i < n; i++){
        dp[1][i] = 1;
    }
    for(int index = 2; index <= n; index++){
        for(int before = 0; before < n; before++){
            if(s[index] == '>'){
                dp[index][before] = (dp[index][before] + dp[index - 1][before]) % mod;
                dp[index][n - index + 1] = (dp[index][n - index + 1] - dp[index - 1][before] + mod)% mod;
                /*
                for(int after = before; after <= n - index; after++){
                    dp[index][after] = (dp[index][after] + dp[index - 1][before]) % mod;
                }
                continue;
                */
            } else {
                dp[index][0] = (dp[index][0] + dp[index - 1][before]) % mod;
                dp[index][before] = (dp[index][before] - dp[index - 1][before] + mod) % mod;
                /*
                for(int after = 0; after < before; after++){
                    dp[index][after] = (dp[index][after] + dp[index - 1][before]) % mod;
                }
                */
            }
        }
        for(int i = 0; i <= n; i++){
            dp[index][i + 1] = (dp[index][i + 1] + dp[index][i]) % mod;
        }
    }
    cout << dp[n][0] << endl;
    return 0;
}


Measured memory_bytes: 70656
import           Control.Monad
import           Data.List

main :: IO ()
main = do
  n <- readLn
  jList <- replicateM n getLine
  let
    app :: [String] -> [(String, Int)]
    app jl = map (\x -> (x, count x jl)) ["AC", "WA", "TLE", "RE"]
      where
        count :: String -> [String] -> Int
        count _ [] = 0
        count str (x:xs) = if str == x then 1 + (count str xs) else count str xs
    afterApp = app jList
  mapM_ (\x -> putStrLn $ (fst x) ++ " x " ++ (show $ snd x)) afterApp


Measured memory_bytes: 36396
import sys
sys.setrecursionlimit(10**6)
INF = 1001001001

N = int(input())
g = [[] for _ in range(N)]
for i in range(N-1):
    a, b, c = map(int, input().split())
    g[a-1].append([b-1, c])
    g[b-1].append([a-1, c])
Q, K = map(int, input().split())
dist = [INF] * N
dist[K-1] = 0

def dfs(n, d):
    if dist[n] == INF:
        dist[n] = d
    for i, c in g[n]:
        if dist[i] == INF:
            dfs(i, dist[n]+c)
    return

dfs(K-1, 0)
# print(dist)

for i in range(Q):
    x, y = map(int, input().split())
    print(dist[x-1]+dist[y-1])


Measured memory_bytes: 137936
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 100000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll x,a,b ;
	cin >> x >> a >> b ;
	cout << (x-a)%b << endl ;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a + b == c || a + c == b || b + c == a)
			System.out.println("Yes");
		else
			System.out.println("No");
		sc.close();
	}
}

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

int main() {
//vector <int> a(3);
int n;
cin >> n ;
vector <int> a(n);
int mins=1e9;
for (size_t i = 0; i < n; i++)
{
  cin>> a.at(i);

    int twos=0;
    while (a.at(i)%2==0)
    {
        twos++;
        a.at(i)/=2;

    }
    mins=min(mins,twos);
    
  
}
cout << mins << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using llu=unsigned long long;
#define mod 1000000007
#define mode 998244353
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mms(x,y) memset(x,y,sizeof(x))
#define pqm priority_queue<ll,vector<ll>,greater<ll>>
#define pb push_back
#define um unordered_map
#define pr pair
#define mm multimap
#define ms multiset
#define mp make_pair
#define vr vector
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define inf INT_MAX
#define ninf INT_MIN
#define ff first
#define ss second
#define gcd __gcd
int main()
{
    fast;
    ll t,n,m,i,j,k;
    string s,p;
    cin>>s>>p;
    n=s.length();
    m=p.length();
    ll dp[n+1][m+1];
    mms(dp,0);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(s[i-1]==p[j-1])
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    string ans;
    i=n;j=m;
    while(i>0 && j>0)
    {
        if(s[i-1]==p[j-1])
        {
            ans=s[i-1]+ans;
            i--;
            j--;
        }
        else
        {
            if(dp[i-1][j]==dp[i][j])i--;
            else j--;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 70656
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

class Main {
	public static void main(String args[]) throws IOException {
		@SuppressWarnings("resource")
		Scanner cin = new Scanner(System.in);
		ArrayList<String> inLines = new ArrayList<String>();
		for (; cin.hasNext();) {
			inLines.add(cin.nextLine());
		}
		String[] strArr = inLines.get(0).split(" ");
		int N = Integer.parseInt(strArr[0]);
		int M = Integer.parseInt(strArr[1]);
		ArrayList<String> A = new ArrayList<String>();
		for (int i = 0; i < N; i++)
			A.add(inLines.get(i + 1));
		ArrayList<String> B = new ArrayList<String>();
		for (int i = 0; i < M; i++)
			B.add(inLines.get(N + i + 1));

		// System.out.println("N=" + N + " M=" + M);
		// System.out.println();
		// for (String s : A)
		// System.out.println(s);
		// System.out.println();
		// for (String s : B)
		// System.out.println(s);

		boolean found = false;
		for (int Ay = 0; !found && Ay <= N - M; Ay++) {
			for (int Ax = 0; !found && Ax <= N - M; Ax++) {
				found = true;
				for (int By = 0; found && By < M; By++) {
					for (int Bx = 0; Bx < M; Bx++) {
						char ca = A.get(Ay + By).charAt(Ax + Bx);
						char cb = B.get(By).charAt(Bx);
						if (ca != cb) {
							found = false;
							break;
						}
					}
				}
			}
		}

		if (found)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 9936
#include "bits/stdc++.h"

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<int> num(n, 1);
    vector<bool> red(n, false);
    red[0] = true;
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        if (red[x]) {
            red[y] = true;
        }
        num[x]--;
        num[y]++;
        if (!num[x]) {
            red[x] = false;
        }
    }
    int res = 0;
    for (int i = 0; i < n; ++i) {
        if (red[i]) res++;
    }
    cout << res << "\n";
    return 0;
}


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

int main() {
	bool cards[4][14];
	int n, rank;
	char suit;

	for (int s = 0; s < 4; s++) {
		for (int r = 0; r <= 13; r++) {
			cards[s][r] = 0;
		}
	}
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> suit >> rank;
		if (suit == 'S') cards[0][rank] = 1;
		if (suit == 'H') cards[1][rank] = 1;
		if (suit == 'C') cards[2][rank] = 1;
		if (suit == 'D') cards[3][rank] = 1;
	}

	for (int i = 0; i < 4; i++) {
		for (int j = 1; j < 14; j++) {
			if (cards[i][j] == 0) {
				if (i == 0) suit = 'S';
				if (i == 1) suit = 'H';
				if (i == 2) suit = 'C';
				if (i == 3) suit = 'D';
				cout << suit << ' ' << j << endl;
			}
		}
	}

	return 0;
}




Measured memory_bytes: 3024
#include<bits/stdc++.h>
#define INF 1<<30
#define MAX 100005
#define ll long long
#define speed ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
using namespace std;
int main()
{
    speed;
    ll N,W,maxv=0,ans=0;
    cin>>N>>W;
    ll wt[N],val[N];
    for(ll i=0;i<N;i++) {cin>>wt[i]>>val[i]; maxv+=val[i];}
    ll K[N+1][maxv+1];
    K[0][0]=0;
    for(ll i=1;i<=maxv;i++)
        K[0][i]=1e18;
    for(ll i=0;i<N;i++)
    for(ll j=0;j<=maxv;j++){
        if(j>=val[i])
            K[i+1][j]=min(K[i][j],K[i][j-val[i]]+wt[i]);
        else
            K[i+1][j]=K[i][j];
        if(K[i+1][j]<=W)
            ans=max(ans,j);
    }
    cout<<ans;
}


Measured memory_bytes: 79232
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int N;
string s;

int expr(int l, int r);

int term(int l, int r) {
  if(l + 1 == r) {
    return s[l] - '0';
  }
  if(l >= r) { return 0; }

  int ret = 1;
  REP(i, l, r+1) {
    if(i == r || s[i] == '*') {
      ret *= expr(l, i);
      l = i + 1;
    }
  }
  return ret;
}

int expr(int l, int r) {
  if(l + 1 == r) {
    return s[l] - '0';
  }
  if(l >= r) { return 0; }

  int ret = 0;
  REP(i, l, r+1) {
    if(i == r || s[i] == '+') {
      ret += term(l, i);
      l = i + 1;
    }
  }
  return ret;
}

int expr2() {
  int ret = s[0] - '0';
  int f = 0;
  REP(i, 1, N) {
    if(s[i] == '+') {
      f = 1;
    }
    else if(s[i] == '*') {
      f = 2;
    }
    else {
      if(f == 1) {
        ret += s[i] - '0';
      }
      else if(f == 2) {
        ret *= s[i] - '0';
      }
      else {
        assert(0);
      }
    }
  }
  return ret;
}

int main() {

  cin >> s;
  N = s.size();

  auto m = expr(0, N);
  auto l = expr2();

  int n; cin >> n;
  if(n == m && n == l) { cout << "U" << endl; }
  else if(n == m) { cout << "M" << endl; }
  else if(n == l) { cout << "L" << endl; }
  else { cout << "I" << endl; }
  
  return 0;
}

Measured memory_bytes: 3220
n = int(input())
A = [int(x) for x in input().split()]
a1 = A[1]
if n > 2:
    for an in A[2:]:
        a1 = a1 ^ an
a_all = A[0] ^ a1
ans = str(a1)
for an in A[1:]:
    ans += ' ' + str(a_all ^ an)
print(ans)


Measured memory_bytes: 31600
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
int findSubarraySum(int arr[], int n, int K) { 
    unordered_map<int, int> prevSum; 
    int res = 0; 
    int currsum = 0; 
  
    for (int i = 0; i < n; i++) { 
        currsum += arr[i]; 
        if (currsum == K) { 
            res++; 
        } 
        if (prevSum.find(currsum - K) 
            != prevSum.end()) 
            res += (prevSum[currsum - K]); 
        prevSum[currsum]++; 
    }  
    return res; 
} 
int32_t main(){
    SPEED;
    int x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    if(x == 0){
        if(k % 2 == 0) cout << 0 << endl;
        else{
            cout << d << endl;
        }
        return 0;
    }
    if(k == 0 || d == 0){
        cout << x << endl;
        return 0;
    }
    int rem = x % d;
    int div = x / d;
    if(div > k){
        cout << abs(x - (k * d)) << endl;
    }
    else{
        if((k - div) % 2 == 0) cout << rem << endl;
        else{
            cout << abs(min(rem + d, rem - d));
        }
    }
}

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

int main(){
	ll n, dp[100005], a[100005];
	cin >> n;
	for( int i = 0 ; i < n ; i++ )
		cin >> a[i];
	dp[n-2] = llabs( a[n-2] - a[n-1]);
	dp[n-1] = 0;
	for( int i = n - 3 ; i > -1 ; i-- )
		dp[i] = min( dp[i+1] + llabs(a[i] - a[i+1]), dp[i+2] + llabs( a[i] - a[i+2]));
	cout << dp[0] << endl;
	return(0);
}

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

int main(){
	int n,x;
	cin >> n >> x;
	vector<int> l(n);
	rep(i, n) cin >> l.at(i);
	
	vector<int> d(n+1);
	d.at(0) = 0;
	for(int i = 1; i <= n; i++){
		d.at(i) = d.at(i-1) + l.at(i-1);
	}

	int ans = 0;
	rep(i, n+1) if(d.at(i) <= x) ans++;

	cout << ans << endl;
}

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

int main() {
	long long x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	if(x>0&&(x/d)>=k)
	{
	   x=x-(k)*d;
	   cout<<x;
	}
    else
    {
      long long y=x/d;
        x-=y*d;
        k-=y;
    if(k%2==0)
    cout<<abs(x);
    else
    cout<<min(abs(x-d),abs(x+d));
    }
	return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;
ll INF=300000;

int main(){
    ll N;
    cin>>N;
    ll NN=pow(N, 0.5);
    vector<bool> Low(1010, false);
    for(ll i=1; i<=NN; i++){
        ll T=i;
        T*=i;
        while(T<=N){
            Low[T]=true;
            T*=i;
            if(i==1){
                T=N+1;
            }
        }
    }
    for(int i=N; i>=1; i--){
        if(Low[i]){
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
import numpy as np

H, W, K = map(int, input().split())

C = []

for h in range(H):
    C.append(list(input()))
    for w in range(W):
        if C[h][w] == "#":
            C[h][w] = 1
        else:
            C[h][w] = 0
arr = np.array(C)

cC = 0

for i in range(2 ** (H+W)):
    t = arr.copy()
    #print("T")
    #print(t)
    red = []
    for j in range(H+W):
        if j < H:
            if ((i >> j) & 1):
                t[j] = 2
        else:
            if ((i >> j) & 1):
                t[:, (j-H)] = 2
    if t[t == 1].sum() == K:
        cC += 1

print(cC)

Measured memory_bytes: 27180
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    int n, m;
    cin >> n >> m;
    vector<pll> ab;
    rep(i,n) {
        ll ai, bi;
        cin >> ai >> bi;
        ab.emplace_back(ai, bi);
    }
    ssort(ab);
    ll ans = 0, rem = m;
    rep(i,n) {
        ll buy = min(rem, ab[i].second);
        ans += buy * ab[i].first;
        rem -= buy;
        if (rem <= 0) break;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 5296
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=100010;
int v[maxn],cnt[2][maxn];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",v+i);
		cnt[i&1][v[i]]++;
	}
	int ans=n,max_cnt=0,sec_cnt=0,max_v;
	for(int i=1;i<=100000;i++)
		if(cnt[0][i]>max_cnt) max_cnt=cnt[0][i],max_v=i;
		else if(cnt[0][i]>sec_cnt) sec_cnt=cnt[0][i];
	for(int i=1;i<=100000;i++)
		if(i==max_v) ans=min(ans,n-sec_cnt-cnt[1][i]);
		else ans=min(ans,n-max_cnt-cnt[1][i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  map<long long, long long> count_plus, count_minus;
  rep(i, N)
  {
    cin >> A[i];
    count_plus[A[i] + (i + 1)]++;
    count_minus[A[i] - (i + 1)]++;
  }
  long long ans = 0;
  for(pair<long long, long long> P : count_plus)
  {
    ans += P.second * count_minus[-P.first];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 38292
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cassert>
#include <iostream>
using std::cin; using std::cout; using std::endl;
#include <algorithm>
using std::sort; using std::min; using std::max;
#include <vector>
using std::vector;
#include <set>
using std::set;
#include <queue>
using std::queue; using std::priority_queue;
#include <utility>
using std::pair;
typedef pair<int, int> pii;
typedef long long LL;
typedef long double LD;
#define pass printf("%s : Line.%d\n", __FUNCTION__, __LINE__);

const int maxN = 200000 + 233;
int n, a[maxN], b[maxN];

int check(int M) {
//	cin >> n;
//	for(int i = 1; i <= n; ++i) cin >> b[i];
//	++n; n /= 2;
	for(int i = 1; i <= 2*n - 1; ++i) b[i] = (a[i] >= M ? 1 : 0);
	b[0] = b[1]; b[2*n] = b[2*n+1] = b[2*n - 1];
//	for(int i = 1; i <= 2*n - 1; ++i) printf("%d ", b[i]); printf("\n");
	for(int i = 1; i <= 2*n - 1; ++i) {
//		printf("i = %d\n", i);
		if(!(b[i] != b[i - 1] && b[i] != b[i + 1])) continue;
		int j = i + 1;
		for(; ; ++j) {
			if(b[j] == b[j + 1]) break;
		}
		--j;
//		printf("found : [%d, %d]\n", i, j);
		for(int k = i; k <= (i + j) / 2; ++k) b[k] = b[i - 1];
		for(int k = (i + j + 1) / 2; k <= j; ++k) b[k] = b[j + 1];
		i = j;
	}
//	for(int i = 1; i <= 2*n - 1; ++i) printf("%d ", b[i]); printf("\n");
	return b[n];
}

int main() {
//	check(233);
	scanf("%d", &n);
	for(int i = 1; i <= 2*n - 1; ++i) scanf("%d", &a[i]);
	int L = 1, R = n*2 - 1;
	while(L < R) {
		int M = (L + R + 1) >> 1;
		if(check(M)) L = M;
		else R = M - 1;
	}
	printf("%d\n", L);
	return 0;
}

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

int main(){
	int h,w,k;
	cin >> h >> w >> k;
	vector<string> s(h);
	for(int i=0;i<h;i++){
		cin >> s.at(i);
	}
	int ans = 0;
	for(int is=0;is < 1<<h;is++){
		for(int ij=0;ij < 1<<w;ij++){
			int cnt = 0;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					if(is>>i&1) continue;
					if(ij>>j&1) continue;
					if(s[i][j] == '#') cnt++;
				}
			}
			if(cnt == k) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3196
#include<stdio.h>

int main(void){
	int s;
	int h,m;
	scanf("%d",&s);
	h = s/60/60;
	m = (s%3600)/60;
	s = s%3600%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}


Measured memory_bytes: 2132
#include<stdio.h>

int main(){
  long int n;
  scanf("%ld",&n);
  long int i=0; 
  if(100000<=n){
    i=90909;
  }else if(10000<=n){
    i=(n-10000+1)+909;
  }else if(1000<=n){
    i=909;
  }else if(100<=n){
    i=(n-100+1)+9;
  }else if(10<=n){
    i=9;
  }else{
    i=n;
  }
  printf("%ld",i);
  return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;


    if (a<0 && b<0) {
        if ((b-a+1)%2) cout << "Negative\n";
        else cout << "Positive\n";
    }
    else if (a<=0 && 0<=b) {
        cout << "Zero\n";
    }
    else if (a>0 && b>0) {
        cout << "Positive\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long int step[200002];
    int h[200002];
    int n,k;
    cin >> n;
    cin >> k;
    for(int i=0;i<n;i++){
        cin >> h[i];
        step[i]=0;
    }
    step[n]=0;
    for(int i=1;i<=n;i++){
        step[i]=step[i-1]+abs(h[i-1]-h[i]);
        //cout << abs(h[i-1]-h[i]) << endl;
        if(i<k){
            for(int j=2;j<=i;j++){
                step[i]=min(step[i],step[i-j]+abs(h[i-j]-h[i]));
            }
        }else{
            for(int j=2;j<=k;j++){
                step[i]=min(step[i],step[i-j]+abs(h[i-j]-h[i]));
            }
        }
    }
    //for(int i=1;i<n+1;i++){
    //    cout << step[i] << " ";
    //}
    //cout << endl;
    cout << step[n-1] << endl;
    return 0;
}


Measured memory_bytes: 2560
import sys
readlines = sys.stdin.readlines
write = sys.stdout.write

L = 9
comb = [[0]*(L+1) for i in range(L+1)]
for i in range(L+1):
    comb[i][0] = comb[i][i] = 1
    for j in range(1, i):
        comb[i][j] = comb[i-1][j-1] + comb[i-1][j]
Y = comb[i]

def solve():
    for line in readlines():
        *X, = map(int, line.strip())
        write("%d\n" % (sum(x * y for x, y in zip(X, Y)) % 10))
solve()


Measured memory_bytes: 5612
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
using namespace std;

void solve() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A < C && C < B)cout << "Yes" << endl;
	else if (A > C &&C > B)cout << "Yes" << endl;
	else cout << "No" << endl;
	return;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int x,a,b;
cin >> x >> a >> b;
int ans = x-a;
ans %= b;
cout << ans << endl;
}


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

int main()
{
    int ans = 0;
    char s[100005];
    scanf("%s", s);
    for (int i = 0; i < (strlen(s) - 1); i++)
    {
        if(s[i] != s[i+1]) ans++;
    }
    printf("%d", ans);
}

Measured memory_bytes: 384