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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

template <typename M> struct SegmentTree {
    using T = typename M::T;
    int n;
    vector<T> dat;
    SegmentTree() {}
    SegmentTree(int n_) { init(n_); }
    SegmentTree(const vector<T> &v) { build(v); }
    void init(int n_) {
        n = 1;
        while(n < n_)
            n <<= 1;
        dat.assign(n << 1, M::ti());
    }
    void build(const vector<T> &v) {
        int n_ = v.size();
        init(n_);
        for(int i = 0; i < n_; i++)
            dat[n + i] = v[i];
        for(int i = n - 1; i; i--)
            dat[i] = M::f(dat[(i << 1) | 0], dat[(i << 1) | 1]);
    }
    void set_val(int k, T x) {
        dat[k += n] = x;
        while(k >>= 1)
            dat[k] = M::f(dat[(k << 1) | 0], dat[(k << 1) | 1]);
    }
    //[a,b)
    T query(int a, int b, int k = 1, int l = 0, int r = -1) {
        if(r < 0)
            r = n;
        if(r <= a || b <= l)
            return M::ti();
        if(a <= l && r <= b)
            return dat[k];
        T vl = query(a, b, k * 2, l, (l + r) / 2);
        T vr = query(a, b, k * 2 + 1, (l + r) / 2, r);
        return M::f(vl, vr);
    }
    T operator[](const int &k) const { return dat[k + n]; }
};

struct Rminmin2maxmax2Q {
    struct T {
        ll min, min2, max, max2;
    };
    static T ti() { return {INT_MAX, INT_MAX, -1, -1}; }
    static T f(const T &l, const T &r) {
        return {min(l.min, r.min), min({max(l.min, r.min), l.min2, r.min2}),
                max(l.max, r.max), max({min(l.max, r.max), l.max2, r.max2})};
    }
};

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int N;
    cin >> N;
    int idx[N];
    for(int i = 0; i < N; i++) {
        int P;
        cin >> P;
        idx[--P] = i;
    }
    vector<Rminmin2maxmax2Q::T> v(N);
    for(int i = 0; i < N; i++) {
        v[i] = {i, INT_MAX, i, -1};
    }
    SegmentTree<Rminmin2maxmax2Q> seg(v);
    ll ans = 0;
    for(int i = 0; i < N; i++) {
        auto left = seg.query(0, idx[i]);
        auto right = seg.query(idx[i] + 1, N);
        if(right.min == INT_MAX)
            right.min = N;
        if(right.min2 == INT_MAX)
            right.min2 = N;
        ans += (i + 1) * (left.max - left.max2) * (right.min - idx[i]);
        ans += (i + 1) * (right.min2 - right.min) * (idx[i] - left.max);
        seg.set_val(idx[i], Rminmin2maxmax2Q::ti());
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12032
package main

import "fmt"
import "strconv"

func main() {
	var s string
	fmt.Scan(&s)
	best := 999999999999

	for i := 0; i < len(s)-2; i++ {
		v, _ := strconv.Atoi(s[i : i+3])
		diff := abs(v - 753)
		if best > diff {
			best = diff
		}
	}
	fmt.Println(best)
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 512
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		long[] list = new long[N+1];
		list[0]=2;
		list[1]=1;
		for(int i=2;i<=N;i++){
			list[i]=list[i-1]+list[i-2];
		}
		System.out.println(list[N]);

	}




	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 22996
n, m = map(int, input().split())
h = list(map(int, input().split()))
li = list(range(1, n+1))
ng = []
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] <= h[b-1]:
        ng.append(a)
    if h[b-1] <= h[a-1]:
        ng.append(b)
print(len(list(set(li)-set(ng))))

Measured memory_bytes: 29732
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  long long i,n,k,h[200000],sum=0;
  cin>>n>>k;
  for(i=0;i<n;i++)
  {
      cin>>h[i];
  }
  sort(h,h+n);
  if(k>=n)
     {
         cout<<"0"<<endl;
     }
        else
        {
            for(i=0;i<=n-k-1;i++)
            {
                sum+=h[i];
            }
            cout<<sum<<endl;
        }
        return 0;
}


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

using namespace std;
using ll = long long;

int main() {
    int N, D;
    cin >> N >> D;
    vector<vector<int> > dot(N,vector<int>(D,0));
    int ans = 0;
    int temp;

    for(int i = 0; i < N; i++) {
        for(int j = 0; j < D; j++) {
            cin >> dot.at(i).at(j);
        }
    }

    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            temp = 0;
            for(int k = 0; k < D; k++) {
                temp += (int)pow(dot.at(i).at(k) - dot.at(j).at(k), 2);
            }
            for(int k = pow(temp, 0.5) -  4; k < pow(temp, 0.5) + 4; k++) {
                if(k*k == temp) {
                    ans++;
                    break;
                }
            }
            //cout << temp << endl;
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3984
n, k = map(int, input().split())
v = list(map(int, input().split()))

ans = 0
for l in range(0, k + 1):
    for r in range(0, k + 1 - l):
        if l == r == 0 or l + r > n:
            continue
        a = sorted(v[:l] + v[n - r:])
        m = min(k - l - r, len(a) - 1)
        ans = max(ans, sum(a[m:] if a[m] <
                           0 else filter(lambda x: x > 0, a)))
print(ans)

Measured memory_bytes: 9220
#define _CRT_SECURE_NO_WARNINGS

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

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

ll N, ans;
ll dvs[11234567];

int main() {

	cin >> N;

	rep(i, N) {
		rep(j, N / (i + 1)) {
			dvs[(i + 1) * (j + 1)]++;
		}
	}

	rep(i, N) {
		ans += dvs[i + 1] * (i + 1);
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 81752
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[100];
  for(int i=0; i<n; i++) cin >> a[i];
  for(int i=0; i<n-1-i; i++) swap(a[i],a[n-1-i]);
  for(int i=0; i<n; i++){
        if(i) cout << " ";
        cout << a[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include <tr1/unordered_map>
#define int long long
#define x first
#define y second
#define pii pair<int,int>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}
const int N=1e5+5;
int en,h[N],sum,n,sz[N];
tr1::unordered_map<int,int> id;
vector<pii> ans;
struct edge{int n,v;}e[N<<1];
inline void add(const int &x,const int &y){
	e[++en]=(edge){h[x],y};
	h[x]=en;
}
struct node{
	int d,i;
	inline bool operator < (const node &nt) const {
		return d>nt.d;
	}
}a[N];
void dfs(int x,int fa,int dis){
	sum+=dis;
	for(int i=h[x];i;i=e[i].n){
		int y=e[i].v;
		if(y==fa) continue;
		dfs(y,x,dis+1);
	}
}
signed main(){
	read(n);
	for(int i=1;i<=n;i++){
		read(a[i].d);
		id[a[i].d]=i;
		a[i].i=i;
		sz[i]=1;
	}
	sort(a+1,a+1+n);
	for(int i=1;i<n;i++){
		int aim=a[i].d-n+(sz[a[i].i]*2);
		id[a[i].d]=0;
		if(!id[aim]){
			puts("-1");
			return 0;
		}
		int nt=id[aim];
		ans.push_back(make_pair(a[i].i,nt));
		add(a[i].i,nt);
		add(nt,a[i].i);
		sz[nt]+=sz[a[i].i];
	}
	dfs(a[n].i,0,0);
	if(sum!=a[n].d){
		puts("-1");
	}
	else{
		for(int i=0;i<ans.size();i++)
			write(ans[i].x),putchar(' '),
			write(ans[i].y),putchar('\n');
	}
}

Measured memory_bytes: 16156
n,h=map(int,input().split())
a=[]
b=[]
for _ in range(n):
    a_i,b_i=map(int,input().split())
    a.append(a_i)
    b.append(b_i)

import bisect,math


b=sorted(b)
index = bisect.bisect_left(b,max(a))

cnt=0
for i in range(n-1,-1,-1):
    if i>=index:
        h-=b[i]
        cnt+=1
    else:
        break
    
    if h<=0:
        h=0
        break

ans=math.ceil(h/max(a))+cnt

print(ans)


Measured memory_bytes: 18040
#include <iostream>
#include <vector>

using namespace std;

int main(){
  
  int N,Y;
  cin >> N >> Y;
  
  int sum = Y / 1000;
  
  
//合計N個の10円,5円,1円でsum円を作ることは可能か？
   
   for(int i=N;i >=0;i--){
     for(int j=0;j < N-i+1;j++){
       if (10*i + 5*j +1*(N-i-j) == sum) {
         cout << i << ' ' << j<< ' '<< N-i-j;goto Exit;}
     }
   }
     
     cout << -1 << ' ' << -1 << ' '<<-1 << ' ';
     
     Exit:;
     
     
   }
     
     
      
      
  
  
     
      
  
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,x=0;cin>>n;int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=2;i<n;i++)if((a[i-2]-a[i-1])*(a[i]-a[i-1])<0)x++;
  cout<<x<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int mod = 924844033;
const int MX = 2001;
ll f[MX];

using V = vector<ll>;
using V2 = vector<V>;
using V3 = vector<V2>;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	f[0] = 1;
	rep(i, MX - 1) f[i + 1] = f[i] * (i + 1) % mod;
	
	int n, k; cin >> n >> k;
	ll ans = 0;
	vector<ll> sum(n + 1);
	sum[0] = 1;
	rep(md, k){
		int m = 0, cur = 0, next = 1;
		for(int i = 1; i <= n; i++) if(i % k == md) m++;
		
		//dp[cur or next][i何個えらんだ][aiつかえるか2bit]
		V3 dp(2, V2(m + 1, V(4)));
		dp[0][0][2] = 1;
		rep(i, m){
			rep(j, i+1) rep(k, 4) if(dp[cur][j][k]){
				int nk = k | (i < m - 1 ? 4 : 0);
				//つかう
				for(int u = 0; u < 3; u += 2) if(nk & 1 << u){
					(dp[next][j + 1][(nk ^ 1 << u) >> 1] += dp[cur][j][k]) %= mod;
				}
				//つかわない
				(dp[next][j][nk >> 1] += dp[cur][j][k]) %= mod;
			}
			swap(cur, next);
			dp[next] = V2(m + 1, V(4));
		}
		
		vector<ll> nsum(n + 1);
		rep(i, n + 1) for(int j = 0; i + j <= n && j <= m; j++) rep(k, 4)
		(nsum[i + j] += dp[cur][j][k] * sum[i] % mod) %= mod;
		sum = nsum;
	}
	//rep(i, n + 1) dbg(i, sum[i]);
	
	rep(i, n + 1){
		ans += (i % 2 ? -1 : 1) * sum[i] * f[n - i] % mod;
	}
	ans = (ans % mod + mod) % mod;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>

#define roop(i, n) for(int i=0;i<n;i++)

using namespace std;
using ll = long long int;
using ull = unsigned long long;

constexpr ull mod = 1e9+7;
constexpr int N = 13;
ull dp[100010][N];

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main() {
	int n;
	cin >> n;
	cout << n * (n + 1) * 0.5 << endl;
	return 0;
}

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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main() {
    string S;
    cin >> S;

    // 後ろから解くかわりにすべての文字列を「左右反転」する
    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

    // 端から切っていく
    bool can = true;
    for (int i = 0; i < S.size();) {
        bool can2 = false; // 4 個の文字列たちどれかで divide できるか
        for (int j = 0; j < 4; ++j) {
            string d = divide[j];
            if (S.substr(i, d.size()) == d) { // d で divide できるか
                can2 = true;
                i += d.size(); // divide できたら i を進める
            }
        }
        if (!can2) { // divide できなかったら
            can = false;
            break;
        }
    }

    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3708
d = int(input())
c = tuple(map(int, input().split()))
s = [
    tuple(map(int, input().split()))
    for _ in range(d)
]

m = 0
ans = []
last = [0] * 26
for i in range(d):
    # for all contest
    mdmax = -10000000000000000
    mdi = 0
    for j, ss in enumerate(s[i]):
        md = 0
        # choose one contest to open
        for k in range(26):
            if j == k:
                md += ss
            else:
                if last[k] > 0:
                    md -= (i + 1 - last[k]) * c[k]
        if md > mdmax:
            mdi = j
            mdmax = md

    ans.append(mdi + 1)
    m += mdmax

    last[j] = d + 1

for a in ans:
    print(a)
# print(m)

Measured memory_bytes: 9420
#include<stdio.h>

int main(){
	int x[5];
	int i;
	int sum=0;
	int ans;
	scanf("%d %d %d %d %d", &x[0],&x[1],&x[2],&x[3],&x[4]);
	for(i=0;i<5;i++){
		sum+=x[i];
	}
	ans = 15 - sum ;
	printf("%d", ans);
}

Measured memory_bytes: 1728
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        int[] input = GetInputsInt();

        Console.WriteLine(Math.Ceiling((float)input[0] / (input[1] *2 +1)) );
    }

    public static int GetInputInt()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] GetInputsInt()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
    public static List<int> GetInputsIntList()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
    }
    public static long[] GetInputsLong()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }

}


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

int main(void)
{
  int N;
  cin >> N;
  int num;
  string result = "APPROVED";
  for (int i = 0; i < N; i++)
  {
    cin >> num;
    if (num % 2 == 0)
    {
      if (!(num % 3 == 0 || num % 5 == 0))
      {
        result = "DENIED";
      }
    }
  }

  cout << result << endl;
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n,a,b;

int main(){
  cin >> n >> a >> b;
  cout << min(a,b) << " " << max(0ll, (a-(n-b))) << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = sorted(list(map(int,input().split())))
b = sorted(list(map(int,input().split())))
c = sorted(list(map(int,input().split())))
bmul = [0]*(n+1)
ci = 0
for bi in range(n):
    while ci != n and c[ci] <= b[bi]:
        ci += 1
    bmul[bi] = n-ci
for i in range(n):
    bmul[n-i-1] += bmul[n-i]
bi = 0
ai = 0
ret = 0
for ai in range(n):
    while bi != n and b[bi] <= a[ai]:
        bi += 1
    ret += bmul[bi]
print(ret)


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

using namespace std;

int par[100001];

void init(int n)
{
	for (int i = 1; i <= n; i++) par[i] = i;
}

int find(int x)
{
	return (x == par[x] ? x : par[x] = find(par[x]));
}

void merge(int x, int y)
{
	x = find(x); y = find(y);

	par[y] = x;
}

bool same(int x, int y)
{
	return (find(x) == find(y));
}

int main()
{
	int n, m;

	while (scanf("%d %d", &n, &m) && n){
		init(n);
		int deg[100001] = {0};
		set< pair<int, int> > s;

		bool ok = true;
		for (int i = 0; i < m; i++){
			int a, b;
			scanf("%d %d", &a, &b);
			if (a == b) ok = false;
			if (s.count(make_pair(a, b))) ok = false;
			if (same(a, b)) ok = false;
			merge(a, b);
			deg[a]++; deg[b]++;
			if (deg[a] > 2 || deg[b] > 2) ok = false;
			s.insert(make_pair(a, b));
			s.insert(make_pair(b, a));
		}

		printf("%s\n", ok ? "yes" : "no");
	}

	return (0);
}

Measured memory_bytes: 24992
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int a,b,c;
	scan(a>>b>>c);
	prin(max(0,c-(a-b)));
	return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
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 long long LLINF=1LL<<60;
//set<int>::iterator it;
//|_
//g++ -std=c++1z temp.cpp
//./a.out

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










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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
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; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll n,a,b;
cin>>n>>a>>b;
ll cnt=0;


if((b-a)%2==0){
    cnt+=(b-a)/2;
}
else{
    if(a-1<n-b){
        cnt+=a-1+1;
        cnt+=((b-(a-1+1))-1)/2;
    }
    else{
        cnt+=n-b+1;
        cnt+=(n-(a+(n-b+1)))/2;
    }
}
cout<<cnt<<endl;
return 0;
}

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

using namespace std;


inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}


void solve() {
    int N; cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    sort(A.begin(), A.end());

    vector<int> plus, minus;

    minus.push_back(A[0]);
    plus.push_back(A[N-1]);
    for (int i = 1; i < N-1; i++) {
        if (A[i] < 0) minus.push_back(A[i]);
        else plus.push_back(A[i]);
    }

    int sum = accumulate(plus.begin(), plus.end(), 0) - accumulate(minus.begin(), minus.end(), 0);

    cout << sum << endl;

    int x = minus[0];
    for (int i = 1; i < plus.size(); i++) {
        print(x, plus[i]);
        x = x - plus[i];
    }
    print(plus[0], x);
    x = plus[0] - x;
    for (int i = 1; i < minus.size(); i++) {
        print(x, minus[i]);
        x = x - minus[i];
    }
}


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

Measured memory_bytes: 4172
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s; cin >> s;
    string allow = "ACGT";

    int count = 0;
    int res   = 0;
    for (int i = 0; i < s.size(); ++i) {
        bool isContinue = false;
        for (int j = 0; j < 4; ++j) {
            if (s[i] == allow[j]) {
                isContinue = true;
                break;
            }
        }

        if (isContinue) {
            ++count;
            res = max(res, count);
        } else {
            count = 0;
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
	int N = in.nextInt();
	long[] A = new long[N];
	long sum = 0;
	for (int i = 0; i < N; i++) {
	    A[i] = in.nextLong();
	    sum += A[i];
	}
	long[] X = new long[N];
	long harfSum = 0;
	for (int i = 1; i < N - 1; i += 2) {
	    harfSum += A[i];
	}
	X[0] = sum - harfSum * 2;
	for (int i = 0; i < N - 1; i++) {
	    X[i + 1] = 2 * A[i] - X[i];
	}
	System.out.println(LongStream.of(X)
			   .mapToObj(String::valueOf)
			   .collect(Collectors.joining(" ")));
    }
}

Measured memory_bytes: 65520
#include<stdio.h>
void reverse(int[],int);
void reverse(int x[],int y){
    int h,i,j;
    j=y;
    y/=2;
    for(i=0;i<j;i++){
        h=x[i];
        x[i]=x[j];
        x[j]=h;
        j--;
    }
    return;
}
int main(void){
    int n,m,N,t;
    scanf("%d",&n);
    m=n-1;
    int a[m];
    scanf("%d",&a[0]);
    for(N=1;N<=m;N++){
        scanf(" %d",&a[N]);
    }
    reverse(a,m);
    for(t=0;t<=m;t++){
        if(t!=0){
            printf(" ");
        }
        printf("%d",a[t]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2104
N, M = map(int, input().split())
A = list(map(int, input().split()))

import numpy as np
import collections

count = 0
BC = []

# Python code to sort the tuples using second element  
# of sublist Inplace way to sort using sort() 
def Sort(sub_li): 
  
    # reverse = None (Sorts in Ascending order) 
    # key is set to sort using second element of  
    # sublist lambda has been used 
    sub_li.sort(key = lambda x: x[1]) 
    return sub_li 

for i in range (0, M):
	BC.append(list(map(int, input().split())))
    
BC = collections.deque(reversed(Sort(BC)))

Secondlist = []

V = 0

while count < N and BC:
	V = BC.popleft()
	for i in range (0, V[0]):
		Secondlist.append(V[1])
		count+=1

C = A+Secondlist
C = sorted(C, reverse = True)
print(sum(C[:N]))

Measured memory_bytes: 55500
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number_list = (lambda: list(map(int, input_list())))

    L, R = input_number_list()
    m = float('inf')
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            m = min(m, (i * j) % 2019)
            if m == 0:
                print(0)
                exit()
    print(m)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
from sys import stdin
n = int(stdin.readline().rstrip())
d = [int(x) for x in stdin.readline().rstrip().split()]
a = [0] * n
k = 1
for i in range(n):
    if d[i] == 0:
        k *= (3 - a[0])
        a[0] += 1
    else:
        k *= ((a[d[i]-1])-a[d[i]])
        a[d[i]] += 1
print(k % 1000000007)


Measured memory_bytes: 53428
#include<algorithm>
#include<iostream>
#include<vector>

int main(){

int N,M,K,ans,i,j,sum=0;

std::cin>>N>>M>>K;

std::vector<int>A(N);
std::vector<int>B(M);
for(int i=1;i<=N;++i){
    std::cin>>A[i];
}

for(int i=1;i<=M;++i){
    std::cin>>B[i];
}

i=j=1;
while(i<=N&&sum+A[i]<=K){
    sum+=A[i];
    i++;
}
while(j<=M&&sum+B[j]<=K){
    sum+=B[j];
    j++;
}
i--,j--; ans=i+j;

while(i){
    sum-=A[i];
    i--;
    j++;
    while(j<=M&&sum+B[j]<=K){
        sum+=B[j];
        j++;
    }j--;
    ans=std::max(ans,i+j);

}
printf("%d",ans);
return 0;
}

Measured memory_bytes: 4432
function Main(input){
var N = new Number(input.split("\n")[0]);
var p = input.split("\n")[1].split(" ");
var origin = [];
for(i=0;i<=(N-1);i++){
  origin[i] = i+1;
}
var judge;
var count=0;
for(j=0;j<=(N-1);j++){
  judge = parseInt(origin[j],10) == parseInt(p[j],10);
  if(judge==false){
    count += 1;
  } 
}
if(count==2||count==0){
  console.log("YES");
}else{
  console.log("NO");
}
}
  Main(require('fs').readFileSync('/dev/stdin','utf8'));

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

int M = 1e9, wc[300005], ec[300005];

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N;
	string S;
	cin >> N >> S;
	for (int i = 0; i < N; i++) {
		if (i) wc[i] = wc[i - 1], ec[i] = ec[i - 1];
		wc[i] += S[i] == 'W';
		ec[i] += S[i] == 'E';
	}
	for (int i = 0; i < N; i++) {
		if (i) M = min(M, wc[i - 1] + (ec[N - 1] - ec[i]));
		else M = min(M, ec[N - 1] - ec[i]);
	}
	cout << M << '\n';
}


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

string s[8];

void rotate(){
	string t[8];
	for(int i = 0;i < 8;i++) t[i] = s[i];
	for(int i = 0;i < 8;i++){
		for(int j = 0;j < 8;j++){
			t[i][j] = s[7 - j][i];
		}
	}
	for(int i = 0;i < 8;i++) s[i] = t[i];
}

int main(){
	for(int i = 0;i < 8;i++) cin >> s[i];
	for(int i = 1;i <= 3;i++){
		cout << i * 90 << endl;
		rotate();
		for(int j = 0;j < 8;j++){
			cout << s[j] << endl;
		}
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N-1);

  int tmp;
  for(int i = 0; i < N; i++){
    cin >> tmp;
    tmp--;
    A[i] = tmp;
  }

  for(int i = 0; i < N; i++){
    cin >> B[i];
  }
  
  for(int i = 0; i < (N-1); i++){
    cin >> C[i];
  }


  int ans = 0;
  int before = -10;

  for(int i = 0; i < N; i++){
    ans += B[A[i]];
    if((A[i] - before) == 1){
      ans += C[A[i]-1];
    }

    before = A[i];
  }

  cout << ans << endl;


  return 0;
}



Measured memory_bytes: 256
use std::io;
fn main() {
    let mut l1 = String::new();
    let mut l2 = String::new();
    let stdin = io::stdin();
    stdin.read_line(&mut l1).unwrap();
    stdin.read_line(&mut l2).unwrap();
    let trimed = l1.trim_end();
    let trimed2 = l2.trim_end();
    let mut itr = trimed.split_ascii_whitespace();
    let mut itr2 = trimed2.split_ascii_whitespace();
    let n = itr.next().unwrap().parse::<i64>().unwrap();
    let m = itr.next().unwrap().parse::<i64>().unwrap();

    let mut count = 0;
    for x in 0..m {
        count = count + itr2.next().unwrap().parse::<i64>().unwrap();
    }

    if (count <= n) {
        println!("{}", n - count);
    } else {
        println!("{}", -1);
    }
}


Measured memory_bytes: 2152
#include<stdio.h>

typedef struct{
  int parent;
  int left;
  int right;
} DATA;

#define MAX 1000000
#define NIL -1

DATA array[MAX];

int main(){
  int i;
  int id;
  int j;
  int n;
  int k;
  int count[100000];
  int hukasa = 0;
  int num;

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    array[i].parent = NIL;
    array[i].left = NIL;
    array[i].right = NIL;
  }
  for(i = 0;i < n;i++){
    scanf("%d%d",&id,&k);
    for(j = 0;j < k;j++){
      scanf("%d",&count[j]);
      if(j == 0){
        array[count[0]].parent = id;
        array[id].left = count[0];
      }
      else{
        array[count[j]].parent = id;
        array[count[j - 1]].right = count[j];
      }
    }
  }

  for(i = 0;i < n;i++){
    printf("node %d: parent = %d, ",i,array[i].parent);
    num = i;
    while(array[num].parent != NIL){
      hukasa++;
      num = array[num].parent;
    }
    printf("depth = %d,",hukasa);
    hukasa = 0;
    if(array[i].parent == NIL && array[i].left == NIL){
      printf(" root, []\n");
    }
    else if(array[i].parent == NIL && array[i].left != NIL){
      printf(" root, [%d",array[i].left);
      for(j = array[array[i].left].right;j != NIL;j = array[j].right){
        printf(", %d",j);
      }
      printf("]\n");
    }
    else if(array[i].left != NIL){
      printf(" internal node, [%d",array[i].left);
      for(j = array[array[i].left].right;j != NIL;j = array[j].right){
        printf(", %d",j);
      }
      printf("]\n");
    }
    else{
      printf(" leaf, []\n");
    }
  }
  return 0;
}



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

using namespace std;
int main(){
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    bool can = false;

    for (int i = 0; i <= K; i++)
    {
        if(A<B && B<C){
            can = true;
            break;
        }
        if(A>=B){
            B *= 2;
        }else{
            C *= 2;
        }
    }
    if(can){
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}

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

int main() {
    string s,t;
    cin>>s>>t;
    t=t.substr(0,s.size());
    if (s==t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int n,k; cin>>n>>k;
	vector<double> p(n),a(n); rep(i,n) cin>>p[i];
	a[0] = p[0]*(p[0]+1)/(2*p[0]);
	reps(i,n-1){
		double tmp = p[i]*(p[i]+1)/(2*p[i]);
		a[i] = a[i-1]+tmp;
	}
	double ans = a[k-1];
	for(int i=k; i<n; i++){
		chmax(ans,a[i]-a[i-k]);
	}
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9+5;
int main()
{
int n,k;
cin>>n>>k;
int a[n];
for(int i = 0;i<n;i++)
{
	cin>>a[i];
}
vector<int> dp(n,INF);
dp[0]=0;
for(int i = 0; i<n ; ++i)
{
	for(int j = i+1; j<=i+k ; ++j)
	{
		if(j<n)
		{
			dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
		}
	}
}
cout<<dp[n-1]<<endl;
}

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

int main(){
    long long A, B, C, D;
    cin >> A >> B >> C >> D;
    long long count, A_count, B_count, G, L, small_C, large_D;
    long long A_C_count=0, A_D_count=0, A_CD_count=0, B_C_count=0, B_D_count=0, B_CD_count=0;
    if(C>D){
        small_C = D;
        large_D = C;
    }
    else{
        small_C = C;
        large_D = D;
    }
    while(true){
        long long R;
        R = large_D%small_C;
        if(R==0){
            G = small_C;
            break;
        }
        large_D = small_C;
        small_C = R;
    }
    L = (C*D)/G;
    

    B_C_count = B / C;
    B_D_count =  B / D;
    B_CD_count = B / L;
    A_C_count = (A-1) / C;
    A_D_count = (A-1) / D;
    A_CD_count = (A-1) / L;
    B_count = B - B_C_count - B_D_count + B_CD_count;
    A_count = (A-1) - A_C_count - A_D_count + A_CD_count;
    count = B_count - A_count;

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int N;
    cin >> N;
    int sum=0,ans=0,over=-1;
    while(sum<N){
        ans++;
        sum+=ans;
    }
    if(sum>N) over=sum-N;
    rep(i,ans+1) if(i!=0 && i!=over) cout << i << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}




int main(){

  ll n,m,x;
  cin >> n >> m >> x;
  vector<ll> c(n),A[n];
  FOR(i,0,n){
    cin >> c[i];
    FOR(j,0,m){
      ll a;
      cin >> a;
      A[i].push_back(a);
    }
  }

  ll ans = INF;
  FOR(i,0,(1LL<<n)){
    vector<ll> up(m,0);
    ll anst = 0;
    bool ok = true;
    FOR(j,0,n){
      if(i&(1LL<<j)){
        anst += c[j];
        FOR(k,0,m){
          up[k] += A[j][k];
        }
      }
    }
    FOR(j,0,m){
      if(up[j]<x)ok = false;
    }
    if(ok){
      ans = min(ans,anst);
    }
  }
  if(ans==INF)ans=-1;
  cout << ans << endl;

}


Measured memory_bytes: 3636
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    6月で水色になるぞ〜!!!
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, Integer};
use num_rational::Rational;
use num_traits::{clamp, one, pow, zero, One, Pow, Zero};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

pub const MOD: usize = 1000000007;
pub const MAX: usize = 1usize << 63usize;
pub const MIN: i64 = i64::MIN;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 'A' as u8;

// code...
// #[fastout]
fn main() {
    input! {
        a: usize
    }

    println!("{}", a * a * a + a * a + a);
}


Measured memory_bytes: 2048
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
using namespace std;

int main(){
    int N,K;cin>>N>>K;
    if(N%K==0)cout<<0<<endl;
    else cout<<1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
void MMS(int *a,int n){
  int k = a[0];
  int l = a[0];
  signed long long int sum = a[0];
  for(int i = 1;i < n;i++){
    if(k < a[i]){
      k = a[i];
    }
    if(l > a[i]){
      l = a[i];
    }
    sum += a[i];
  }
  printf("%d %d %ld\n",l,k,sum);
}

int main(void){
    int n,k,i;
    int *a;
    scanf("%d",&n);
    a =(int *)malloc(sizeof(int)*n);
    for(i = 0;i < n;i++){
      scanf("%d",&a[i]);
    }
    MMS(a,n);
    free(a);
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll N,W;cin>>N>>W;
  ll v[N],w[N];rep(i,0,N)cin>>v[i]>>w[i];
  const int MAX_N=101,MAX_W=10001,inf=-1;

  ll dp[MAX_N][MAX_W];
  CLR(dp,inf);

  rep(j,0,W+1)dp[0][j]=0;

  rep(i,0,N){
    rep(j,0,W+1){
      if(j-w[i]>=0&&j-w[i]<=W)chmax(dp[i+1][j],max(dp[i][j],dp[i][j-w[i]]+v[i]));
      else chmax(dp[i+1][j],dp[i][j]);
    }
  }

  out(dp[N][W]);

  return 0;
}



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

const double eps = 1e-9;

int sgn(double x)
{
	if (abs(x) < eps) return 0;
	return x > 0 ? 1 : -1;
}

struct Point{
	double x, y;
	Point(){}
	Point(double _x, double _y):
		x(_x), y(_y){}
	double len(){return sqrt(x * x + y * y);}
	Point operator - (Point _){return Point(x - _.x, y - _.y);}
};

typedef Point Vector;

struct Line{
	Point base;
	Vector dir;
};

double dot(Point a, Point b)
{
	return a.x * b.x + a.y * b.y;
}

double w, h, r, vx, vy, lft;
int n;

vector<Point> ball;
Line st;

double check_hit(Point pt)
{
	pt.x -= st.base.x;
	pt.y -= st.base.y;
	double dist = pt.len();
	double vec = st.dir.len();
	double dotval = dot(st.dir, pt);
	double a = 1, b = - 2 * dotval / vec, c = dot(pt, pt) - 4 * r * r;
	if (sgn(b * b - 4 * c) < 0)
		return 9999999;
	return (-b - sqrt(b * b - 4 * c)) / 2;
}

void sol()
{
	scanf("%lf%lf%lf%lf%lf", &w, &h, &r, &vx, &vy);
	scanf("%lf%lf", &st.base.x, &st.base.y);
	ball.clear();
	for (int i = 1; i < n; i++)
	{
		double x, y;
		scanf("%lf%lf", &x, &y);
		ball.push_back(Point(x, y));
	}
	st.dir.x = vx;st.dir.y = vy;
	lft = 10000.;
	int ans = -1;
	while ((sgn(lft) > 0) && (ans == -1))
	{
		Line nxt = st;
//		printf("At (%f, %f) / Dir (%f, %f) / Left %f\n", st.base.x, st.base.y, st.dir.x, st.dir.y, lft);
		if (sgn(st.dir.x) > 0)
		{
			double hit_t = (w - r - st.base.x) / st.dir.x;
			double hit_y = hit_t * st.dir.y + st.base.y;
			if (sgn(hit_y - r) >= 0 && sgn(h - hit_y - r) >= 0)
			{
				nxt.base.y = hit_y;
				nxt.base.x = w - r;
				nxt.dir.x = -st.dir.x;
			}
		} else if (sgn(st.dir.x) < 0)
		{
			double hit_t = (r - st.base.x) / st.dir.x;
			double hit_y = hit_t * st.dir.y + st.base.y;
			if (sgn(hit_y - r) >= 0 && sgn(h - hit_y - r) >= 0)
			{
				nxt.base.y = hit_y;
				nxt.base.x = r;
				nxt.dir.x = -st.dir.x;
			}
		}
		if (sgn(st.dir.y) > 0)
		{
			double hit_t = (h - r - st.base.y) / st.dir.y;
			double hit_x = hit_t * st.dir.x + st.base.x;
			if (sgn(hit_x - r) >= 0 && sgn(w - hit_x - r) >= 0)
			{
				nxt.base.x = hit_x;
				nxt.base.y = h - r;
				nxt.dir.y = -st.dir.y;
			}
		} else if (sgn(st.dir.y) < 0)
		{
			double hit_t = (r - st.base.y) / st.dir.y;
			double hit_x = hit_t * st.dir.x + st.base.x;
			if (sgn(hit_x - r) >= 0 && sgn(w - hit_x - r) >= 0)
			{
				nxt.base.x = hit_x;
				nxt.base.y = r;
				nxt.dir.y = -st.dir.y;
			}
		}
		double gonxt = (nxt.base - st.base).len();
		double hitlen = 999999;
		for (int i = 0; i < (int) ball.size(); i++)
		{
			double golen = check_hit(ball[i]);
			if (sgn(golen) >= 0 && golen < hitlen && golen < lft)
			{
				hitlen = golen;
				ans = i;
			}
		}
		st = nxt;
		lft -= gonxt;
	}
	printf("%d\n", (~ans) ? ans + 2 : -1);
}

int main()
{
	while ((~scanf("%d", &n)) && n)
		sol();
	return 0;
}

Measured memory_bytes: 3220
import math
n,d = map(int,input().split())
x = []
for i in range(n):
    tmp_x = list(map(int,input().split()))
    x.append(tmp_x)
#print(x)
cnt = 0
for i in range(n):
    for j in range(i+1,n):
        ans = 0
        for k in range(d):
            ans += (x[i][k]-x[j][k])**2
        tmp = int(math.sqrt(ans))
        if tmp ** 2 == ans:
            cnt += 1
print(cnt)

Measured memory_bytes: 9212
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef vector <string> VS;
typedef vector <int> VI;

int main( void )
{
	int n, m;
	while ( cin >> n >> m && n )
	{
		VS numbers(n); VI prizes(n);
		for ( int i = 0; i < n; i++ ) cin >> numbers[i] >> prizes[i];

		VS my_numbers(m);
		for ( int i = 0; i < m; i++ ) cin >> my_numbers[i];

		long long answer = 0;
		for ( VS::iterator it_i = my_numbers.begin(); it_i != my_numbers.end(); it_i++ )
		{
			string& checking = *it_i;
			for ( int i = 0; i < numbers.size(); i++ )
			{
				string& number = numbers[i];
				bool found = true;
				for ( int j = 0; found && j < 8; j++ )
				{
					if ( number[j] != '*' && checking[j] != number[j] ) found = false; 
				}
				if ( found )
				{
					answer += (long long)prizes[i];
					break;
				}
			}
		}
		cout << answer << endl;
	}

	return 0;
}

Measured memory_bytes: 0
n, k = map(int, input().split())
dlist = [s for s in input().split()]
ans = n
while True:
    blnOk = True
    for d in str(ans):
        if d in dlist:
            blnOk = False
            break
    if blnOk:
        print(ans)
        exit()
    else:
        ans += 1


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

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

	vector<int> cell(value);

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

	int times = 0;
	int inner_times = 0;
	for (int i = 0; i < value - 1; i++) {
		if (cell[i] >= cell[i + 1]) {
			inner_times++;
		}
		else {
			if (inner_times >= times) {
				times = inner_times;
			}
			inner_times = 0;
		}
	}

	if (inner_times > times) {
		times = inner_times;
	}

	cout << times;

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define MAXN 200000+5
using namespace std;
typedef long long LL;
struct node
{
	LL x,y;
}P[MAXN];
LL n,minans=LLONG_MAX;
LL Rmax,Rmin,Lmax,Lmin;
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&P[i].x,&P[i].y);
	}
	for(int k=1;k<=100;k++)
	{
		srand(time(0));
		random_shuffle(P+1,P+n+1);
		Rmax=Rmin=P[1].x,Lmax=Lmin=P[1].y;
		for(int i=2;i<=n;i++)
		{
			LL rmax=Rmax,rmin=Rmin,lmax=Lmax,lmin=Lmin,ans=0;
			rmax=max(rmax,P[i].x),rmin=min(rmin,P[i].x);
			lmax=max(lmax,P[i].y),lmin=min(lmin,P[i].y);
			ans=(rmax-rmin)*(lmax-lmin);
			rmax=Rmax,rmin=Rmin,lmax=Lmax,lmin=Lmin;
			swap(P[i].x,P[i].y);
			rmax=max(rmax,P[i].x),rmin=min(rmin,P[i].x);
			lmax=max(lmax,P[i].y),lmin=min(lmin,P[i].y);
			if(ans>(rmax-rmin)*(lmax-lmin))
			{
				Rmax=max(Rmax,P[i].x),Rmin=min(Rmin,P[i].x);
				Lmax=max(Lmax,P[i].y),Lmin=min(Lmin,P[i].y);
			}
			else
			{
				Rmax=max(Rmax,P[i].y),Rmin=min(Rmin,P[i].y);
				Lmax=max(Lmax,P[i].x),Lmin=min(Lmin,P[i].x);
			}
		}
		minans=min(minans,(Rmax-Rmin)*(Lmax-Lmin));
	}
	printf("%lld ",minans);
	return 0;
}


Measured memory_bytes: 3456
n = list(map(int,input().split()))
p = list(map(int,input().split()))
k = 0
for i in range(1,n[0]-1):
    if p[i-1] > p[i] and p[i] > p[i+1]:
        k += 1
    elif p[i-1] < p[i] and p[i] < p[i+1]:
        k += 1
print(k)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> a, b;
    int x;
    for (size_t i = 0; i < N+1; ++i) {
        cin >> x;
        a.push_back(x);
    }
    for (size_t i = 0; i < N; ++i) {
        cin >> x;
        b.push_back(x);
    }

    long r = 0;
    int l;
    for (size_t i = 0; i < N; ++i) {
        if (a[i] >= b[i]) {
            r += b[i];
        }
        else {
            r += a[i];
            l = b[i] - a[i];
            if (a[i+1] >= l) {
                r += l;
                a[i+1] -= l;
            }
            else {
                r += a[i+1];
                a[i+1] = 0;
            }
        }
    }
    cout << r << endl;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main(){
  string str;
  cin >> str;
  for(int i=0;i<str.size();i++){
    if(str[i] <= 'C') str[i] += 26;
    str[i] -= 3;
  }
  cout << str << endl;
  return (0);
}

Measured memory_bytes: 3180
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String tmp = sc.nextLine();
        String[] line = tmp.split(" ");
        int a = Integer.parseInt(line[0]);
        int b = Integer.parseInt(line[1]);
        int area = a*b;
        int circumference = (a+b)*2;
        System.out.println(area + " " + circumference);
        sc.close();
    }
}


Measured memory_bytes: 26108