akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll n; cin >> n;
  vector<Pll> a(n);
  rep(i, n) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(all(a));
  reverse(all(a));

  VVll dp(n+1, Vll(n+1));

  rep(i, n+1) rep(j, n+1) {
    if (i+j > n) continue;
    if (i+j == 0) continue;
    ll x, y;
    tie(x, y) = a[i+j-1];
    if (i) chmax(dp[i][j], dp[i-1][j] + x * abs(y-(i-1)));
    if (j) chmax(dp[i][j], dp[i][j-1] + x * abs(y-(n-j)));
  }

  ll ans = 0;
  rep(i, n+1) chmax(ans, dp[i][n-i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 34616
#include <bits/stdc++.h>
#include <vector>
#include <cstdlib>
using namespace std;
int main(void){
  int x, A, B;
  cin >> x >> A >> B;
  if(abs(x - A) < abs(x - B)){
    cout << "A";
  } else {
    cout << "B";
  }
}

Measured memory_bytes: 256
a, b = map(int, input().split())
ans = 0

for i in range(a//10000, b//10000+1):
    for j in range(0,10):
        for k in range(0,10):
            x = i*10001 + j*1010 + k*100
            if a<=x<=b:
                ans+=1
print(ans, flush=True)



Measured memory_bytes: 9164
#include <cstdio>

using namespace std;

double x1,y1,x2,y2,x3,y3,x4,y4;
    

int main()
{
    int n; scanf( "%d\n", &n );
    while( n > 0 )
    {
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf\n", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4 );
        double dx1 = x2 - x1, dx2 = x4 - x3, dy1 = y2 - y1, dy2 = y4 - y3, det = dx1 * dy2 - dx2 * dy1;
        if( det < 0 )
        {
            det *= -1;
        }

        if( det < 0.0000000001 )
        {
            printf( "YES\n" );
        }
        else
        {
            printf( "NO\n" );
        }

        /* if( (dx1 == 0 && dx2 == 0) || (dy1 == 0 && dy2 == 0 ) )
        {
            printf( "YES\n" );
        }
        else if( dx1 != 0 && dx2 != 0 )
        {
            dy1 /= dx1;
            dy2 /= dx2;
            if( dy1 == dy2 || dy1 == -dy2 )
            {
                printf( "YES\n" );
            }
        }
        else
        {
            printf( "NO\n" );
        }
         */
        n--;
    }
    return 0;
}


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

int main() {
    int a ,b, c;
    cin >> a >> b >> c;
    
    if (a < b){
        if (b < c){
            cout << a << " " << b << " " << c << endl;
        }
        else {
            if (a < c){
                cout << a << " " << c << " " << b << endl;
            }
            else{
                cout << c << " " << a << " " << b << endl;
            }
        }
    }
    else {
        if (a < c){
            cout << b << " " << a << " " << c << endl;
        }
        else {
            if (b < c){
                cout << b << " " << c << " " << a << endl;
            }
            else{
                cout << c << " " << b << " " << a << endl;
            }
        }
    }
}


Measured memory_bytes: 3100
arr = list(map(int, input().split()))

length = len(arr)

for i in range(length):
	for j in range(1, length):
		if i < j and arr[i] > arr[j]:
			temp = arr[i]
			arr[i] = arr[j]
			arr[j] = temp

arrStr = ''
for i in range(length):
	arrStr += str(arr[i])
	if i != length - 1:
		arrStr += ' '

print(arrStr)


Measured memory_bytes: 5596
n = int(input())
a_l = list(map(int, input().split()))
b_l = list(map(int, input().split()))

ans = 0
c = 0
for i in range(1, n+1):
    a = a_l[-i]
    if b_l[-i] + c >= a:
        ans += a
        d = c-a
        if d >=0:
            d=0
        c = b_l[-i] - abs(d)
    else:
        ans += b_l[-i] + c
        c = 0

if a_l[0] >= c:
    ans+= c
else:
    ans+= a_l[0]
print(ans) 

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

using namespace std;

int N;
int a[100];

void solve() {
  int swap_cnt = 0;
  for (int i = 0; i < N; i++) {
    for (int j = N-1; j > i; j--) {
      if(a[j] < a[j-1]) {
        swap(a[j], a[j-1]);
        swap_cnt++;
      }
    }
  }

  for (int i = 0; i < N; i++) {
    cout << a[i] << (i == N-1 ? "\n" : " ");
  }
  cout << swap_cnt << endl;
}

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  solve();
}



Measured memory_bytes: 3076
#include <iostream>

using namespace std;

int main(void) {
	int A,B,C,X;
	cin >> A >> B >> C >> X;
	int count = 0;
	for (int i = 0; i < A+1; ++i) {
		for (int j = 0; j < B+1; ++j) {
			for (int k = 0; k < C+1; ++k) {
				if (((500*i)+(100*j)+(50*k)) == X) {
					++count;
				}
			}
		}
	}
	cout << count << endl;
	return 0;
}



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

int main() {
  ull n,a,b;
  cin>>n>>a>>b;
  ull x=n/(a+b);
  ull w=x*(a+b);
  ull y=0;
  if(n-w>=a) {
    x++;
  }else {
    y=n-w;
  }
  cout<<x*a+y;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int N,K;
    cin >> N >> K;
    int ans = 0;
    for ( int i = 0; i < N; i++ ) {
        int a;
        cin >> a;
        
        ans += min( a*2, (K-a)*2 );
    }
    
    cout << ans << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1100000000;
constexpr long long LLINF = 1100000000000000000LL;
constexpr long long MOD = 1000000007;

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


// A^2 - 2AK + K^2 = B^2 - 2BK + K^2
// 2(B - A)K = B^2 - A^2 = (B + A)(B - A)
// 2K = B + A
int main()
{
  int A, B;
  cin >> A >> B;
  if ((A + B) % 2 == 0) cout << (A + B) / 2 << endl;
  else cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    long long a,b,c,d,e;

    cin >> a >> b >> c >> d >> e;

    if(a==0)
        cout << 1 << endl;
    if(b==0)
        cout << 2 << endl;
    if(c==0)
        cout << 3 << endl;
    if(d==0)
        cout << 4 << endl;
    if(e==0)
        cout << 5 << endl;

    return 0;
}


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

using namespace std;

int main() {
	int N, M, X; 
	cin >> N >> M >> X;
	vector<int>C(N);
	vector<vector<int>>A(N, vector<int>(M));
	for (int n1 = 0;  n1 < N;++n1) {
		cin >> C[n1];
		for (int n2 = 0; n2 < M ; ++n2 ) {
			cin >> A[n1][n2];
		}
	}
	int all = 1 << N;//2^N
	int nRet = -1; 
	for (int n3 = 0 ; n3 < all;++n3) {
		vector<int>D(M);//理解度
		int nCost = 0;
		for (int n4 = 0; n4 < N; ++n4) {
			if (0 != (n3 & (1 << n4))) {
				for (int n5 = 0 ; n5 < M; ++n5) {
					D[n5] += A[n4][n5];
				}
				nCost += C[n4];
			}
		}
		bool b = true;
		for (int n6 = 0 ; n6 < M; ++n6) {
			if (X > D[n6]) {
				b = false;
			}
		}
		if (b) {
			if (nRet == -1) {
				nRet = nCost;
			}
			else {
				if (nRet > nCost) {
					nRet = nCost;
				}
			}
		}
	}
	cout << nRet << endl;

	return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		long cnt = 0;
		
		
		for(int i = 1; i <= n; i++) {
			if(i % 3 == 0 && i % 5 == 0) {
			}else if(i % 3 == 0) {
			}else if(i % 5 == 0) {
			}else {
				cnt += i;
			}
		}
		
		System.out.println(cnt);
		
		
	}

}


Measured memory_bytes: 35824
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  ll x,y; cin>>x>>y;
  if (abs(x-y) < 2) cout << "Brown" << endl;
  else cout << "Alice" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int s,x;
	while(cin>>s>>x)
	{
		int ans=0;
		int n=1;
		while(n<x)
		{
			n=n-1+s;
			ans++;
		}
		cout<<ans<<endl;
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
   
const ll Mod = 1e9 + 7;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    int n ; cin >> n;
    int A[3][n+1];
    for(int i = 1 ;i <= n ; i++)
        cin >> A[0][i] >> A[1][i] >> A[2][i];
    
    int dp[n+1][3];
    memset(dp , 0 , sizeof(dp));

    for(int i = 1 ;i <= n; i++){
        for(int j = 0 ;j < 3; j++){
            for(int k = 0 ; k < 3 ; k++){
                if(j == k)
                    continue;
                dp[i][j] = max(dp[i][j] , dp[i-1][k] + A[j][i]);
              
            }
        }
    }
    int ans = max(dp[n][0] , max(dp[n][1] , dp[n][2]));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

const int MAX_N = 200000;

int N, Q, a, b, p, x;

vector<int> G[MAX_N];
int cnt[MAX_N];
bool visited[MAX_N];

void dfs(int);

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

    // make G
    REP(i, N-1) {
        cin >> a >> b;
        a--; b--;
        G[a].PB(b);
        G[b].PB(a);
    }

    // make cnt
    REP(i, Q) {
        cin >> p >> x;
        p--;
        cnt[p] += x;
    }

    // init visited
    REP(i, N) visited[i] = false;

    // DFS
    dfs(0);

    // output
    printf("%d", cnt[0]);
    REP2(i, 1, N) printf(" %d", cnt[i]);
    printf("\n");

    return 0;
}

void dfs(int pos) {
    visited[pos] = true;
    REP(i, G[pos].size()) {
        int to = G[pos][i];
        if (visited[to]) continue;
        cnt[to] += cnt[pos];
        dfs(to);
    }
    return;
}

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

int main(){
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++){
    if (i % 2 == 1){
      int count = 0;
      for (int j = 1 ; j <= i ; j++){
        
        if (i % j == 0){
          count++;
        }
      }
      if (count == 8){
        ans++;
      }
    }
    
  }
  cout << ans << endl;
}
          
  
  

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
S = readline().rstrip().decode('utf-8')

def solve_partial(S):
    INF = 10**18
    """
    ・Sは1から始まり、1で終わる
    ・Sは00を含まない
    ・したがって、Sは1,01に分解可能
    ・残る最小個数を調べるdp。これは、1, 101111,111101 の3種を数えることと同じ
    ・a, b0cccc, dddd0e として、「現在の1がどれであるか -> 最小個数」でdp
    ・個数はa,b,eのときに数える
    """
    S = S.replace('01','2')
    a,b,c,d,e = 1,1,INF,0,INF
    for x in S[1:]:
        if x == '1':
            a2 = min(a,c,e)+1
            c2 = c
            d2 = min(a,c,d,e)
            e2 = INF
        else:
            a2 = min(a,c,e)+1
            c2 = a
            d2 = min(a,c,e)
            e2 = d+1
        a,c,d,e = a2,c2,d2,e2
    return len(S)-min(a,c,e)

answer = 0
for x in S.split('00'):
    x = x.strip('0')
    if x:
        answer += solve_partial(x)

print(answer)

Measured memory_bytes: 8360
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>
#include <cassert>

using ll = long long;
using ull = unsigned long long;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

constexpr ll NOT_SPECIFIED_VALUE_MIN = INT64_MIN;
constexpr ll NOT_SPECIFIED_VALUE_MAX = INT64_MAX;

template <typename T>
T extGCD(T a, T b, T &x, T &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	T d = extGCD(b, a%b, y, x); // 再帰的に解く
	y -= a / b * x;
	return d;
}

// 負の数にも対応した mod 
template <typename T>
T modG(T a, T m) {
	return (a % m + m) % m;
}

// 逆元計算 
template <typename T>
T modinv(T a, T m) {
	T x, y;
	extGCD(a, m, x, y);
	return modG(x, m);
}


int main()
{
	ll sum = 0;
	ll n;
	cin >> n;
	vector<ll> v( n );
	for( ll i = 0; i < n; i++ )
	{
		cin >> v[i];
		sum += v[i];
		sum %= mop;
	}

	ll ans = 0;
	for(ll i=0;i<n;i++){
		ans += ( v[i] * modG( sum - v[i], mop ) ) % mop;
		ans %= mop;
	}
	
	cout << (ans * modinv(2LL, mop)) % mop << endl;


}


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

typedef long long ll;
const int maxn=2e5+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int dp[maxn][35];
int a[maxn],b[maxn],A[maxn],B[maxn];

int32_t main()
{
    IOS
    int n,t;
    cin>>n>>t;

    vector<int> v;
    for (int i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i];
        v.pb(i);
    }
    sort(all(v),[&](int x,int y)
         {
             return a[x]*(b[y]+1)>a[y]*(b[x]+1);
         });
    for (int i=1;i<=n;i++) A[i]=a[v[i-1]],B[i]=b[v[i-1]];

    vector<int> ttmp;
    for (int i=n;i>0;i--)
    {
        if (A[i]==0)
        {
            ttmp.pb(B[i]);
            n--;
        }
    }
    sort(all(ttmp));

    for (int j=1;j<=32;j++) dp[0][j]=inff;

    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=32;j++)
        {
            dp[i][j]=dp[i-1][j];
            if (dp[i-1][j-1]!=inff) dp[i][j]=min(dp[i][j],dp[i-1][j-1]+1+(dp[i-1][j-1]+1)*A[i]+B[i]);
            if (dp[i][j]>t) dp[i][j]=inff;
        }
    }

    int ans=0;
    for (int j=0;j<=32;j++)
    {
        int tmp=j,now=dp[n][j];
        if (dp[n][j]!=inff)
        {
            for (int i:ttmp) if (now+i+1<=t) now+=(i+1),tmp++;
            ans=max(ans,tmp);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 62832
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M; cin >> N >> M;
	vector<int> A(N); rep(i, 0, N) { cin >> A[i]; }
	int ans = 0;
	int i = 0;
	while (true) {
		int mini = INF, maxi = 0;
		rep(j, 0, M) {
			chmin(mini, A[i]);
			chmax(maxi, A[i]);

			i++;
			i %= N;
		}
		ans += maxi - mini;
		dump(ans);
		if (i == 0)break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3116
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    s = lines[0]

    return (s, )


def solve(s):

    week = dict()
    week["SUN"] = 7
    week["MON"] = 6
    week["TUE"] = 5
    week["WED"] = 4
    week["THU"] = 3
    week["FRI"] = 2
    week["SAT"] = 1

    return  week[s]

def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3064
#include "bits/stdc++.h"
 
using namespace std;
 
 
const int MAX_N = 100 + 5;
const int MAX_W = 1e9 + 5;
const int MAX_V = 1e5 + 5 ;
 
bool v[MAX_N][MAX_V];
int dp[MAX_N][MAX_V];
int N, W;
vector<pair<int, int>> ks;
 
int solve(int n, int va){
	if (va <= 0)
		return 0;
 
	if (n == N)
		return MAX_W;
 
	if (v[n][va]) return dp[n][va];
	
	dp[n][va] = min(solve(n+1, va - ks[n].second) + ks[n].first, solve(n+1, va));
 
	v[n][va] = 1;
	return dp[n][va];
	
}
 
int max_weight(){
 
	for (int i = MAX_V;i >= 0;i--){
		if( solve(0, i) <= W)
			return i;
	}
	return 0;
}
 
int main(){
	cin >> N >> W;
 
	for(int i = 0;i < N;i++){
		int x;
		int y;
		cin >> x;
		cin >> y;
		ks.push_back({x, y});
	}
 
	cout << max_weight() << endl;
	return 0;
}

Measured memory_bytes: 52188
function compare(a,b)
  if a[1] == b[1]
    if a[2] > b[2]
      return true
    else
      return false
    end
  end
  if a[1] < b[1]
    return true
  else
    return false
  end
end

function main()
  n = parse(Int, readline())
  sp = []
  for i in 1:n
    s,p = split(readline(), " ")
    #sp[i] = [s, parse(Int, p), i]
    push!(sp, [s, parse(Int, p), i])
  end
  sort!(sp, lt=compare)
  for v in sp
    println(v[3])
  end
end

main()

Measured memory_bytes: 170780
#include <iostream>

using namespace std;

int main()
{
    int n,ac=0,tle=0,wa=0,re=0;
    string s;
    cin>>n;
    while(n--){
        cin>>s;
        if(s=="AC")ac++;
        if(s=="TLE")tle++;
        if(s=="WA")wa++;
        if(s=="RE")re++;


    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;

    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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 (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    
    int N; cin >> N;
  cout << (N - 2) * 180 << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>  //stdio
#include <vector>    //vector
#include <algorithm> //sort
#include <numeric>   //accumulate
#include <queue>     //priority_queue
using namespace std;

int main(void)
{

    int n, m;
    long long int sum = 0, tmp;
    priority_queue<long long int,vector<long long int> >que;

    cin >> n >> m;

    for (int i = 0; i < n; i++)
    {
        cin >> tmp;
        que.push(tmp);
    }
    ///*
    while (m != 0)
    {
        //cout << que.top() << endl;
        tmp = (que.top() / 2);
        que.pop();
        m--;
        que.push(tmp);
    }
    //*/
    while (!que.empty())
    {
        sum += que.top();
        //cout << que.top()<<endl;
        que.pop();
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

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

bool pairCompare(const P& p1, const P& p2)
{
    if(p1.second == p2.second) return p1.first < p2.first;
    return p1.second < p2.second;
}

void step(vector<P>& d, vector< vector<int> >& edges, int node)
{
    queue<int> Q;
    Q.push(node);
    while(!Q.empty())
    {
        node = Q.front();
        Q.pop();
        for(int v : edges[node])
        {
            if(d[v].second < d[node].second + 1){
                d[v].second = d[node].second + 1;
                Q.push(v);
            }
        }
    }
}

void topological_sort(vector<P>& d, vector< vector<int> >& edges)
{
    int n = d.size();
    for(int i=0;i<n;++i)
    {
        if(d[i].second == 0) step(d, edges, i);
    }
    sort(d.begin(), d.end(), pairCompare);
}

int main()
{
    int N, M, s, t;
    cin >> N >> M;
    vector< vector<int> > edges(N);
    vector<P> d(N);
    for(int i=0;i<M;++i)
    {
        cin >> s >> t;
        edges[s].push_back(t);
    }
    for(int i=0;i<N;++i)
    {
        d[i] = make_pair(i, 0);
    }
    topological_sort(d, edges);
    for(int i=0;i<N;++i)
    {
        cout << d[i].first << endl;
    }
}



Measured memory_bytes: 3684
/// kazuki08
/*
#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;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int x,y,a,b,c;

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> x >> y >> a >> b >> c;
  vpi v;
  for(int i=1;i<=a;i++){
    int p;
    cin >> p;
    v.pb({p,1});
  }
  for(int i=1;i<=b;i++){
    int p;
    cin >> p;
    v.pb({p,2});
  }
  for(int i=1;i<=c;i++){
    int p;
    cin >> p;
    v.pb({p,3});
  }
  sort(all(v));
  int tot = x+y,ans=0;
  for(int i=(int)v.size()-1;i>=0;i--){
    int cur = v[i].sc;
    if(cur==1){
      if(!x)continue;
      x--;
    }
    if(cur==2){
      if(!y)continue;
      y--;
    }
    tot--;
    ans+=v[i].fs;
    if(!tot)break;
  }
  cout << ans << endl;


return 0;
}
///....


Measured memory_bytes: 10604
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	string s;
	cin >> s;
	int l = s.length();
	if((l % 2 == 0) ^ (s[0] == s[l - 1])){
		cout << "Second" << endl;
	} else {
		cout << "First" << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int, int> P;
 
signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
    
  int N, M;
  cin >> N >> M;
  cout << N * (N-1) / 2 + M * (M-1) / 2 << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
int a[3][3];
void check(int c)
{
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
			if (c == a[i][j])
			{
				a[i][j] = 0;

			}
	}
}
void solve()
{
	
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
			cin >> a[i][j];
	}
	int n,b;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> b;
		check(b);
	}
	for (int i = 0; i < 3; i++)
	{
		if (a[i][1] == 0 && a[i][2] == 0 && a[i][0] == 0)
		{
			cout << "Yes" << endl;
			return;
		}
	}
	for (int i = 0; i < 3; i++)
	{
		if (a[1][i] == 0 && a[2][i] == 0 && a[0][i] == 0)
		{
			cout << "Yes" << endl;
			return;
		}
	}
	if (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0)
	{
		cout << "Yes" << endl;
		return;
	}
	if (a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0)
	{
		cout << "Yes" << endl;
		return;
	}
	cout << "No" << endl;
	return;
}
int main()
{

	solve();
		
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    ll m = 100;
    ll year = 0;
    while(true)
    {
        if(m >= x) break;
        m *= 1.01;
        year++;
    }

    cout << year << endl;
}

Measured memory_bytes: 3648
import java.util.Scanner;
 public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
       
      String a ="SUN";
      String b ="MON";
      String c ="TUE";
      String d ="WED";
      String e ="THU";
      String f ="FRI";
      String g ="SAT";
      
      if(S.equals(a)){
      System.out.println("7");
      }
      else if(S.equals(b)){
      System.out.println("6");
      }
      else if(S.equals(c)){
      System.out.println("5");
      }
      else if(S.equals(d)){
      System.out.println("4");
      }
      else if(S.equals(e)){
      System.out.println("3");
      }
      else if(S.equals(f)){
      System.out.println("2");
      }
      else if(S.equals(g)){
      System.out.println("1");
      }
    }
 }

Measured memory_bytes: 21844
def main():
    N = int(input())
    s_dict = dict()

    for i in range(1, N + 1):
        S, P = input().split()
        if S in s_dict:
            s_dict[S].append((i, int(P)))
        else:
            s_dict[S] = [(i, int(P))]

    s_dict_keys = sorted(list(s_dict.keys()))

    for key in s_dict_keys:
        s_dict[key].sort(key=lambda x: x[1], reverse=True)
        for i, _ in s_dict[key]:
            print(i)


if __name__ == "__main__":
    main()


Measured memory_bytes: 62772
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
ans = []
for i in range(n):
  mean = t - h[i]*0.006
  if a >= 0 and mean < 0:
    ans.append(a+abs(mean))
  elif a >= 0 and mean >= 0:
    ans.append(abs(a-mean))
  elif a < 0 and mean >= 0:
    ans.append(abs(a)+mean)
  elif a < 0 and mean < 0:
    ans.append(abs(a-mean))
print(ans.index(min(ans))+1)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>

#define REP(i,n) for(i=0; i < (n); i++)
#define REPONE(i, n) for(i=1; i <= (n); i++)
#define LOOP(n) for(int loopCount=1; loopCount <= (n); loopCount++)
#define ITER(c) __typeof((c).begin())
#define EACH(c,it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define SZ(c) ((int) (c).size())
#define ALL(c) c.begin(), c.end()
#define SUM(c) accumulate(ALL(c), 0)
#define EXIST(c,v) (find(ALL(c), (v)) != (c).end())
#define PB push_back
#define MP make_pair
#define fs first
#define sc second

using namespace std;
static const double EPS = 1e-9;
static const double PI = 3.141592653589793238462643383279;
typedef long long ll;

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

inline int PtoN(int x, int y){
    return 20*x + y;
}

int main(){
    int w, h, i, j, d, st, best, dd, cur;
    string line;
    while(scanf("%d%d\n",&w,&h)){
        if(!(w||h)) break;
        vector<string> board;
        vector< vector<int> > dist(400, vector<int>(400,1<<21));
        vector<int> ds;
        d = 0;
        REP(i,h){
            getline(cin,line);
            board.PB(line);
        }
        REP(i,h)REP(j,w){
            if(board[i][j]=='*'){
                d++;
                ds.PB(PtoN(j,i));
            }
            else if(board[i][j]=='o'){
                st = PtoN(j,i);
            }
        }
        sort(ALL(ds));
        ds.PB(st);
        REP(i,d+1){
            queue< int > Q;
            Q.push(1000*ds[i] + 0);
            while(!Q.empty()){
                int tp=Q.front();
                int cd = tp/1000, cx=cd/20, cy=cd%20, dss=tp%1000;
                REP(j,4){
                    int x=cx+dx[j], y=cy+dy[j];
                    if(0<=x && x<w && 0<=y && y<h &&
                            board[y][x]!='x' &&
                            dist[ds[i]][PtoN(x,y)]>(1<<20)){
                        Q.push(1000*PtoN(x,y)+dss+1);
                        dist[ds[i]][PtoN(x,y)] = dss+1;
                    }
                }
                Q.pop();
            }
        }
        ds.pop_back();
        best = 1<<21;
        do{
            dd = 0;
            cur = st;
            REP(i,d){
                dd += dist[cur][ds[i]];
                if(dd>=best) goto end;
                cur = ds[i];
            }
            best = dd;
end:;
        }while(next_permutation(ALL(ds)));
        printf("%d\n",(best>(1<<20))?-1:best);
    }
    return 0;
}

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


int main(){
  int N;
  cin >> N;
  
  int ans = 0;
  int ii = 0;
  while(true){
    int tmp = ii;
    long long int jj = 0;
    long long int kk = 1;
    vector<int> C(4, 0);
    while(tmp){
      int digit = tmp%4;
      C[digit]++;
      if(digit){
        jj += (digit*2+1) * kk;
      }
      tmp/=4;
      kk*=10;
    }
    if(jj>N) break;
    if(C[0]==0 && C[1] && C[2] && C[3]) ans ++;
    ii++;
  }
  cout << ans << endl;
  return 0;
}


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


int main() {
    int H,W;
    cin >> H >> W;
    vector<string> img(H);
    for(int i=0;i<H;i++) cin >> img[i];
    for(int i=0;i<H;i++) {
        cout << img[i] << endl;
        cout << img[i] << endl;
    }
}

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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k,s;
    cin>>n>>k>>s;
    vector<ll>arr(n);
    for(int i=0;i<k;i++){
        arr[i]=s;
    }
    for(int j=k;j<n;j++){
        arr[j]=s-1;
      	if(arr[j]==0)
          arr[j]=12345;
    }
    for(int i=0;i<n;i++)
        cout<<arr[i]<<" ";
    return 0;
}


Measured memory_bytes: 2176
/n,a,b=gets.split.map(&:to_i)/
/.sort/
/S = gets.chomp.chars/
a,b=gets.split.map(&:to_i)
count=0
i=0
while i<2
  if(a>=b)
    count+=a
    a-=1
  else
    count+=b
    b-=1
  end
  i+=1
end
puts count

Measured memory_bytes: 1788
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI=3.14159265358979323846;

int main() {
    int A, B;
    cin >> A >> B;

    if (B % A == 0) {
        cout << A + B << endl;
    } else {
        cout << B - A << endl;
    }

    return 0;
}


Measured memory_bytes: 888
import std.stdio;
import std.algorithm;
import std.conv;
import std.datetime;
import std.numeric;
import std.math;
import std.string;

string my_readln() { return chomp(readln()); }

void main()
{//try{
	auto tokens = split(my_readln());
	auto D = to!ulong(tokens[0]);

	if (D == 25)
		writeln("Christmas");
	else if (D == 24)
		writeln("Christmas Eve");
	else if (D == 23)
		writeln("Christmas Eve Eve");
	else if (D == 22)
		writeln("Christmas Eve Eve Eve");
	stdout.flush();
/*}catch (Throwable e)
	{
		writeln(e.toString());
	}
readln();*/
}

Measured memory_bytes: 256
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  string s;
  set<string> memo;
  rep(i,n){
    cin >> s;
    memo.insert(s);
  }
  int ans = memo.size();
  printf("%d\n", ans);
  return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    vector<int> p(n);
    rep(i,n) cin>>p[i];
    sort(all(p));
    ll su = 0;
    rep(i, k) su += p[i];
    cout<<su<<endl;
    return 0;
}

Measured memory_bytes: 3560
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
    int a,b,ans=0;
    cin>>a>>b;
    if(a<=b){
        for(int i=0; i<a; i++){
           ans++ ;
        }
    }
    else{
        for(int i=0; i<a-1; i++){
           ans++ ;
        }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define EM 100000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
LL mod = 1e9+7;
using vint = vector<int>;
using vLL = vector<LL>;
using vvint = vector<vector<int>>;
using vvLL = vector<vector<LL>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	int N;
	cin >> N;
	vector<int>	A(N+1), ans(N+1);
	for(int i = 1;i <= N;i++)	cin >> A[i];
	for(int i = 1;i <= N;i++){
		if(i&1) ans[1] += A[i];
		else 	ans[1] -= A[i];
	}
	for(int i = 2;i <= N;i++){
		ans[i] = A[i-1]-ans[i-1]/2;
		ans[i] *= 2;
	}
	for(int i = 1;i <= N;i++)	cout << ans[i] << " ";
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

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

  vector<ll> a;
  FOR(i, 1, 9) a.push_back(i);

  int count = 0;
  while(1) {
    if(a.size() >= K) {
      cout << a[K-1] << endl;
      return 0;
    }
    K -= a.size();

    vector<ll> prev;
    swap(a, prev);
    for(ll x : prev) {
      for(int i=-1; i<=1; i++) {
        ll d = x%10 + i;
        if( d < 0 || d > 9) continue;
        ll nx = x*10 + d;
        a.push_back(nx);
      }
    }

  }
  return 0;
}


Measured memory_bytes: 4608
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> t(n);
	FOR(i, 0, n) {
		cin >> t[i];
	}
	int sumx = accumulate(t.begin(), t.end(), 0);
	int diff = 0;
	int m;
	cin >> m;
	// diffmax
	int diffi = 0;
	FOR(i, 0, m) {
		int p, x;
		cin >> p >> x;
		p--;

		cout << sumx - t[p] + x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

ans_num = 1
ans_para = h[0]
for i, r in enumerate(h):
    deg = t - (r * 0.006)
    ans_para_deg = t - (ans_para * 0.006)
    if abs(a - ans_para_deg) >= abs(a - deg):
        ans_para = r
        ans_num = i+1
print(ans_num)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  ll N, N0; cin >> N;
  N0 = N;
  vector<int> digit;
  int dsum = 0;
  while (N0>0){
    digit.push_back(N0%10);
    dsum += N0%10;
    N0 /= 10;
  }

  if (digit.size()==1) cout << N << endl;
  else cout << max(dsum, digit[digit.size()-1]-1 + 9*((int)digit.size()-1)) << endl;




  

  // cout << fixed << setprecision(6);
  return 0;
}



Measured memory_bytes: 256
s=input()

if s=="SUN":
    print(7)
elif s=="MON":
    print(6)
elif s=="TUE":
    print(5)
elif s=="WED":
    print(4)
elif s=="THU":
    print(3)
elif s=="FRI":
    print(2)
elif s=="SAT":
    print(1)


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

int main(){

  int n, y, k;
  cin >> n >> y;

  for (int i = 0; i < n + 1; i++) {
    for (int j = 0; j < n + 1 - i; j++) {
      k = n - i - j;
      if (10000 * i + 5000 * j + 1000 * k == y) {
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}


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

void deleteFirst(int**);
void deleteLast(int**);
void insertOne(int**, int**, int, int);
bool deleteOne(int**, int**, int);

int main(void){
    int xs[2000001] = {};
    int* default_ptr = xs + 2000000;
    int* fp = default_ptr;
    int* lp = default_ptr;
    int len = 0;
    int n;
    char str[20];
    scanf("%d\n", &n);
    for(int i=0; i < n; ++i){
        fgets(str, sizeof(str), stdin);
        if(str[6] == 'F'){
            deleteFirst(&fp);
            --len;
        }else if(str[6] == 'L'){
            deleteLast(&lp);
            --len;
        }else{
            char *tp;
            int m;
            tp = strtok(str, " " );
            tp = strtok(NULL," ");
            sscanf(tp, "%d", &m);
            if(str[0] == 'i'){
                insertOne(&fp, &lp, m, len);
                ++len;
            }else if(deleteOne(&fp, &lp, m)){
                --len;
            }
        }
        
        if(len == 0){
            fp = default_ptr;
            lp = default_ptr;
        }
    }
    
    for(int i = 0; i < lp - fp; ++i){
        if(*(fp + i) != -1){
            printf("%d ", *(fp + i));
        }
    }
    printf("%d\n", *lp);
}

void deleteFirst(int** fp){
    **fp = -1;
    while(**fp == -1) ++*fp;
}

void deleteLast(int** lp){
    **lp = -1;
    while(**lp == -1) --*lp;
}

void insertOne(int** fp, int** lp, int m, int len){
    if(len == 0){
        **fp = m;
    }else{
        --*fp;
        **fp = m;
    }
}

bool deleteOne(int** fp, int** lp, int m){
    for(int j = 0; j <= *lp - *fp; ++j){
        if(*(*fp + j) == m){
            *(*fp + j) = -1;
            if(j == 0){
                while(**fp == -1) ++*fp;
            }else if((*fp + j) == *lp){
                while(**lp == -1) --*lp;
            }
            return true;
        }
    }
    return false;
}

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

using namespace std;
#define chmax(x, y) x = max(x,y);
ll MOD=1000000007;
ll MAX=1000000001;

#include <iostream>
using namespace std;

//N^P(modM)




long long gt[200001],igt[200001];
ll n,k;
long long modpow(long long a,long long b)
{
    if (b==0) return 1;
    if (b%2==0) return modpow((a*a)%MOD,b/2);
    return (a*modpow((a*a)%MOD,b/2))%MOD;
}

void init()
{
    gt[0]=1;
    for (int i=1;i<=n;++i)
        gt[i]=(gt[i-1]*i)%MOD;
    igt[n]=modpow(gt[n],MOD-2);
    for (int i=n-1;i>=0;--i)
        igt[i]=(igt[i+1]*(i+1))%MOD;
}

long long nCk(int n,int k)
{
    return ((gt[n]*igt[k])%MOD*igt[n-k])%MOD;
}


int main(){


cin>>n>>k;
ll ans=0;
init();
for (ll i=0; i<min(k+1,n); i++){
  ans=ans+nCk(n,i)*nCk(n-1,n-i-1)%MOD;
  ans=ans%MOD;
}
cout<<ans;
}


Measured memory_bytes: 3328
import math

a, b, h, m = map(int, input().split())

h_angle = h * 30 + m * 0.5
m_angle = m * 6
angle = abs(h_angle - m_angle)
c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(angle)))
print(c)


Measured memory_bytes: 9500
use proconio::input;
use std::cmp::max;

#[allow(unused_variables)]
fn main() {
    input! {
      n: usize, m: usize, k: usize,
      aa: [usize; n],
      ba: [usize; m]
    };

    let mut x = vec![0];
    let mut y = vec![0];

    // 先に配列を用意

    // x = [a0, a1, a2, ..., an]
    // a0 = aa[0]
    // a1 = aa[0] + aa[1]
    // a2 = aa[0] + aa[1] + aa[2]
    for i in 0..n {
        x.push(aa[i] + x[i]);
    }

    for i in 0..m {
        y.push(ba[i] + y[i]);
    }

    // 片方のみループを回す

    let mut ans = 0;
    let mut j = m;

    // n + 1 -> 最初に0があるから
    for i in 0..n + 1 {
        // x[i]の値がkを超えていたら終了
        if x[i] > k {
            break;
        }
        // x[i]を差し引いた時間が制限時間に入るまでループ
        while y[j] > k - x[i] {
            j -= 1;
        }
        // 最大の値を更新
        ans = max(ans, i + j);
    }

    println!("{}", ans);
}


Measured memory_bytes: 12660
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

const ll inf = 10000000001000000;
int n;
ll a[55];

int main() {
	ll sum=0;
	scanf("%d", &n);
	FOR(i,n) scanf("%lld", &a[i]);
	FOR(i,n) sum += a[i];
	for (ll k = sum - n*(n-1); k <= sum; k++) {
		if (k < 0) continue;
		bool ok=true;
		ll res=0;
		FOR(i,n) {
			ll mlo = (a[i]+k+1) / (n+1), mhi = (a[i]+k) / (n+1);
			if (mlo <= mhi) res += mlo;
			else ok=false;
		}
		if (ok && res==k) {
			printf("%lld\n", res);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256