akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <utility>
#include <algorithm>
#include <vector>
#include <cmath>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
  int n,t,l,b;
  while(cin>>n>>t>>l>>b,n){
    vi board(n+1);
    rep(i,l){
      int x;
      cin>>x;
      board[x]=1;
    }
    rep(i,b){
      int x;
      cin>>x;
      board[x]=2;
    }
    vector<vector<double>> dp(2*t,vector<double>(n+1));
    dp[0][0]=1.0;
    rep(i,t){
      rep(j,n){
	if(dp[i][j]==0.0)continue;
	REP(d,1,6){
	  int p=j+d;
	  int tt=i+1;
	  if(p>n)p=2*n-p;
	  if(board[p]==1)tt++;
	  if(board[p]==2)p=0;
	  dp[tt][p]+=dp[i][j]*1.0/6.0;
	}
      }
    }
    double ans=0;
    rep(i,t+1)ans+=dp[i][n];
    cout<<ans<<endl;
  }
}



Measured memory_bytes: 3412
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int64_t N, K;
  cin >> N >> K;
  vector<double> p(N);
  vector<double> memo(N + 1);
  memo.at(0) = 0;
  for (int64_t i = 0; i < N; i++) {
    cin >> p.at(i);
    memo.at(i + 1) = (memo.at(i) + ((p.at(i) + 1) / 2.0));
  }
  double ans = 0;
  for (int64_t i = 0; i <= N - K; i++) {
    double M = (memo.at(i + K) - memo.at(i));
    ans = max(M, ans);
  }
  cout << fixed << setprecision(16);
  cout << ans << endl;
}
    

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

void solve(){
    int n;
    cin >> n;
    double v[n+10];
    rep(i,n){
        cin >> v[i];
    }
    sort(v,v+n);
    double sum = v[0];
    for(int i=1; i<n; i++){
        sum = (sum + v[i])/2;
    }
    cout << setprecision(10) << sum << endl; 
}

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


Measured memory_bytes: 256
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : August 22, 2020 6:00 PM
 *    Problem Name  : A - Takoyaki
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc176/tasks/abc176_a
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
#define ll long long int 
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;

    ll sum = 0;

    for(ll i=0; i<s.length(); i++){
        sum = sum + s[i]-'0';
    }

    if(sum % 9 == 0){
        cout << "Yes" << endl;
    }

    else{
        cout << "No" << endl;
    }


    return 0 ;
}


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

using namespace std;

template <class T> bool uax(T& a, T b) {return a < b ? (a = b, true) : false; }
template <class T> bool uin(T& a, T b) {return a > b ? (a = b, true) : false; }

const int mod = (int) 1e9 + 7;
const int MANY = 1 << 30;
const int N = (int) 1e6;

int a[N], n, m;

int d[N];

int32_t main() {
//#ifndef QQQ
//    freopen("input.in", "r", stdin);
//    freopen("output.out", "w", stdout);
//#endif
#ifdef QQQ
    freopen("../input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(11);
    cerr << fixed << setprecision(6);

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

    d[1] = abs(a[0] - a[1]);
    for (int j = 2; j < n; ++j) {
        d[j] = min(d[j-1] + abs(a[j] - a[j-1]), d[j-2] + abs(a[j-2] - a[j]));
    }
    cout << d[n-1];
}

Measured memory_bytes: 4736
N= int(input())
X =list(map(int,input().split()))
X.sort()
P = [i for i in range(X[0],X[-1] + 1)]
MIN=-1
for p in P:
    total=0
    for x in X:
        total+=(x - p)**2
    if(MIN == -1):
        MIN=total
    else:
        MIN=min(MIN,total)
print(MIN)

Measured memory_bytes: 3064
def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

# print(prime_decomposition(25))
n = int(input())
p = prime_decomposition(n)
# print(p)

cnt = 0
for k in set(p):
    b = p.count(k)
    a = 1
    c = 1
    while c <= b:
        a += 1
        c += a
    cnt += a - 1

print(cnt)

Measured memory_bytes: 9284
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        BigInteger N=new BigInteger("1000000000000000000");
        BigInteger ans=new BigInteger("1");
        BigInteger n0=new BigInteger("0");


        int flag=1;
        int num=1;
        for(int i=1;i<=n;++i){
            BigInteger x=sc.nextBigInteger();
            if(x.compareTo(n0)==0) num=0;
            if(flag==0) continue;
            ans=ans.multiply(x);
            if(ans.compareTo(N)>0) {
                flag=0;
            }
        }

        if(num==0) System.out.println(0);
        else if(ans.compareTo(N)>0||flag==0) System.out.println("-1");
        else System.out.println(ans);
    }
}

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

int main(){
	int a,b; cin>>a>>b;
	if(a<=8&&b<=8) cout << "Yay!" << endl;
	else cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
 
int main() {
    int a,b;
    string s;
    cin>>a>>b>>s;
 
    //sの-の数を数える
    int count=0;
    rep(i,a+b+1){
        if(s[i]=='-')count++;
    }
 
    if(s[a]=='-'&&count==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
      	//入力読み込み
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();      
      	int cost[][] = new int[n][3];
      	for(int i = 0; i < n; i++)
          for(int j = 0; j < 3; j++)
            cost[i][j] = sc.nextInt();
      
      	//コスト初期化
      	int dp[][] = new int[n][3];
      	for(int j = 0; j < n; j++)
      		for(int i = 0; i < 3; i++)
				dp[j][i] = 0;
      	dp[0][0] = cost[0][0];
      	dp[0][1] = cost[0][1];
      	dp[0][2] = cost[0][2];
 
      
      	//コストの計算
      	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;
            	if(dp[i][j] < cost[i][j] + dp[i-1][k])
                  dp[i][j] = cost[i][j] + dp[i-1][k];
            }
          }
        }
      
      	int max = 0;
        for(int j = 0; j < 3; j++)
          if(max < dp[n-1][j]) max = dp[n-1][j];
        System.out.println(max);
    }
}

Measured memory_bytes: 96156
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const ll mod = 1e9+7;
const ll INF = 1e10;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int h,w,k;
    cin >> h >> w >> k;
    string field[h];
    rep(i,h){
        cin >> field[i];
    }
    ll ans=0;
    rep(bit_h,1<<h){
        rep(bit_w,1<<w){
            int count=0;
            rep(i,h){
                rep(j,w){
                    if(field[i][j]=='#' && !(bit_h & (1<<i)) && !(bit_w & (1<<j))){
                        count++;
                    }
                }
            }
            if(count == k){
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {
	ll N;
	cin >> N;
//	vector<ll> A(N);
	ll A;
	map<ll, int> D;
	string ans = "YES";
	rep(i, N) {
		cin >> A;
		if(D[A]==0) {
			D[A] = 1;
		} else {
			ans = "NO";
			break;
		}
	}

	cout << ans << endl;

  return 0;
}

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

enum { U, B, L, F, R, D };
struct Dice {
	int face[6];

	Dice() {
		face[F] = 1;
		face[R] = 2;
		face[U] = 3;
		face[B] = 6;
		face[L] = 5;
		face[D] = 4;
	}

	int find_face(int f) {
		for(int i = 0; i < 6; i++) {
			if(face[i] == f) return i;
		}
		return -1;
	}

	void turn(int dir) {
		switch(dir) {
		case R:
			rotate(U, R, D, L);
			break;
		case B:
			rotate(U, B, D, F);
			break;
		case L:
			rotate(U, L, D, R);
			break;
		case F:
			rotate(U, F, D, B);
			break;
		case U:
			rotate(F, R, B, L);
			break;  // ??????????????????????¨???????
		case D:
			rotate(F, L, B, R);
			break;  // ??????????????????????¨???????
		default:
			assert(false);
		}
	}

	int& operator[](int n) { return face[n]; }

	const int& operator[](int n) const { return face[n]; }

	std::vector<Dice> all_rolls() {
		std::vector<Dice> res;
		for(int k = 0; k < 6; k++) {
			for(int i = 0; i < 4; i++) {
				res.push_back(*this);
				turn(R);
			}
			turn(k % 2 == 1 ? U : F);
		}
		return res;
	}

	void rotate(int a, int b, int c, int d) {
		int t = face[d];
		face[d] = face[c];
		face[c] = face[b];
		face[b] = face[a];
		face[a] = t;
	}
};

typedef pair<int, int> P;

Dice dice[15];
int X[15], Y[15];
string rot[15];
map<P, int> pos[15];
int dp[16][1 << 15];
set<P> used[1 << 15];

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

	int N;
	while(cin >> N, N) {
		for(int i = 0; i < N; i++) {
			int l, r, f, b, d, u;
			cin >> X[i] >> Y[i];
			cin >> l >> r >> f >> b >> d >> u;
			cin >> rot[i];
			dice[i][L] = l;
			dice[i][R] = r;
			dice[i][F] = f;
			dice[i][B] = b;
			dice[i][D] = d;
			dice[i][U] = u;

			Dice t = dice[i];
			int x = X[i], y = Y[i];
			pos[i].clear();
			pos[i][{ x, y }] = t[D];
			for(auto c : rot[i]) {
				if(c == 'L') t.turn(L), x--;
				if(c == 'R') t.turn(R), x++;
				if(c == 'F') t.turn(F), y--;
				if(c == 'B') t.turn(B), y++;
				pos[i][{ x, y }] = t[D];
			}
		}

		for(int i = 0; i < 1 << N; i++) {
			used[i].clear();
			for(int j = 0; j < N; j++) {
				if(i >> j & 1) {
					for(auto p : pos[j]) {
						int x = p.first.first, y = p.first.second;
						used[i].insert({ x, y });
					}
				}
			}
		}

		memset(dp, -1, sizeof dp);
		dp[0][0] = 0;
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < 1 << N; j++) {
				if(dp[i][j] == -1) continue;
				int s = dp[i][j];
				for(int k = 0; k < N; k++) {
					if(j >> k & 1) continue;
					int ns = s;
					for(auto p : pos[k]) {
						int x = p.first.first, y = p.first.second;
						int point = p.second;
						if(used[j].count({ x, y })) continue;
						ns += point;
					}
					dp[i + 1][j | (1 << k)] = max(dp[i + 1][j | (1 << k)], ns);
				}
			}
		}

		int ans = 0;
		for(int j = 0; j < 1 << N; j++) {
			ans = max(ans, dp[N][j]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 237228
#include<bits/stdc++.h>
using namespace std;
long long n,k,num=0,m,na;
int main(){
	cin>>n>>k;
	m=(n-2)/11;
	na=(n-2)%11;
	for(int i=1;i<=na;i++)
		for(int j=2;j<=6;j++)
			if((i*63+j*9)%11==k)num++;
	cout<<num+m*5<<endl;	
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

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




/******************************************************************************************/



//素数判定
bool is_prime(ll n) {
	for (ll i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return n != 1;//1の場合は除外
}



//約数の列挙
template<typename T>
vector<T> divisor(T n) {
	vector<T> res;
	for (T i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			res.push_back(i);
			if (i != n / i) {
				res.push_back(n / i);
			}
		}
	}
	return res;
}




//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}



//繋げる方向を一方向にする
typedef struct union_find {

	vector<ll> pa;//親
	vector<ll> ra;//木の深さ
	vector<ll> siz;
	//n要素で初期化
	void init(ll n) {
		pa.resize(n);
		ra.resize(n);
		siz.resize(n);
		for (ll i = 0; i < n; i++) {
			pa[i] = i;/*各ノードに番号を振る,この時par[x]=xとなる時は木の根となる*/
			ra[i] = 0LL;/*各ノード自体の高さは0*/
			siz[i] = 1LL;
		}
	}
	//木の根を求める
	ll find(ll x) {
		if (pa[x] == x) {
			return x;/*根ならそのノードの番号を返す*/
		}
		else {
			return pa[x] = find(pa[x]);/*根でないならさらにノードの根を探す*/
		}
	}

	//xとyの属する集合を併合する
	void unite(ll x, ll y) {
		x = find(x);//xの根の番号を探す
		y = find(y);//yの根の番号を探す
		if (x == y) {//一致すればつながっている
			return;
		}
		pa[y] = x;
		siz[x] += siz[y];
	}

	//xとyが同じ集合に属するか判定
	bool same(ll x, ll y) {
		return find(x) == find(y);//同じ集合なら1、違うなら0が返る
	}
}UF;



vector<int> g[30];

int main() {

	
	int n, t;
	cin >> n >> t;

	priority_queue<pii> que;
	for (int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		que.push(pii(a, 0));
		que.push(pii(b, 1));
	}

	int ans = 0;
	while (t > 0) {

		pii tmp = que.top();
		que.pop();

		if (tmp.second == 1) {
			t -= tmp.first;
			ans++;
		}
		else
		{
			ans += (t - 1) / tmp.first + 1;
			break;
		}


	}
	

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

Measured memory_bytes: 2420
N, A = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]

XX = sum(X) + 1

dp = [[[0 for i in range(XX * 2)] for i in range(N + 3)] for i in range(N + 3)]

dp[0][0][0] = 1

for i in range(N):
    for j in range(N + 1):
        for n in range(XX):
            dp[i + 1][j][n] += dp[i][j][n]
            dp[i + 1][j + 1][n + X[i]] += dp[i][j][n]

ans = 0
for i in range(1, N + 1):
    if i * A < XX:
        ans += dp[N][i][i * A]

print(ans)

Measured memory_bytes: 153352
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
#include <map>
#include <cstdlib>

using namespace std;

int gcd(int x, int y){
  int r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

void solve(){
  double t, x; cin >> t >> x;
  cout << t / x << endl;
  return;
}

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


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

int main(){
  int A,B,K;
  cin>>A>>B>>K;
  for(int i=0;i<K;i++){
    if(i%2==0){
      A -= A%2;
      B += A/2;
      A /= 2;
    }
    else{
      B-=B%2;
      A+=B/2;
      B/=2;
    }
  }
  cout << A <<" "<< B << endl;
}


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

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

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

int main() {
  int r;
  cin >> r;
  printf("%.15f\n", r * 2 * M_PI);
  return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  map<string,ll> m;
  ll N;cin>>N;
  rep(i,N){
    string s; cin>>s;
    m[s]++;
  }
  cout<<m.size()<<endl;


}


Measured memory_bytes: 19100
n = int(input())
t,a = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]

ans = 1
tmpans = t - (h[0] * 0.006)
for i in range(1,n):
    tmp = t - (h[i] * 0.006)
    if abs(a - tmp) < abs(a - tmpans):
        ans = i + 1
        tmpans = tmp

print(ans)


Measured memory_bytes: 3060
n = int(input())
a =[]
for i in range(2):
    a.append(list(map(int, input().split())))

total = []
for j in range(n):
    upper = sum(a[0][jj] for jj in range(j+1))
    bottom = sum(a[1][jj] for jj in range(j, n))
    total.append(upper + bottom)

print(max(total))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

int main(){
  int a,b; cin >>a >>b;
  if((a+b)%2) cout <<"IMPOSSIBLE";
  else cout <<(a+b)/2;
return 0;}

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

int main() {
    string s;
    ll k;
    ll count = 0;
    cin >> s >> k;
    char ans = '1';
    for(int i=0; i<s.size(); i++){
        count++;
        if(s.at(i) != '1'){
            ans = s.at(i);
            break;
        }
        if(count == k) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main() {
    int n, a;
    long min = (long) 1e6, max = (long) -1e6, sum = 0;

    cin >> n;
    while (n) {
        cin >> a;
        if (min > a) min = a;
        if (max < a) max = a;
        sum += a;
        --n;
    }
    cout << min << ' ' << max << ' ' << sum << endl;
    return 0;
}

Measured memory_bytes: 1160
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,k = LI()
    a = LI_()

    m = [-1] * n
    m[0] = k
    c = 0
    while k > 0:
        k -= 1
        c = a[c]
        if m[c] >= 0:
            s = m[c] - k
            k %= s
            m = [-1] * n
        m[c] = k

    return c + 1

print(main())





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

using namespace std;
using std::vector;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

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

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

int main(){
 
  int n; cin >> n;
  vi a(n), b(n), c(n);
  vector<ll> dp_a(n), dp_b(n), dp_c(n);

  rep(i, n)
    cin >> a[i] >> b[i] >> c[i];
  
  dp_a[0] = a[0];
  dp_b[0] = b[0];
  dp_c[0] = c[0];

  for(int i = 1; i < n; i++){
    dp_a[i] = max(dp_b[i - 1] + a[i], dp_c[i - 1] + a[i]);
    dp_b[i] = max(dp_a[i - 1] + b[i], dp_c[i - 1] + b[i]);
    dp_c[i] = max(dp_a[i - 1] + c[i], dp_b[i - 1] + c[i]);
  }

  pr(max(dp_a[n - 1], max(dp_b[n - 1], dp_c[n - 1])));

  return 0;
}


Measured memory_bytes: 3840
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
using namespace std;
int n; char s[100010];
int main() {
	scanf("%s", s + 1); n = strlen(s + 1);
	if ((s[1] == s[n]) ^ (n & 1)) printf("First");
		else printf("Second");
	return 0;
}

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


int main()
{
   
    ll i,j,n,p,m=1000000007,flag=0,temp=0;
    bool ans=false;
    string s;
    cin>>s;
    char arr[4];
    arr[0]=s[0];
    arr[1]=s[1];
    arr[2]=s[2];
    arr[3]=s[3];

    sort(arr,arr+4);

    if(arr[0]==arr[1]&&arr[2]==arr[3]&&arr[1]!=arr[2])ans=true;
    
          if(ans)cout<<"Yes"<<endl;
          else cout<<"No"<<endl;

    return 0;

  }


Measured memory_bytes: 256
from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
GCD= a[0]
dp = [set() for i in range(n)]
dp[0].add(a[0])
dp[0].add(a[1])
for i in range(1,n):
    x = a[i]
    for j in dp[i-1]:
            dp[i].add(gcd(j,x))
    if x % GCD != 0:
        dp[i].add(GCD)
        GCD = gcd(GCD,x)
print(max(dp[n-1]))


Measured memory_bytes: 32108
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int K;

int main(){
  cin >> K;
  cout << (K / 2) * (K - K / 2) <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define per(i,n,j) for(int i=(n);i>=(j);i--)
using ll=long long;
using namespace std;
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; }
const ll INF=1LL<<60;

int n;
string c;

int main(){
    cin>>n>>c;
    int cnt=0;
    rep(i,0,c.size()) if(c[i]=='R') cnt++;
    int ans=0;
    rep(i,0,cnt) if(c[i]=='W') ans++;
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3744
n,k=map(int,input().split())
p=[int(i) for i in input().split()]


tmp=sum(p[0:k])
Msum=tmp

for i in range(1,n-k+1):
    a=p[i-1]
    b=p[i+k-1]
    tmp=tmp-a+b
    Msum = max(tmp,Msum)

print((Msum+k)/2)

Measured memory_bytes: 71792
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;

bool of=0;
string expr;

void ck(pi a)
{
	if(abs(a.first)>10000||abs(a.second)>10000)
	of=1;
}

pi add(pi a,pi b,char op)
{
	ck(a),ck(b);
	pi ret;
	ret.first=a.first+(op=='+'?b.first:-b.first);
	ret.second=a.second+(op=='+'?b.second:-b.second);
	
	ck(ret);
	return ret;
}
pi mul(pi x,pi y)
{
	ck(x),ck(y);
	int a=x.first,b=x.second,c=y.first,d=y.second;
	pi ret=mp(a*c-b*d,a*d+b*c);
	
	ck(ret);
	return ret;
}
pi eval(int s,int t)
{
	int p=t-1,d=0;
	for(;p>s;p--)
	{
		char c=expr[p];
		if(c=='(')d++;
		if(c==')')d--;
		if(d==0&&(c=='+'||c=='-'))break;
	}
	//unary
	if(p==s)
	{
		if(expr[s]=='-')
		{
			pi ret=eval(s+1,t);
			ret.first*=-1,ret.second*=-1;
			return ret;
		}
		if(expr[s]=='+')return eval(s+1,t);
		
		for(p=t-1,d=0;p>s;p--)
		{
			char c=expr[p];
			if(c=='(')d++;
			if(c==')')d--;
			if(d==0&&c=='*')break;
		}
		//one-factor
		if(p==s)
		{
			if(expr[s]=='(')return eval(s+1,t-1);
			
			if(expr[s]=='i')return mp(0,1);
			int n=0;
			for(int i=s;i<t;i++)
			{
				n*=10,n+=expr[i]-'0';
				if(n>10000)of=1;
			}
			return mp(n,0);
		}
		return mul(eval(s,p),eval(p+1,t));
	}
	//mulary
	return add(eval(s,p),eval(p+1,t),expr[p]);
}

int main()
{
	while(getline(cin,expr))
	{
		of=0;
		pi ans=eval(0,expr.size());
		
		if(of)cout<<"overflow"<<endl;
		else
		{
			int a=ans.first,b=ans.second;
			
			if(a==0&&b==0)cout<<0<<endl;
			else if(a==0) cout<<b<<"i"<<endl;
			else if(b==0)cout<<a<<endl;
			else if(b>0)cout<<a<<"+"<<b<<"i"<<endl;
			else cout<<a<<b<<"i"<<endl;
		}
	}
	return 0;
}

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

using namespace std;

const int   N   = 701;

typedef pair<int,int>   ii;

bool E[N][N];
int n, m, c[N];

vector<ii>  CB;

bool ok[N];

int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> n >> m;

    for(int i = 1 ; i <= n ; ++i)   E[i][i] = 1;

    while(m--)  {
        int x, y;
        cin >> x >> y;
        E[x][y] = E[y][x] = 1;
    }

    memset(c,-1,sizeof c);

    for(int i = 1 ; i <= n ; ++i)   {
        if(c[i] >= 0)   continue;
        queue<int>  q;
        q.push(i);  c[i] = 0;
        int cnt[] = {0,0};
        while(q.size()) {
            int u = q.front();  q.pop();
            cnt[c[u]]++;
            for(int v = 1 ; v <= n ; ++v)   {
                if(E[u][v]) continue;
                if(c[u] == c[v])
                    return 0 * puts("-1");
                if(c[v] < 0)    {
                    q.push(v);
                    c[v] = c[u] ^ 1;
                }
            }
        }
        CB.push_back({cnt[0],cnt[1]});
    }

    ok[0] = 1;

    for(ii tmp : CB)
    for(int i = n ; i >= 0 ; --i)   {
        bool cur = 0;
        if(i >= tmp.first)  cur |= ok[i - tmp.first];
        if(i >= tmp.second) cur |= ok[i - tmp.second];
        ok[i] = cur;
    }

    int ans = 1e9 + 7;

    for(int i = 0 ; i <= n ; ++i)
        if(ok[i])   ans = min(ans,i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);

    cout << ans << endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
using namespace std;
 
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair
 
static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}


int main(){
	vint a(3);
	cin>>a[0]>>a[1]>>a[2];
	sort(ALL(a));
	rep(i,3){
	if(i) cout<<" ";
	cout<<a[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1208
N = int(input())
*A, = map(int, input().split())
ans = 0
mode = 0 # neutral
for i in range(1, N):
    if A[i] - A[i-1] > 0:
        if mode == 2:
            ans += 1
            mode = 0
        elif mode == 0:
            mode = 1 # non-decreasing
    elif A[i] - A[i-1] < 0:
        if mode == 1:
            ans += 1
            mode = 0
        elif mode == 0:
            mode = 2 # non-increasing
ans += 1
print(ans)

Measured memory_bytes: 14100
#include<iostream>
#include<iomanip>
#include<math.h>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<set>
#include<vector>
using namespace std;

#define INF 1<<21
#define MOD 10e9+7

int main(){
    string s;
    int cnt=0;
    int ans=0;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='S')cnt++;
        if(s[i]=='T'){
            if(cnt==0)continue;
            ans+=2;
            cnt--;
        }
    }
    cout<<s.length()-ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
#define int long long int
signed main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans=0,R=0,G=0,B=0,count=0;
    for(int i=0;i<N;i++)
    {
        if(S[i] == 'R') R++;
        if(S[i] == 'G') G++;
        if(S[i] == 'B') B++;
        for(int j=N-1;j>i+1;j--)
        {
            if((i+j)%2 ==0)
            {
                char temp = S[(i+j)/2];
                if(temp != S[j] && temp != S[i] && S[j] != S[i])
                    count++;
            }
        }
    }
    
    cout << R*G*B-count << endl;
 return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    vector<long long> arr(3);
    for(int i = 0;i < 3;i++)
        cin >> arr[i];
    sort(arr.begin(),arr.end());
    int k;
    cin >> k;
    while(k--)
        arr[2] *= 2;
    cout << arr[1] + arr[0] + arr[2];

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define db long double
#define fi first
#define se second
#define  pb push_back
#define  pob pop_back
#define W while
#define fn(i,x) for(int i=0;i<x;i++)
#define fs(i,s,x) for(int i=s;i<x;i++)
#define fr(i,x) for(int i=x;i>=0;i--)
#define fit(it,s) for(auto it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 1000000007
#define MAX 1005
using namespace std;
vector<ll> graph[100005];
ll vis[100005]={0};
ll col[100005] = {0};
map<pll,ll> m;
void dfs(ll par,ll cur)
{
   vis[cur]=1;
   ll len=graph[cur].size();
   
   fn(i,len)
   {
      ll node=graph[cur][i];
      if(m[mp(cur,node)]%2 == 1) col[node] = 1LL^col[cur];
      else col[node] = col[cur];
      //cout << m[mp(cur,node)] << "\n";
      if(!vis[node] && node!=par)
      dfs(cur,node); 
 
   }
} 
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

    // freopen("in.txt","r",stdin);
    // freopen("out.txt","w",stdout);
    
    ll n;
    cin >> n;
   

    fn(i,n-1){
      ll u,v,w;
      cin >> u >> v >> w;
      graph[u].pb(v);
      graph[v].pb(u);
      m[mp(u,v)]=w;
      m[mp(v,u)]=w;
    }
    
    dfs(0,1);
    fs(i,1,n+1) cout << col[i] << "\n";
    return 0;

}

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

int A[100][100];
int B[100][100];

bool dp[100][100][20000]; //ここ怪しくないか ０点は6400点へと補正

int main(){
  
  int h,w; 
  
  cin >> h >> w;
  
  for(int i = 0; i < 80; i++){
    for(int j = 0; j < 80; j++){
      for(int k = 0; k < 12800; k++){
        dp[i][j][k] = false;
      }
    }

  }
  
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){ 
     cin >> A[i][j];}
  }
  
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> B[i][j];
    }
  }
  
  dp[0][0][A[0][0]-B[0][0]+6400] = true;
  dp[0][0][-A[0][0]+B[0][0]+6400] = true;
  
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      for(int k = 0; k < 12800; k++){
      
      if(i && dp[i-1][j][k]){ //上からおりれるとき
        dp[i][j][k+A[i][j]-B[i][j]] = true;
        dp[i][j][k+B[i][j]-A[i][j]] = true;
      }
      
      if(j && dp[i][j-1][k] ){ //したから降りれる時
        
        dp[i][j][k+A[i][j]-B[i][j]] = true;
        dp[i][j][k+B[i][j]-A[i][j]] = true;
       
      }
      
           }
    }
  }
           
  
  //dp遷移終了
  
  int ans = 2e9;
  
  for(int i = 0; i < 20000; i++){
    if( dp[h-1][w-1][i] ){ 
      
      ans = min(ans, abs(i-6400));
    }
  }
  
  cout << ans << endl;
  
  
  
  return 0;
} 

Measured memory_bytes: 157440
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

int main(){
	ll n,ans=0;//10^5
	cin>>n;
	vector<ll> a(3*n);
	rep(i,3*n)cin>>a[i];
	sort(all(a),greater<int>());
	//big big small
	for(ll i=1;i<2*n;i+=2){
		// dbg(i);
		ans+=a[i];
	}

	cout<<ans<<endl;

    return 0;
}

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

int main() {
  int X, A, B;
  cin >> X >> A >> B;
  if (A-B>=0){
    cout << "delicious" << endl;
  }
  else if (B-A>X){
    cout << "dangerous" << endl;
  }
  else{
    cout << "safe" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int n, m, k;
   cin >> n >> m >> k;
   vector<int> a(n), b(m);
   rep(i, 0, n) cin >> a[i];
   rep(i, 0, m) cin >> b[i];

   vector<ll> sum_b(m + 1);
   rep(i, 1, m + 1) sum_b[i] = sum_b[i - 1] + b[i - 1];

   ll sum_a = 0;
   int ans = 0;
   rep(i, 0, n + 1) {
      int cnt = upper_bound(all(sum_b), k - sum_a) - sum_b.begin();
      //printf("%lld %d %d\n", k - sum_a, i, cnt);
      cnt--;
      if (sum_a <= k) cnt += i;
      chmax(ans, cnt);
      if (i == n) break;
      sum_a += a[i];
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 6376
/**
 *    author:  gzhffIThh
 *    created: 19.08.2020
**/
#include <bits/stdc++.h>

using namespace std;

const int N=200010;

int n;
long long a[N];

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

  scanf("%d",&n);
  long long ans=0;
  for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
  for(int i=2;i<=n;i++){
  	if(a[i]<a[i-1]){
  		ans+=a[i-1]-a[i];
  		a[i]=a[i-1];
  	}
  }
  printf("%lld",ans);
  return 0;
}


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

int main(){
	
	int N;
	int a[1001];
	cin >> N;
	while(N>0){
		REP(i,N)cin >> a[i];
		int m = 1e9;
		REP(i,N){
			REP(j,N){
				if(i != j)m = min(m, abs(a[i] - a[j]));
			}
		}
		cout << m << endl;
		cin >> N;
	}
	return 0;
}


Measured memory_bytes: 3064
let ans = ref 0
let k, s = Scanf.scanf "%d %d" (fun a b -> a, b)

let () =
  for x = 0 to k do
    for y = 0 to k do
      let z = s - x - y in
      if 0 <= z && z <= k then incr ans
    done;
  done;
  Printf.printf "%d\n" !ans


Measured memory_bytes: 384
package main

import "fmt"

const mod int = 1e9 + 7

func main() {
	var s string
	fmt.Scan(&s)

	dp := [13]int{}
	dp[0] = 1

	mul := 1
	for i := len(s) - 1; i >= 0; i-- {
		ndp := [13]int{}
		if s[i] == '?' {
			for j := 0; j < 13; j++ {
				for k := 0; k < 10; k++ {
					ndp[(k*mul+j)%13] += dp[j]
					ndp[(k*mul+j)%13] %= mod
				}
			}
		} else {
			for j := 0; j < 13; j++ {
				k := int(s[i] - '0')
				ndp[(k*mul+j)%13] += dp[j]
				ndp[(k*mul+j)%13] %= mod
			}
		}
		dp = ndp
		mul = mul * 10 % 13
	}

	fmt.Println(dp[5])
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define int long long

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

  int n;  cin >> n;
  vector< tuple<int,int,int> > S(n);
  for(int i = 0; i < n; i++){
      int a,b;  cin >> a >> b;
      S[i] = make_tuple(a+b,a,b);
  }
  sort(S.rbegin(), S.rend());

  int ans = 0;
  for(int i = 0; i < n; i++){
    if(i%2 == 0){
      ans += get<1>(S[i]);
    }
    else {
      ans -= get<2>(S[i]);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i, a, b) for(int i=(a) ; i<=(b) ; ++i)
#define Task ""
using namespace std;
const int N=1005;
int dp[15][N], n, g, s[15], p[15], c[15];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen(Task".inp", "r", stdin);
    //freopen(Task".out", "w", stdout);
    cin >> n >> g;
    rep(i, 1, n) {
        cin >> p[i] >> c[i];
        s[i]=s[i-1]+p[i];
    }
    rep(i, 1, p[1]-1) dp[1][i]=100*i;
    dp[1][p[1]]=100*p[1]+c[1];
    rep(i, 2, n)
        rep(j, 1, s[i])
            rep(k, 0, j) {
                int xx=0;
                if(j-k>p[i]) continue;
                if(j-k==p[i]) xx=c[i];
                dp[i][j]=max(dp[i][j], dp[i-1][k]+100*i*(j-k)+xx);
            }
    rep(i, 0, s[n]) {
        if(dp[n][i]>=g) return cout << i, 0;
    }
    return 0;
}


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

#define pb push_back
#define mp make_pair

typedef long long ll;

ll arr[200005];
ll val[200005];
int pos[200005];
ll tree[800005];
vector <pair<ll,ll> > has;

void update(int a,int low,int high,int e,ll d)
{
	if(high<e || low>e)return;
	else if(e<=low && e>=high)tree[a]=d;
	else
	{
		int mid=(low+high)/2;
		update(a*2,low,mid,e,d);
		update(a*2+1,mid+1,high,e,d);
		tree[a]=max(tree[a*2],tree[a*2+1]);
	}
}

ll query(int a,int low,int high,int e,int r)
{
	if(high<e || low>r)return 0;
	else if(e<=low && r>=high)return tree[a];
	else
	{
		int mid=(low+high)/2;
		
		return max(query(a*2,low,mid,e,r),query(a*2+1,mid+1,high,e,r));
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int z;
	cin>>z;
	
	for(int q=1;q<=z;q++)
	{
		cin>>arr[q];
		pos[arr[q]]=q;
	}
	
	for(int q=1;q<=z;q++)
	{
		cin>>val[q];
		has.pb(mp(arr[q],val[q]));
	}
	
	sort(has.begin(),has.end());
	
	for(int q=0;q<has.size();q++)
	{
		int temp=pos[has[q].first];
		ll d=query(1,1,z,1,temp);
		update(1,1,z,temp,d+has[q].second);
	}
	
	cout<<tree[1]<<endl;
}

Measured memory_bytes: 14444
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;
	
	int x, y, z, k;
	cin >> x >> y >> z >> k;
	vec<ll> a(x), b(y), c(z);

	for (auto& e : a)
	{
		cin >> e;
	}
	for (auto& e : b)
	{
		cin >> e;
	}
	for (auto& e : c)
	{
		cin >> e;
	}

	vec<ll> D;

	for (auto ea : a)
		for (auto eb : b)
			D.push_back(ea + eb);

	sort(D.rbegin(), D.rend());

	vec<ll> E;

	for (int i = 0; i < min({k + 0_sz, D.size()}); ++i)
	{
		for (auto e : c)
		{
			E.push_back(D[i] + e);
		}
	}

	sort(E.rbegin(), E.rend());

	for (int i = 0; i < k; ++i)
	{
		cout << E[i] << endl;
	}


    return 0;
}

Measured memory_bytes: 43240
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
//#include <cassert>
//#include <stack>
//#include <queue>
//#include <deque>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

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

// template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//  order_of_key (k) : Number of items strictly smaller than k .
//  find_by_order(k) : K-th element in a set (counting from zero).
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
#define int ll

const int N = 2e5 + 5;
const int oo = 1e9 + 5;

ll n, a[N], cnt[N], ans;
 
void solve() {
	cin >> n;
	fo (i, 1, n, 1) {
		cin >> a[i];
		++cnt[a[i]];
		ans += (cnt[a[i]] - 1);
	}
	fo (k, 1, n, 1) {
		ans -= (cnt[a[k]] - 1);
		cout << ans <<'\n';
		ans += (cnt[a[k]] - 1);
	}
}

 main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tt = 1;
	while (tt --) {
		solve();
	}
	return 0;
}
/*
	“I’m not gonna run away, I never go back on my word! That’s my nindo: my ninja way.” Naruto
ц*/

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    map<ll, ll> m;
    rep(i, 3) {
        ll temp;
        cin >> temp;
        m[temp]++;
    }
    cout << (m.size() != 3 && ((*m.begin()).second == 1 || (*(--m.end())).second == 1) ? "Yes" : "No") << endl;
    return 0;
}


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

long long N, X[1 << 18], Y[1 << 18]; vector<long long>P, Q, V1, V2;

long long dist(long long px, long long py, long long qx, long long qy) {
	if (px == qx && px % 20 == 0) return abs(py - qy);
	if (py == qy && py % 20 == 0) return abs(px - qx);

	long long ans = 0;

	if (px % 20 == 0 && qx % 20 == 0) {
		if ((py / 20) == (qy / 20)) {
			long long V1 = abs(px - qx);
			long long A1 = py - ((py / 20) * 20), A2 = qy - ((qy / 20) * 20);
			V1 += min(A1 + A2, 40LL - (A1 + A2));
			ans = V1;
		}
		else ans = abs(px - qx) + abs(py - qy);
	}
	else if (py % 20 == 0 && qy % 20 == 0) {
		if ((px / 20) == (qx / 20)) {
			long long V1 = abs(py - qy);
			long long A1 = px - ((px / 20) * 20), A2 = qx - ((qx / 20) * 20);
			V1 += min(A1 + A2, 40LL - (A1 + A2));
			ans = V1;
		}
		else ans = abs(px - qx) + abs(py - qy);
	}
	else {
		ans = abs(px - qx) + abs(py - qy);
	}
	return ans;
}

long long solve(long long px, long long py) {
	long long sum = 0;
	for (int i = 0; i < N; i++) {
		sum = max(sum, dist(px, py, X[i], Y[i]));
	}
	return sum;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> X[i] >> Y[i]; X[i] *= 2; Y[i] *= 2;
		X[i] += 200000000; Y[i] += 200000000;
		P.push_back(X[i] + Y[i]);
		Q.push_back(X[i] - Y[i]);
	}
	sort(P.begin(), P.end());
	sort(Q.begin(), Q.end());
	long long CX = (P[0] + P[N - 1]) / 2;
	long long CY = (Q[0] + Q[N - 1]) / 2;
	long long DX = (CX + CY) / 2;
	long long DY = CX - DX;

	for (int i = -100; i <= 100; i++) V1.push_back(DX + i);
	for (int i = -100; i <= 100; i++) V2.push_back(DY + i);

	long long minx = (1LL << 60);
	for (int i = 0; i < V1.size(); i++) {
		for (int j = 0; j < V2.size(); j++) {
			if (!(V1[i] % 20 == 0 || V2[j] % 20 == 0)) continue;
			minx = min(minx, solve(V1[i], V2[j]));
		}
	}
	printf("%.12Lf\n", 0.5L * minx);
	return 0;
}


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

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; i ++) {
    cin >> d[i];
  }
  int sum = 0;
  for (int i = 0; i < n - 1; i ++) {
    for (int j = i + 1; j < n; j ++) {
      sum += d[i] * d[j];
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 384
using System;
class Program {
    static void Main(string[] args) {
        string S = Console.ReadLine();
        int n = int.Parse(S);
        
        int h = n / 3600;
        int m = (n % 3600) / 60;
        int s = (n % 3600) % 60 % 60;
        
        Console.WriteLine(h+":"+m+":"+s);
    }
}

Measured memory_bytes: 9100